Skip to content

Commit

Permalink
Merge branch 'develop' into fix_apigw_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nannan00 authored Aug 9, 2024
2 parents 0f9e38c + 66adf2b commit 36bab5e
Show file tree
Hide file tree
Showing 15 changed files with 957 additions and 773 deletions.
3 changes: 1 addition & 2 deletions frontend/build/paas-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ const GLOBAL_VAR = {
BK_DOCS_URL_PREFIX: process.env.BK_DOCS_URL_PREFIX || '',
BK_DOMAIN: process.env.BK_DOMAIN || '',
BK_SHARED_RES_URL: process.env.BK_SHARED_RES_URL || '',
BK_APP_CODE: process.env.BK_APP_CODE || '',
VERSION: process.env.VERSION || ''
BK_APP_CODE: process.env.BK_APP_CODE || ''
};

// APA 重定向回首页,由首页Route响应处理
Expand Down
6 changes: 2 additions & 4 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
const BK_COMPONENT_API_URL = '{{ BK_COMPONENT_API_URL }}' || ''
const BK_SHARED_RES_URL = '{{ BK_SHARED_RES_URL }}' || ''
const BK_APP_CODE = '{{ BK_APP_CODE }}' || ''
const VERSION = '{{ VERSION }}' || ''
document.domain = '{{ SESSION_COOKIE_DOMAIN }}'
window.LOGIN_SERVICE_URL = LOGIN_SERVICE_URL
window.AJAX_URL_PREFIX = AJAX_URL_PREFIX
Expand All @@ -57,7 +56,6 @@
window.BK_COMPONENT_API_URL = BK_COMPONENT_API_URL
window.BK_SHARED_RES_URL = BK_SHARED_RES_URL
window.BK_APP_CODE = BK_APP_CODE
window.VERSION = VERSION
})()

function getLanguage () {
Expand All @@ -77,9 +75,9 @@
CUR_LANGUAGE = 'zh-cn'
}
if (CUR_LANGUAGE === 'en') {
document.title = 'BKIAM | Tencent Blueking'
document.title = 'lAM | Tencent BlueKing'
} else {
document.title = '权限中心 | 腾讯蓝鲸智云'
document.title = '权限中心 | 蓝鲸智云'
}

return CUR_LANGUAGE
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^4.0.1",
"better-npm-run": "~0.1.1",
"bk-magic-vue": "^2.5.9-beta.17",
"bk-magic-vue": "^2.5.9-beta.37",
"body-parser": "~1.19.0",
"chalk": "~2.4.2",
"cheerio": "~1.0.0-rc.3",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/common/router-handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const getRouterDiff = (payload) => {
'user',
'approval',
'permRenewal',
'permTransfer',
'audit',
'systemAccess',
'systemAccessCreate',
Expand Down Expand Up @@ -167,6 +168,7 @@ export const getRouterDiff = (payload) => {
'administrator',
'approval',
'permRenewal',
'permTransfer',
'audit',
'systemAccess',
'systemAccessCreate',
Expand Down Expand Up @@ -200,6 +202,7 @@ export const getRouterDiff = (payload) => {
'administrator',
'approval',
'permRenewal',
'permTransfer',
'audit',
'systemAccess',
'systemAccessCreate',
Expand Down Expand Up @@ -348,6 +351,7 @@ export const getNavRouterDiff = (navIndex, managerPerm = '') => {
'approvalProcess',
'approval',
'permRenewal',
'permTransfer',
'groupPermRenewal',
'permTemplateEdit',
'permTemplateDiff',
Expand Down Expand Up @@ -382,6 +386,7 @@ export const getNavRouterDiff = (navIndex, managerPerm = '') => {
'orgPermDetail',
'approval',
'permRenewal',
'permTransfer',
'systemAccess',
'systemAccessCreate',
'systemAccessAccess',
Expand Down
62 changes: 50 additions & 12 deletions frontend/src/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,20 +627,58 @@ export function formatI18nKey () {
* @param {callback} str 回调名
*
*/
export function jsonpRequest (url, params, callbackName) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
if (callbackName) {
callbackName = callbackName + Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
// export function jsonpRequest (url, params, callbackName) {
// return new Promise((resolve, reject) => {
// const script = document.createElement('script');
// if (callbackName) {
// callbackName = callbackName + Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
// }
// Object.assign(params, callbackName ? { callback: callbackName } : {});
// const arr = Object.keys(params).map(key => `${key}=${params[key]}`);
// script.src = `${url}?${arr.join('&')}`;
// document.body.appendChild(script);
// if (callbackName) {
// window[callbackName] = (data) => {
// resolve(data);
// };
// }
// });
// }
export function jsonpRequest (url, data) {
if (!url) throw new Error('invalid URL');
const callback = `CALLBACK${Math.random().toString().slice(9, 18)}`;
const JSONP = document.createElement('script');
JSONP.setAttribute('type', 'text/javascript');
const headEle = document.getElementsByTagName('head')[0];
let query = '';
if (data) {
if (typeof data === 'string') {
query = `&${data}`;
} else if (typeof data === 'object') {
for (const [key, value] of Object.entries(data)) {
query += `&${key}=${encodeURIComponent(value)}`;
}
}
Object.assign(params, callbackName ? { callback: callbackName } : {});
const arr = Object.keys(params).map(key => `${key}=${params[key]}`);
script.src = `${url}?${arr.join('&')}`;
document.body.appendChild(script);
if (callbackName) {
window[callbackName] = (data) => {
resolve(data);
query += `&_time=${Date.now()}`;
}
let promiseRejecter = null;
JSONP.src = `${url}?callback=${callback}${query}`;
JSONP.onerror = function (event) {
if (promiseRejecter) {
promiseRejecter = event;
}
};
return new Promise((resolve, reject) => {
promiseRejecter = reject;
try {
window[callback] = (result) => {
resolve(result);
headEle.removeChild(JSONP);
delete window[callback];
};
headEle.appendChild(JSONP);
} catch (err) {
reject(err);
}
});
}
Expand Down
42 changes: 33 additions & 9 deletions frontend/src/components/header-nav/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
import { buildURLParams } from '@/common/url';
import { formatI18nKey, jsonpRequest, getManagerMenuPerm } from '@/common/util';
import { NEED_CONFIRM_DIALOG_ROUTER } from '@/common/constants';
import SystemLog from '../system-log';
import { getRouterDiff, getNavRouterDiff } from '@/common/router-handle';
import Cookie from 'js-cookie';
import SystemLog from '../system-log';
import Cookies from 'js-cookie';
import magicbox from 'bk-magic-vue';
import logoSvg from '@/images/logo.svg';
Expand Down Expand Up @@ -623,16 +623,40 @@
locale.use(magicBoxLanguageMap[formatI18nKey()]);
window.CUR_LANGUAGE = formatI18nKey();
this.$i18n.locale = formatI18nKey();
window.location.reload();
},
handleChangeLocale (language) {
Cookie.remove('blueking_language', { path: '' });
Cookie.set('blueking_language', language, {
domain: window.BK_DOMAIN
});
async handleChangeLocale (language) {
const curDomain = window.BK_DOMAIN || window.location.hostname.replace(/^.*(\.[^.]+\.[^.]+)$/, '$1');
Cookies.remove(
'blueking_language',
{
expires: -1,
domain: curDomain,
path: ''
}
);
// 增加语言cookie有效期为一年
const expires = new Date();
expires.setFullYear(expires.getFullYear() + 1);
Cookies.set(
'blueking_language',
language,
{
expires: expires,
domain: curDomain
}
);
this.setMagicBoxLocale(language);
jsonpRequest(`${window.BK_COMPONENT_API_URL}/api/c/compapi/v2/usermanage/fe_update_user_language/?language=${language}`, { language });
if (window.BK_COMPONENT_API_URL) {
const url = `${window.BK_COMPONENT_API_URL}/api/c/compapi/v2/usermanage/fe_update_user_language/`;
try {
await jsonpRequest(url, { language });
} finally {
window.location.reload();
}
return;
}
window.location.reload();
},
handleSwitchIdentity () {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/nav/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
if (item.path === this.$route.path) {
// 因为vuex是同步操作,需要从缓存里获取最新的位置处理多个标签页之间不同权限页面之间的切换场景
const storageNavIndex = window.localStorage.getItem('index');
if (this.index !== storageNavIndex) {
if (this.index !== Number(storageNavIndex)) {
return;
}
bus.$emit('reload-page', item);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/language/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ export const m = {
'普通成员': 'Ordinary Member',
'退出登录': 'Sign out',
'我的管理空间': 'My Management Space',
'资源权限管理': 'Resource Perm Management',
'资源权限管理': 'Resource Permission Management',
'发起需求': 'Initiate Request',
'工作台': 'Workspace',
'开发者': 'Developers',
Expand All @@ -656,7 +656,7 @@ export const m = {
'克隆二级管理空间': 'Clone Secondary management space',
'用户组设置': 'User Group Setting',
'敏感等级': 'Sensitivity Level',
'人员模板': 'Members Template',
'人员模板': 'Member Templates',
'用户/组织': 'User/Organization',
'续期通知': 'Renewal Notice'
},
Expand Down Expand Up @@ -797,7 +797,7 @@ export const m = {
'通过组织加入': 'Through Organization',
'组权限': 'Permissions',
'所属组织用户组权限': 'Group Permissions of the Organization',
'所属人员模板用户组权限': 'Member Template User Group Permissions',
'所属人员模板用户组权限': 'Group Permissions of Member Templates',
'临时权限申请': 'Apply for temporary permissions',
'一组实例权限': ' A Set of Instance Permissions',
'不能删除当前操作': 'Unable to delete current permission',
Expand Down
23 changes: 17 additions & 6 deletions frontend/src/model/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default class Policy {
this.count = payload.count || 0;
this.tag = payload.tag || '';
this.isTempora = payload.isTempora || false;
// 是否是无权限申请页面
this.isNoPermApplyPage = payload.isNoPermApplyPage || false;
this.isShowCustom = false;
this.customValue = '';
this.environment = payload.environment || {};
Expand Down Expand Up @@ -96,20 +98,29 @@ export default class Policy {
}

this.resource_groups = payload.resource_groups.reduce((prev, item) => {
const relatedRsourceTypes = item.related_resource_types.map(
item => new RelateResourceTypes({ ...item, isTempora: payload.isTempora },
action, flag, instanceNotDisabled, this.isNew)
const relatedResourceTypes = item.related_resource_types.map((item) =>
new RelateResourceTypes(
{
...item,
isTempora: payload.isTempora,
isNoPermApplyPage: payload.isNoPermApplyPage
},
action,
flag,
instanceNotDisabled,
this.isNew
)
);

if ((this.related_environments && !!this.related_environments.length)) {
const environments = item.environments && !!item.environments.length ? item.environments : [];
prev.push({ id: item.id, related_resource_types: relatedRsourceTypes, environments: environments });
prev.push({ id: item.id, related_resource_types: relatedResourceTypes, environments: environments });
} else {
if (item.environments && !!item.environments.length) {
// eslint-disable-next-line max-len
prev.push({ id: item.id, related_resource_types: relatedRsourceTypes, environments: item.environments });
prev.push({ id: item.id, related_resource_types: relatedResourceTypes, environments: item.environments });
} else {
prev.push({ id: item.id, related_resource_types: relatedRsourceTypes });
prev.push({ id: item.id, related_resource_types: relatedResourceTypes });
}
}
return prev;
Expand Down
39 changes: 20 additions & 19 deletions frontend/src/model/related-resource-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,28 @@ export default class RelateResourceTypes {
if (payload.isTempora) { // 临时权限标识
this.condition = payload.condition;
this.conditionBackup = payload.condition;
} else {
const isEmpty = !payload.condition
|| ((payload.condition.length > 0)
&& payload.condition.every(item =>
(item.attributes && item.attributes.length < 1)
&& (item.instance && item.instance.length < 1)
return;
}
const isEmpty = !payload.condition || ((payload.condition.length > 0)
&& payload.condition.every((item) =>
(item.attributes && item.attributes.length < 1)
&& (item.instance && item.instance.length < 1)
&& (item.instances && item.instances.length < 1)
));
if (isEmpty) {
this.condition = ['none'];
this.conditionBackup = ['none'];
return;
}
this.condition = payload.condition.map(
item => new Condition(item, '', flag, true, true, instanceNotDisabled)
) || [];

this.conditionBackup = payload.condition.map(
item => new Condition(item, '', flag, true, true, instanceNotDisabled)
) || [];
)
);
// 无限制申请页面首次加载不存在无限制场景需要置空
if (isEmpty || (payload.isNoPermApplyPage && (!payload.condition || !payload.condition.length))) {
this.condition = ['none'];
this.conditionBackup = ['none'];
return;
}
this.condition = payload.condition.map(
(item) => new Condition(item, '', flag, true, true, instanceNotDisabled)
) || [];

this.conditionBackup = payload.condition.map(
(item) => new Condition(item, '', flag, true, true, instanceNotDisabled)
) || [];
}

get isDefaultLimit () {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/store/modules/global-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default {
separator: '|' // 网站名称路由分隔符
},
name: '权限中心',
nameEn: 'BK_IAM',
brandName: '腾讯蓝鲸智云',
brandNameEn: 'BlueKing',
nameEn: 'IAM',
brandName: '蓝鲸智云',
brandNameEn: 'Tencent BlueKing',
appLogo: require('@/images/logo.svg'),
favicon: require('@/images/logo.svg'),
version: ''
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/views/perm-apply/apply-custom-perm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,14 @@
if (!item.resource_groups || !item.resource_groups.length) {
item.resource_groups = item.related_resource_types.length ? [{ id: '', related_resource_types: item.related_resource_types }] : [];
}
return new Policy({ ...item, tag: 'add' }, 'custom');
return new Policy(
{
...item,
tag: 'add',
isNoPermApplyPage: !!(this.routerQuery.cache_id && !this.isShowHasUserGroup)
},
'custom'
);
});
this.tableRecommendData = data;
this.tableRecommendData.forEach(item => {
Expand Down Expand Up @@ -2324,7 +2331,8 @@
return new Policy({
...item,
related_actions: relatedActions,
tid: this.routerQuery.cache_id ? this.routerQuery.cache_id : ''
tid: this.routerQuery.cache_id ? this.routerQuery.cache_id : '',
isNoPermApplyPage: !!(this.routerQuery.cache_id && !this.isShowHasUserGroup)
});
});
this.tableData = data || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@
resItem.isLimitExceeded = false;
resItem.isError = true;
} else {
resItem.condition = data;
const { isMainAction, related_actions } = this.tableList[this.curIndex];
// 如果为主操作
if (isMainAction) {
Expand Down
Loading

0 comments on commit 36bab5e

Please sign in to comment.