Skip to content

Commit c073cbc

Browse files
committed
feat(data-source): add field workflow_exec_enabled
1 parent 62d02a3 commit c073cbc

File tree

14 files changed

+201
-14
lines changed

14 files changed

+201
-14
lines changed

packages/base/src/locale/en-US/dmsDataSource.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export default {
6060
'If you do not enable the SQL audit service, the DB instance cannot be used in SQL audit related services, are you sure to close it?',
6161
needAuditForSqlQuery: 'Whether SQL query needs audit',
6262
allowQueryWhenLessThanAuditLevel: 'Highest audit level for running queries',
63+
allowExecuteNonDqlInWorkflow:
64+
'Allow executing non-DQL SQL via workflow in SQL workbench',
65+
allowExecuteNonDqlInWorkflowTips:
66+
'When enabled, allows executing non-DQL SQL statements via workflow in SQL workbench',
6367
passwordTips:
6468
'The current DB instance password you have configured will not be displayed here. if you do not fill in the password when submitting, the DB instance password will not be changed.',
6569
needUpdatePassword: 'Update password',

packages/base/src/locale/zh-CN/dmsDataSource.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
allowQueryWhenLessThanAuditLevel: '自动放行的最高审核等级',
8282
allowQueryWhenLessThanAuditLevelTips:
8383
'低于或等于此等级的审核结果将自动放行',
84+
allowExecuteNonDqlInWorkflow: '通过工单上线执行工作台非DQL类型SQL',
85+
allowExecuteNonDqlInWorkflowTips:
86+
'开启后,允许通过工单上线执行工作台非DQL类型的SQL语句',
8487
dataExportAuditRuleTemplate: '数据导出审核规则模板',
8588
dataExportAuditRuleTemplateTips:
8689
'此功能强制开启审核,请为数据导出选择规则模板',

packages/base/src/page/DataSource/components/AddDataSource/index.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ describe('page/DataSource/AddDataSource', () => {
161161
fireEvent.click(getBySelector('div[title="warn"]', baseElement));
162162
await act(async () => jest.advanceTimersByTime(0));
163163

164+
// allowExecuteNonDqlInWorkflow
165+
fireEvent.click(
166+
getBySelector('#allowExecuteNonDqlInWorkflow', baseElement)
167+
);
168+
await act(async () => jest.advanceTimersByTime(0));
169+
164170
// submit
165171
await act(async () => {
166172
fireEvent.click(screen.getByText('提 交'));
@@ -212,7 +218,8 @@ describe('page/DataSource/AddDataSource', () => {
212218
allow_query_when_less_than_audit_level: 'warn',
213219
audit_enabled: true,
214220
rule_template_id: '3',
215-
rule_template_name: 'default_MySQL1'
221+
rule_template_name: 'default_MySQL1',
222+
workflow_exec_enabled: true
216223
}
217224
},
218225
user: 'root'
@@ -435,7 +442,8 @@ describe('page/DataSource/AddDataSource', () => {
435442
data_export_rule_template_name: 'default_MySQL1',
436443
sql_query_config: {
437444
allow_query_when_less_than_audit_level: undefined,
438-
audit_enabled: undefined
445+
audit_enabled: undefined,
446+
workflow_exec_enabled: undefined
439447
}
440448
},
441449
user: 'root',

packages/base/src/page/DataSource/components/AddDataSource/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const AddDataSource = () => {
5656
values.allowQueryWhenLessThanAuditLevel,
5757
audit_enabled: values.needAuditForSqlQuery,
5858
rule_template_id: values.workbenchTemplateId,
59-
rule_template_name: values.workbenchTemplateName
59+
rule_template_name: values.workbenchTemplateName,
60+
workflow_exec_enabled: values.allowExecuteNonDqlInWorkflow
6061
}
6162
},
6263
// #endif

packages/base/src/page/DataSource/components/Form/SqlAuditFields/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ exports[`SqlAuditFields should match snapshot when needSqlAuditService and needA
546546
</div>
547547
</div>
548548
<div
549-
class="ant-form-item has-required-style has-label-tip no-margin-field css-1jlm9cy"
549+
class="ant-form-item has-required-style has-label-tip css-1jlm9cy"
550550
>
551551
<div
552552
class="ant-row ant-form-item-row"
@@ -669,6 +669,69 @@ exports[`SqlAuditFields should match snapshot when needSqlAuditService and needA
669669
</div>
670670
</div>
671671
</div>
672+
<div
673+
class="ant-form-item has-label-tip no-margin-field css-1jlm9cy"
674+
>
675+
<div
676+
class="ant-row ant-form-item-row"
677+
>
678+
<div
679+
class="ant-col ant-form-item-label"
680+
>
681+
<label
682+
class=""
683+
for="allowExecuteNonDqlInWorkflow"
684+
title=""
685+
>
686+
<div
687+
class="label-cont-custom"
688+
>
689+
<div>
690+
通过工单上线执行工作台非DQL类型SQL
691+
</div>
692+
<div
693+
class="tip-content-box"
694+
>
695+
开启后,允许通过工单上线执行工作台非DQL类型的SQL语句
696+
</div>
697+
</div>
698+
</label>
699+
</div>
700+
<div
701+
class="ant-col ant-form-item-control"
702+
>
703+
<div
704+
class="ant-form-item-control-input"
705+
>
706+
<div
707+
class="ant-form-item-control-input-content"
708+
>
709+
<button
710+
aria-checked="false"
711+
class="ant-switch basic-switch-wrapper css-g6dhbn"
712+
id="allowExecuteNonDqlInWorkflow"
713+
role="switch"
714+
type="button"
715+
>
716+
<div
717+
class="ant-switch-handle"
718+
/>
719+
<span
720+
class="ant-switch-inner"
721+
>
722+
<span
723+
class="ant-switch-inner-checked"
724+
/>
725+
<span
726+
class="ant-switch-inner-unchecked"
727+
/>
728+
</span>
729+
</button>
730+
</div>
731+
</div>
732+
</div>
733+
</div>
734+
</div>
672735
</div>
673736
</div>
674737
</div>

packages/base/src/page/DataSource/components/Form/SqlAuditFields/index.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type SqlAuditFieldsValue = {
3030
workbenchTemplateId: string;
3131
workbenchTemplateName: string;
3232
allowQueryWhenLessThanAuditLevel: string;
33+
allowExecuteNonDqlInWorkflow: boolean;
3334
};
3435
type SqlAuditFieldsProps = {
3536
getTemplateOptionsLoading: boolean;
@@ -236,7 +237,7 @@ const SqlAuditFields: React.FC<SqlAuditFieldsProps> = ({
236237
})
237238
}
238239
]}
239-
className="has-required-style has-label-tip no-margin-field"
240+
className="has-required-style has-label-tip"
240241
>
241242
<BasicSelect prefix={<FaLessThanEqualOutlined />}>
242243
{Object.values(
@@ -250,6 +251,23 @@ const SqlAuditFields: React.FC<SqlAuditFieldsProps> = ({
250251
})}
251252
</BasicSelect>
252253
</FormItemLabel>
254+
<FormItemLabel
255+
label={
256+
<CustomLabelContent
257+
title={t(
258+
'dmsDataSource.dataSourceForm.allowExecuteNonDqlInWorkflow'
259+
)}
260+
tips={t(
261+
'dmsDataSource.dataSourceForm.allowExecuteNonDqlInWorkflowTips'
262+
)}
263+
/>
264+
}
265+
name="allowExecuteNonDqlInWorkflow"
266+
valuePropName="checked"
267+
className="has-label-tip no-margin-field"
268+
>
269+
<BasicSwitch />
270+
</FormItemLabel>
253271
</div>
254272
</EmptyBox>
255273
</div>

packages/base/src/page/DataSource/components/Form/__snapshots__/index.test.tsx.snap

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4144,7 +4144,7 @@ exports[`page/DataSource/DataSourceForm render change switch when page is update
41444144
</div>
41454145
</div>
41464146
<div
4147-
class="ant-form-item has-required-style has-label-tip no-margin-field css-1jlm9cy"
4147+
class="ant-form-item has-required-style has-label-tip css-1jlm9cy"
41484148
>
41494149
<div
41504150
class="ant-row ant-form-item-row"
@@ -4267,6 +4267,69 @@ exports[`page/DataSource/DataSourceForm render change switch when page is update
42674267
</div>
42684268
</div>
42694269
</div>
4270+
<div
4271+
class="ant-form-item has-label-tip no-margin-field css-1jlm9cy"
4272+
>
4273+
<div
4274+
class="ant-row ant-form-item-row"
4275+
>
4276+
<div
4277+
class="ant-col ant-col-11 ant-form-item-label ant-form-item-label-left"
4278+
>
4279+
<label
4280+
class="ant-form-item-no-colon"
4281+
for="allowExecuteNonDqlInWorkflow"
4282+
title=""
4283+
>
4284+
<div
4285+
class="label-cont-custom"
4286+
>
4287+
<div>
4288+
通过工单上线执行工作台非DQL类型SQL
4289+
</div>
4290+
<div
4291+
class="tip-content-box"
4292+
>
4293+
开启后,允许通过工单上线执行工作台非DQL类型的SQL语句
4294+
</div>
4295+
</div>
4296+
</label>
4297+
</div>
4298+
<div
4299+
class="ant-col ant-col-11 ant-col-push-2 ant-form-item-control"
4300+
>
4301+
<div
4302+
class="ant-form-item-control-input"
4303+
>
4304+
<div
4305+
class="ant-form-item-control-input-content"
4306+
>
4307+
<button
4308+
aria-checked="false"
4309+
class="ant-switch basic-switch-wrapper css-g6dhbn"
4310+
id="allowExecuteNonDqlInWorkflow"
4311+
role="switch"
4312+
type="button"
4313+
>
4314+
<div
4315+
class="ant-switch-handle"
4316+
/>
4317+
<span
4318+
class="ant-switch-inner"
4319+
>
4320+
<span
4321+
class="ant-switch-inner-checked"
4322+
/>
4323+
<span
4324+
class="ant-switch-inner-unchecked"
4325+
/>
4326+
</span>
4327+
</button>
4328+
</div>
4329+
</div>
4330+
</div>
4331+
</div>
4332+
</div>
42704333
</div>
42714334
</div>
42724335
</div>

packages/base/src/page/DataSource/components/Form/index.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ describe('page/DataSource/DataSourceForm', () => {
182182
);
183183
expect(getBySelector('#workbenchTemplateName')).toBeInTheDocument();
184184
expect(allowQueryLevel).toBeInTheDocument();
185+
expect(
186+
getBySelector('#allowExecuteNonDqlInWorkflow', baseElement)
187+
).toBeInTheDocument();
185188
fireEvent.mouseDown(allowQueryLevel);
186189
await act(async () => jest.advanceTimersByTime(300));
187190
expect(baseElement).toMatchSnapshot();

packages/base/src/page/DataSource/components/Form/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ const DataSourceForm: React.FC<IDataSourceFormProps> = (props) => {
102102
'dataExportRuleTemplateName',
103103
'dataExportRuleTemplateId',
104104
'workbenchTemplateName',
105-
'workbenchTemplateId'
105+
'workbenchTemplateId',
106+
'allowExecuteNonDqlInWorkflow'
106107
]);
107108
// #endif
108109
// #if [sqle && ee]
@@ -150,14 +151,18 @@ const DataSourceForm: React.FC<IDataSourceFormProps> = (props) => {
150151
const changeAuditEnabled = (check: boolean) => {
151152
if (!check) {
152153
props.form.setFieldsValue({
153-
allowQueryWhenLessThanAuditLevel: undefined
154+
allowQueryWhenLessThanAuditLevel: undefined,
155+
allowExecuteNonDqlInWorkflow: undefined
154156
});
155157
} else {
156158
if (props.defaultData) {
157159
props.form.setFieldsValue({
158160
allowQueryWhenLessThanAuditLevel:
159161
props.defaultData.sqle_config?.sql_query_config
160-
?.allow_query_when_less_than_audit_level
162+
?.allow_query_when_less_than_audit_level,
163+
allowExecuteNonDqlInWorkflow:
164+
!!props.defaultData.sqle_config?.sql_query_config
165+
?.workflow_exec_enabled
161166
});
162167
}
163168
}
@@ -205,6 +210,9 @@ const DataSourceForm: React.FC<IDataSourceFormProps> = (props) => {
205210
allowQueryWhenLessThanAuditLevel:
206211
props.defaultData.sqle_config?.sql_query_config
207212
?.allow_query_when_less_than_audit_level,
213+
allowExecuteNonDqlInWorkflow:
214+
!!props.defaultData.sqle_config?.sql_query_config
215+
?.workflow_exec_enabled,
208216
// #endif
209217
needUpdatePassword: false,
210218
environmentTagId: props.defaultData.environment_tag?.uid ?? '',

packages/base/src/page/DataSource/components/Form/index.type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type DataSourceFormField = {
2525
needAuditForSqlQuery?: boolean;
2626
workbenchTemplateId?: string;
2727
workbenchTemplateName?: string;
28+
allowExecuteNonDqlInWorkflow?: boolean;
2829
dataExportRuleTemplateId?: string;
2930
dataExportRuleTemplateName?: string;
3031
params?: BackendFormValues;

0 commit comments

Comments
 (0)