diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ec51dac30..f552b85c8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -88,7 +88,7 @@ import '@blueking/functional-dependency/vue2/vue2.css'; import '@blueking/notice-component-vue2/dist/style.css'; // import IamGuide from '@/components/iam-guide/index.vue'; - import { existValue, formatI18nKey } from '@/common/util'; + import { existValue, formatI18nKey, navDocCenterPath } from '@/common/util'; import { bus } from '@/common/bus'; import { mapGetters } from 'vuex'; import { afterEach } from '@/router'; @@ -150,7 +150,7 @@ }; }, computed: { - ...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout']), + ...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout', 'versionLogs']), isShowNoticeAlert () { return this.showNoticeAlert && this.isEnableNoticeAlert; }, @@ -382,14 +382,15 @@ window.open(`${window.BK_DOCS_URL_PREFIX}${payload}`); }, - getRouteInstanceSearch (payload = {}) { + async getRouteInstanceSearch (payload = {}) { const { show, routeName } = payload; + const curPath = await navDocCenterPath(this.versionLogs, `/UserGuide/Feature/PermissionsApply.md`, false); const routeMap = { applyCustomPerm: () => { this.noInstanceSearchData = Object.assign({}, { show: show || false, mode: 'dialog', - url: `/IAM//1.8/UserGuide/Feature/PermissionsApply.md`, + url: curPath, title: this.$t(`m.permApply['未启用用户组自动推荐功能']`), functionalDesc: this.t(`m.permApply['该功能可以根据用户当前的权限需求,自动匹配相关的用户组']`), guideTitle: this.$t(`m.permApply['如需启用该功能,请联系部署同学部署相关ES服务']`), diff --git a/frontend/src/common/util.js b/frontend/src/common/util.js index 7c979018c..c0d3b3759 100644 --- a/frontend/src/common/util.js +++ b/frontend/src/common/util.js @@ -829,3 +829,25 @@ export const getRoutePath = (subPath) => { const path = subPath.startsWith('/') ? subPath.slice(1) : subPath; return rootPath ? `${rootPath}${path}` : subPath; }; + +/** + * 跳转不同页面的文档中心 + * @param {versionLog} versionLog 传入的版本列表 + * @param {path} path 传入的文档路径 + * @param {autoOpen} autoOpen 是否自动跳转到文档中心 + */ +export const navDocCenterPath = (versionLog, path, autoOpen = true) => { + let curVersion = '1.16'; + const curLang = formatI18nKey().toLowerCase().indexOf('en') > -1 ? 'EN' : 'ZH'; + if (versionLog.length) { + const { version } = versionLog[0]; + const lastIndex = version.lastIndexOf('.'); + curVersion = version.substring(1, lastIndex !== -1 ? lastIndex : version.length); + } + const curPath = `/${curLang}/IAM/${curVersion}${path}`; + if (autoOpen) { + window.open(`${window.BK_DOCS_URL_PREFIX}${curPath}`); + } else { + return curPath; + } +}; diff --git a/frontend/src/components/header-nav/index.vue b/frontend/src/components/header-nav/index.vue index 8343001d2..1a3079f7a 100644 --- a/frontend/src/components/header-nav/index.vue +++ b/frontend/src/components/header-nav/index.vue @@ -126,7 +126,7 @@ import { il8n, language } from '@/language'; import { bus } from '@/common/bus'; import { buildURLParams } from '@/common/url'; - import { formatI18nKey, jsonpRequest, getManagerMenuPerm } from '@/common/util'; + import { formatI18nKey, jsonpRequest, getManagerMenuPerm, navDocCenterPath } from '@/common/util'; import { NEED_CONFIRM_DIALOG_ROUTER } from '@/common/constants'; import { getRouterDiff, getNavRouterDiff } from '@/common/router-handle'; import SystemLog from '../system-log'; @@ -173,40 +173,6 @@ }; }; - const NORMAL_DOCU_LINK = '/IAM/UserGuide/Introduce/README.md'; - // const GRADE_DOCU_LINK = '/权限中心/产品白皮书/场景案例/GradingManager.md'; - - const docuLinkMap = new Map([ - // 权限模板 - [['permTemplate', 'permTemplateDetail', 'permTemplateCreate'], NORMAL_DOCU_LINK], - // 首页 - [['', 'index'], NORMAL_DOCU_LINK], - // 用户组 - [ - ['userGroup', 'userGroupDetail', 'createUserGroup', 'userGroupPermDetail'], - NORMAL_DOCU_LINK - ], - // 系统接入 - [['systemAccess'], NORMAL_DOCU_LINK], - // 我的申请 - [['apply'], NORMAL_DOCU_LINK], - // 权限申请 'permApply' - [['applyCustomPerm', 'applyJoinUserGroup'], NORMAL_DOCU_LINK], - // 我的权限 - [['myPerm', 'templatePermDetail', 'groupPermDetail', 'permRenewal'], NORMAL_DOCU_LINK], - // 管理空间 - [ - ['ratingManager', 'gradingAdminDetail', 'gradingAdminCreate', 'gradingAdminEdit'], - NORMAL_DOCU_LINK - ], - // 管理员 - [['administrator'], NORMAL_DOCU_LINK], - // 审批流程 - [['approvalProcess'], NORMAL_DOCU_LINK], - // 用户 - [['user'], NORMAL_DOCU_LINK] - ]); - export default { inject: ['reloadCurPage'], components: { @@ -253,8 +219,6 @@ getTabData: getTabData, curRoleList: [], searchValue: '', - docuLinkMap: docuLinkMap, - curDocuLink: `${window.BK_DOCS_URL_PREFIX}${NORMAL_DOCU_LINK}`, showGuide: false, isShowHeader: false, placeholderValue: '', @@ -294,7 +258,8 @@ 'roleList', 'index', 'navCurRoleId', - 'externalSystemId' + 'externalSystemId', + 'versionLogs' ]), ...mapGetters('userGlobalConfig', ['globalConfig']), style () { @@ -334,12 +299,6 @@ } this.active = active; } - for (const [key, value] of this.docuLinkMap.entries()) { - if (key.includes(to.name)) { - this.curDocuLink = `${window.BK_DOCS_URL_PREFIX}${value}`; - break; - } - } }, user: { handler (value) { @@ -466,7 +425,7 @@ }, handleOpenDocu () { - window.open(this.curDocuLink); + navDocCenterPath(this.versionLogs, '/UserGuide/Introduce/README.md', true); }, handleOpenQuestion () { diff --git a/frontend/src/views/grading-admin/index.vue b/frontend/src/views/grading-admin/index.vue index bf331f50a..923df5b07 100644 --- a/frontend/src/views/grading-admin/index.vue +++ b/frontend/src/views/grading-admin/index.vue @@ -273,7 +273,7 @@ import _ from 'lodash'; import { mapGetters } from 'vuex'; import { buildURLParams } from '@/common/url'; - import { getWindowHeight, formatCodeData } from '@/common/util'; + import { getWindowHeight, formatCodeData, navDocCenterPath } from '@/common/util'; import ConfirmDialog from '@/components/iam-confirm-dialog/index'; import ApplyDialog from './components/apply-join-dialog'; import IamEditInput from '@/views/my-manage-space/components/iam-edit/input'; @@ -355,16 +355,16 @@ }; }, computed: { - ...mapGetters(['user']), - isStaff () { - return this.user.role.type === 'staff'; - }, - disabledPerm () { - return (payload) => { - const result = payload.members.map(item => item.username).includes(this.user.username); - return !result; - }; - } + ...mapGetters(['user', 'versionLogs']), + isStaff () { + return this.user.role.type === 'staff'; + }, + disabledPerm () { + return (payload) => { + const result = payload.members.map(item => item.username).includes(this.user.username); + return !result; + }; + } }, watch: { searchValue (newVal, oldVal) { @@ -864,10 +864,8 @@ }, handleOpenDocu () { - const GRADE_DOCU_LINK = '/IAM/UserGuide/Feature/ManagerCreate.md'; - window.open(`${window.BK_DOCS_URL_PREFIX}${GRADE_DOCU_LINK}`); + navDocCenterPath(this.versionLogs, `/UserGuide/Feature/ManagerCreate.md`, true); } - } }; diff --git a/frontend/src/views/group/components/render-instance-table.vue b/frontend/src/views/group/components/render-instance-table.vue index 2bd5f25d2..87bbae34e 100644 --- a/frontend/src/views/group/components/render-instance-table.vue +++ b/frontend/src/views/group/components/render-instance-table.vue @@ -1304,10 +1304,9 @@ let scopeInstanceList = []; let scopeAttributeList = []; payload.forEach(item => { - const curIndex = this.tableList.findIndex(sub => sub.id === item.id - && item.resource_groups[this.curGroupIndex] - && sub.detail.system.id === item.resource_groups[this.curGroupIndex] - .related_resource_types[0].system_id); + const curIndex = this.tableList.findIndex(sub => + sub.id === item.id && item.resource_groups[this.curGroupIndex] + ); if (curIndex > -1) { const { isTemplate, detail } = this.tableList[curIndex]; const systemId = this.isCreateMode && detail ? detail.system.id : this.systemId; diff --git a/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue b/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue index 93efba8dc..27238e91d 100644 --- a/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue +++ b/frontend/src/views/manage-spaces/secondary-manage-space/components/render-instance-table.vue @@ -982,10 +982,9 @@ let scopeInstanceList = []; let scopeAttributeList = []; payload.forEach(item => { - const curIndex = this.tableList.findIndex(sub => sub.id === item.id - && item.resource_groups[this.curGroupIndex] - && sub.detail.system.id === item.resource_groups[this.curGroupIndex] - .related_resource_types[0].system_id); + const curIndex = this.tableList.findIndex(sub => + sub.id === item.id && item.resource_groups[this.curGroupIndex] + ); if (curIndex > -1) { const { isTemplate, detail } = this.tableList[curIndex]; const systemId = this.isCreateMode && detail ? detail.system.id : this.systemId; @@ -1017,8 +1016,16 @@ resource.instances.forEach((ins) => { ins.path.forEach((p, pathIndex) => { if (p.length > 0) { + // 处理授权范围是父级,但是选择了子集数据,需要查找所选数据是不是属于授权范围内的子集数据 + let curParentChain = []; + const tempPath = p.filter(v => v.id !== '*'); + if (tempPath.length) { + curParentChain = tempPath.slice(0, tempPath.length - 1); + } + // 判断授权范围是不是父级数据 + const isExistParent = curParentChain.filter((subPath) => scopeInsList.includes(`${subPath.id}&${subPath.name}&${subPath.type}`)); // 只获取授权范围内的资源实例 - ins.path[pathIndex] = p.filter((subPath) => scopeInsList.includes(`${subPath.id}&${subPath.name}&${subPath.type}`)); + ins.path[pathIndex] = p.filter((subPath) => scopeInsList.includes(`${subPath.id}&${subPath.name}&${subPath.type}`) || isExistParent.length > 0); } }); // 因为path链路是多维数组且无法确定链路数量,所以这里需要过滤掉空数组 @@ -1027,6 +1034,8 @@ ins.paths = _.cloneDeep(ins.path); } }); + // 这里会存在path的内容不在授权范围内会被过滤掉,而path内容是必填项 + resource.instances = resource.instances.filter((k) => k.path && k.path.length > 0); if (resource.attributes && resource.attributes.length > 0 && scopeAttributeList && scopeAttributeList.length > 0 ) { diff --git a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue index ba5aa3f96..c523dabdd 100644 --- a/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue +++ b/frontend/src/views/my-manage-space/components/iam-edit/member-selector.vue @@ -2,22 +2,23 @@