Skip to content

Commit

Permalink
feat(frontend): mongodb删除规则加二次确认 #8407
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25974
  • Loading branch information
JustaCattt authored and hLinx committed Dec 5, 2024
1 parent 25eb97b commit 27c1b7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,6 @@
"您输入的访问 DB 名不符合要求_访问 DB 名应以字母开头_且仅包含字母_数字和下划线": "您输入的访问 DB 名不符合要求。访问 DB 名应以字母开头,且仅包含字母、数字和下划线",
"访问 DB 不能为空": "访问 DB 不能为空",
"访问 DB 名不允许为 admin": "访问 DB 名不允许为 admin",
"删除规则后将不能恢复,请谨慎操作": "删除规则后将不能恢复,请谨慎操作",
"这行勿动!新增翻译请在上一行添加!": ""

}
29 changes: 13 additions & 16 deletions dbm-ui/frontend/src/views/db-manage/common/permission/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@
return acc;
}, {}));

const skipApproval = computed(() => props.accountType === AccountTypes.MONGODB);

/**
* search select 过滤参数
*/
Expand Down Expand Up @@ -479,17 +481,15 @@
configMap[props.accountType].buttonController[ButtonTypes.DELETE_RULE] &&
<bk-pop-confirm
width="288"
content={t('删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。')}
content={skipApproval.value ? t('删除规则后将不能恢复,请谨慎操作') : t('删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。')}
title={t('确认删除该规则?')}
trigger="click"
disabled={props.accountType === AccountTypes.MONGODB}
onConfirm={() => handlePopDeleteRule(data, index)}
onConfirm={() => handleDeleteRule(data, index)}
>
<bk-button
theme="primary"
class="ml-8"
disabled={data.rules[index].priv_ticket?.ticket_id}
onClick={() => handleDeleteRule(data, index)}
text>
{t('删除')}
</bk-button>
Expand Down Expand Up @@ -655,7 +655,15 @@
/**
* 删除规则
*/
const handlePopDeleteRule = (row: PermissionRule, index: number) => {
const handleDeleteRule = (row: PermissionRule, index: number) => {
if (skipApproval.value) {
deleteAccountRuleRun({
account_id: row.account.account_id,
account_type: props.accountType,
rule_id: row.rules[index].rule_id,
});
return;
}
const ticketTypeMap = {
[AccountTypes.MYSQL]: TicketTypes.MYSQL_ACCOUNT_RULE_CHANGE,
[AccountTypes.TENDBCLUSTER]: TicketTypes.TENDBCLUSTER_ACCOUNT_RULE_CHANGE,
Expand All @@ -676,17 +684,6 @@
},
});
};

/**
* 删除规则(不需要审批)
*/
const handleDeleteRule = (row: PermissionRule, index: number) => {
deleteAccountRuleRun({
account_id: row.account.account_id,
account_type: props.accountType,
rule_id: row.rules[index].rule_id,
});
};
</script>

<style lang="less" scoped>
Expand Down

0 comments on commit 27c1b7b

Please sign in to comment.