Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#2691 from lhzzforever/dev/develop_ci
Browse files Browse the repository at this point in the history
fix: 申请用户组—>无权限申请权限和常用推荐权限需要过滤掉指定的操作
  • Loading branch information
ielgnaw authored Jun 6, 2024
2 parents 6aea390 + f72d2f9 commit 37dd3e0
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 46 deletions.
97 changes: 52 additions & 45 deletions frontend/src/views/perm-apply/apply-custom-perm/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
>
<resource-instance-table
:has-system="true"
:is-no-perm-page="true"
:cache-id="routerQuery.cache_id"
:list="newTableList"
:original-table-list="tableDataBackup"
Expand All @@ -582,6 +583,7 @@
>
<resource-instance-table
:has-system="true"
:is-no-perm-page="true"
:is-recommend="isRecommend"
:cache-id="routerQuery.cache_id"
:list="newRecommendTableList"
Expand Down Expand Up @@ -1055,9 +1057,9 @@
};
try {
const res = await this.$store.dispatch('perm/getRecommended', params);
const recommendActions = res.data.actions || [];
// 常用操作需要过滤掉需要隐藏的操作
const recommendActions = res.data.actions.filter((item) => !item.hidden) || [];
const recommendPolicies = res.data.policies || [];
const data = recommendActions.map(item => {
const resourceGroups = recommendPolicies.find(sub => sub.id === item.id);
if (resourceGroups) {
Expand Down Expand Up @@ -2289,51 +2291,56 @@
}
try {
const res = await this.$store.dispatch('permApply/getPolicies', params);
const data = res.data.map(item => {
let relatedActions = [];
const findLinerActions = this.linearActionList.find(sub => sub.id === item.id);
if (findLinerActions) {
const { related_actions, related_environments } = findLinerActions;
// eslint-disable-next-line camelcase
relatedActions = [...related_actions];
// eslint-disable-next-line camelcase
item.related_environments = related_environments;
}
// 此处处理related_resource_types中value的赋值
return new Policy({
...item,
related_actions: relatedActions,
tid: this.routerQuery.cache_id ? this.routerQuery.cache_id : ''
});
});
this.tableData = data;
this.tableData.forEach(item => {
// item.expired_at = 1627616000
// 无权限跳转过来, 新增的操作过期时间为 0 即小于 user.timestamp 时,expired_at 就设置为六个月 15552000
if (item.tag === 'add') {
if (item.expired_at <= this.user.timestamp) {
item.expired_at = 15552000;
// 无权限申请过滤需要隐藏的操作
if (res.data && res.data.length > 0) {
const allPolicyList = this.linearActionList.filter((v) => !v.hidden).map((item) => `${item.name}&${item.id}`);
const result = res.data.filter((item) => allPolicyList.includes(`${item.name}&${item.id}`));
const data = result.map(item => {
let relatedActions = [];
const findLinerActions = this.linearActionList.find(sub => sub.id === item.id);
if (findLinerActions) {
const { related_actions, related_environments } = findLinerActions;
// eslint-disable-next-line camelcase
relatedActions = [...related_actions];
// eslint-disable-next-line camelcase
item.related_environments = related_environments;
}
} else {
// 新增的权限不判断是否过期
if (item.expired_at <= this.user.timestamp) {
item.isShowRenewal = true;
item.isExpired = true;
// 此处处理related_resource_types中value的赋值
return new Policy({
...item,
related_actions: relatedActions,
tid: this.routerQuery.cache_id ? this.routerQuery.cache_id : ''
});
});
this.tableData = data || [];
this.tableData.forEach(item => {
// item.expired_at = 1627616000
// 无权限跳转过来, 新增的操作过期时间为 0 即小于 user.timestamp 时,expired_at 就设置为六个月 15552000
if (item.tag === 'add') {
if (item.expired_at <= this.user.timestamp) {
item.expired_at = 15552000;
}
} else {
// 新增的权限不判断是否过期
if (item.expired_at <= this.user.timestamp) {
item.isShowRenewal = true;
item.isExpired = true;
}
}
}
// // 新增的权限不判断是否过期
// if (item.expired_at <= this.user.timestamp && item.tag !== 'add') {
// item.isShowRenewal = true
// item.isExpired = true
// // this.$set(item, 'isShowRenewal', true)
// // this.$set(item, 'isExpired', true)
// }
});
this.newTableList = _.cloneDeep(this.tableData.filter(item => {
return !item.isExpiredAtDisabled;
}));
// // 新增的权限不判断是否过期
// if (item.expired_at <= this.user.timestamp && item.tag !== 'add') {
// item.isShowRenewal = true
// item.isExpired = true
// // this.$set(item, 'isShowRenewal', true)
// // this.$set(item, 'isExpired', true)
// }
});
this.newTableList = _.cloneDeep(this.tableData.filter(item => {
return !item.isExpiredAtDisabled;
}));
}
this.tableDataBackup = _.cloneDeep(this.tableData);
this.aggregationsTableData = _.cloneDeep(this.tableData);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
margin-top: 0px;
padding-top: 20px;
}
.recommend-action-name-empty {
margin-top: 0;
height: auto;
padding-top: 0;
}
.empty-text {
padding-top: 0px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
:class="row.isEmpty ? 'action-name-empty' : 'action-name-cell'">
<span class="action-name" :title="row.name">{{ row.name }}</span>
</div>
<div v-else :class="row.isEmpty ? 'action-name-empty' : 'action-name-cell'">
<div v-else
:class="[
'action-name-cell',
{ 'action-name-empty': row.isEmpty },
{ 'recommend-action-name-empty': isNoPermPage }
]"
>
<span class="action-name" style="padding: 10px 0;" :title="row.name">{{ row.name }}</span>
<span v-if="!emptyResourceGroupsList.length">
<iam-svg name="icon-new" ext-cls="iam-new-action" v-if="row.isNew && curLanguageIsCn" />
Expand Down Expand Up @@ -359,6 +365,10 @@
type: Boolean,
default: false
},
isNoPermPage: {
type: Boolean,
default: false
},
hasSystem: {
type: Boolean,
default: false
Expand Down

0 comments on commit 37dd3e0

Please sign in to comment.