Skip to content

Commit

Permalink
feat(frontend): mysql、spider库表校验规则调整 TencentBlueKing#6595
Browse files Browse the repository at this point in the history
  • Loading branch information
jinquantianxia committed Sep 5, 2024
1 parent 5817c63 commit d17e723
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 102 deletions.
3 changes: 3 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3487,5 +3487,8 @@
"数量(台)": "数量(台)",
"统计视图": "统计视图",
"主机列表": "主机列表",
"库表只能由[0-9],[a-z],[A-Z],-,_ 组成,支持* % ?通配符,最大35字符": "库表只能由[0-9],[a-z],[A-Z],-,_ 组成,支持* % ?通配符,最大35字符",
"不允许填写系统库": "不允许填写系统库",
"不能以stage_truncate开头或dba_rollback结尾": "不能以 stage_truncate 开头或 dba_rollback 结尾",
"这行勿动!新增翻译请在上一行添加!": ""
}
14 changes: 14 additions & 0 deletions dbm-ui/frontend/src/views/mysql/common/edit-field/DbName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
return props.rules;
}

const systemDbNames = ['mysql', 'db_infobase', 'information_schema', 'performance_schema', 'sys', 'infodba_schema'];

return [
{
validator: (value: string[]) => {
Expand All @@ -89,6 +91,18 @@
},
message: t('DB 名不能为空'),
},
{
validator: (value: string[]) => _.every(value, (item) => /^(?!stage_truncate)(?!.*dba_rollback$).*/.test(item)),
message: t('不能以stage_truncate开头或dba_rollback结尾'),
},
{
validator: (value: string[]) => _.every(value, (item) => /^[-_a-zA-Z0-9*?%]{0,35}$/.test(item)),
message: t('库表只能由[0-9],[a-z],[A-Z],-,_ 组成,支持* % ?通配符,最大35字符'),
},
{
validator: (value: string[]) => _.every(value, (item) => !systemDbNames.includes(item)),
message: t('不允许填写系统库'),
},
{
validator: (value: string[]) => {
if (props.allowAsterisk) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
},
message: t('表名不能为空'),
},
{
validator: (value: string[]) => _.every(value, (item) => /^[-_a-zA-Z0-9*?%]{0,35}$/.test(item)),
message: t('库表只能由[0-9],[a-z],[A-Z],-,_ 组成,支持* % ?通配符,最大35字符'),
},
{
validator: (value: string[]) => {
if (props.allowAsterisk) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,48 @@
field: 'databases',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
},
{
label: t('目标表'),
field: 'tables',
label: t('忽略库'),
field: 'databases_ignore',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
},
{
label: t('忽略库'),
field: 'databases_ignore',
label: t('目标表'),
field: 'tables',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
},
{
label: t('忽略表'),
field: 'tables_ignore',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,48 +103,48 @@
field: 'db_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
},
{
label: t('目标表名'),
field: 'table_patterns',
label: t('忽略DB名'),
field: 'ignore_dbs',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
},
{
label: t('忽略DB名'),
field: 'ignore_dbs',
label: t('目标表名'),
field: 'table_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
},
{
label: t('忽略表名'),
field: 'ignore_tables',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
<div
class="text-overflow"
v-overflow-tips={{ content: cell }}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@
name: string,
}

/**
* mysql 库表备份
*/

const columns: any = [{
label: t('集群ID'),
field: 'cluster_id',
render: ({ cell }: { cell: number }) => <span>{cell || '--'}</span>,
}, {
label: t('集群名称'),
field: 'immute_domain',
showOverflowTooltip: false,
render: ({ data }: { data: any }) => (
const columns = [
{
label: t('集群ID'),
field: 'cluster_id',
render: ({ cell }: { cell: number }) => <span>{cell || '--'}</span>,
},
{
label: t('集群名称'),
field: 'immute_domain',
showOverflowTooltip: false,
render: ({ data }: { data: backupItem }) => (
<div class="cluster-name text-overflow"
v-overflow-tips={{
content: `
Expand All @@ -69,55 +67,61 @@
<span class="cluster-name__alias">{data.name}</span>
</div>
),
}, {
label: t('备份源'),
field: 'backup_on',
render: ({ cell }: { cell: string }) => <span>{cell || '--'}</span>,
}, {
label: t('备份DB名'),
field: 'db_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
},
{
label: t('备份源'),
field: 'backup_on',
render: ({ cell }: { cell: string }) => <span>{cell || '--'}</span>,
},
{
label: t('备份DB名'),
field: 'db_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
}, {
label: t('忽略DB名'),
field: 'ignore_dbs',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
},
{
label: t('忽略DB名'),
field: 'ignore_dbs',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
}, {
label: t('备份表名'),
field: 'table_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
},
{
label: t('备份表名'),
field: 'table_patterns',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.map(item => <bk-tag>{item}</bk-tag>)}
</div>
),
}, {
label: t('忽略表名'),
field: 'ignore_tables',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
},
{
label: t('忽略表名'),
field: 'ignore_tables',
showOverflowTooltip: false,
render: ({ cell }: { cell: string[] }) => (
<div class="text-overflow" v-overflow-tips={{
content: cell,
}}>
{cell.length > 0 ? cell.map(item => <bk-tag>{item}</bk-tag>) : '--'}
</div>
),
}];
}
];

const dataList = computed(() => {
const list: backupItem[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@
showOverflowTooltip: true,
},
{
label: t('目标表'),
field: 'tableName',
label: t('忽略库'),
field: 'ignoreDbName',
showOverflowTooltip: true,
},
{
label: t('忽略库'),
field: 'ignoreDbName',
label: t('目标表'),
field: 'tableName',
showOverflowTooltip: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
showOverflowTooltip: true,
},
{
label: t('备份表名'),
field: 'tableName',
label: t('忽略DB名'),
field: 'ignoreDbName',
showOverflowTooltip: true,
},
{
label: t('忽略DB名'),
field: 'ignoreDbName',
label: t('备份表名'),
field: 'tableName',
showOverflowTooltip: true,
},
{
Expand Down

0 comments on commit d17e723

Please sign in to comment.