From 9c7eaee88380a263feb4ca4e328446ceceab3fe3 Mon Sep 17 00:00:00 2001 From: Zero Date: Mon, 6 Sep 2021 14:37:17 +0800 Subject: [PATCH] adjust msp router & add member manage & add notify-group manage (#1046) * feat(msp): add member manage * feat(msp): adjust msp router feat(msp): remove service analysis * feat(msp): notify group fix(msp): mamber manage fix(msp): remove mock fix(msp): remove cconsole * fix(msp): add locales --- cspell.json | 4 ++ .../common/components/add-member-modal.tsx | 2 + .../components/authorize-member-modal.tsx | 2 + .../app/common/components/member-selector.tsx | 7 +++ shell/app/common/components/members-table.tsx | 16 +++++- shell/app/common/services/index.ts | 44 +++++++++++++--- shell/app/common/stores/member-scope.ts | 1 + shell/app/common/stores/msp-project-member.ts | 19 +++++++ shell/app/common/types/member.d.ts | 6 ++- shell/app/common/utils/go-to.tsx | 3 +- shell/app/locales/en.json | 1 + shell/app/locales/zh.json | 2 + .../app-notify/common-notify-group.tsx | 27 +++++++--- .../application/stores/notify-group.ts | 21 ++++++-- .../types/common-notify-group.d.ts | 14 ++++-- .../cmp/common/alarm-record/detail.tsx | 2 +- .../modules/cmp/common/alarm-record/index.tsx | 2 +- .../cmp/common/alarm-strategy/index.tsx | 20 +++++--- .../modules/cmp/common/custom-alarm/index.tsx | 4 +- .../custom-dashboard/custom-dashboard.tsx | 4 +- .../cmp/common/custom-dashboard/index.tsx | 2 +- .../cmp/stores/_common-custom-alarm.ts | 2 +- .../cmp/stores/_common-custom-dashboard.ts | 2 +- .../alarm-record/index.ts | 4 +- .../alarm-record/pages/detail.tsx | 2 +- .../alarm-record/pages/index.tsx | 2 +- .../alarm-record/services/alarm-record.ts | 0 .../alarm-record/stores/alarm-record.ts | 0 .../alarm-strategy}/index.js | 2 +- .../pages/alarm-index/index.tsx | 27 ++++++++++ .../pages/custom-alarm/index.tsx | 2 +- .../services/alarm-strategy.ts | 0 .../alarm-strategy}/services/custom-alarm.ts | 0 .../alarm-strategy}/stores/alarm-strategy.ts | 6 +-- .../stores/analysis-monitor-metadata.ts | 2 +- .../alarm-strategy}/stores/custom-alarm.ts | 2 +- shell/app/modules/msp/alarm-manage/index.ts | 50 +++++++++++++++++++ .../msp/alarm-manage/notify-group/index.scss | 7 +++ .../msp/alarm-manage/notify-group/index.tsx | 32 ++++++++++++ .../app/modules/msp/{config.ts => config.tsx} | 45 +++++++++++++---- shell/app/modules/msp/env-overview/index.ts | 24 +++++++++ .../service-list/index.ts | 13 +++-- .../service-list/pages/anomaly.tsx | 0 .../service-list/pages/index.scss | 0 .../service-list/pages/index.tsx | 2 +- .../service-list/pages/overview.tsx | 0 .../service-list/pages/process.tsx | 0 .../pages/service-list-dashboard.tsx | 2 +- .../service-list/pages/transaction.tsx | 2 +- .../topology/index.js | 10 ++-- .../service-mesh/circuit-breaker-form.tsx | 0 .../pages/service-mesh/fault-inject-form.tsx | 0 .../service-mesh/service-mesh-drawer.tsx | 0 .../pages/service-mesh/service-mesh.scss | 0 .../pages/topology-dashboard/index.scss | 0 .../pages/topology-dashboard/index.tsx | 2 +- .../pages/topology/components/box-ele.scss | 0 .../pages/topology/components/box-ele.tsx | 0 .../pages/topology/components/config.ts | 0 .../pages/topology/components/index.scss | 0 .../pages/topology/components/index.tsx | 0 .../topology/components/render-utils.tsx | 0 .../topology/components/scaleSelector.scss | 0 .../topology/components/scaleSelector.tsx | 0 .../topology/components/topology-ele.scss | 0 .../topology/components/topology-ele.tsx | 0 .../topology/components/topology-utils-v1.tsx | 0 .../topology/components/topology-utils-v2.tsx | 0 .../topology/components/topology-utils.scss | 0 .../pages/topology/components/utils.ts | 0 .../topology/pages/topology/link-text.scss | 0 .../topology/pages/topology/link-text.tsx | 0 .../topology/pages/topology/node-item.scss | 0 .../topology/pages/topology/node-item.tsx | 0 .../topology/pages/topology/topology.scss | 0 .../topology/pages/topology/topology.tsx | 4 +- .../topology/services/service-mesh.ts | 0 .../topology/services/topology.ts | 0 .../topology/stores/service-mesh.ts | 0 .../topology/stores/topology.ts | 0 .../topology/types/topology.d.ts | 0 .../msp/{pages => env-setting}/info/index.tsx | 2 +- .../member-manage}/index.tsx | 15 ++++-- .../msp/monitor/monitor-overview/index.js | 23 --------- .../custom-dashboard/index.ts | 6 +-- .../pages/custom-dashboard.tsx | 4 +- .../custom-dashboard/pages/index.tsx | 4 +- .../services/custom-dashboard.ts | 0 .../stores/custom-dashboard.ts | 2 +- .../stores/query-monitor-metadata.ts | 2 +- shell/app/modules/msp/query-analysis/index.ts | 23 +++++++++ shell/app/modules/msp/router.js | 48 ++++++++++++++---- .../app/modules/msp/stores/micro-service.tsx | 12 +++-- shell/app/styles/_mixin.scss | 17 +++++++ shell/app/styles/util.scss | 15 +----- .../user/common/perm-editor/perm-editor.tsx | 30 ++++++++--- shell/app/user/services/user.ts | 10 ++++ shell/app/user/stores/_perm-msp.ts | 24 +++++++++ shell/app/user/stores/_perm-project.ts | 41 +++++++++++++++ shell/app/user/stores/_perm-state.ts | 3 ++ shell/app/user/stores/permission.ts | 14 ++++-- shell/app/views/index.ejs | 2 +- 102 files changed, 588 insertions(+), 158 deletions(-) create mode 100644 shell/app/common/stores/msp-project-member.ts rename shell/app/modules/msp/{monitor => alarm-manage}/alarm-record/index.ts (81%) rename shell/app/modules/msp/{monitor => alarm-manage}/alarm-record/pages/detail.tsx (89%) rename shell/app/modules/msp/{monitor => alarm-manage}/alarm-record/pages/index.tsx (89%) rename shell/app/modules/msp/{monitor => alarm-manage}/alarm-record/services/alarm-record.ts (100%) rename shell/app/modules/msp/{monitor => alarm-manage}/alarm-record/stores/alarm-record.ts (100%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/index.js (89%) create mode 100644 shell/app/modules/msp/alarm-manage/alarm-strategy/pages/alarm-index/index.tsx rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/pages/custom-alarm/index.tsx (91%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/services/alarm-strategy.ts (100%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/services/custom-alarm.ts (100%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/stores/alarm-strategy.ts (100%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/stores/analysis-monitor-metadata.ts (93%) rename shell/app/modules/msp/{monitor/monitor-alarm => alarm-manage/alarm-strategy}/stores/custom-alarm.ts (87%) create mode 100644 shell/app/modules/msp/alarm-manage/index.ts create mode 100644 shell/app/modules/msp/alarm-manage/notify-group/index.scss create mode 100644 shell/app/modules/msp/alarm-manage/notify-group/index.tsx rename shell/app/modules/msp/{config.ts => config.tsx} (65%) create mode 100644 shell/app/modules/msp/env-overview/index.ts rename shell/app/modules/msp/{monitor => env-overview}/service-list/index.ts (77%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/anomaly.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/index.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/index.tsx (97%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/overview.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/process.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/service-list-dashboard.tsx (97%) rename shell/app/modules/msp/{monitor => env-overview}/service-list/pages/transaction.tsx (99%) rename shell/app/modules/msp/{monitor => env-overview}/topology/index.js (78%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/service-mesh/circuit-breaker-form.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/service-mesh/fault-inject-form.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/service-mesh/service-mesh-drawer.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/service-mesh/service-mesh.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology-dashboard/index.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology-dashboard/index.tsx (99%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/box-ele.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/box-ele.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/config.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/index.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/index.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/render-utils.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/scaleSelector.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/scaleSelector.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/topology-ele.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/topology-ele.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/topology-utils-v1.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/topology-utils-v2.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/topology-utils.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/components/utils.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/link-text.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/link-text.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/node-item.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/node-item.tsx (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/topology.scss (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/pages/topology/topology.tsx (98%) rename shell/app/modules/msp/{monitor => env-overview}/topology/services/service-mesh.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/services/topology.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/stores/service-mesh.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/stores/topology.ts (100%) rename shell/app/modules/msp/{monitor => env-overview}/topology/types/topology.d.ts (100%) rename shell/app/modules/msp/{pages => env-setting}/info/index.tsx (95%) rename shell/app/modules/msp/{monitor/monitor-alarm/pages/alarm-index => env-setting/member-manage}/index.tsx (69%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/index.ts (75%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/pages/custom-dashboard.tsx (83%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/pages/index.tsx (84%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/services/custom-dashboard.ts (100%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/stores/custom-dashboard.ts (93%) rename shell/app/modules/msp/{monitor => query-analysis}/custom-dashboard/stores/query-monitor-metadata.ts (94%) create mode 100644 shell/app/modules/msp/query-analysis/index.ts create mode 100644 shell/app/user/stores/_perm-msp.ts diff --git a/cspell.json b/cspell.json index 51ec84253d..7899ea26e2 100644 --- a/cspell.json +++ b/cspell.json @@ -38,6 +38,7 @@ "captcha", "Cascader", "cerr", + "chaxunfenxi", "chenweitao", "chunkhash", "CIDR", @@ -92,7 +93,9 @@ "fangfa", "filemanager", "filetree", + "fuwuguancesvg", "fwsl", + "gaojingguanli", "getrule", "gittar", "Glusterfs", @@ -109,6 +112,7 @@ "Hiragino", "holderjs", "hoverable", + "huanjinggailan", "huidaodingbu", "iconfont", "iconpark", diff --git a/shell/app/common/components/add-member-modal.tsx b/shell/app/common/components/add-member-modal.tsx index cc959a0d19..367779f49c 100644 --- a/shell/app/common/components/add-member-modal.tsx +++ b/shell/app/common/components/add-member-modal.tsx @@ -24,6 +24,7 @@ import { insertWhen } from '../utils'; import { getApps } from 'common/services'; import { useMount } from 'react-use'; import { Alert, message } from 'core/nusi'; +import mspProjectMember from 'common/stores/msp-project-member'; interface IProps { visible: boolean; @@ -41,6 +42,7 @@ const storeMap = { [MemberScope.ORG]: orgMemberStore, [MemberScope.APP]: appMemberStore, [MemberScope.SYS]: sysMemberStore, + [MemberScope.MSP]: mspProjectMember, }; export const AddMemberModal = ({ diff --git a/shell/app/common/components/authorize-member-modal.tsx b/shell/app/common/components/authorize-member-modal.tsx index 99a5f0e5a2..730c255890 100644 --- a/shell/app/common/components/authorize-member-modal.tsx +++ b/shell/app/common/components/authorize-member-modal.tsx @@ -24,6 +24,7 @@ import sysMemberStore from 'common/stores/sys-member'; import React from 'react'; import { useTempPaging } from './use-hooks'; import { useEffectOnce } from 'react-use'; +import mspProjectMember from 'common/stores/msp-project-member'; const { Option } = Select; @@ -37,6 +38,7 @@ const storeMap = { [MemberScope.PROJECT]: projectMemberStore, [MemberScope.ORG]: orgMemberStore, [MemberScope.APP]: appMemberStore, + [MemberScope.MSP]: mspProjectMember, [MemberScope.SYS]: sysMemberStore, }; diff --git a/shell/app/common/components/member-selector.tsx b/shell/app/common/components/member-selector.tsx index 3e0e0a16d3..47a8a590c1 100644 --- a/shell/app/common/components/member-selector.tsx +++ b/shell/app/common/components/member-selector.tsx @@ -29,11 +29,13 @@ import orgStore from 'app/org-home/stores/org'; import userStore from 'app/user/stores'; import sysMemberStore from 'common/stores/sys-member'; import { useUserMap } from 'core/stores/userMap'; +import mspProjectMember from 'common/stores/msp-project-member'; const storeMap = { [MemberScope.PROJECT]: projectMemberStore, [MemberScope.ORG]: orgMemberStore, [MemberScope.APP]: appMemberStore, + [MemberScope.MSP]: mspProjectMember, [MemberScope.SYS]: sysMemberStore, }; @@ -387,6 +389,11 @@ export const AddMemberSelector = (props: IAddProps) => { scopeType: MemberScope.ORG, scopeId: orgId, }, + [MemberScope.MSP]: { + // 添加项目成员:从org成员中选择 + scopeType: MemberScope.ORG, + scopeId: orgId, + }, [MemberScope.APP]: { // 添加项目成员:从project中选择 scopeType: MemberScope.PROJECT, diff --git a/shell/app/common/components/members-table.tsx b/shell/app/common/components/members-table.tsx index 9177946735..aaf108f86b 100644 --- a/shell/app/common/components/members-table.tsx +++ b/shell/app/common/components/members-table.tsx @@ -36,11 +36,13 @@ import memberLabelStore from 'common/stores/member-label'; import orgStore from 'app/org-home/stores/org'; import './members-table.scss'; import { FULL_ROOT_DOMAIN } from '../constants'; +import mspProjectMember from 'common/stores/msp-project-member'; const storeMap = { [MemberScope.ORG]: orgMemberStore, [MemberScope.PROJECT]: projectMemberStore, [MemberScope.APP]: appMemberStore, + [MemberScope.MSP]: mspProjectMember, [MemberScope.SYS]: sysMemberStore, }; @@ -82,7 +84,11 @@ export const MembersTable = ({ const currentOrg = orgStore.useStore((s) => s.currentOrg); const { id: orgId, name: orgName, displayName: orgDisplayName } = currentOrg; - const [projectMemberPerm, appMemberPerm] = usePerm((s) => [s.project.member, s.app.member]); + const [projectMemberPerm, appMemberPerm, mspProjectMemberPerm] = usePerm((s) => [ + s.project.member, + s.app.member, + s.project.microService.member, + ]); const { id: currentUserId } = loginUser; const { params } = routeInfoStore.getState((s) => s); const isAdminManager = scopeKey === MemberScope.SYS && loginUser.adminRoles.includes('Manager'); @@ -116,6 +122,7 @@ export const MembersTable = ({ [MemberScope.ORG]: String(orgId), [MemberScope.PROJECT]: `${params.projectId || ''}`, [MemberScope.APP]: `${params.appId || ''}`, + [MemberScope.MSP]: `${params.projectId || ''}`, }; const scopeId = scopeIdMap[scopeKey]; @@ -140,6 +147,13 @@ export const MembersTable = ({ showAuthorize: false, // 应用级别无授权 invite: false, }, + [MemberScope.MSP]: { + add: mspProjectMemberPerm.addProjectMember.pass, + edit: mspProjectMemberPerm.editProjectMember.pass, + delete: mspProjectMemberPerm.removeProjectMember.pass, + showAuthorize: false, + invite: false, + }, }; const memberAuth = { ...memberAuthMap[scopeKey], ...overwriteAuth }; diff --git a/shell/app/common/services/index.ts b/shell/app/common/services/index.ts index b8d3b0a441..eb12a9a42a 100644 --- a/shell/app/common/services/index.ts +++ b/shell/app/common/services/index.ts @@ -12,6 +12,7 @@ // along with this program. If not, see . import agent from 'agent'; +import { MemberScope } from 'common/stores/member-scope'; interface IPlatformUser { avatar: string; @@ -38,10 +39,28 @@ export const fetchLog = ({ .then((response: any) => response.body); }; +const convert = (payload: MEMBER.UpdateMemberBody) => { + if (payload.scope.type === MemberScope.MSP) { + return { + ...payload, + scope: { + ...payload.scope, + type: MemberScope.PROJECT, + }, + }; + } + return payload; +}; + export function getMembers(payload: MEMBER.GetListServiceQuery) { + const url = payload.scopeType === MemberScope.MSP ? '/api/msp/members' : '/api/members'; + const newPayload = { ...payload }; + if (newPayload.scopeType === MemberScope.MSP) { + newPayload.scopeType = MemberScope.PROJECT; + } return agent - .get('/api/members') - .query(payload) + .get(url) + .query(newPayload) .then((response: any) => response.body); } @@ -64,23 +83,31 @@ export const searchPlatformUserList = ( }; export function getRoleMap(payload: MEMBER.GetRoleTypeQuery): IPagingResp { + const url = + payload.scopeType === MemberScope.MSP ? '/api/msp/members/action/list-roles' : '/api/members/actions/list-roles'; + const newPayload = { ...payload }; + if (newPayload.scopeType === MemberScope.MSP) { + newPayload.scopeType = MemberScope.PROJECT; + } return agent - .get('/api/members/actions/list-roles') - .query(payload) + .get(url) + .query(newPayload) .then((response: any) => response.body); } export function updateMembers(payload: MEMBER.UpdateMemberBody) { + const url = payload.scope.type === MemberScope.MSP ? '/api/msp/members' : '/api/members'; return agent - .post('/api/members') - .send({ ...payload, options: { rewrite: true } }) // 接口上写死options.rewrite=true,避免新增用户(已有的用户)设置角色无用 + .post(url) + .send({ ...convert(payload), options: { rewrite: true } }) // 接口上写死options.rewrite=true,避免新增用户(已有的用户)设置角色无用 .then((response: any) => response.body); } export function removeMember(payload: MEMBER.RemoveMemberBody) { + const url = payload.scope.type === MemberScope.MSP ? '/api/msp/members/action/remove' : '/api/members/actions/remove'; return agent - .post('/api/members/actions/remove') - .send(payload) + .post(url) + .send(convert(payload)) .then((response: any) => response.body); } @@ -137,3 +164,4 @@ export const getRenderPageLayout = (payload: CONFIG_PAGE.RenderConfig) => { .send(payload) .then((response: any) => response.body); }; +// can ignore the default pageSize diff --git a/shell/app/common/stores/member-scope.ts b/shell/app/common/stores/member-scope.ts index 2be7a125a7..6bd3f4a105 100644 --- a/shell/app/common/stores/member-scope.ts +++ b/shell/app/common/stores/member-scope.ts @@ -17,5 +17,6 @@ export enum MemberScope { ORG = 'org', PROJECT = 'project', APP = 'app', + MSP = 'msp', SYS = 'sys', } diff --git a/shell/app/common/stores/msp-project-member.ts b/shell/app/common/stores/msp-project-member.ts new file mode 100644 index 0000000000..b36e595114 --- /dev/null +++ b/shell/app/common/stores/msp-project-member.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import { createMemberStore } from 'common/stores/_member'; +import { MemberScope } from 'app/common/stores/member-scope'; + +const mspProjectMember = createMemberStore(MemberScope.MSP); + +export default mspProjectMember; diff --git a/shell/app/common/types/member.d.ts b/shell/app/common/types/member.d.ts index da7daef193..d19e17c954 100644 --- a/shell/app/common/types/member.d.ts +++ b/shell/app/common/types/member.d.ts @@ -12,6 +12,7 @@ // along with this program. If not, see . declare namespace MEMBER { + type ScopeType = import('common/stores/member-scope').MemberScope; interface GetListQuery extends Partial { pageNo: number; scope: MemberScope; @@ -28,7 +29,7 @@ declare namespace MEMBER { interface GetListServiceQuery { pageNo: number; pageSize: number; - scopeType: string; + scopeType: ScopeType; scopeId: string; role?: string[]; q?: string; @@ -46,7 +47,7 @@ declare namespace MEMBER { interface MemberScope { id: string; - type: string; + type: ScopeType; } interface UpdateMemberBody { @@ -59,6 +60,7 @@ declare namespace MEMBER { } interface RemoveMemberBody { + scopeType: ScopeType; scope: MemberScope; userIds: string[]; } diff --git a/shell/app/common/utils/go-to.tsx b/shell/app/common/utils/go-to.tsx index 15d207f820..b163ab5d7e 100644 --- a/shell/app/common/utils/go-to.tsx +++ b/shell/app/common/utils/go-to.tsx @@ -200,6 +200,7 @@ export enum pages { mspOverviewRoot = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}', mspOverview = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}?appId={appId}&runtimeId={runtimeId}', mspApiStrategy = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/gateway/api-package/{packageId}/detail/api-policies/safety-policy', + mspProjectNotifyGroup = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/alarm-management/{terminusKey}/notify-group', mspTopology = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/topology/{terminusKey}?appId={appId}', monitorAPIOverview = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/gateway/apis/api-monitor?appId={appId}&runtimeId={runtimeId}', microTraceSearch = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/monitor/{terminusKey}/trace/search?appId={appId}&timeFrom={timeFrom}&timeTo={timeTo}&status={status}', @@ -245,7 +246,7 @@ export enum pages { micro_serviceCustomDashboardDetail = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/monitor/{terminusKey}/custom-dashboard/{customDashboardId}', // 微服务-服务分析页 - mspServiceAnalyze = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/monitor/{terminusKey}/service-list/{applicationId}/{serviceId}/{serviceName}', + mspServiceAnalyze = '/{orgName}/msp/{projectId}/{env}/{tenantGroup}/synopsis/{terminusKey}/service-list/{applicationId}/{serviceId}/{serviceName}', // 企业日志分析规则 addLogAnalyzeRule = '/{orgName}/cmp/log/rule/add?source={source}', diff --git a/shell/app/locales/en.json b/shell/app/locales/en.json index 9cf91864f0..669944b4e6 100644 --- a/shell/app/locales/en.json +++ b/shell/app/locales/en.json @@ -2168,6 +2168,7 @@ "node traffic management": "node traffic management", "normal": "normal", "not satisfied": "not satisfied", + "notification group management": "notification group management", "number of connection": "number of connection", "number of errors": "number of errors", "number of occurrences": "number of occurrences", diff --git a/shell/app/locales/zh.json b/shell/app/locales/zh.json index a673fe8ff0..bb873968e5 100644 --- a/shell/app/locales/zh.json +++ b/shell/app/locales/zh.json @@ -1413,6 +1413,7 @@ "default": "默认", "default value": "默认值", "delete": "删除", + "delete {name}": "删除{name}", "delete certificate": "删除证书", "deleted": "已删除", "deleted successfully": "删除成功", @@ -2168,6 +2169,7 @@ "node traffic management": "节点流量管理", "normal": "正常", "not satisfied": "不满意", + "notification group management": "通知组管理", "number of connection": "连接数", "number of errors": "错误次数", "number of occurrences": "发生次数", diff --git a/shell/app/modules/application/pages/settings/components/app-notify/common-notify-group.tsx b/shell/app/modules/application/pages/settings/components/app-notify/common-notify-group.tsx index 990957b477..119a031291 100644 --- a/shell/app/modules/application/pages/settings/components/app-notify/common-notify-group.tsx +++ b/shell/app/modules/application/pages/settings/components/app-notify/common-notify-group.tsx @@ -14,10 +14,10 @@ import React from 'react'; import moment from 'moment'; import i18n from 'i18n'; -import { isEmpty, map, take, head } from 'lodash'; -import { Spin, Modal, Tooltip, Select, Table, Button, message } from 'core/nusi'; -import { ErdaCustomIcon, Avatar, useSwitch, FormModal, useUpdate, MemberSelector } from 'common'; -import { FormInstance, ColumnProps } from 'core/common/interface'; +import { head, isEmpty, map, take } from 'lodash'; +import { Button, message, Modal, Select, Spin, Table, Tooltip } from 'core/nusi'; +import { Avatar, ErdaCustomIcon, FormModal, MemberSelector, useSwitch, useUpdate } from 'common'; +import { ColumnProps, FormInstance } from 'core/common/interface'; import { useMount, useUnmount } from 'react-use'; import { useUserMap } from 'core/stores/userMap'; import { useLoading } from 'core/stores/loading'; @@ -85,6 +85,7 @@ interface IProps { commonPayload: { scopeType: string; scopeId: string; + projectId?: string; }; memberStore: any; } @@ -179,9 +180,23 @@ const NotifyGroup = ({ memberStore, commonPayload }: IProps) => { }); const isEditing = !isEmpty(activedData); + const isInMsp = commonPayload.scopeType.includes('msp'); + + const memberSelectProps = isInMsp + ? { + scopeType: 'msp', + scopeId: commonPayload.projectId, + } + : commonPayload; + + const scope = isInMsp ? 'msp' : commonPayload.scopeType; + useMount(() => { handleGetNotifyGroups(); - getRoleMap({ scopeType: commonPayload.scopeType, scopeId: commonPayload.scopeId }); + getRoleMap({ + scopeType: scope, + scopeId: commonPayload.scopeId, + }); }); useUnmount(() => { @@ -356,7 +371,7 @@ const NotifyGroup = ({ memberStore, commonPayload }: IProps) => { label: groupTargetMap[groupType], required: true, getComp: () => { - return ; + return ; }, }; break; diff --git a/shell/app/modules/application/stores/notify-group.ts b/shell/app/modules/application/stores/notify-group.ts index 5f3f2bb02c..2376c821cf 100644 --- a/shell/app/modules/application/stores/notify-group.ts +++ b/shell/app/modules/application/stores/notify-group.ts @@ -30,22 +30,37 @@ const initState: IState = { }, }; +const convertScope = (payload: T): T => { + const data = { ...payload }; + if (payload?.scopeType === 'msp') { + data.scopeType = 'project'; + } + return data; +}; + const notifyGroup = createStore({ name: 'common-notify-group', state: initState, effects: { async getNotifyGroups({ call, update }, payload?: COMMON_NOTIFY.IGetNotifyGroupQuery) { - const { list } = await call(getNotifyGroups, payload); + const { list } = await call( + getNotifyGroups, + payload ? convertScope(payload) : payload, + ); update({ notifyGroups: list }); }, async deleteNotifyGroups({ call }, payload: string) { await call(deleteNotifyGroups, payload, { successMsg: i18n.t('deleted successfully') }); }, async createNotifyGroups({ call }, payload: COMMON_NOTIFY.ICreateNotifyGroupQuery) { - await call(createNotifyGroups, payload, { successMsg: i18n.t('established successfully') }); + await call(createNotifyGroups, convertScope(payload), { + successMsg: i18n.t('established successfully'), + }); }, async updateNotifyGroups({ call }, payload: COMMON_NOTIFY.ICreateNotifyGroupQuery) { - await call(updateNotifyGroups, payload, { successMsg: i18n.t('updated successfully') }); + await call(updateNotifyGroups, convertScope(payload), { + successMsg: i18n.t('updated successfully'), + }); }, }, reducers: { diff --git a/shell/app/modules/application/types/common-notify-group.d.ts b/shell/app/modules/application/types/common-notify-group.d.ts index 7c368a348e..9b32ef6687 100644 --- a/shell/app/modules/application/types/common-notify-group.d.ts +++ b/shell/app/modules/application/types/common-notify-group.d.ts @@ -12,6 +12,8 @@ // along with this program. If not, see . declare namespace COMMON_NOTIFY { + type ScopeType = 'org' | 'app' | 'project' | 'msp'; + interface INotifyGroupTarget { type: string; values: Array<{ @@ -19,26 +21,32 @@ declare namespace COMMON_NOTIFY { secret?: string; }>; } + interface INotifyGroup { createdAt: string; creator: string; id: number; name: string; scopeId: string; - scopeType: string; + scopeType: ScopeType; targets: INotifyGroupTarget[]; } + interface ICreateNotifyGroupQuery { id?: number; - scopeType?: string; + scopeType?: ScopeType; scopeId?: string; + label?: string; name: string; targets: INotifyGroupTarget[]; } + interface IGetNotifyGroupQuery { - scopeType: string; + scopeType: ScopeType; scopeId: string; + label?: string; } + interface ExternalUserInfo { uniKey: string; username: string; diff --git a/shell/app/modules/cmp/common/alarm-record/detail.tsx b/shell/app/modules/cmp/common/alarm-record/detail.tsx index 8255104a6c..95c3c4c19b 100644 --- a/shell/app/modules/cmp/common/alarm-record/detail.tsx +++ b/shell/app/modules/cmp/common/alarm-record/detail.tsx @@ -28,7 +28,7 @@ import SelectProjectModal from '../select-project-modal'; import { ISSUE_TYPE } from 'project/common/components/issue/issue-config'; import orgAlarmRecordStore from 'cmp/stores/alarm-record'; -import mspAlarmRecordStore from 'msp/monitor/alarm-record/stores/alarm-record'; +import mspAlarmRecordStore from 'msp/alarm-manage/alarm-record/stores/alarm-record'; import './detail.scss'; diff --git a/shell/app/modules/cmp/common/alarm-record/index.tsx b/shell/app/modules/cmp/common/alarm-record/index.tsx index 7b31347d30..293e7aa0eb 100644 --- a/shell/app/modules/cmp/common/alarm-record/index.tsx +++ b/shell/app/modules/cmp/common/alarm-record/index.tsx @@ -26,7 +26,7 @@ import { AlarmState } from 'cmp/common/alarm-state'; import { useUserMap } from 'core/stores/userMap'; import routeInfoStore from 'core/stores/route'; import orgAlarmRecordStore from 'cmp/stores/alarm-record'; -import mspAlarmRecordStore from 'msp/monitor/alarm-record/stores/alarm-record'; +import mspAlarmRecordStore from 'msp/alarm-manage/alarm-record/stores/alarm-record'; export enum AlarmRecordScope { ORG = 'org', diff --git a/shell/app/modules/cmp/common/alarm-strategy/index.tsx b/shell/app/modules/cmp/common/alarm-strategy/index.tsx index e8b39310da..8cb1ed866c 100644 --- a/shell/app/modules/cmp/common/alarm-strategy/index.tsx +++ b/shell/app/modules/cmp/common/alarm-strategy/index.tsx @@ -25,7 +25,7 @@ import notifyGroupStore from 'application/stores/notify-group'; import orgMemberStore from 'common/stores/org-member'; import projectMemberStore from 'common/stores/project-member'; import cmpAlarmStrategyStore from 'app/modules/cmp/stores/alarm-strategy'; -import mspAlarmStrategyStore from 'app/modules/msp/monitor/monitor-alarm/stores/alarm-strategy'; +import mspAlarmStrategyStore from 'app/modules/msp/alarm-manage/alarm-strategy/stores/alarm-strategy'; import { notifyChannelOptionsMap, smsNotifyChannelOptionsMap, @@ -35,12 +35,14 @@ import { usePerm, WithAuth } from 'user/common'; import clusterStore from 'cmp/stores/cluster'; import orgStore from 'app/org-home/stores/org'; import './index.scss'; +import routeInfoStore from 'core/stores/route'; const { confirm, warning } = Modal; enum ScopeType { ORG = 'org', PROJECT = 'project', + MSP = 'msp', } enum SilencePeriodType { @@ -55,26 +57,28 @@ const SILENCE_PERIOD_POLICY_MAP = { const alarmStrategyStoreMap = { [ScopeType.ORG]: cmpAlarmStrategyStore, - [ScopeType.PROJECT]: mspAlarmStrategyStore, + [ScopeType.MSP]: mspAlarmStrategyStore, }; const memberStoreMap = { [ScopeType.ORG]: orgMemberStore, - [ScopeType.PROJECT]: projectMemberStore, + [ScopeType.MSP]: projectMemberStore, }; const notifyGroupPage = { [ScopeType.ORG]: goTo.pages.cmpNotifyGroup, - [ScopeType.PROJECT]: goTo.pages.projectNotifyGroup, + [ScopeType.MSP]: goTo.pages.mspProjectNotifyGroup, }; interface IProps { - scopeType: ScopeType.ORG | ScopeType.PROJECT; + scopeType: ScopeType.ORG | ScopeType.MSP; scopeId: string; + commonPayload?: Obj; } -export default ({ scopeType, scopeId }: IProps) => { +export default ({ scopeType, scopeId, commonPayload }: IProps) => { const memberStore = memberStoreMap[scopeType]; + const params = routeInfoStore.useStore((s) => s.params); const roleMap = memberStore.useStore((s) => s.roleMap); const { getRoleMap } = memberStore.effects; const alarmStrategyStore = alarmStrategyStoreMap[scopeType]; @@ -117,7 +121,7 @@ export default ({ scopeType, scopeId }: IProps) => { getAlerts(); getAlarmScopes(); getAlertTypes(); - getNotifyGroups({ scopeType, scopeId }); + getNotifyGroups(scopeType === ScopeType.MSP ? commonPayload : { scopeType, scopeId }); getRoleMap({ scopeType, scopeId }); }); @@ -415,7 +419,7 @@ export default ({ scopeType, scopeId }: IProps) => { { - goTo(notifyGroupPage[scopeType], { projectId: scopeId }); + goTo(notifyGroupPage[scopeType], { projectId: scopeId, ...params }); }} > {i18n.t('org:add more notification groups')} diff --git a/shell/app/modules/cmp/common/custom-alarm/index.tsx b/shell/app/modules/cmp/common/custom-alarm/index.tsx index 24c949e3c9..ab3c5aea19 100644 --- a/shell/app/modules/cmp/common/custom-alarm/index.tsx +++ b/shell/app/modules/cmp/common/custom-alarm/index.tsx @@ -52,9 +52,9 @@ import { useMount } from 'react-use'; import { FormInstance } from 'core/common/interface'; import { useLoading } from 'core/stores/loading'; import orgCustomAlarmStore from 'app/modules/cmp/stores/custom-alarm'; -import mspCustomAlarmStore from 'msp/monitor/monitor-alarm/stores/custom-alarm'; +import mspCustomAlarmStore from 'msp/alarm-manage/alarm-strategy/stores/custom-alarm'; import orgMonitorMetaDataStore from 'app/modules/cmp/stores/analysis-monitor-metadata'; -import mspMonitorMetaDataStore from 'app/modules/msp/monitor/monitor-alarm/stores/analysis-monitor-metadata'; +import mspMonitorMetaDataStore from 'app/modules/msp/alarm-manage/alarm-strategy/stores/analysis-monitor-metadata'; import { createLoadDataFn } from 'cmp/common/custom-dashboard/data-loader'; import './index.scss'; diff --git a/shell/app/modules/cmp/common/custom-dashboard/custom-dashboard.tsx b/shell/app/modules/cmp/common/custom-dashboard/custom-dashboard.tsx index cfb0fe2608..86bf3572b2 100644 --- a/shell/app/modules/cmp/common/custom-dashboard/custom-dashboard.tsx +++ b/shell/app/modules/cmp/common/custom-dashboard/custom-dashboard.tsx @@ -22,9 +22,9 @@ import moment, { Moment } from 'moment'; import { useMount } from 'react-use'; import routeInfoStore from 'core/stores/route'; import orgMonitorMetaDataStore from 'cmp/stores/query-monitor-metadata'; -import mspMonitorMetaDataStore from 'msp/monitor/custom-dashboard/stores/query-monitor-metadata'; +import mspMonitorMetaDataStore from 'msp/query-analysis/custom-dashboard/stores/query-monitor-metadata'; import orgCustomDashboardStore from 'app/modules/cmp/stores/custom-dashboard'; -import mspCustomDashboardStore from 'msp/monitor/custom-dashboard/stores/custom-dashboard'; +import mspCustomDashboardStore from 'msp/query-analysis/custom-dashboard/stores/custom-dashboard'; import { CustomDashboardScope } from 'app/modules/cmp/stores/_common-custom-dashboard'; import { getVariableStr } from '../utils'; import { createLoadDataFn as createOldLoadDataFn } from './data-loader'; diff --git a/shell/app/modules/cmp/common/custom-dashboard/index.tsx b/shell/app/modules/cmp/common/custom-dashboard/index.tsx index 9e88c342f9..dc48776cf6 100644 --- a/shell/app/modules/cmp/common/custom-dashboard/index.tsx +++ b/shell/app/modules/cmp/common/custom-dashboard/index.tsx @@ -19,7 +19,7 @@ import i18n from 'i18n'; import routeInfoStore from 'core/stores/route'; import { useLoading } from 'core/stores/loading'; import orgCustomDashboardStore from 'app/modules/cmp/stores/custom-dashboard'; -import mspCustomDashboardStore from 'msp/monitor/custom-dashboard/stores/custom-dashboard'; +import mspCustomDashboardStore from 'msp/query-analysis/custom-dashboard/stores/custom-dashboard'; import { CustomDashboardScope } from 'app/modules/cmp/stores/_common-custom-dashboard'; const storeMap = { diff --git a/shell/app/modules/cmp/stores/_common-custom-alarm.ts b/shell/app/modules/cmp/stores/_common-custom-alarm.ts index 2872b82e8f..cb6a7ef7a5 100644 --- a/shell/app/modules/cmp/stores/_common-custom-alarm.ts +++ b/shell/app/modules/cmp/stores/_common-custom-alarm.ts @@ -13,7 +13,7 @@ import { createStore } from 'core/cube'; import { keyBy, map, isEmpty } from 'lodash'; -import * as mspCustomAlarmService from 'msp/monitor/monitor-alarm/services/custom-alarm'; +import * as mspCustomAlarmService from 'msp/alarm-manage/alarm-strategy/services/custom-alarm'; import * as orgCustomAlarmService from 'app/modules/cmp/services/custom-alarm'; import i18n from 'i18n'; import { PAGINATION } from 'app/constants'; diff --git a/shell/app/modules/cmp/stores/_common-custom-dashboard.ts b/shell/app/modules/cmp/stores/_common-custom-dashboard.ts index ca9035c050..541597a964 100644 --- a/shell/app/modules/cmp/stores/_common-custom-dashboard.ts +++ b/shell/app/modules/cmp/stores/_common-custom-dashboard.ts @@ -17,7 +17,7 @@ import { getDefaultPaging, getTimeSpan } from 'common/utils'; import breadcrumbStore from 'app/layout/stores/breadcrumb'; import * as orgCustomDashboardService from 'cmp/services/custom-dashboard'; -import * as mspCustomDashboardService from 'msp/monitor/custom-dashboard/services/custom-dashboard'; +import * as mspCustomDashboardService from 'msp/query-analysis/custom-dashboard/services/custom-dashboard'; import { ITimeRange, transformRange } from 'common/components/time-select/common'; export enum CustomDashboardScope { diff --git a/shell/app/modules/msp/monitor/alarm-record/index.ts b/shell/app/modules/msp/alarm-manage/alarm-record/index.ts similarity index 81% rename from shell/app/modules/msp/monitor/alarm-record/index.ts rename to shell/app/modules/msp/alarm-manage/alarm-record/index.ts index c8b1a1dd4a..06bb53ec0e 100644 --- a/shell/app/modules/msp/monitor/alarm-record/index.ts +++ b/shell/app/modules/msp/alarm-manage/alarm-record/index.ts @@ -20,10 +20,10 @@ export default () => ({ { path: ':recordId', breadcrumbName: '{alarmRecordName}', - getComp: (cb: any) => cb(import('msp/monitor/alarm-record/pages/detail')), + getComp: (cb: RouterGetComp) => cb(import('msp/alarm-manage/alarm-record/pages/detail')), }, { - getComp: (cb: any) => cb(import('msp/monitor/alarm-record/pages')), + getComp: (cb: RouterGetComp) => cb(import('msp/alarm-manage/alarm-record/pages')), }, ], }); diff --git a/shell/app/modules/msp/monitor/alarm-record/pages/detail.tsx b/shell/app/modules/msp/alarm-manage/alarm-record/pages/detail.tsx similarity index 89% rename from shell/app/modules/msp/monitor/alarm-record/pages/detail.tsx rename to shell/app/modules/msp/alarm-manage/alarm-record/pages/detail.tsx index 864c852e5c..34989b3e5b 100644 --- a/shell/app/modules/msp/monitor/alarm-record/pages/detail.tsx +++ b/shell/app/modules/msp/alarm-manage/alarm-record/pages/detail.tsx @@ -12,7 +12,7 @@ // along with this program. If not, see . import React from 'react'; -import AlarmRecordDetail, { AlarmRecordScope } from 'app/modules/cmp/common/alarm-record/detail'; +import AlarmRecordDetail, { AlarmRecordScope } from 'cmp/common/alarm-record/detail'; import routeInfoStore from 'core/stores/route'; export default () => { diff --git a/shell/app/modules/msp/monitor/alarm-record/pages/index.tsx b/shell/app/modules/msp/alarm-manage/alarm-record/pages/index.tsx similarity index 89% rename from shell/app/modules/msp/monitor/alarm-record/pages/index.tsx rename to shell/app/modules/msp/alarm-manage/alarm-record/pages/index.tsx index 7f9ae70a42..4f1e760ae2 100644 --- a/shell/app/modules/msp/monitor/alarm-record/pages/index.tsx +++ b/shell/app/modules/msp/alarm-manage/alarm-record/pages/index.tsx @@ -12,6 +12,6 @@ // along with this program. If not, see . import React from 'react'; -import AlarmRecord, { AlarmRecordScope } from 'app/modules/cmp/common/alarm-record'; +import AlarmRecord, { AlarmRecordScope } from 'cmp/common/alarm-record'; export default () => ; diff --git a/shell/app/modules/msp/monitor/alarm-record/services/alarm-record.ts b/shell/app/modules/msp/alarm-manage/alarm-record/services/alarm-record.ts similarity index 100% rename from shell/app/modules/msp/monitor/alarm-record/services/alarm-record.ts rename to shell/app/modules/msp/alarm-manage/alarm-record/services/alarm-record.ts diff --git a/shell/app/modules/msp/monitor/alarm-record/stores/alarm-record.ts b/shell/app/modules/msp/alarm-manage/alarm-record/stores/alarm-record.ts similarity index 100% rename from shell/app/modules/msp/monitor/alarm-record/stores/alarm-record.ts rename to shell/app/modules/msp/alarm-manage/alarm-record/stores/alarm-record.ts diff --git a/shell/app/modules/msp/monitor/monitor-alarm/index.js b/shell/app/modules/msp/alarm-manage/alarm-strategy/index.js similarity index 89% rename from shell/app/modules/msp/monitor/monitor-alarm/index.js rename to shell/app/modules/msp/alarm-manage/alarm-strategy/index.js index 4b8d974898..fb455bf7a8 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/index.js +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/index.js @@ -17,7 +17,7 @@ function AlarmRouter() { return { path: 'alarm', pageName: i18n.t('alarm strategy'), - getComp: (cb) => cb(import('monitor-alarm/pages/alarm-index')), + getComp: (cb) => cb(import('msp/alarm-manage/alarm-strategy/pages/alarm-index')), }; } diff --git a/shell/app/modules/msp/alarm-manage/alarm-strategy/pages/alarm-index/index.tsx b/shell/app/modules/msp/alarm-manage/alarm-strategy/pages/alarm-index/index.tsx new file mode 100644 index 0000000000..8078cc9af1 --- /dev/null +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/pages/alarm-index/index.tsx @@ -0,0 +1,27 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React from 'react'; +import routeInfoStore from 'core/stores/route'; +import AlarmStrategy from 'cmp/common/alarm-strategy'; + +export default () => { + const { env, terminusKey, projectId } = routeInfoStore.useStore((s) => s.params); + return ( + + ); +}; diff --git a/shell/app/modules/msp/monitor/monitor-alarm/pages/custom-alarm/index.tsx b/shell/app/modules/msp/alarm-manage/alarm-strategy/pages/custom-alarm/index.tsx similarity index 91% rename from shell/app/modules/msp/monitor/monitor-alarm/pages/custom-alarm/index.tsx rename to shell/app/modules/msp/alarm-manage/alarm-strategy/pages/custom-alarm/index.tsx index 992c30e7d1..f134f34899 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/pages/custom-alarm/index.tsx +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/pages/custom-alarm/index.tsx @@ -12,6 +12,6 @@ // along with this program. If not, see . import React from 'react'; -import CustomAlarm from 'app/modules/cmp/common/custom-alarm'; +import CustomAlarm from 'cmp/common/custom-alarm'; export default () => ; diff --git a/shell/app/modules/msp/monitor/monitor-alarm/services/alarm-strategy.ts b/shell/app/modules/msp/alarm-manage/alarm-strategy/services/alarm-strategy.ts similarity index 100% rename from shell/app/modules/msp/monitor/monitor-alarm/services/alarm-strategy.ts rename to shell/app/modules/msp/alarm-manage/alarm-strategy/services/alarm-strategy.ts diff --git a/shell/app/modules/msp/monitor/monitor-alarm/services/custom-alarm.ts b/shell/app/modules/msp/alarm-manage/alarm-strategy/services/custom-alarm.ts similarity index 100% rename from shell/app/modules/msp/monitor/monitor-alarm/services/custom-alarm.ts rename to shell/app/modules/msp/alarm-manage/alarm-strategy/services/custom-alarm.ts diff --git a/shell/app/modules/msp/monitor/monitor-alarm/stores/alarm-strategy.ts b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/alarm-strategy.ts similarity index 100% rename from shell/app/modules/msp/monitor/monitor-alarm/stores/alarm-strategy.ts rename to shell/app/modules/msp/alarm-manage/alarm-strategy/stores/alarm-strategy.ts index a764af7094..3860b3eb52 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/stores/alarm-strategy.ts +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/alarm-strategy.ts @@ -14,13 +14,13 @@ import { createStore } from 'core/cube'; import { forEach } from 'lodash'; import { - getAlerts, - getAlertDetail, createAlert, + deleteAlert, editAlert, + getAlertDetail, + getAlerts, getAlertTypes, toggleAlert, - deleteAlert, } from '../services/alarm-strategy'; import { getApps } from 'common/services'; import i18n from 'i18n'; diff --git a/shell/app/modules/msp/monitor/monitor-alarm/stores/analysis-monitor-metadata.ts b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/analysis-monitor-metadata.ts similarity index 93% rename from shell/app/modules/msp/monitor/monitor-alarm/stores/analysis-monitor-metadata.ts rename to shell/app/modules/msp/alarm-manage/alarm-strategy/stores/analysis-monitor-metadata.ts index f0f09fc02e..6091548b14 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/stores/analysis-monitor-metadata.ts +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/analysis-monitor-metadata.ts @@ -15,7 +15,7 @@ import { MonitorMetaDataScope, MonitorMetaDataMode, createMonitorMetaDataStore, -} from 'app/modules/cmp/stores/_common-monitor-metadata'; +} from 'cmp/stores/_common-monitor-metadata'; const analysisMonitorMetadata = createMonitorMetaDataStore( MonitorMetaDataScope.MICRO_SERVICE, diff --git a/shell/app/modules/msp/monitor/monitor-alarm/stores/custom-alarm.ts b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/custom-alarm.ts similarity index 87% rename from shell/app/modules/msp/monitor/monitor-alarm/stores/custom-alarm.ts rename to shell/app/modules/msp/alarm-manage/alarm-strategy/stores/custom-alarm.ts index 601734b999..982239e0da 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/stores/custom-alarm.ts +++ b/shell/app/modules/msp/alarm-manage/alarm-strategy/stores/custom-alarm.ts @@ -11,7 +11,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { createCustomAlarmStore, CustomAlarmScope } from 'app/modules/cmp/stores/_common-custom-alarm'; +import { createCustomAlarmStore, CustomAlarmScope } from 'cmp/stores/_common-custom-alarm'; const customAlarm = createCustomAlarmStore(CustomAlarmScope.MICRO_SERVICE); diff --git a/shell/app/modules/msp/alarm-manage/index.ts b/shell/app/modules/msp/alarm-manage/index.ts new file mode 100644 index 0000000000..0cbea53202 --- /dev/null +++ b/shell/app/modules/msp/alarm-manage/index.ts @@ -0,0 +1,50 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import alarmRouter from 'msp/alarm-manage/alarm-strategy'; +import alarmRecordRouter from 'msp/alarm-manage/alarm-record'; +import i18n from 'i18n'; + +const alarmManageRouters = [ + alarmRouter(), + alarmRecordRouter(), + { + path: 'custom-alarm', + breadcrumbName: i18n.t('custom alarm'), + routes: [ + { + path: ':dashboardId', + breadcrumbName: '{dashboardName}', + layout: { fullHeight: true }, + getComp: (cb: RouterGetComp) => cb(import('msp/query-analysis/custom-dashboard/pages/custom-dashboard')), + }, + { + getComp: (cb: RouterGetComp) => cb(import('msp/alarm-manage/alarm-strategy/pages/custom-alarm')), + }, + ], + }, + { + path: 'notify-group', + breadcrumbName: i18n.t('msp:notification group management'), + getComp: (cb: RouterGetComp) => cb(import('msp/alarm-manage/notify-group')), + }, +]; + +const getAlarmManageRouter = () => { + return { + path: ':terminusKey', + routes: alarmManageRouters, + }; +}; + +export default getAlarmManageRouter; diff --git a/shell/app/modules/msp/alarm-manage/notify-group/index.scss b/shell/app/modules/msp/alarm-manage/notify-group/index.scss new file mode 100644 index 0000000000..7146b604b2 --- /dev/null +++ b/shell/app/modules/msp/alarm-manage/notify-group/index.scss @@ -0,0 +1,7 @@ +.msp-notify-group { + .notify-group-manage { + .notify-group-action { + @extend %top-button-group; + } + } +} diff --git a/shell/app/modules/msp/alarm-manage/notify-group/index.tsx b/shell/app/modules/msp/alarm-manage/notify-group/index.tsx new file mode 100644 index 0000000000..02de22a561 --- /dev/null +++ b/shell/app/modules/msp/alarm-manage/notify-group/index.tsx @@ -0,0 +1,32 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import React from 'react'; +import NotifyGroup from 'application/pages/settings/components/app-notify/common-notify-group'; +import memberStore from 'common/stores/msp-project-member'; +import routeInfoStore from 'core/stores/route'; +import './index.scss'; + +const NotifyGroups = () => { + const { env, terminusKey, projectId } = routeInfoStore.useStore((s) => s.params); + return ( +
+ +
+ ); +}; + +export default NotifyGroups; diff --git a/shell/app/modules/msp/config.ts b/shell/app/modules/msp/config.tsx similarity index 65% rename from shell/app/modules/msp/config.ts rename to shell/app/modules/msp/config.tsx index fc00643ddb..d21fef661d 100644 --- a/shell/app/modules/msp/config.ts +++ b/shell/app/modules/msp/config.tsx @@ -11,6 +11,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +import React from 'react'; import i18n from 'i18n'; import { goTo } from 'common/utils'; import { @@ -22,6 +23,7 @@ import { Log as IconLog, Components as IconComponents, } from '@icon-park/react'; +import { ErdaCustomIcon } from 'common'; export const envMap = { DEV: i18n.t('common:DEV'), @@ -39,27 +41,39 @@ interface IMSPathParams { terminusKey: string; logKey: string; } + export const getMSFrontPathByKey = (key: string, params: IMSPathParams) => { const { projectId, env, tenantGroup, tenantId, terminusKey, logKey } = params; const rootPath = `${goTo.resolve.mspOverviewRoot({ projectId, env, tenantGroup })}/`; + // service monitor const monitorPrefix = `monitor/${terminusKey}`; + // alarm management + const alarmManagementPrefix = `alarm-management/${terminusKey}`; + // query analysis + const analysisPrefix = `analysis/${terminusKey}`; + // env synopsis + const envOverViewPrefix = `synopsis/${terminusKey}`; const targetPath = { - ServiceGovernance: 'topology', - Overview: `topology/${terminusKey}`, - + Overview: `${envOverViewPrefix}/topology`, AppMonitor: `topology/${terminusKey}`, - ServiceList: `${monitorPrefix}/service-list`, + EnvironmentalOverview: envOverViewPrefix, + ServiceList: `${envOverViewPrefix}/service-list`, + ServiceObservation: monitorPrefix, + ServiceAnalysis: `${monitorPrefix}/service-analysis/overview`, BrowserInsight: `${monitorPrefix}/bi`, AppInsight: `${monitorPrefix}/mi`, ErrorInsight: `${monitorPrefix}/error`, Transaction: `${monitorPrefix}/trace`, StatusPage: `${monitorPrefix}/status`, - Alarm: `${monitorPrefix}/alarm`, - AlarmRecord: `${monitorPrefix}/alarm-record`, - CustomAlarm: `${monitorPrefix}/custom-alarm`, - CustomDashboard: `${monitorPrefix}/custom-dashboard`, + AlarmManagement: alarmManagementPrefix, + AlertStrategy: `${alarmManagementPrefix}/alarm`, + AlarmHistory: `${alarmManagementPrefix}/alarm-record`, + RuleManagement: `${alarmManagementPrefix}/custom-alarm`, + NotifyGroupManagement: `${alarmManagementPrefix}/notify-group`, + QueryAnalysis: analysisPrefix, + Dashboard: `${analysisPrefix}/custom-dashboard`, Reports: `${monitorPrefix}/reports`, LogAnalyze: `log/${logKey}/query`, @@ -84,14 +98,25 @@ export const getMSFrontPathByKey = (key: string, params: IMSPathParams) => { ConfigCenter: 'configIntro', ConfigIntro: 'configIntro', Configs: `config/${tenantId}`, - - ComponentInfo: `info${tenantId ? `/${tenantId}` : ''}`, + EnvironmentSet: 'environment', + AccessConfig: `environment/${terminusKey}/configuration`, + MemberManagement: `environment/${terminusKey}/member`, + ComponentInfo: `environment/info${tenantId ? `/${tenantId}` : ''}`, }[key]; return rootPath + targetPath; }; +const renderIcon = (type: string) => () => { + return ; +}; + export const MSIconMap = { + EnvironmentalOverview: renderIcon('huanjinggailan'), + QueryAnalysis: renderIcon('chaxunfenxi'), + ServiceObservation: renderIcon('fuwuguancesvg'), + AlarmManagement: renderIcon('gaojingguanli'), + EnvironmentSet: IconComponents, ServiceGovernance: IconServer, AppMonitor: IconMonitorCamera, RegisterCenter: IconNotebookAndPen, diff --git a/shell/app/modules/msp/env-overview/index.ts b/shell/app/modules/msp/env-overview/index.ts new file mode 100644 index 0000000000..23448a6dff --- /dev/null +++ b/shell/app/modules/msp/env-overview/index.ts @@ -0,0 +1,24 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import getTopologyRouter from 'msp/env-overview/topology'; +import serviceListRouter from 'msp/env-overview/service-list'; + +const getEnvOverViewRouter = () => { + return { + path: ':terminusKey', + routes: [getTopologyRouter(), serviceListRouter()], + }; +}; + +export default getEnvOverViewRouter; diff --git a/shell/app/modules/msp/monitor/service-list/index.ts b/shell/app/modules/msp/env-overview/service-list/index.ts similarity index 77% rename from shell/app/modules/msp/monitor/service-list/index.ts rename to shell/app/modules/msp/env-overview/service-list/index.ts index d958963f4a..ca1cdac877 100644 --- a/shell/app/modules/msp/monitor/service-list/index.ts +++ b/shell/app/modules/msp/env-overview/service-list/index.ts @@ -44,29 +44,29 @@ export default () => ({ path: 'overview', tabs, layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages/overview')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages/overview')), }, { path: 'transaction', tabs, layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages/transaction')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages/transaction')), }, { path: 'anomaly', tabs, layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages/anomaly')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages/anomaly')), }, { path: 'process', tabs, layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages/process')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages/process')), }, { layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages/overview')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages/overview')), }, ], }, @@ -75,8 +75,7 @@ export default () => ({ ], }, { - // layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/service-list/pages')), + getComp: (cb: RouterGetComp) => cb(import('msp/env-overview/service-list/pages')), }, ], }); diff --git a/shell/app/modules/msp/monitor/service-list/pages/anomaly.tsx b/shell/app/modules/msp/env-overview/service-list/pages/anomaly.tsx similarity index 100% rename from shell/app/modules/msp/monitor/service-list/pages/anomaly.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/anomaly.tsx diff --git a/shell/app/modules/msp/monitor/service-list/pages/index.scss b/shell/app/modules/msp/env-overview/service-list/pages/index.scss similarity index 100% rename from shell/app/modules/msp/monitor/service-list/pages/index.scss rename to shell/app/modules/msp/env-overview/service-list/pages/index.scss diff --git a/shell/app/modules/msp/monitor/service-list/pages/index.tsx b/shell/app/modules/msp/env-overview/service-list/pages/index.tsx similarity index 97% rename from shell/app/modules/msp/monitor/service-list/pages/index.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/index.tsx index 6fe53fdc60..982543d997 100644 --- a/shell/app/modules/msp/monitor/service-list/pages/index.tsx +++ b/shell/app/modules/msp/env-overview/service-list/pages/index.tsx @@ -17,7 +17,7 @@ import { PureBoardGrid } from 'common'; import i18n from 'i18n'; import { goTo } from 'common/utils'; import DC from '@erda-ui/dashboard-configurator/dist'; -import topologyStore from 'topology/stores/topology'; +import topologyStore from 'msp/env-overview/topology/stores/topology'; import routeInfoStore from 'core/stores/route'; import { TimeSelectWithStore } from 'msp/components/time-select'; import monitorCommonStore from 'common/stores/monitorCommon'; diff --git a/shell/app/modules/msp/monitor/service-list/pages/overview.tsx b/shell/app/modules/msp/env-overview/service-list/pages/overview.tsx similarity index 100% rename from shell/app/modules/msp/monitor/service-list/pages/overview.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/overview.tsx diff --git a/shell/app/modules/msp/monitor/service-list/pages/process.tsx b/shell/app/modules/msp/env-overview/service-list/pages/process.tsx similarity index 100% rename from shell/app/modules/msp/monitor/service-list/pages/process.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/process.tsx diff --git a/shell/app/modules/msp/monitor/service-list/pages/service-list-dashboard.tsx b/shell/app/modules/msp/env-overview/service-list/pages/service-list-dashboard.tsx similarity index 97% rename from shell/app/modules/msp/monitor/service-list/pages/service-list-dashboard.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/service-list-dashboard.tsx index 08eee58cf6..e55f93215d 100644 --- a/shell/app/modules/msp/monitor/service-list/pages/service-list-dashboard.tsx +++ b/shell/app/modules/msp/env-overview/service-list/pages/service-list-dashboard.tsx @@ -15,7 +15,7 @@ import React, { useState, useEffect, useMemo } from 'react'; import { PureBoardGrid } from 'common'; import DC from '@erda-ui/dashboard-configurator/dist'; import monitorCommonStore from 'common/stores/monitorCommon'; -import dashboardStore from 'app/common/stores/dashboard'; +import dashboardStore from 'common/stores/dashboard'; import routeInfoStore from 'core/stores/route'; import { isEqual } from 'lodash'; diff --git a/shell/app/modules/msp/monitor/service-list/pages/transaction.tsx b/shell/app/modules/msp/env-overview/service-list/pages/transaction.tsx similarity index 99% rename from shell/app/modules/msp/monitor/service-list/pages/transaction.tsx rename to shell/app/modules/msp/env-overview/service-list/pages/transaction.tsx index 020254c94f..a89e6e8939 100644 --- a/shell/app/modules/msp/monitor/service-list/pages/transaction.tsx +++ b/shell/app/modules/msp/env-overview/service-list/pages/transaction.tsx @@ -21,7 +21,7 @@ import monitorCommonStore from 'common/stores/monitorCommon'; import { useLoading } from 'core/stores/loading'; import routeInfoStore from 'core/stores/route'; import topologyServiceStore from 'msp/stores/topology-service-analyze'; -import TraceSearchDetail from 'msp/monitor/trace-insight/pages/trace-querier/trace-search-detail'; +import TraceSearchDetail from 'trace-insight/pages/trace-querier/trace-search-detail'; import ServiceListDashboard from './service-list-dashboard'; import { TimeSelectWithStore } from 'msp/components/time-select'; diff --git a/shell/app/modules/msp/monitor/topology/index.js b/shell/app/modules/msp/env-overview/topology/index.js similarity index 78% rename from shell/app/modules/msp/monitor/topology/index.js rename to shell/app/modules/msp/env-overview/topology/index.js index 3675b9fbf0..23fac311b7 100644 --- a/shell/app/modules/msp/monitor/topology/index.js +++ b/shell/app/modules/msp/env-overview/topology/index.js @@ -11,20 +11,20 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import getSIRouter from 'msp/monitor/service-insight'; -import getEIRouter from 'msp/monitor/external-insight'; -import getGatewayIngressMonitorRouter from 'msp/monitor/gateway-ingress'; +import getSIRouter from 'service-insight'; +import getEIRouter from 'external-insight'; +import getGatewayIngressMonitorRouter from 'gateway-ingress'; import i18n from 'i18n'; function monitorTopologyRouter() { return { - path: 'topology/:terminusKey', + path: 'topology', pageName: i18n.t('msp:monitoring overview'), breadcrumbName: i18n.t('msp:monitoring overview'), routes: [ { layout: { fullHeight: true }, - getComp: (cb) => cb(import('topology/pages/topology/topology')), + getComp: (cb) => cb(import('msp/env-overview/topology/pages/topology/topology')), }, getGatewayIngressMonitorRouter(), getEIRouter(), diff --git a/shell/app/modules/msp/monitor/topology/pages/service-mesh/circuit-breaker-form.tsx b/shell/app/modules/msp/env-overview/topology/pages/service-mesh/circuit-breaker-form.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/service-mesh/circuit-breaker-form.tsx rename to shell/app/modules/msp/env-overview/topology/pages/service-mesh/circuit-breaker-form.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/service-mesh/fault-inject-form.tsx b/shell/app/modules/msp/env-overview/topology/pages/service-mesh/fault-inject-form.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/service-mesh/fault-inject-form.tsx rename to shell/app/modules/msp/env-overview/topology/pages/service-mesh/fault-inject-form.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/service-mesh/service-mesh-drawer.tsx b/shell/app/modules/msp/env-overview/topology/pages/service-mesh/service-mesh-drawer.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/service-mesh/service-mesh-drawer.tsx rename to shell/app/modules/msp/env-overview/topology/pages/service-mesh/service-mesh-drawer.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/service-mesh/service-mesh.scss b/shell/app/modules/msp/env-overview/topology/pages/service-mesh/service-mesh.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/service-mesh/service-mesh.scss rename to shell/app/modules/msp/env-overview/topology/pages/service-mesh/service-mesh.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology-dashboard/index.scss b/shell/app/modules/msp/env-overview/topology/pages/topology-dashboard/index.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology-dashboard/index.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology-dashboard/index.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology-dashboard/index.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology-dashboard/index.tsx similarity index 99% rename from shell/app/modules/msp/monitor/topology/pages/topology-dashboard/index.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology-dashboard/index.tsx index c3d9b8cde2..3bdb9a35b2 100644 --- a/shell/app/modules/msp/monitor/topology/pages/topology-dashboard/index.tsx +++ b/shell/app/modules/msp/env-overview/topology/pages/topology-dashboard/index.tsx @@ -20,7 +20,7 @@ import { PureBoardGrid } from 'common'; import { goTo } from 'common/utils'; import i18n from 'i18n'; import routeInfoStore from 'core/stores/route'; -import dashboardStore from 'app/common/stores/dashboard'; +import dashboardStore from 'common/stores/dashboard'; import monitorCommonStore from 'common/stores/monitorCommon'; import topologyServiceStore from 'msp/stores/topology-service-analyze'; import mspStore from 'msp/stores/micro-service'; diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/box-ele.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/components/box-ele.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/box-ele.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/box-ele.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/box-ele.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/box-ele.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/box-ele.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/box-ele.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/config.ts b/shell/app/modules/msp/env-overview/topology/pages/topology/components/config.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/config.ts rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/config.ts diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/index.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/components/index.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/index.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/index.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/index.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/index.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/index.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/index.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/render-utils.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/render-utils.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/render-utils.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/render-utils.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/scaleSelector.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/components/scaleSelector.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/scaleSelector.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/scaleSelector.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/scaleSelector.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/scaleSelector.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/scaleSelector.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/scaleSelector.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/topology-ele.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-ele.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/topology-ele.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-ele.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/topology-ele.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-ele.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/topology-ele.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-ele.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils-v1.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils-v1.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils-v1.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils-v1.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils-v2.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils-v2.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils-v2.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils-v2.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/topology-utils.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/topology-utils.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/components/utils.ts b/shell/app/modules/msp/env-overview/topology/pages/topology/components/utils.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/components/utils.ts rename to shell/app/modules/msp/env-overview/topology/pages/topology/components/utils.ts diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/link-text.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/link-text.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/link-text.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/link-text.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/link-text.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/link-text.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/link-text.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/link-text.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/node-item.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/node-item.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/node-item.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/node-item.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/node-item.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/node-item.tsx similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/node-item.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/node-item.tsx diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/topology.scss b/shell/app/modules/msp/env-overview/topology/pages/topology/topology.scss similarity index 100% rename from shell/app/modules/msp/monitor/topology/pages/topology/topology.scss rename to shell/app/modules/msp/env-overview/topology/pages/topology/topology.scss diff --git a/shell/app/modules/msp/monitor/topology/pages/topology/topology.tsx b/shell/app/modules/msp/env-overview/topology/pages/topology/topology.tsx similarity index 98% rename from shell/app/modules/msp/monitor/topology/pages/topology/topology.tsx rename to shell/app/modules/msp/env-overview/topology/pages/topology/topology.tsx index a574491445..228f3f511e 100644 --- a/shell/app/modules/msp/monitor/topology/pages/topology/topology.tsx +++ b/shell/app/modules/msp/env-overview/topology/pages/topology/topology.tsx @@ -18,11 +18,11 @@ import { TimeSelector, ContractiveFilter } from 'common'; import i18n from 'i18n'; import NodeEle from './node-item'; import LinkText, { linkTextHoverAction } from './link-text'; -import TopologyChart from './components/index'; +import TopologyChart from './components'; import TopologyDashboard from '../topology-dashboard'; import ServiceMeshDrawer from '../service-mesh/service-mesh-drawer'; import { ScaleSelector } from './components/scaleSelector'; -import topologyStore from 'topology/stores/topology'; +import topologyStore from 'msp/env-overview/topology/stores/topology'; import routeInfoStore from 'core/stores/route'; import monitorCommonStore from 'common/stores/monitorCommon'; import topologyServiceStore from 'msp/stores/topology-service-analyze'; diff --git a/shell/app/modules/msp/monitor/topology/services/service-mesh.ts b/shell/app/modules/msp/env-overview/topology/services/service-mesh.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/services/service-mesh.ts rename to shell/app/modules/msp/env-overview/topology/services/service-mesh.ts diff --git a/shell/app/modules/msp/monitor/topology/services/topology.ts b/shell/app/modules/msp/env-overview/topology/services/topology.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/services/topology.ts rename to shell/app/modules/msp/env-overview/topology/services/topology.ts diff --git a/shell/app/modules/msp/monitor/topology/stores/service-mesh.ts b/shell/app/modules/msp/env-overview/topology/stores/service-mesh.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/stores/service-mesh.ts rename to shell/app/modules/msp/env-overview/topology/stores/service-mesh.ts diff --git a/shell/app/modules/msp/monitor/topology/stores/topology.ts b/shell/app/modules/msp/env-overview/topology/stores/topology.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/stores/topology.ts rename to shell/app/modules/msp/env-overview/topology/stores/topology.ts diff --git a/shell/app/modules/msp/monitor/topology/types/topology.d.ts b/shell/app/modules/msp/env-overview/topology/types/topology.d.ts similarity index 100% rename from shell/app/modules/msp/monitor/topology/types/topology.d.ts rename to shell/app/modules/msp/env-overview/topology/types/topology.d.ts diff --git a/shell/app/modules/msp/pages/info/index.tsx b/shell/app/modules/msp/env-setting/info/index.tsx similarity index 95% rename from shell/app/modules/msp/pages/info/index.tsx rename to shell/app/modules/msp/env-setting/info/index.tsx index 61bd6cf26f..f23d60a3a9 100644 --- a/shell/app/modules/msp/pages/info/index.tsx +++ b/shell/app/modules/msp/env-setting/info/index.tsx @@ -11,7 +11,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { PureAddonSettings } from 'app/common/components/addon-settings'; +import { PureAddonSettings } from 'common/components/addon-settings'; import { useLoading } from 'core/stores/loading'; import { Copy, SettingsTabs } from 'common'; import { isZh } from 'i18n'; diff --git a/shell/app/modules/msp/monitor/monitor-alarm/pages/alarm-index/index.tsx b/shell/app/modules/msp/env-setting/member-manage/index.tsx similarity index 69% rename from shell/app/modules/msp/monitor/monitor-alarm/pages/alarm-index/index.tsx rename to shell/app/modules/msp/env-setting/member-manage/index.tsx index b8593f0dfb..f5d6525372 100644 --- a/shell/app/modules/msp/monitor/monitor-alarm/pages/alarm-index/index.tsx +++ b/shell/app/modules/msp/env-setting/member-manage/index.tsx @@ -12,10 +12,15 @@ // along with this program. If not, see . import React from 'react'; -import routeInfoStore from 'core/stores/route'; -import AlarmStrategy from 'app/modules/cmp/common/alarm-strategy'; +import { MembersTable } from 'common'; +import { MemberScope } from 'common/stores/member-scope'; -export default () => { - const params = routeInfoStore.useStore((s) => s.params); - return ; +const MemberManage = () => { + return ( +
+ +
+ ); }; + +export default MemberManage; diff --git a/shell/app/modules/msp/monitor/monitor-overview/index.js b/shell/app/modules/msp/monitor/monitor-overview/index.js index 7bbb6a4291..e9d9f73440 100644 --- a/shell/app/modules/msp/monitor/monitor-overview/index.js +++ b/shell/app/modules/msp/monitor/monitor-overview/index.js @@ -18,11 +18,7 @@ import getApiInsightRouter from 'msp/monitor/api-insight'; import monitorTraceRouter from 'msp/monitor/trace-insight'; import monitorErrorRouter from 'msp/monitor/error-insight'; import monitorStatusRouter from 'msp/monitor/status-insight'; -import alarmRouter from 'msp/monitor/monitor-alarm'; import projectReportRouter from 'msp/monitor/project-report'; -import customDashboardRouter from 'msp/monitor/custom-dashboard'; -import alarmRecordRouter from 'msp/monitor/alarm-record'; -import serviceListRouter from 'msp/monitor/service-list'; import i18n from 'i18n'; const monitorChildRouters = [ @@ -38,25 +34,6 @@ const monitorChildRouters = [ monitorTraceRouter(), monitorStatusRouter(), monitorErrorRouter(), - alarmRouter(), - serviceListRouter(), - { - path: 'custom-alarm', - breadcrumbName: i18n.t('custom alarm'), - routes: [ - { - path: ':dashboardId', - breadcrumbName: '{dashboardName}', - layout: { fullHeight: true }, - getComp: (cb) => cb(import('msp/monitor/custom-dashboard/pages/custom-dashboard')), - }, - { - getComp: (cb) => cb(import('monitor-alarm/pages/custom-alarm')), - }, - ], - }, - alarmRecordRouter(), - customDashboardRouter(), projectReportRouter(), ]; diff --git a/shell/app/modules/msp/monitor/custom-dashboard/index.ts b/shell/app/modules/msp/query-analysis/custom-dashboard/index.ts similarity index 75% rename from shell/app/modules/msp/monitor/custom-dashboard/index.ts rename to shell/app/modules/msp/query-analysis/custom-dashboard/index.ts index 3d573f67aa..569aabfde5 100644 --- a/shell/app/modules/msp/monitor/custom-dashboard/index.ts +++ b/shell/app/modules/msp/query-analysis/custom-dashboard/index.ts @@ -21,16 +21,16 @@ export default () => ({ path: 'add', breadcrumbName: i18n.t('org:new O & M dashboard'), layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/custom-dashboard/pages/custom-dashboard')), + getComp: (cb: RouterGetComp) => cb(import('msp/query-analysis/custom-dashboard/pages/custom-dashboard')), }, { path: ':dashboardId', breadcrumbName: '{dashboardName}', layout: { fullHeight: true }, - getComp: (cb: any) => cb(import('msp/monitor/custom-dashboard/pages/custom-dashboard')), + getComp: (cb: RouterGetComp) => cb(import('msp/query-analysis/custom-dashboard/pages/custom-dashboard')), }, { - getComp: (cb: any) => cb(import('msp/monitor/custom-dashboard/pages')), + getComp: (cb: RouterGetComp) => cb(import('msp/query-analysis/custom-dashboard/pages')), }, ], }); diff --git a/shell/app/modules/msp/monitor/custom-dashboard/pages/custom-dashboard.tsx b/shell/app/modules/msp/query-analysis/custom-dashboard/pages/custom-dashboard.tsx similarity index 83% rename from shell/app/modules/msp/monitor/custom-dashboard/pages/custom-dashboard.tsx rename to shell/app/modules/msp/query-analysis/custom-dashboard/pages/custom-dashboard.tsx index 7627f205ad..283b00b85e 100644 --- a/shell/app/modules/msp/monitor/custom-dashboard/pages/custom-dashboard.tsx +++ b/shell/app/modules/msp/query-analysis/custom-dashboard/pages/custom-dashboard.tsx @@ -13,8 +13,8 @@ import React from 'react'; import routeInfoStore from 'core/stores/route'; -import { CustomDashboardScope } from 'app/modules/cmp/stores/_common-custom-dashboard'; -import CustomDashboard from 'app/modules/cmp/common/custom-dashboard/custom-dashboard'; +import { CustomDashboardScope } from 'cmp/stores/_common-custom-dashboard'; +import CustomDashboard from 'cmp/common/custom-dashboard/custom-dashboard'; export default () => { const { terminusKey } = routeInfoStore.useStore((s) => s.params); diff --git a/shell/app/modules/msp/monitor/custom-dashboard/pages/index.tsx b/shell/app/modules/msp/query-analysis/custom-dashboard/pages/index.tsx similarity index 84% rename from shell/app/modules/msp/monitor/custom-dashboard/pages/index.tsx rename to shell/app/modules/msp/query-analysis/custom-dashboard/pages/index.tsx index 8641e642dd..2fc5603914 100644 --- a/shell/app/modules/msp/monitor/custom-dashboard/pages/index.tsx +++ b/shell/app/modules/msp/query-analysis/custom-dashboard/pages/index.tsx @@ -13,8 +13,8 @@ import React from 'react'; import routeInfoStore from 'core/stores/route'; -import { CustomDashboardScope } from 'app/modules/cmp/stores/_common-custom-dashboard'; -import CustomDashboardList from 'app/modules/cmp/common/custom-dashboard'; +import { CustomDashboardScope } from 'cmp/stores/_common-custom-dashboard'; +import CustomDashboardList from 'cmp/common/custom-dashboard'; export default () => { const { terminusKey } = routeInfoStore.useStore((s) => s.params); diff --git a/shell/app/modules/msp/monitor/custom-dashboard/services/custom-dashboard.ts b/shell/app/modules/msp/query-analysis/custom-dashboard/services/custom-dashboard.ts similarity index 100% rename from shell/app/modules/msp/monitor/custom-dashboard/services/custom-dashboard.ts rename to shell/app/modules/msp/query-analysis/custom-dashboard/services/custom-dashboard.ts diff --git a/shell/app/modules/msp/monitor/custom-dashboard/stores/custom-dashboard.ts b/shell/app/modules/msp/query-analysis/custom-dashboard/stores/custom-dashboard.ts similarity index 93% rename from shell/app/modules/msp/monitor/custom-dashboard/stores/custom-dashboard.ts rename to shell/app/modules/msp/query-analysis/custom-dashboard/stores/custom-dashboard.ts index 55156c4629..95754dc648 100644 --- a/shell/app/modules/msp/monitor/custom-dashboard/stores/custom-dashboard.ts +++ b/shell/app/modules/msp/query-analysis/custom-dashboard/stores/custom-dashboard.ts @@ -11,7 +11,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import { createCustomDashboardStore, CustomDashboardScope } from 'app/modules/cmp/stores/_common-custom-dashboard'; +import { createCustomDashboardStore, CustomDashboardScope } from 'cmp/stores/_common-custom-dashboard'; const customDashboard = createCustomDashboardStore(CustomDashboardScope.MICRO_SERVICE); diff --git a/shell/app/modules/msp/monitor/custom-dashboard/stores/query-monitor-metadata.ts b/shell/app/modules/msp/query-analysis/custom-dashboard/stores/query-monitor-metadata.ts similarity index 94% rename from shell/app/modules/msp/monitor/custom-dashboard/stores/query-monitor-metadata.ts rename to shell/app/modules/msp/query-analysis/custom-dashboard/stores/query-monitor-metadata.ts index dd79d982d7..5b238fbb34 100644 --- a/shell/app/modules/msp/monitor/custom-dashboard/stores/query-monitor-metadata.ts +++ b/shell/app/modules/msp/query-analysis/custom-dashboard/stores/query-monitor-metadata.ts @@ -15,7 +15,7 @@ import { MonitorMetaDataScope, MonitorMetaDataMode, createMonitorMetaDataStore, -} from 'cmp/stores/_common-monitor-metadata.ts'; +} from 'cmp/stores/_common-monitor-metadata'; const queryMonitorMetadata = createMonitorMetaDataStore(MonitorMetaDataScope.MICRO_SERVICE, MonitorMetaDataMode.QUERY); diff --git a/shell/app/modules/msp/query-analysis/index.ts b/shell/app/modules/msp/query-analysis/index.ts new file mode 100644 index 0000000000..2767974490 --- /dev/null +++ b/shell/app/modules/msp/query-analysis/index.ts @@ -0,0 +1,23 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import customDashboardRouter from 'msp/query-analysis/custom-dashboard'; + +const getQueryAnalysisRouter = () => { + return { + path: ':terminusKey', + routes: [customDashboardRouter()], + }; +}; + +export default getQueryAnalysisRouter; diff --git a/shell/app/modules/msp/router.js b/shell/app/modules/msp/router.js index 753c410ce5..1a65cf4194 100644 --- a/shell/app/modules/msp/router.js +++ b/shell/app/modules/msp/router.js @@ -12,11 +12,11 @@ // along with this program. If not, see . import getMonitorRouter from './monitor/monitor-overview'; -import getTopologyRouter from 'msp/monitor/topology'; - +import getAlarmManageRouter from 'msp/alarm-manage'; +import getEnvOverViewRouter from 'msp/env-overview'; import i18n from 'i18n'; - import wrapper from './pages/wait-wrapper'; +import getQueryAnalysisRouter from 'msp/query-analysis'; const injectWrapper = (route) => { route.wrapper = wrapper; @@ -47,10 +47,9 @@ function getMspRouter() { breadcrumbName: '{mspProjectName}', mark: 'mspDetail', routes: [ - getTopologyRouter(), { - path: 'configuration', - getComp: (cb) => cb(import('msp/pages/configuration')), + path: 'synopsis', + routes: [getEnvOverViewRouter()], }, { path: 'monitor', @@ -71,10 +70,39 @@ function getMspRouter() { getComp: (cb) => cb(import('msp/pages/zkproxy/governance')), }, { - path: 'info/:tenantId?', - breadcrumbName: i18n.t('msp:component info'), - layout: { fullHeight: true }, - getComp: (cb) => cb(import('msp/pages/info')), + path: 'analysis', + routes: [getQueryAnalysisRouter()], + }, + { + path: 'alarm-management', + routes: [getAlarmManageRouter()], + }, + { + path: 'environment', + routes: [ + { + path: ':terminusKey/configuration', + breadcrumbName: '{mspProjectName}', + getComp: (cb) => cb(import('msp/pages/configuration')), + }, + { + path: ':terminusKey/member', + breadcrumbName: i18n.t('org:member management'), + getComp: (cb) => cb(import('msp/env-setting/member-manage')), + }, + { + path: 'info/:tenantId?', + breadcrumbName: i18n.t('msp:component info'), + layout: { fullHeight: true }, + getComp: (cb) => cb(import('msp/env-setting/info')), + }, + ], + }, + { + path: 'perm', + pageName: i18n.t('role permissions description'), + layout: { showSubSidebar: false, fullHeight: true }, + getComp: (cb) => cb(import('user/common/perm-editor/perm-editor'), 'MspPermEditor'), }, ], }), diff --git a/shell/app/modules/msp/stores/micro-service.tsx b/shell/app/modules/msp/stores/micro-service.tsx index d6b78f2ab8..3f8c80c7ff 100644 --- a/shell/app/modules/msp/stores/micro-service.tsx +++ b/shell/app/modules/msp/stores/micro-service.tsx @@ -31,6 +31,7 @@ import { import React from 'react'; import switchEnv from 'msp/pages/micro-service/switch-env'; import breadcrumbStore from 'layout/stores/breadcrumb'; +import permStore from 'user/stores/permission'; const docUrlMap = { apiGatewayIntro: DOC_MSP_API_GATEWAY, @@ -70,7 +71,7 @@ const generateMSMenu = (menuData: MS_INDEX.IMspMenu[], params: Record : 'zujian', text: currentLocale.key === 'zh' ? cnName : enName, @@ -79,7 +80,7 @@ const generateMSMenu = (menuData: MS_INDEX.IMspMenu[], params: Record m.exists) .map((child) => { const childHref = getMSFrontPathByKey(child.key, { ...child.params, ...params } as any); @@ -92,7 +93,7 @@ const generateMSMenu = (menuData: MS_INDEX.IMspMenu[], params: Record [s.currentEnvInfo, s.currentProject]); if (isIn('mspDetail')) { + permStore.effects.checkRouteAuth({ + type: 'msp', + id: projectId, + routeMark: 'mspDetail', + }); if (projectId !== currentEnvInfo.projectId) { mspStore.reducers.updateCurrentEnvInfo({ projectId, env, tenantGroup }); await mspStore.effects.getMspProjectDetail(); diff --git a/shell/app/styles/_mixin.scss b/shell/app/styles/_mixin.scss index 903fe8487c..61431d7ebb 100644 --- a/shell/app/styles/_mixin.scss +++ b/shell/app/styles/_mixin.scss @@ -169,3 +169,20 @@ $lg-break-width: $sider-width + $subsider-width + $lg-content-break-width; border-radius: 50%; } } + +%top-button-group { + position: fixed; + + top: 45px; + right: 16px; + + @include md-width() { + & { + right: 12px; + } + } + + button { + margin-left: $p8; + } +} diff --git a/shell/app/styles/util.scss b/shell/app/styles/util.scss index 7975d9c775..4d3e1eb563 100644 --- a/shell/app/styles/util.scss +++ b/shell/app/styles/util.scss @@ -82,20 +82,7 @@ } .top-button-group { - position: fixed; - - top: 45px; - right: 16px; - - @include md-width() { - & { - right: 12px; - } - } - - button { - margin-left: $p8; - } + @extend %top-button-group; } .status-pointer { diff --git a/shell/app/user/common/perm-editor/perm-editor.tsx b/shell/app/user/common/perm-editor/perm-editor.tsx index 2d5db11cd1..719e963f56 100644 --- a/shell/app/user/common/perm-editor/perm-editor.tsx +++ b/shell/app/user/common/perm-editor/perm-editor.tsx @@ -20,6 +20,7 @@ import routeInfoStore from 'core/stores/route'; import { orgPerm, orgRoleMap } from 'user/stores/_perm-org'; import { appPerm, appRoleMap } from 'user/stores/_perm-app'; import { projectPerm, projectRoleMap } from 'user/stores/_perm-project'; +import { mspPerm, mspRoleMap } from 'user/stores/_perm-msp'; import i18n from 'i18n'; import PermExport from './perm-export'; import PermRoleEditor, { IRoleData } from './role-editor'; @@ -29,6 +30,7 @@ import AddScope from './add-scope'; import './perm-editor.scss'; const { TabPane } = Tabs; + interface IAction { name: string; role: string[]; @@ -44,13 +46,13 @@ interface IPerm { [key: string]: IPermItem; } -export const originRoleMap = { +export const roleMaps = { org: orgRoleMap, app: appRoleMap, project: projectRoleMap, }; -const permData = { +const permDatas = { org: orgPerm, project: projectPerm, app: appPerm, @@ -73,11 +75,21 @@ const getRoleMap = (_roleMap: Obj, isEdit: boolean) => { return reRoleMap; }; -export const PermEditor = () => { - const [{ scope }, { projectId }] = routeInfoStore.useStore((s) => [s.query, s.params]); +interface IProps { + data: Obj; + roleMap: Obj; + scope?: string; +} + +export const PermEditor = (props: IProps) => { + const [{ scope = 'org', mode }, { projectId }] = routeInfoStore.getState((s) => [s.query, s.params]); + const isMsp = props.scope === 'msp'; + const permData = isMsp ? props.data : permDatas; + const originRoleMap = isMsp ? props.roleMap : roleMaps; + const defaultScope = isMsp ? props.scope : scope; const [{ data, tabKey, searchKey, roleMap, reloadKey }, updater, update] = useUpdate({ data: permData, - tabKey: scope || 'org', + tabKey: defaultScope, searchKey: '', roleMap: originRoleMap, reloadKey: 1, @@ -85,7 +97,7 @@ export const PermEditor = () => { // 默认在项目下,即为编辑状态: project/:id/perm // 在根路由下,即为查看状态:/perm - const isEdit = !!projectId; + const isEdit = isMsp ? mode === 'edit' : !!projectId; const onChangeRole = (_data: IRoleChange) => { const { key, role, checked } = _data; const newData = produce(data, (draft) => { @@ -122,7 +134,7 @@ export const PermEditor = () => { const reset = () => { update({ data: permData, - tabKey: scope || 'org', + tabKey: defaultScope, searchKey: '', roleMap: originRoleMap, reloadKey: reloadKey + 1, @@ -206,3 +218,7 @@ export const PermEditor = () => { ); }; + +export const MspPermEditor = () => { + return ; +}; diff --git a/shell/app/user/services/user.ts b/shell/app/user/services/user.ts index c9359c5307..91b2e93fca 100644 --- a/shell/app/user/services/user.ts +++ b/shell/app/user/services/user.ts @@ -92,3 +92,13 @@ export const getResourcePermissions = ({ .send({ scope: { type: scope, id: String(scopeID) } }) .then((response: any) => response.body); }; + +export const getMspResourcePermissions = ({ + scope, + scopeID, +}: IGetScopePermQuery): Promise> => { + return agent + .post('/api/msp/permission/access') + .send({ scope: { type: scope, id: String(scopeID) } }) + .then((response: any) => response.body); +}; diff --git a/shell/app/user/stores/_perm-msp.ts b/shell/app/user/stores/_perm-msp.ts new file mode 100644 index 0000000000..eaf3da7fd3 --- /dev/null +++ b/shell/app/user/stores/_perm-msp.ts @@ -0,0 +1,24 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// This program is free software: you can use, redistribute, and/or modify +// it under the terms of the GNU Affero General Public License, version 3 +// or later ("AGPL"), as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +import { projectPerm } from './_perm-project'; + +export const mspRoleMap = { + Owner: { name: '项目所有者', value: 'Owner' }, + Lead: { name: '研发主管', value: 'Lead' }, + Dev: { name: '开发工程师', value: 'Dev' }, +}; + +export const mspPerm = { + ...projectPerm.microService, +}; diff --git a/shell/app/user/stores/_perm-project.ts b/shell/app/user/stores/_perm-project.ts index 74a267cbb7..8ad500e34e 100644 --- a/shell/app/user/stores/_perm-project.ts +++ b/shell/app/user/stores/_perm-project.ts @@ -13,6 +13,8 @@ import i18n from 'i18n'; // 通过权限配置页面导出角色数据覆盖,勿手动修改 +import i18n from 'i18n'; + export const projectRoleMap = { Owner: { name: i18n.t('user:Project Owner'), value: 'Owner' }, Lead: { name: i18n.t('user:Project Leader'), value: 'Lead' }, @@ -502,4 +504,43 @@ export const projectPerm = { name: i18n.t('application:view'), }, }, + microService: { + name: i18n.t('msp'), + member: { + name: i18n.t('org:member management'), + addProjectMember: { + name: i18n.t('add member'), + pass: false, + role: ['Owner', 'Lead'], + }, + editProjectMember: { + name: i18n.t('edit {name}', { name: i18n.t('member') }), + pass: false, + role: ['Owner', 'Lead'], + }, + removeProjectMember: { + name: i18n.t('delete {name}', { name: i18n.t('member') }), + pass: false, + role: ['Owner', 'Lead'], + }, + }, + accessConfiguration: { + name: '接入配置', + createAccessKey: { + name: '创建 AccessKey', + pass: false, + role: ['Owner', 'Lead'], + }, + deleteAccessKey: { + name: '删除 AccessKey', + pass: false, + role: ['Owner', 'Lead'], + }, + viewAccessKeySecret: { + name: '查看 AccessKeySecret', + pass: false, + role: ['Owner', 'Lead'], + }, + }, + }, }; diff --git a/shell/app/user/stores/_perm-state.ts b/shell/app/user/stores/_perm-state.ts index c254aabf67..f0410d489c 100644 --- a/shell/app/user/stores/_perm-state.ts +++ b/shell/app/user/stores/_perm-state.ts @@ -15,6 +15,7 @@ import { map, compact } from 'lodash'; import { orgPerm } from './_perm-org'; import { projectPerm } from './_perm-project'; import { appPerm } from './_perm-app'; +import { mspPerm } from './_perm-msp'; import { sysPerm } from './_perm-sys'; import yaml from 'js-yaml'; @@ -24,10 +25,12 @@ export const permState = { project: projectPerm, app: appPerm, sys: sysPerm, + msp: mspPerm, }; export type OrgPermType = typeof orgPerm; export type ProjectPermType = typeof projectPerm; export type AppPermType = typeof appPerm; +export type MspPermType = typeof mspPerm; const scopeNames = Object.keys(permState); diff --git a/shell/app/user/stores/permission.ts b/shell/app/user/stores/permission.ts index 3db3efc3f3..b8d71b6269 100644 --- a/shell/app/user/stores/permission.ts +++ b/shell/app/user/stores/permission.ts @@ -12,10 +12,11 @@ // along with this program. If not, see . import { createStore } from 'core/cube'; -import { getResourcePermissions } from '../services/user'; +import { getResourcePermissions, getMspResourcePermissions } from '../services/user'; import { orgRoleMap } from './_perm-org'; import { projectRoleMap } from './_perm-project'; import { appRoleMap } from './_perm-app'; +import { mspRoleMap } from './_perm-msp'; import { map, set, get, cloneDeep } from 'lodash'; import routeInfoStore from 'core/stores/route'; import { getUserMap } from 'core/stores/userMap'; @@ -26,6 +27,7 @@ const rolesMap = { app: appRoleMap, project: projectRoleMap, org: orgRoleMap, + msp: mspRoleMap, }; const getPermObj = (data: IPermResponseData, scope: string) => { @@ -109,17 +111,19 @@ const permission = createStore({ cb?: (arg?: any) => any; }, ) { - const data = (await call(getResourcePermissions, { scope, scopeID })) as unknown as IPermResponseData; + const realScope = scope === 'msp' ? 'project' : scope; + const request = scope === 'msp' ? getMspResourcePermissions : getResourcePermissions; + const data = (await call(request, { scope: realScope, scopeID })) as unknown as IPermResponseData; const { access, exist, contactsWhenNoPermission } = data; if (exist === false) { userStore.reducers.setNotFound(); return; } // API 管理可以继承项目和应用权限, - const needShowNoAuth = routeMark === 'apiManage' && ['project', 'app'].includes(scope); + const needShowNoAuth = routeMark === 'apiManage' && ['project', 'app'].includes(realScope); if (!access && !needShowNoAuth) { // 新的scope无权限时才清理,新的scope有权限时会在下面更新掉,无需清理 - permission.reducers.clearScopePerm(scope); + permission.reducers.clearScopePerm(realScope); const userMap = getUserMap(); userStore.reducers.setNoAuth( map(contactsWhenNoPermission || [], (id) => { @@ -130,7 +134,7 @@ const permission = createStore({ return; } - permission.reducers.updatePerm(scope, data); + permission.reducers.updatePerm(realScope, data); cb(data); }, }, diff --git a/shell/app/views/index.ejs b/shell/app/views/index.ejs index f0efb1f210..2a811df7d2 100644 --- a/shell/app/views/index.ejs +++ b/shell/app/views/index.ejs @@ -40,7 +40,7 @@ - +