Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class FeatureSchemaManager {
if (configurator) {
const currentVersion = this.config[feature]?.VERSION || 'V1';
configurator.initialize(currentVersion);
const menuConfig = configurator.getMenu();
const menuConfig = configurator.getMenu(this.config);

if (configurator.uiAffect) {
configurator.uiAffect.forEach((uiAffect) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/config/global-config/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type ApiClientsSchemaType = {

export interface FeatureConfiguratorType {
getRoutes: (isAdmin?: boolean) => RouteConfig|null;
getMenu: (isAdmin?: boolean) => FeatureMenuConfig;
getMenu: (config?: GlobalServiceConfig) => FeatureMenuConfig;
initialize: (version: FeatureVersion) => void;
uiAffect: FeatureUiAffect[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ import {
import type { DataTableFieldType } from '@cloudforet/mirinae/types/data-display/tables/data-table/type';

import type { ListResponse } from '@/api-clients/_common/schema/api-verbs/list';
import type { UserListParameters } from '@/api-clients/identity/user/schema/api-verbs/list';
import type { UserModel } from '@/api-clients/identity/user/schema/model';
import type { WorkspaceUserListParameters } from '@/api-clients/identity/workspace-user/schema/api-verbs/list';
import type { WorkspaceUserModel } from '@/api-clients/identity/workspace-user/schema/model';
import { i18n } from '@/translations';

import { useAppContextStore } from '@/store/app-context/app-context-store';

import ErrorHandler from '@/common/composables/error/errorHandler';
import { useQueryTags } from '@/common/composables/query-tags';

Expand All @@ -36,6 +40,7 @@ interface Props {

const props = defineProps<Props>();

const appContextStore = useAppContextStore();
const userGroupPageStore = useUserGroupPageStore();
const userGroupPageState = userGroupPageStore.state;
const userGroupPageGetters = userGroupPageStore.getters;
Expand Down Expand Up @@ -70,6 +75,7 @@ const state = reactive({
userItemTotalCount: computed<number>(() => userGroupPageState.users.totalCount),
filteredUserList: [] as UserListItemType[],
totalCount: 0,
isAdminMode: computed<boolean>(() => appContextStore.getters.isAdminMode),
});

const tableState = reactive({
Expand Down Expand Up @@ -139,8 +145,11 @@ const handleChange = async (options: any = {}) => {

/* API */
const fetchWorkspaceUserList = async (params: WorkspaceUserListParameters) => {
const fetcher = state.isAdminMode
? SpaceConnector.clientV2.identity.user.list<UserListParameters, ListResponse<UserModel>>
: SpaceConnector.clientV2.identity.workspaceUser.list<WorkspaceUserListParameters, ListResponse<WorkspaceUserModel>>;
try {
const { results, total_count } = await SpaceConnector.clientV2.identity.workspaceUser.list<WorkspaceUserListParameters, ListResponse<WorkspaceUserModel>>(params);
const { results, total_count } = await fetcher(params);
state.filteredUserList = results ?? [];
userGroupPageState.users.list = results;
state.totalCount = total_count ?? 0;
Expand Down
36 changes: 23 additions & 13 deletions apps/web/src/services/iam/configurator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { RouteConfig } from 'vue-router';

import type { FeatureConfiguratorType, FeatureMenuConfig, FeatureUiAffect } from '@/lib/config/global-config/types/type';
import type {
FeatureConfiguratorType, FeatureMenuConfig, FeatureUiAffect, GlobalServiceConfig,
} from '@/lib/config/global-config/types/type';
import type { Menu } from '@/lib/menu/config';
import { MENU_ID } from '@/lib/menu/config';

Expand All @@ -21,31 +23,39 @@ class IamConfigurator implements FeatureConfiguratorType {
return isAdmin ? adminIamRoutes : iamRoutes;
}

getMenu(): FeatureMenuConfig {
getMenu(config?: GlobalServiceConfig): FeatureMenuConfig {
const alertManagerVersion = config?.ALERT_MANAGER?.VERSION;
const baseMenu: Menu = {
id: MENU_ID.IAM,
needPermissionByRole: true,
subMenuList: [],
order: 8,
};

const workspaceSubMenuList: Menu[] = [
{ id: MENU_ID.USER, needPermissionByRole: true },
{ id: MENU_ID.APP, needPermissionByRole: true },
];

const adminSubMenuList: Menu[] = [
{ id: MENU_ID.USER },
{ id: MENU_ID.APP },
{ id: MENU_ID.ROLE },
];

if (alertManagerVersion === 'V2') {
workspaceSubMenuList.splice(1, 0, { id: MENU_ID.USER_GROUP, needPermissionByRole: true });
adminSubMenuList.splice(1, 0, { id: MENU_ID.USER_GROUP });
}

return {
menu: {
...baseMenu,
subMenuList: [
{ id: MENU_ID.USER, needPermissionByRole: true },
{ id: MENU_ID.USER_GROUP, needPermissionByRole: true },
{ id: MENU_ID.APP, needPermissionByRole: true },
],
subMenuList: workspaceSubMenuList,
},
adminMenu: {
...baseMenu,
subMenuList: [
{ id: MENU_ID.USER },
{ id: MENU_ID.USER_GROUP },
{ id: MENU_ID.APP },
{ id: MENU_ID.ROLE },
],
subMenuList: adminSubMenuList,
},
version: this.version,
};
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/services/ops-flow/configurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class OpsFlowConfigurator implements FeatureConfiguratorType {
subMenuList: [
{ id: MENU_ID.OPS_FLOW_LANDING, needPermissionByRole: true },
{ id: MENU_ID.TASK_BOARD, needPermissionByRole: true },
{ id: MENU_ID.APP, needPermissionByRole: true },
],
},
adminMenu: {
Expand Down
Loading