Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into ft_subject_template
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Nov 15, 2023
2 parents c07dcc5 + 5e3d4c6 commit b3313b4
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 45 deletions.
4 changes: 3 additions & 1 deletion frontend/src/language/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ export const m = {
'不可续期的用户组成员如下': 'The non renewable user group members are as follows: {value}',
'管理员组不能添加权限': 'Administrators group cannot add permissions',
'只读用户组不能添加权限': 'Read only user groups cannot add permissions',
'申请加入失败,用户组数量超出上限(100个),请在“我的权限”中退出用户组后重试': 'Application to join failed. The number of user groups exceeds the maximum limit (100), please exit {value} user group in "My permissions" and try again'
'申请加入失败,用户组数量超出上限(100个),请在“我的权限”中退出用户组后重试': 'Application to join failed. The number of user groups exceeds the maximum limit (100), please exit {value} user group in "My permissions" and try again',
'最多添加一个管理员': 'Add at most one administrator',
'管理员不可重复添加': 'Administrators cannot be added repeatedly'
},
// 二次确认弹窗相关
dialog: {
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/language/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ export const m = {
'不可续期的用户组成员如下': '不可续期的用户组成员如下:{value}',
'管理员组不能添加权限': '管理员组不能添加权限',
'只读用户组不能添加权限': '只读用户组不能添加权限',
'申请加入失败,用户组数量超出上限(100个),请在“我的权限”中退出用户组后重试': '申请加入失败,用户组数量超出上限(100个),请在"我的权限"中退出{value}个用户组后重试'
'申请加入失败,用户组数量超出上限(100个),请在“我的权限”中退出用户组后重试': '申请加入失败,用户组数量超出上限(100个),请在"我的权限"中退出{value}个用户组后重试',
'最多添加一个管理员': '最多添加一个管理员',
'管理员不可重复添加': '管理员不可重复添加'
},
// 二次确认弹窗相关
dialog: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,12 @@
handleActionLinearData () {
const linearActions = [];
this.curSystemActions.forEach((item) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/group/detail/group-perm-new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,12 @@
handleActionLinearData () {
const linearActions = [];
this.originalCustomTmplList.forEach((item, index) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,22 @@
handleActionLinearData () {
const linearActions = [];
this.curSystemActions.forEach((item) => {
item.actions = item.actions.filter(v => !v.hidden);
if (['myManageSpaceCreate'].includes(this.$route.name)
&& (['gradingAdminCreate'].includes(this.$route.name)
&& ['staff'].includes(this.user.role.type))
) {
item.actions = item.actions.filter(v => !v.hidden);
}
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
if (['myManageSpaceCreate'].includes(this.$route.name)
&& (['gradingAdminCreate'].includes(this.$route.name)
&& ['staff'].includes(this.user.role.type))
) {
sub.actions = sub.actions.filter(v => !v.hidden);
}
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
if (!item.actions) {
this.$set(item, 'actions', []);
}
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag));
this.$set(act, 'disabled', act.tag === 'readonly');
Expand All @@ -501,7 +501,7 @@
if (!sub.actions) {
this.$set(sub, 'actions', []);
}
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
this.$set(act, 'checked', ['checked', 'readonly', 'delete'].includes(act.tag));
this.$set(act, 'disabled', act.tag === 'readonly');
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/perm/components/render-renewal-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -939,12 +939,12 @@
handleActionLinearData () {
const linearActions = [];
this.originalCustomTmplList.forEach((item) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/perm/custom-perm/custom-perm-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@
handleActionLinearData () {
const linearActions = [];
this.originalCustomTmplList.forEach((item, index) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@
handleActionLinearData () {
const linearActions = [];
this.originalCustomTmplList.forEach((item, index) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
65 changes: 49 additions & 16 deletions frontend/src/views/set/components/render-super-manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
<bk-table-column :label="$t(`m.common['操作']`)" width="120">
<template slot-scope="{ row, $index }">
<template v-if="row.isEdit">
<bk-button theme="primary" text :disabled="isDisabled(row)" @click="handleSave(row)">
<bk-button
theme="primary"
text
:title="saveDisableTip"
:disabled="isDisabled(row)"
@click="handleSave(row)">
{{ $t(`m.common['保存']`) }}
</bk-button>
<bk-button theme="primary" text style="margin-left: 10px;"
Expand Down Expand Up @@ -125,6 +130,7 @@
data () {
return {
subTitle: this.$t(`m.set['超级管理员提示']`),
saveDisableTip: '',
superUserList: [],
userApi: window.BK_USER_API,
emptyData: {
Expand All @@ -136,21 +142,28 @@
};
},
computed: {
...mapGetters(['user']),
isDisabled () {
return payload => {
if (payload.user.length !== 1) {
return true;
}
if (this.superUserList.filter(item => item.user[0] === payload.user[0]).length > 1) {
return true;
}
return false;
};
},
tableHeight () {
return getWindowHeight() - 297;
}
...mapGetters(['user']),
isDisabled () {
return (payload) => {
if (!payload.user.length) {
this.saveDisableTip = this.$t(`m.verify['管理员不能为空']`);
return true;
}
if (payload.user.length > 1) {
this.saveDisableTip = this.$t(`m.info['最多添加一个管理员']`);
return true;
}
if (this.superUserList.filter(item => item.user[0] === payload.user[0]).length > 1) {
this.saveDisableTip = this.$t(`m.info['管理员不可重复添加']`);
return true;
}
this.saveDisableTip = '';
return false;
};
},
tableHeight () {
return getWindowHeight() - 297;
}
},
created () {
this.fetchSuperManager();
Expand Down Expand Up @@ -198,6 +211,16 @@
handleSuperRtxChange (payload, row) {
row.user = [...payload];
if (this.superUserList.length) {
const hasManager = this.superUserList.filter(item => item.user[0] === row.user[0]).length > 1;
if (hasManager) {
if (row.user.length < 2) {
return this.messageWarn(this.$t(`m.info['管理员不可重复添加']`), 3000);
} else {
return this.messageWarn(this.$t(`m.info['最多添加一个管理员']`), 3000);
}
}
}
},
handleSuperRtxEnter (event, payload) {
Expand All @@ -206,6 +229,16 @@
}
if (event.keyCode === 13) {
event.stopPropagation();
if (this.superUserList.length) {
const hasManager = this.superUserList.filter(item => item.user[0] === payload.user[0]).length > 1;
if (hasManager) {
if (payload.user.length < 2) {
return this.messageWarn(this.$t(`m.info['管理员不可重复添加']`), 3000);
} else {
return this.messageWarn(this.$t(`m.info['最多添加一个管理员']`), 3000);
}
}
}
const flag = _.isEqual(payload.user.sort(), payload.userBackup.sort());
if (flag) {
payload.isEdit = false;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/user/components/perm-table-edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@
handleActionLinearData () {
const linearActions = [];
this.originalCustomTmplList.forEach((item, index) => {
item.actions = item.actions.filter(v => !v.hidden);
// item.actions = item.actions.filter(v => !v.hidden);
item.actions.forEach(act => {
linearActions.push(act);
});
(item.sub_groups || []).forEach(sub => {
sub.actions = sub.actions.filter(v => !v.hidden);
// sub.actions = sub.actions.filter(v => !v.hidden);
sub.actions.forEach(act => {
linearActions.push(act);
});
Expand Down
2 changes: 2 additions & 0 deletions saas/backend/apps/subject/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class SubjectGroupSLZ(serializers.Serializer):
description = serializers.CharField(label="描述", allow_blank=True)
department_id = serializers.IntegerField(label="部门ID", help_text="0则为个人,其他为继承的部门ID")
department_name = serializers.CharField(label="部门名称")
user_count = serializers.IntegerField(label="用户数")
department_count = serializers.IntegerField(label="部门数")


class QueryRoleSLZ(serializers.Serializer):
Expand Down
12 changes: 1 addition & 11 deletions saas/backend/biz/application_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,7 @@ def copy_policy_by_instance_path(policy, resource_group, rrt, instance, path):
)
]
),
policy_id=policy.policy_id,
expired_at=policy.expired_at,
type=policy.type,
name=policy.name,
name_en=policy.name_en,
description=policy.description,
description_en=policy.description_en,
expired_display=policy.expired_display,
action_id=policy.action_id,
backend_policy_id=policy.backend_policy_id,
auth_type=policy.auth_type,
**policy.dict(exclude={"resource_groups"}),
)


Expand Down
5 changes: 5 additions & 0 deletions saas/backend/biz/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class SubjectGroupBean(BaseModel):
department_id: int = 0
department_name: str = ""

user_count: int = 0
department_count: int = 0


class GroupMemberBean(BaseModel):
type: str
Expand Down Expand Up @@ -380,6 +383,8 @@ def _convert_to_subject_group_beans(self, relations: List[SubjectGroup]) -> List
created_time=utc_string_to_local(relation.created_at),
department_id=relation.department_id,
department_name=relation.department_name,
user_count=group.user_count,
department_count=group.department_count,
)
)

Expand Down

0 comments on commit b3313b4

Please sign in to comment.