Skip to content

Commit

Permalink
feat: Enable delegated admin feature. (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianliuwk1019 authored Nov 20, 2024
1 parent 192d8f1 commit 0667a7e
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 109 deletions.
63 changes: 30 additions & 33 deletions frontend/src/components/ManagePermissionsTable/index.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
<script setup lang="ts">
import { ref, nextTick } from "vue";
import { useRoute, useRouter } from "vue-router";
import { FilterMatchMode } from "primevue/api";
import ConfirmDialog from "primevue/confirmdialog";
import Column from "primevue/column";
import DataTable from "primevue/datatable";
import { useMutation, useQuery } from "@tanstack/vue-query";
import RecentlyViewedIcon from "@carbon/icons-vue/es/recently-viewed/16";
import TrashIcon from "@carbon/icons-vue/es/trash-can/16";
import { useMutation, useQuery } from "@tanstack/vue-query";
import { isAxiosError } from "axios";
import { useConfirm } from "primevue/useconfirm";
import {
type FamAccessControlPrivilegeGetResponse,
type FamAppAdminGetResponse,
} from "fam-admin-mgmt-api/model";
import type { FamApplicationUserRoleAssignmentGetSchema } from "fam-app-acsctl-api/model";
import { FilterMatchMode } from "primevue/api";
import Column from "primevue/column";
import ConfirmDialog from "primevue/confirmdialog";
import DataTable from "primevue/datatable";
import { useConfirm } from "primevue/useconfirm";
import { nextTick, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import TableToolbar from "@/components/Table/TableToolbar.vue";
import TableHeaderTitle from "@/components/Table/TableHeaderTitle.vue";
import TableSkeleton from "@/components/Skeletons/TableSkeleton.vue";
import ErrorText from "@/components/UI/ErrorText.vue";
import TableHeaderTitle from "@/components/Table/TableHeaderTitle.vue";
import TableToolbar from "@/components/Table/TableToolbar.vue";
import Chip from "@/components/UI/Chip.vue";
import { ManagePermissionsTableEnum } from "@/types/ManagePermissionsTypes";
import {
AdminMgmtApiService,
AppActlApiService,
} from "@/services/ApiServiceFactory";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import { formatUserNameAndId } from "@/utils/UserUtils";
import ErrorText from "@/components/UI/ErrorText.vue";
import {
DEFAULT_ROW_PER_PAGE,
TABLE_ROWS_PER_PAGE,
TABLE_PAGINATOR_TEMPLATE,
TABLE_CURRENT_PAGE_REPORT_TEMPLATE,
TABLE_PAGINATOR_TEMPLATE,
TABLE_ROWS_PER_PAGE,
} from "@/constants/constants";
import { formatAxiosError } from "@/utils/ApiUtils";
import {
AddAppPermissionRoute,
AddFamPermissionRoute,
UserDetailsRoute,
} from "@/router/routes";
import {
AdminMgmtApiService,
AppActlApiService,
} from "@/services/ApiServiceFactory";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import { selectedApp } from "@/store/ApplicationState";
import { ManagePermissionsTableEnum } from "@/types/ManagePermissionsTypes";
import type { PermissionNotificationType } from "@/types/NotificationTypes";
import { NewFamAdminQueryParamKey } from "@/views/AddFamPermission/utils";
import { formatAxiosError } from "@/utils/ApiUtils";
import { formatUserNameAndId } from "@/utils/UserUtils";
import {
NewAppAdminQueryParamKey,
NewDelegatedAddminQueryParamKey,
} from "@/views/AddAppPermission/utils";
import { NewFamAdminQueryParamKey } from "@/views/AddFamPermission/utils";
import NewUserTag from "./NewUserTag.vue";
import ConfirmDialogText from "./ConfirmDialogText.vue";
import NewUserTag from "./NewUserTag.vue";
import {
getTableHeaderDescription,
getTableHeaderTitle,
getGrantButtonLabel,
filterList,
getHeaders,
type ConfirmTextType,
createNotification,
deleteAppUserRoleNotificationContext,
deleteDelegatedAdminNotificationContext,
deleteFamPermissionNotificationContext,
filterList,
getGrantButtonLabel,
getHeaders,
getTableHeaderDescription,
getTableHeaderTitle,
NEW_ACCESS_STYLE_IN_TABLE,
type ConfirmTextType,
} from "./utils";
const router = useRouter();
Expand Down Expand Up @@ -148,10 +148,7 @@ const delegatedAdminQuery = useQuery({
.getAccessControlPrivilegesByApplicationId(props.appId)
.then((res) => res.data),
refetchOnMount: "always",
enabled:
props.tableType === ManagePermissionsTableEnum.DelegatedAdmin &&
// DelegatedAdminFeatureFlag
!environment.isProdEnvironment(),
enabled: props.tableType === ManagePermissionsTableEnum.DelegatedAdmin,
select: (data) => {
const sortedByUserName = data.sort((a, b) =>
a.user.user_name.localeCompare(b.user.user_name)
Expand Down
74 changes: 37 additions & 37 deletions frontend/src/views/AddAppPermission/index.vue
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
<script setup lang="ts">
import { useRouter } from "vue-router";
import CheckmarkIcon from "@carbon/icons-vue/es/checkmark/16";
import type { AddAppPermissionRouteProps } from "@/types/RouteTypes";
import type { BreadCrumbType } from "@/types/BreadCrumbTypes";
import { ManagePermissionsRoute } from "@/router/routes";
import ForestClientSection from "@/components/AddPermissions/ForestClientSection.vue";
import RoleSelectTable from "@/components/AddPermissions/RoleSelectTable.vue";
import UserDomainSelect from "@/components/AddPermissions/UserDomainSelect.vue";
import UserNameInput from "@/components/AddPermissions/UserNameSection.vue";
import BoolCheckbox from "@/components/UI/BoolCheckbox.vue";
import BreadCrumbs from "@/components/UI/BreadCrumbs.vue";
import Button from "@/components/UI/Button.vue";
import PageTitle from "@/components/UI/PageTitle.vue";
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
import StepContainer from "@/components/UI/StepContainer.vue";
import useAuth from "@/composables/useAuth";
import { ManagePermissionsRoute } from "@/router/routes";
import {
AdminMgmtApiService,
AppActlApiService,
} from "@/services/ApiServiceFactory";
import { Form } from "vee-validate";
import StepContainer from "@/components/UI/StepContainer.vue";
import { computed, ref, watch } from "vue";
import useAuth from "@/composables/useAuth";
import {
UserType,
type FamForestClientSchema,
type FamUserRoleAssignmentCreateSchema,
type IdimProxyBceidInfoSchema,
type IdimProxyIdirInfoSchema,
} from "fam-app-acsctl-api/model";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import { isProdAppSelectedOnProdEnv } from "@/services/utils";
import type { BreadCrumbType } from "@/types/BreadCrumbTypes";
import type { AddAppPermissionRouteProps } from "@/types/RouteTypes";
import {
getDefaultFormData,
type AppPermissionFormType,
getPageTitle,
getRoleSectionTitle,
getRoleSectionSubtitle,
validateAppPermissionForm,
generatePayload,
AddAppUserPermissionSuccessQuerykey,
AddAppUserPermissionErrorQuerykey,
AddDelegatedAdminSuccessQuerykey,
AddAppUserPermissionSuccessQuerykey,
AddDelegatedAdminErrorQuerykey,
AddDelegatedAdminSuccessQuerykey,
generatePayload,
getApplicationWithUniqueRoles,
NewDelegatedAddminQueryParamKey,
getDefaultFormData,
getPageTitle,
getRoleSectionSubtitle,
getRoleSectionTitle,
NewAppAdminQueryParamKey,
NewDelegatedAddminQueryParamKey,
validateAppPermissionForm,
type AppPermissionFormType,
} from "@/views/AddAppPermission/utils";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import UserDomainSelect from "@/components/AddPermissions/UserDomainSelect.vue";
import UserNameInput from "@/components/AddPermissions/UserNameSection.vue";
import RoleSelectTable from "@/components/AddPermissions/RoleSelectTable.vue";
import { AdminRoleAuthGroup, type FamRoleDto } from "fam-admin-mgmt-api/model";
import ForestClientSection from "@/components/AddPermissions/ForestClientSection.vue";
import BoolCheckbox from "@/components/UI/BoolCheckbox.vue";
import Button from "@/components/UI/Button.vue";
import CheckmarkIcon from "@carbon/icons-vue/es/checkmark/16";
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
import type { FamAccessControlPrivilegeCreateRequest } from "fam-admin-mgmt-api/model";
import { AdminRoleAuthGroup, type FamRoleDto } from "fam-admin-mgmt-api/model";
import {
UserType,
type FamForestClientSchema,
type FamUserRoleAssignmentCreateSchema,
type IdimProxyBceidInfoSchema,
type IdimProxyIdirInfoSchema,
} from "fam-app-acsctl-api/model";
import ConfirmDialog from "primevue/confirmdialog";
import { useConfirm } from "primevue/useconfirm";
import { Form } from "vee-validate";
import { computed, ref, watch } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const auth = useAuth();
Expand Down Expand Up @@ -123,8 +124,7 @@ watch(
auth.authState.famLoginUser?.idpProvider === "idir"
? UserType.I
: UserType.B,
env.isProdEnvironment() &&
selectedApp.value!.application.env === "PROD"
isProdAppSelectedOnProdEnv()
);
}
},
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/views/LandingView/index.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<script setup lang="ts">
import { IdpProvider } from "@/enum/IdpEnum";
import LoginIcon from "@carbon/icons-vue/es/login/16";
import Button from "primevue/button";
import { IdpProvider } from "@/enum/IdpEnum";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import logo from "@/assets/images/bc-gov-logo.png";
import TreeLogs from "@/assets/images/tree-logs.jpg";
import useAuth from "@/composables/useAuth";
const environmentSettings = new EnvironmentSettings();
const isProdEnvironment = environmentSettings.isProdEnvironment();
const auth = useAuth();
</script>

Expand Down Expand Up @@ -47,7 +43,6 @@ const auth = useAuth();
<Button
class="landing-button"
outlined
:disabled="isProdEnvironment"
:label="`Login with ${IdpProvider.BCEIDBUSINESS}`"
id="login-business-bceid-button"
@click="auth.login(IdpProvider.BCEIDBUSINESS)"
Expand Down
63 changes: 30 additions & 33 deletions frontend/src/views/ManagePermissionsView/index.vue
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
<script setup lang="ts">
import { computed, onUnmounted, ref, watch, type Component } from "vue";
import { useRoute, useRouter } from "vue-router";
import { isAxiosError } from "axios";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import type { DropdownChangeEvent } from "primevue/dropdown";
import TabView, { type TabViewChangeEvent } from "primevue/tabview";
import TabPanel from "primevue/tabpanel";
import EnterpriseIcon from "@carbon/icons-vue/es/enterprise/16";
import UserIcon from "@carbon/icons-vue/es/user/16";
import { AdminRoleAuthGroup } from "fam-admin-mgmt-api/model";
import ManagePermissionsTable from "@/components/ManagePermissionsTable";
import TablePlaceholder from "@/components/ManagePermissionsTable/TablePlaceholder.vue";
import Dropdown from "@/components/UI/Dropdown.vue";
import PageTitle from "@/components/UI/PageTitle.vue";
import { AdminMgmtApiService } from "@/services/ApiServiceFactory";
import { EnvironmentSettings } from "@/services/EnvironmentSettings";
import Dropdown from "@/components/UI/Dropdown.vue";
import TablePlaceholder from "@/components/ManagePermissionsTable/TablePlaceholder.vue";
import {
activeTabIndex,
selectedApp,
setSelectedApp,
activeTabIndex,
} from "@/store/ApplicationState";
import {
formatAxiosError,
getUniqueApplications,
isSelectedAppAuthorized,
} from "@/utils/ApiUtils";
import ManagePermissionsTable from "@/components/ManagePermissionsTable";
import {
ManagePermissionsTableEnum,
type ManagePermissionsTabHeaderType,
type ManagePermissionsTabType,
} from "@/types/ManagePermissionsTypes";
import type { PermissionNotificationType } from "@/types/NotificationTypes";
import {
formatAxiosError,
getUniqueApplications,
isSelectedAppAuthorized,
} from "@/utils/ApiUtils";
import NotificationStack from "@/views/ManagePermissionsView/NotificationStack.vue";
import EnterpriseIcon from "@carbon/icons-vue/es/enterprise/16";
import UserIcon from "@carbon/icons-vue/es/user/16";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { isAxiosError } from "axios";
import { AdminRoleAuthGroup } from "fam-admin-mgmt-api/model";
import type { FamUserRoleAssignmentRes } from "fam-app-acsctl-api/model";
import type { DropdownChangeEvent } from "primevue/dropdown";
import TabPanel from "primevue/tabpanel";
import TabView, { type TabViewChangeEvent } from "primevue/tabview";
import { computed, onUnmounted, ref, watch, type Component } from "vue";
import { useRoute, useRouter } from "vue-router";
import {
AddAppUserPermissionErrorQuerykey,
AddAppUserPermissionSuccessQuerykey,
AddDelegatedAdminErrorQuerykey,
AddDelegatedAdminSuccessQuerykey,
type AppPermissionQueryErrorType,
} from "../AddAppPermission/utils";
import type { FamUserRoleAssignmentRes } from "fam-app-acsctl-api/model";
import {
AddFamPermissionErrorQueryKey,
AddFamPermissionSuccessQueryKey,
} from "../AddFamPermission/utils";
import {
generateAppPermissionErrorNotifications,
generateAppPermissionSuccessNotifications,
generateFamNotification,
} from "./utils";
import {
AddFamPermissionErrorQueryKey,
AddFamPermissionSuccessQueryKey,
} from "../AddFamPermission/utils";
const queryClient = useQueryClient();
const route = useRoute();
Expand Down Expand Up @@ -143,15 +143,12 @@ const tabs: ManagePermissionsTabType[] = [
{
// Delegated Admin table
key: ManagePermissionsTableEnum.DelegatedAdmin,
visible: computed(
() =>
// DelegatedAdminFeatureFlag
!environment.isProdEnvironment() &&
isSelectedAppAuthorized(
AdminRoleAuthGroup.AppAdmin,
selectedApp.value?.id,
adminUserAccessQuery.data.value
)
visible: computed(() =>
isSelectedAppAuthorized(
AdminRoleAuthGroup.AppAdmin,
selectedApp.value?.id,
adminUserAccessQuery.data.value
)
),
icon: EnterpriseIcon as Component,
},
Expand Down

0 comments on commit 0667a7e

Please sign in to comment.