Unverified Commit e5b86bef authored by Zzm0809's avatar Zzm0809 Committed by GitHub

improve web finish button type to submit && modify layout (#2630)

* improve-web-finish-buttontype * Spotless Apply * fix udf bug * Spotless Apply * improve-web-finish-buttontype * Spotless Apply * modify ant-notification top padding * fix datasource bug * Spotless Apply * modify alert layout * Spotless Apply * fix git sort * Spotless Apply * fix i18n * fix i18n file --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent 3a9bf5cc
......@@ -160,23 +160,23 @@ daemon.task.not.support=threaded task types are notsupported
sys.flink.settings.useRestAPI=Use Rest API
sys.flink.settings.useRestAPI.note=Whether to use RestAPI when operating and maintaining Flink tasks
sys.flink.settings.sqlSeparator=SQL Separator
sys.flink.settings.sqlSeparator.note=SQL Separator
sys.flink.settings.sqlSeparator.note=please note: The default delimiter is ';', if your SQL contains ';', please modify this configuration to other characters, for example: ';\\n', please ignore the single quotes!!!!
sys.flink.settings.jobIdWait=Job submission waiting time
sys.flink.settings.jobIdWait.note=Maximum waiting time (seconds) for obtaining Job ID when submitting Application or PerJob tasks
sys.maven.settings.settingsFilePath=Maven configuration file path
sys.maven.settings.settingsFilePath.note=Maven configuration file path, eg
sys.maven.settings.settingsFilePath.note=Maven configuration file path, eg: /opt/maven-3.9.2/conf/settings.xml, please note: By default, the MAVEN_HOME environment variables of the host will be obtained, so there is no need to fill in here. If there is no configuration, please fill in the absolute path.
sys.maven.settings.repository=Maven warehouse address
sys.maven.settings.repository.note=Maven warehouse address
sys.maven.settings.repositoryUser=Maven warehouse user name
sys.maven.settings.repositoryUser.note=Maven private server authentication user name
sys.maven.settings.repositoryUser.note=Maven private server authentication user name, if you need to configure Maven private server warehouse authentication information, please fill in this
sys.maven.settings.repositoryPassword=Maven warehouse password
sys.maven.settings.repositoryPassword.note=Maven private server authentication password, please note
sys.maven.settings.repositoryPassword.note=Maven private server authentication password, if you need to configure Maven private server warehouse authentication information, please fill in this item
sys.env.settings.pythonHome=Python Env variables
sys.env.settings.pythonHome.note=Python Env variables
sys.env.settings.pythonHome.note=Python environment variables, used to submit Python tasks and build Python Udf
sys.env.settings.dinkyAddr=Dinky Address
sys.env.settings.dinkyAddr.note=The address must be the same as the address configured in the Dinky Application background url
sys.dolphinscheduler.settings.enable=Whether to enable DolphinScheduler
sys.dolphinscheduler.settings.enable.note=Whether to enable DolphinScheduler, the relevant functions of DolphinScheduler can only be used after it is enabled, please ensure that the relevant configuration of DolphinScheduler is correct
sys.dolphinscheduler.settings.enable.note=Whether to enable DolphinScheduler. Only after enabling it can you use the related functions of DolphinScheduler. Please fill in the following configuration items first, and then enable this configuration after completion. Also: Please ensure that the related configurations of DolphinScheduler are correct.
sys.dolphinscheduler.settings.url=DolphinScheduler address
sys.dolphinscheduler.settings.url.note=The address must be consistent with the address configured in the DolphinScheduler background, eg: http://127.0.0.1:12345/dolphinscheduler
sys.dolphinscheduler.settings.token=DolphinScheduler Token
......
......@@ -46,6 +46,8 @@ export const PopconfirmDeleteBtn: React.FC<PopconfirmProps> = (props) => {
{...options}
title={l('button.delete')}
key={'DeleteIcon'}
htmlType={'submit'}
autoFocus
icon={<DangerDeleteIcon />}
/>
</Popconfirm>
......
......@@ -157,6 +157,68 @@ export const EmailSvg = (props: any) => {
);
};
export const AliYunSmsSvg = (props: any) => {
const size = props.size || defaultSvgSize;
return (
<>
<Icon
style={style}
component={() => (
<svg
className='icon'
viewBox='0 0 1024 1024'
version='1.1'
xmlns='http://www.w3.org/2000/svg'
width={size}
height={size}
>
<path d='M512 0A512 512 0 1 1 0 512 512 512 0 0 1 512 0z' fill='#FF6A00'></path>
<path
d='M298.141538 615.581538a30.72 30.72 0 0 1-24.418461-29.735384v-163.052308A31.901538 31.901538 0 0 1 298.141538 393.846154l151.236924-32.689231 16.147692-64.984615H289.476923A111.458462 111.458462 0 0 0 177.230769 406.252308v193.378461a113.033846 113.033846 0 0 0 112.246154 112.246154h176.049231l-15.950769-64.590769zM738.658462 295.384615h-177.23077l16.147693 64.984616L728.615385 393.846154a30.72 30.72 0 0 1 24.418461 29.538461v163.249231A31.704615 31.704615 0 0 1 728.615385 615.581538l-151.63077 32.886154-16.147692 64.984616h177.230769a112.443077 112.443077 0 0 0 112.836923-112.049231v-194.56a113.033846 113.033846 0 0 0-112.246153-111.458462z'
fill='#FFFFFF'
></path>
<path d='M449.378462 495.852308h129.378461V512h-129.378461z' fill='#FFFFFF'></path>
</svg>
)}
/>
</>
);
};
export const TencentSmsSvg = (props: any) => {
const size = props.size || defaultSvgSize;
return (
<>
<Icon
style={style}
component={() => (
<svg
className='icon'
viewBox='0 0 1024 1024'
version='1.1'
xmlns='http://www.w3.org/2000/svg'
width={size}
height={size}
>
<path
d='M515.12132 140c143.23 0 264.603 91.954 305.177 218.55-15.114-1.86-30.46-1.976-45.69-0.698-18.601 1.744-36.854 5.697-54.641 11.625C686.48532 291.94 607.31332 237.65 515.00432 237.65c-110.096 0-201.475 77.306-218.914 178.792-32.32-6.626-65.453-8.137-98.238-4.185C217.84932 258.808 352.24232 140 515.12132 140z'
fill='#006DFE'
></path>
<path
d='M236.68232 410.514c59.757 0 114.398 22.087 156.135 58.59 17.671 15.461 49.642 43.477 95.913 84.281l-8.138-7.207-67.662 66.727-59.757-59.636c-37.551-37.549-72.545-52.545-116.607-52.545-81.032 0-146.718 65.565-146.718 146.591 0 81.026 65.686 146.591 146.718 146.591 11.742 0 32.204 0.814 61.617 2.558l-99.284 84.63C69.73632 859.936-17.92268 738.222 3.12032 609.185c18.718-114.39 117.537-198.439 233.562-198.671z'
fill='#00CDD8'
></path>
<path
d='M693.34432 429.346c120.443-51.034 259.604 5.115 310.758 125.434 51.153 120.319-5.116 259.354-125.559 310.388-16.857 7.09-41.97 17.553-69.29 17.786-79.172 0.697-268.09 0.93-566.99 1.046h-46.968C340.85032 744.965 486.17132 605.814 631.26132 466.43c20.113-19.298 45.225-29.876 62.082-37.084z m46.038 88.35c-10.114 4.301-25.344 10.695-37.435 22.32-33.134 31.969-120.792 115.901-262.976 251.914h58.71c162.762 0 266.58-0.233 311.572-0.581 16.509-0.117 31.622-6.394 41.853-10.812 72.661-30.806 106.609-114.622 75.684-187.162-30.808-72.656-114.747-106.485-187.408-75.679z'
fill='#00A2FF'
></path>
</svg>
)}
/>
</>
);
};
export const SmsSvg = (props: any) => {
const size = props.size || defaultSvgSize;
......
......@@ -88,7 +88,7 @@ const ErrorShowModal = (props: ShowModalProps) => {
title={title}
closable={closable}
footer={
<Button type='primary' onClick={() => setShowModal(false)}>
<Button type='primary' htmlType={'submit'} autoFocus onClick={() => setShowModal(false)}>
{l('global.notification.iknow')}
</Button>
}
......
......@@ -535,6 +535,7 @@ h5 {
padding: 4px 4px 4px 6px;
white-space: nowrap;
}
.butterfly-lineage-dag .table-node .field.hover-chain {
color: #fff;
transition: all 0.5s ease-in-out;
......@@ -550,6 +551,7 @@ h5 {
height: 100%;
max-height: 4vh;
margin: 0 20px;
.operator-item {
margin-left: 15px;
}
......@@ -582,15 +584,18 @@ h5 {
right: 0;
background: #0366d6;
}
// ==================== lineage style end ====================
.card-list-item-wrapper {
display: flex;
}
.card-list-item {
width: 100%;
margin: 0;
}
.card-list-item {
transition: 0.3s;
}
......@@ -678,4 +683,9 @@ span .mtkb {
.DragLayer.vertical {
cursor: col-resize;
}
// ============================= layout split pane style end =============================
.ant-notification-notice-wrapper {
top: 80px !important;
}
......@@ -84,6 +84,10 @@ const RoleModalForm: React.FC<RoleModalProps> = (props) => {
title={values.id ? l('role.update') : l('role.create')}
open={modalVisible}
onCancel={() => handleCancel()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => submitForm()}
>
<RoleProForm form={form} values={values} />
......
......@@ -101,6 +101,10 @@ export const PermissionsModal: React.FC<RolePermissionsFormProps> = (props) => {
title={values.id ? l('rowPermissions.update') : l('rowPermissions.create')}
open={modalVisible}
onOk={() => submitForm()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onCancel={() => handleCancel()}
>
<PermissionsForm form={form} values={values} roles={roleList} />
......
......@@ -81,6 +81,10 @@ const TenantModalForm: React.FC<TenantModalFormProps> = (props) => {
title={values.id ? l('tenant.update') : l('tenant.create')}
open={modalVisible}
onOk={() => submitForm()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onCancel={() => handleCancel()}
>
<TenantForm values={values} form={form} />
......
......@@ -48,6 +48,10 @@ const TenantModalTransfer: React.FC<TableTransferFromProps> = (props) => {
maskClosable={false}
width={'75%'}
onCancel={() => onCancel()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => handleSubmit(targetKeys)}
>
<TenantTransfer tenant={tenant} onChange={(value) => handleValueChange(value)} />
......
......@@ -134,7 +134,14 @@ const TokenModalForm: React.FC<TokenModalFormProps & connect> = (props) => {
<Button key={'cancel'} onClick={() => handleCancel()}>
{l('button.cancel')}
</Button>,
<Button key={'finish'} loading={loading} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={loading}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -85,6 +85,10 @@ const PasswordModal: React.FC<PasswordModalFormProps> = (props) => {
title={l('button.changePassword')}
open={modalVisible}
onCancel={() => handleCancel()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => submitForm()}
>
<PasswordForm values={values as UserBaseInfo.User} form={form} />
......
......@@ -52,6 +52,10 @@ const RoleModalTransfer = (props: RoleTransferFromProps) => {
maskClosable={false}
width={'75%'}
onCancel={() => handleCancel()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => handleSubmit(targetKeys)}
>
<RoleTransfer role={user} onChange={(value) => handleValueChange(value)} />
......
......@@ -72,8 +72,8 @@ const UserModalForm: React.FC<UserModalFormProps> = (props) => {
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
await handleSubmit({ ...values, ...fieldsValue });
await handleCancel();
handleSubmit({ ...values, ...fieldsValue });
handleCancel();
};
return (
......@@ -82,6 +82,10 @@ const UserModalForm: React.FC<UserModalFormProps> = (props) => {
title={values.id ? l('user.update') : l('user.create')}
open={modalVisible}
onCancel={() => handleCancel()}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => submitForm()}
>
<UserForm values={values} form={form} />
......
......@@ -44,6 +44,8 @@ export const JobDetailInfoModel: React.FC<JobDetailInfoModelProps> = (props) =>
destroyOnClose
maskClosable={false}
okButtonProps={{
htmlType: 'submit',
autoFocus: true,
style: {
display: 'none'
}
......
......@@ -33,7 +33,7 @@ const JobRunningModal: React.FC<JobRunningModalProps> = (props) => {
return (
<Modal
title={`Job ${value?.jobName} is running`}
title={value?.taskId ? `Job ${value?.jobName} is running` : 'No job running'}
open={visible}
onOk={onOk}
width={'50%'}
......@@ -47,7 +47,15 @@ const JobRunningModal: React.FC<JobRunningModalProps> = (props) => {
<Progress
showInfo
strokeLinecap={'round'}
percent={100}
percent={
value?.taskId
? value?.jobState === 'RUNNING'
? 50
: value?.jobState === 'FINISHED'
? 100
: 0
: 0
}
status='active'
strokeColor={{ from: '#108ee9', to: '#87d068' }}
/>
......
......@@ -65,7 +65,7 @@ const FolderModal: React.FC<JobModalProps> = (props) => {
*/
const submitForm = async (formData: Catalogue) => {
await form.validateFields();
const newValue = await form.getFieldsValue();
const newValue = form.getFieldsValue();
onSubmit({ ...values, name: newValue.name } as Catalogue);
};
......@@ -82,6 +82,10 @@ const FolderModal: React.FC<JobModalProps> = (props) => {
modalProps={{
destroyOnClose: true,
maskClosable: false,
okButtonProps: {
htmlType: 'submit',
autoFocus: true
},
onCancel: handleCancel
}}
onFinish={async (values) => submitForm(values)}
......
......@@ -27,6 +27,7 @@ import { l } from '@/utils/intl';
import { ModalForm, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { ProFormCascader } from '@ant-design/pro-form/lib';
import { Form } from 'antd';
import { DefaultOptionType } from 'antd/es/select';
import React, { useEffect } from 'react';
type JobModalProps = {
......@@ -39,7 +40,7 @@ type JobModalProps = {
const JobModal: React.FC<JobModalProps> = (props) => {
const { onCancel, onSubmit, modalVisible, title, values } = props;
const [jobType, setJobType] = React.useState<string>(values.type || 'FlinkSql');
const [udfTemplate, setUdfTemplate] = React.useState<any[]>([]);
const [udfTemplate, setUdfTemplate] = React.useState<DefaultOptionType[]>([]);
const [form] = Form.useForm<Catalogue>();
/**
......@@ -60,34 +61,43 @@ const JobModal: React.FC<JobModalProps> = (props) => {
form.setFieldsValue(newValues);
}, [open, values, form]);
const queryUdfTemplate = async () => {
await queryDataByParams(API_CONSTANTS.UDF_TEMPLATE_TREE).then((res) => {
res.map((item: any) => {
if (item.value === jobType) res = item.children.map((item: any) => item);
const queryUdfTemplate = () => {
queryDataByParams<DefaultOptionType[]>(API_CONSTANTS.UDF_TEMPLATE_TREE).then((res) => {
const newRes: DefaultOptionType[] = [];
res?.forEach((item: any) => {
if (item.value === jobType) {
item.children.forEach((item: any) => {
newRes.push(item);
});
}
});
setUdfTemplate(res);
setUdfTemplate(newRes);
});
};
useEffect(() => {
if (isUDF(jobType)) queryUdfTemplate();
if (isUDF(jobType)) {
queryUdfTemplate();
}
}, [jobType, form]);
/**
* handle cancel
*/
const handleCancel = () => {
onCancel();
formContext.resetForm();
onCancel();
};
/**
* form values change
* @param changedValues
* @param allValues
*/
const onValuesChange = (changedValues: any, allValues: any) => {
if (allValues.type) setJobType(allValues.type);
const onValuesChange = (changedValues: any) => {
if (changedValues.type) {
setJobType(changedValues.type);
form.resetFields(['configJson']); // 如果是UDF,重置configJson, 否则 模版id 会有渲染问题
}
};
/**
......@@ -179,6 +189,10 @@ const JobModal: React.FC<JobModalProps> = (props) => {
modalProps={{
destroyOnClose: true,
maskClosable: false,
okButtonProps: {
htmlType: 'submit',
autoFocus: true
},
onCancel: handleCancel
}}
onFinish={async (values) => submitForm(values)}
......
......@@ -162,7 +162,7 @@ export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[]) => {
key: -1
}
];
for (const item of alertGroups) {
alertGroups?.forEach((item) => {
alertGroupOptions.push({
label: (
<TagAlignLeft>
......@@ -173,7 +173,7 @@ export const buildAlertGroupOptions = (alertGroups: Alert.AlertGroup[]) => {
value: item.id,
key: item.id
});
}
});
return alertGroupOptions;
};
......
......@@ -78,6 +78,12 @@ const MetricsConfigForm = (props: MetricsConfigFormProps) => {
layout={'horizontal'}
title={l('devops.jobinfo.metrics.configMetrics')}
trigger={<Button type='primary'>{l('devops.jobinfo.metrics.configMetrics')}</Button>}
modalProps={{
okButtonProps: {
htmlType: 'submit',
autoFocus: true
}
}}
onFinish={async () => await saveJobMetrics()}
>
<Tabs items={itemTabs} />
......
......@@ -128,7 +128,7 @@ const JobVersionTab = (props: JobProps) => {
return (
<>
<ProCard size={'small'} bodyStyle={{ height: parent.innerHeight - 180, overflow: 'auto' }}>
<ProCard size={'small'} bodyStyle={{ height: 'calc(100vh - 180px)', overflow: 'auto' }}>
{renderVersionList()}
</ProCard>
</>
......
......@@ -61,6 +61,8 @@ const ChooseModal: React.FC<ChooseModalProps> = (props) => {
okText={l('button.confirm')}
okButtonProps={{
disabled: check,
htmlType: 'submit',
autoFocus: true,
loading: submitting
}}
>
......
......@@ -113,7 +113,13 @@ const AlertGroupForm: React.FC<AlertGroupFormProps & connect> = (props) => {
<Button key={'GroupCancel'} onClick={() => handleModalVisible(false)}>
{l('button.cancel')}
</Button>,
<Button key={'GroupFinish'} type='primary' onClick={() => submitForm()}>
<Button
key={'GroupFinish'}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -94,16 +94,6 @@ export const renderCommonSmsForm = (smsType: string) => {
rules={[{ required: true, message: l('rc.ai.templateIdPleaseHolder') }]}
placeholder={l('rc.ai.templateIdPleaseHolder')}
/>
<ProFormText
name={['params', 'configId']}
label={l('rc.ai.configId')}
width={'md'}
disabled
hidden
initialValue={randomStr(32)}
rules={[{ required: true, message: l('rc.ai.configIdPleaseHolder') }]}
placeholder={l('rc.ai.configIdPleaseHolder')}
/>
<ProFormDigit
name={['params', 'weight']}
label={l('rc.ai.weight')}
......@@ -128,6 +118,16 @@ export const renderCommonSmsForm = (smsType: string) => {
rules={[{ required: true, message: l('rc.ai.maxRetriesPleaseHolder') }]}
placeholder={l('rc.ai.maxRetriesPleaseHolder')}
/>
<ProFormText
name={['params', 'configId']}
label={l('rc.ai.configId')}
width={'md'}
disabled
hidden
initialValue={randomStr(32)}
rules={[{ required: true, message: l('rc.ai.configIdPleaseHolder') }]}
placeholder={l('rc.ai.configIdPleaseHolder')}
/>
</>
);
};
......@@ -140,14 +140,14 @@ export const renderAlibabaSmsForm = (smsType: string) => {
<ProFormText
name={['params', 'requestUrl']}
label={l('rc.ai.requestUrl')}
width={'lg'}
width={'md'}
rules={[{ required: true, message: l('rc.ai.requestUrlPleaseHolder') }]}
placeholder={l('rc.ai.requestUrlPleaseHolder')}
/>
<ProFormSelect
name={['params', 'regionId']}
label={l('rc.ai.regionId')}
width={'md'}
width={'sm'}
options={AliYunArea}
rules={[{ required: true, message: l('rc.ai.regionIdPleaseHolder') }]}
placeholder={l('rc.ai.regionIdPleaseHolder')}
......@@ -171,7 +171,6 @@ export const renderAlibabaSmsForm = (smsType: string) => {
initialValue={'SendSms'}
placeholder={l('rc.ai.actionPleaseHolder')}
/>
<ProFormText
name={['params', 'version']}
label={l('rc.ai.version')}
......
......@@ -103,7 +103,14 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
<Button key={'AlertTest'} type='primary' loading={loading} onClick={testSend}>
{l('button.test')}
</Button>,
<Button key={'AlertFinish'} type='primary' loading={loading} onClick={submit}>
<Button
key={'AlertFinish'}
type='primary'
htmlType={'submit'}
autoFocus
loading={loading}
onClick={submit}
>
{l('button.finish')}
</Button>
];
......
......@@ -17,29 +17,59 @@
*
*/
import {
AliYunSmsSvg,
DingTalkSvg,
EmailSvg,
FeiShuSvg,
SmsSvg,
TencentSmsSvg,
WeChatSvg
} from '@/components/Icons/AlertIcon';
import { ALERT_TYPE } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import { Space } from 'antd';
import { DefaultOptionType } from 'rc-select/es/Select';
export const ALERT_TYPE_LIST_OPTIONS: DefaultOptionType[] = [
{
label: l('rc.ai.dingTalk'),
label: (
<Space align={'baseline'} size={5}>
<DingTalkSvg size={16} /> {l('rc.ai.dingTalk')}
</Space>
),
value: ALERT_TYPE.DINGTALK
},
{
label: l('rc.ai.wechat'),
label: (
<Space align={'baseline'} size={5}>
<WeChatSvg size={16} /> {l('rc.ai.wechat')}
</Space>
),
value: ALERT_TYPE.WECHAT
},
{
label: l('rc.ai.feishu'),
label: (
<Space align={'baseline'} size={5}>
<FeiShuSvg size={16} /> {l('rc.ai.feishu')}
</Space>
),
value: ALERT_TYPE.FEISHU
},
{
label: l('rc.ai.email'),
label: (
<Space align={'baseline'} size={5}>
<EmailSvg size={16} /> {l('rc.ai.email')}
</Space>
),
value: ALERT_TYPE.EMAIL
},
{
label: l('rc.ai.sms'),
label: (
<Space align={'baseline'} size={5}>
<SmsSvg size={16} /> {l('rc.ai.sms')}
</Space>
),
value: ALERT_TYPE.SMS
}
];
......@@ -60,12 +90,22 @@ export enum SMS_TYPE {
export const MANU_FRACTURES = [
{
label: l('rc.ai.mf.alibaba'),
value: SMS_TYPE.ALIBABA
label: (
<Space align={'baseline'} size={5}>
<AliYunSmsSvg size={16} /> {l('rc.ai.mf.alibaba')}
</Space>
),
value: SMS_TYPE.ALIBABA,
key: l('rc.ai.mf.alibaba')
},
{
label: l('rc.ai.mf.tencent'),
value: SMS_TYPE.TENCENT
label: (
<Space align={'baseline'} size={5}>
<TencentSmsSvg size={16} /> {l('rc.ai.mf.tencent')}
</Space>
),
value: SMS_TYPE.TENCENT,
key: l('rc.ai.mf.tencent')
}
// todo: 以下短信暂不实现
// {
......
......@@ -54,5 +54,5 @@ export const getAlertIcon = (type: string, size?: number) => {
};
export const getSmsType = (type: string) => {
return MANU_FRACTURES.find((item) => item.value === type)?.label;
return MANU_FRACTURES.find((item) => item.value === type)?.key || '';
};
......@@ -93,7 +93,7 @@ const AlertTemplateForm: React.FC<AlertTemplateFormProps> = (props) => {
<CodeEdit
{...CodeEditProps}
code={codeValue}
onChange={(value) => setCodeValue(value ?? '')}
onChange={(value: string) => setCodeValue(value ?? '')}
/>
</ProForm.Item>
</>
......@@ -108,7 +108,13 @@ const AlertTemplateForm: React.FC<AlertTemplateFormProps> = (props) => {
<Button key={'AlertTemplateCancel'} onClick={() => handleModalVisible(false)}>
{l('button.cancel')}
</Button>,
<Button key={'AlertTemplateFinish'} type='primary' onClick={() => submitForm()}>
<Button
key={'AlertTemplateFinish'}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -30,17 +30,15 @@ import { l } from '@/utils/intl';
import { useRequest } from '@@/exports';
import { PlusOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-layout';
import { Button, Card, List, Modal, Typography } from 'antd';
import { Button, Card, List, Modal } from 'antd';
import { useState } from 'react';
import Markdown from 'react-markdown';
const { Paragraph } = Typography;
export default () => {
const [alertTemplateState, setAlertTemplateState] =
useState<AlertTemplateState>(InitAlertTemplateState);
const { data, loading, run } = useRequest({ url: API_CONSTANTS.ALERT_TEMPLATE });
const nullData: Partial<Alert.AlertTemplate> = {};
/**
* edit click callback
......@@ -151,11 +149,24 @@ export default () => {
return (
<PageContainer>
<Button
style={{ width: '100%', margin: '10px 0' }}
type={'dashed'}
icon={<PlusOutlined />}
onClick={() =>
setAlertTemplateState((prevState) => ({
...prevState,
addedOpen: true
}))
}
>
{l('button.create')}
</Button>
<List<Alert.AlertTemplate>
rowKey='id'
loading={loading}
grid={{ gutter: 16, xs: 1, sm: 2, md: 3, lg: 3, xl: 4, xxl: 4 }}
dataSource={[nullData, ...(data ?? [])]}
dataSource={data ?? []}
renderItem={(item) => renderTemplateCard(item)}
/>
......
......@@ -84,7 +84,14 @@ const InstanceModal: React.FC<ConfigurationModalProps> = (props) => {
<Button key={'cancel'} onClick={() => handleCancel()}>
{l('button.cancel')}
</Button>,
<Button key={'finish'} loading={submitting} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={submitting}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -85,7 +85,14 @@ const InstanceModal: React.FC<InstanceModalProps> = (props) => {
<Button key={'cancel'} onClick={() => handleCancel()}>
{l('button.cancel')}
</Button>,
<Button key={'finish'} loading={submitting} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={submitting}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -30,11 +30,13 @@ import { AutoComplete, Form } from 'antd';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import TextArea from 'antd/es/input/TextArea';
import { Values } from 'async-validator';
import React, { useState } from 'react';
import React from 'react';
type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>;
form: FormInstance<Values>;
dbType: string;
excludeFormItem: boolean;
flinkConfigChange: (value: string) => void;
flinkTemplateChange: (value: string) => void;
};
......@@ -47,19 +49,7 @@ const CodeEditProps = {
};
const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
const { values, form, flinkTemplateChange, flinkConfigChange } = props;
const [excludeFormItem, setExcludeFormItem] = useState<boolean>(false);
const [dbType, setDbType] = useState<string>(values.type ?? 'MySQL');
const handleTypeChange = (value: any) => {
if (value.type) setDbType(value.type);
if (value.type === 'Hive' || value.type === 'Presto') {
setExcludeFormItem(true);
} else {
setExcludeFormItem(false);
}
};
const { values, form, dbType, excludeFormItem, flinkTemplateChange, flinkConfigChange } = props;
const renderDataSourceForm = () => {
return (
......
......@@ -23,7 +23,7 @@ import { DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { ModalForm } from '@ant-design/pro-components';
import { Button, Form } from 'antd';
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
type DataSourceModalProps = {
visible: boolean;
......@@ -40,6 +40,8 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
const [flinkTemplateValue, setFlinkTemplateValue] = React.useState<string>(
values.flinkTemplate || ''
);
const [dbType, setDbType] = useState<string>(values.type ?? 'MySQL');
const [excludeFormItem, setExcludeFormItem] = useState<boolean>(false);
/**
* init form
......@@ -122,12 +124,28 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
<Button key={'test'} loading={submitting} type='primary' onClick={handleTestConnect}>
{l('button.test')}
</Button>,
<Button key={'finish'} loading={submitting} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={submitting}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
};
const handleTypeChange = (value: any) => {
if (value.type) setDbType(value.type);
if (value.type === 'Hive' || value.type === 'Presto') {
setExcludeFormItem(true);
} else {
setExcludeFormItem(false);
}
};
/**
* render
*/
......@@ -139,6 +157,7 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
modalProps={{ onCancel: handleCancel }}
title={values.id ? l('rc.ds.modify') : l('rc.ds.create')}
form={form}
onValuesChange={handleTypeChange}
submitter={{ render: () => [...renderFooter()] }}
initialValues={{
...values,
......@@ -148,6 +167,8 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
>
<DataSourceProForm
values={values}
excludeFormItem={excludeFormItem}
dbType={dbType}
form={form}
flinkConfigChange={handleFlinkConfigValueChange}
flinkTemplateChange={handleFlinkTemplateValueChange}
......
......@@ -72,6 +72,10 @@ const DocumentModalForm: React.FC<DocumentModalProps> = (props) => {
{...NORMAL_MODAL_OPTIONS}
title={values.id ? l('rc.doc.modify') : l('rc.doc.create')}
open={modalVisible}
okButtonProps={{
htmlType: 'submit',
autoFocus: true
}}
onOk={() => submitForm()}
onCancel={() => handleModalVisible()}
>
......
......@@ -153,7 +153,7 @@ const JarList: React.FC<JarListProps> = (props) => {
expandedRowRender: (record) => renderUdf(record)
}}
dragSortKey={'orderLine'}
onDragSortEnd={handleDragSortEnd}
onDragSortEnd={(beforeIndex, afterIndex, newDataSource) => handleDragSortEnd(newDataSource)}
/>
);
};
......
......@@ -214,6 +214,8 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
key={'finish'}
type={'primary'}
hidden={showLog}
htmlType={'submit'}
autoFocus
disabled={steps[currentStep - 1]?.status === 'error' && percent !== 99}
loading={currentStep !== steps.length && percent !== 99}
onClick={() => handleCancel()}
......
......@@ -91,7 +91,14 @@ const ProjectModal: React.FC<ProjectModalProps> = (props) => {
<Button key={'cancel'} onClick={() => handleCancel()}>
{l('button.cancel')}
</Button>,
<Button key={'finish'} loading={submitting} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={submitting}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -304,6 +304,8 @@ const ProjectProTable: React.FC = () => {
<Button
title={l('button.build')}
key={`${record.id}_buildbtn`}
htmlType={'submit'}
autoFocus
icon={<BuildTwoTone />}
/>
</Popconfirm>
......@@ -391,7 +393,7 @@ const ProjectProTable: React.FC = () => {
request={(params, sorter, filter: any) =>
queryList(API_CONSTANTS.GIT_PROJECT, { ...params, sorter, filter })
}
onDragSortEnd={handleDragSortEnd}
onDragSortEnd={(beforeIndex, afterIndex, newDataSource) => handleDragSortEnd(newDataSource)}
/>
{/* added modal form */}
<ProjectModal
......
......@@ -79,6 +79,7 @@ const GlobalVarModal: React.FC<GlobalVarModalProps> = (props) => {
{...NORMAL_MODAL_OPTIONS}
title={values.id ? l('rc.gv.modify') : l('rc.gv.create')}
open={modalVisible}
okButtonProps={{ htmlType: 'submit', autoFocus: true }}
onOk={() => submitForm()}
onCancel={() => handleModalVisible()}
>
......
......@@ -18,7 +18,7 @@
*/
import { FormContextValue } from '@/components/Context/FormContext';
import { Resource } from '@/pages/RegCenter/Resource/components/ResourceOverView';
import { ResourceInfo } from '@/types/RegCenter/data.d';
import { ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { Form } from 'antd';
import React, { useEffect } from 'react';
......@@ -27,8 +27,8 @@ type ResourceModalProps = {
title: string;
visible: boolean;
onClose: () => void;
onOk: (value: Partial<Resource>) => void;
formValues: Partial<Resource>;
onOk: (value: Partial<ResourceInfo>) => void;
formValues: Partial<ResourceInfo>;
};
const ResourceModal: React.FC<ResourceModalProps> = (props) => {
......@@ -70,15 +70,19 @@ const ResourceModal: React.FC<ResourceModalProps> = (props) => {
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
await handleSubmit({ ...formValues, ...fieldsValue });
await handleCancel();
handleSubmit({ ...formValues, ...fieldsValue });
handleCancel();
};
return (
<>
<ModalForm<Resource>
<ModalForm<ResourceInfo>
title={title}
modalProps={{ destroyOnClose: true, onCancel: handleModalVisible }}
modalProps={{
destroyOnClose: true,
onCancel: handleModalVisible,
okButtonProps: { htmlType: 'submit', autoFocus: true }
}}
onFinish={submitForm}
form={form}
open={visible}
......
......@@ -59,7 +59,13 @@ const ResourcesUploadModal: React.FC<ResourcesUploadModalProps> = (props) => {
}
};
return (
<Modal title={l('rc.resource.upload')} onOk={onOk} onCancel={onClose} open={visible}>
<Modal
title={l('rc.resource.upload')}
okButtonProps={{ htmlType: 'submit', autoFocus: true }}
onOk={onOk}
onCancel={onClose}
open={visible}
>
<Dragger {...uploadProps}>
<p className='ant-upload-drag-icon'>
<InboxOutlined />
......
......@@ -46,6 +46,7 @@ const UDFRegisterModal: React.FC<UDFRegisterModalProps> = (props) => {
destroyOnClose
closable
maskClosable={false}
okButtonProps={{ htmlType: 'submit', autoFocus: true }}
onCancel={() => openChange(false)}
onOk={() => onOk()}
>
......
......@@ -84,7 +84,14 @@ const TemplateModal: React.FC<TemplateModalProps> = (props) => {
<Button key={'cancel'} onClick={() => handleCancel()}>
{l('button.cancel')}
</Button>,
<Button key={'finish'} loading={submitting} type='primary' onClick={() => submitForm()}>
<Button
key={'finish'}
loading={submitting}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submitForm()}
>
{l('button.finish')}
</Button>
];
......
......@@ -77,7 +77,13 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
<Button key={'RuleCancel'} onClick={() => handleModalVisible(false)}>
{l('button.cancel')}
</Button>,
<Button key={'RuleFinish'} type='primary' onClick={() => submit()}>
<Button
key={'RuleFinish'}
type='primary'
htmlType={'submit'}
autoFocus
onClick={() => submit()}
>
{l('button.finish')}
</Button>
];
......
......@@ -37,7 +37,10 @@ export const TestLogin = () => {
width={400}
onFinish={testLogin}
form={form}
modalProps={{ onCancel: () => form.resetFields() }}
modalProps={{
onCancel: () => form.resetFields(),
okButtonProps: { htmlType: 'submit', autoFocus: true }
}}
trigger={
<Tag icon={<LoginOutlined />} color='#108ee9'>
{l('sys.ldap.settings.testLogin')}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment