Skip to content

Commit

Permalink
Merge pull request #2816 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nannan00 authored Oct 11, 2024
2 parents 7e7cfb3 + 138ed58 commit 0444851
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 126 deletions.
9 changes: 5 additions & 4 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -150,7 +150,7 @@
};
},
computed: {
...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout']),
...mapGetters(['mainContentLoading', 'user', 'externalSystemsLayout', 'versionLogs']),
isShowNoticeAlert () {
return this.showNoticeAlert && this.isEnableNoticeAlert;
},
Expand Down Expand Up @@ -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服务']`),
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
49 changes: 4 additions & 45 deletions frontend/src/components/header-nav/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -253,8 +219,6 @@
getTabData: getTabData,
curRoleList: [],
searchValue: '',
docuLinkMap: docuLinkMap,
curDocuLink: `${window.BK_DOCS_URL_PREFIX}${NORMAL_DOCU_LINK}`,
showGuide: false,
isShowHeader: false,
placeholderValue: '',
Expand Down Expand Up @@ -294,7 +258,8 @@
'roleList',
'index',
'navCurRoleId',
'externalSystemId'
'externalSystemId',
'versionLogs'
]),
...mapGetters('userGlobalConfig', ['globalConfig']),
style () {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -466,7 +425,7 @@
},
handleOpenDocu () {
window.open(this.curDocuLink);
navDocCenterPath(this.versionLogs, '/UserGuide/Introduce/README.md', true);
},
handleOpenQuestion () {
Expand Down
26 changes: 12 additions & 14 deletions frontend/src/views/grading-admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
};
</script>
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/views/group/components/render-instance-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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链路是多维数组且无法确定链路数量,所以这里需要过滤掉空数组
Expand All @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
<div class="iam-edit-selector" :style="styles">
<template v-if="!isEditable">
<div class="edit-wrapper">
<div class="edit-content" :title="displayValue.map(item => item.username) || ''">
<slot>
<span
v-for="(item, i) in displayValue"
:key="i"
class="member-item"
:class="item.readonly ? 'member-readonly' : ''"
>
{{ item.username }}
<!-- <Icon v-if="!isShowRole" type="close-small"
@click.stop="handleDelete(index)" />
<Icon v-else type="close-small"
@click.stop="handleDelete(index)" /> -->
</span>
</slot>
</div>
<template v-if="displayValue.length">
<div class="edit-content" v-bk-tooltips="{ content: displayValue.map(item => item.username) }">
<slot>
<span
v-for="(item, i) in displayValue"
:key="i"
class="member-item"
:class="item.readonly ? 'member-readonly' : ''"
>
{{ item.username }}
</span>
</slot>
</div>
</template>
<template v-else>
<span>--</span>
</template>
<div class="edit-action-box" v-if="isEditMode">
<Icon
type="edit-fill"
Expand Down
54 changes: 24 additions & 30 deletions frontend/src/views/my-manage-space/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@
iconColor[1] : iconColor[0] }" />
<iam-edit-input
field="name"
mode="edit"
:placeholder="$t(`m.verify['请输入']`)"
:value="row.name"
:mode="formatMode(row)"
style="width: 100%; margin-left: 5px"
:index="$index"
:remote-hander="handleUpdateManageSpace"
Expand All @@ -211,9 +211,9 @@
<iam-edit-member-selector
field="members"
width="200"
mode="edit"
:placeholder="$t(`m.verify['请输入']`)"
:value="row.members"
:mode="formatMode(row)"
:index="$index"
@on-change="handleUpdateMembers"
/>
Expand All @@ -224,9 +224,9 @@
<iam-edit-textarea
field="description"
width="300"
mode="edit"
:placeholder="$t(`m.verify['请输入']`)"
:value="row.description"
:mode="formatMode(row)"
:index="$index"
:remote-hander="handleUpdateManageSpace"
/>
Expand Down Expand Up @@ -319,7 +319,7 @@
<script>
import _ from 'lodash';
import { mapGetters } from 'vuex';
import { getWindowHeight, formatCodeData } from '@/common/util';
import { getWindowHeight, formatCodeData, navDocCenterPath } from '@/common/util';
import IamEditInput from './components/iam-edit/input';
import IamEditMemberSelector from './components/iam-edit/member-selector';
import IamEditTextarea from './components/iam-edit/textarea';
Expand Down Expand Up @@ -393,30 +393,24 @@
};
},
computed: {
...mapGetters(['user', 'roleList', 'externalSystemId']),
tableHeight () {
return getWindowHeight() - 185;
},
disabledPerm () {
return (payload, roleType) => {
const { type, members } = payload;
if (['subset_manager'].includes(type) || roleType) {
return false;
} else {
const result = members.map((item) => item.username).includes(this.user.username);
return !result;
}
};
},
isStaff () {
return this.user.role.type === 'staff';
},
formatMode () {
return (payload) => {
// return payload.is_member || this.isFilter ? 'edit' : 'detail';
return 'edit';
};
}
...mapGetters(['user', 'roleList', 'externalSystemId', 'versionLogs']),
tableHeight () {
return getWindowHeight() - 185;
},
disabledPerm () {
return (payload, roleType) => {
const { type, members } = payload;
if (['subset_manager'].includes(type) || roleType) {
return false;
} else {
const result = members.map((item) => item.username).includes(this.user.username);
return !result;
}
};
},
isStaff () {
return this.user.role.type === 'staff';
}
},
watch: {
searchValue (newVal, oldVal) {
Expand Down Expand Up @@ -968,9 +962,9 @@
}
);
},
handleOpenDocu () {
const GRADE_DOCU_LINK = '/IAM/UserGuide/Feature/UserApply.md';
window.open(`${window.BK_DOCS_URL_PREFIX}${GRADE_DOCU_LINK}`);
navDocCenterPath(this.versionLogs, `/UserGuide/Feature/UserApply.md`, true);
}
}
};
Expand Down
Loading

0 comments on commit 0444851

Please sign in to comment.