-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: system config ReplayCallback (#498)
Co-authored-by: onePone <[email protected]>
- Loading branch information
Showing
9 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/arex/src/panes/SystemSetting/CallbackUrl/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { getLocalStorage, useTranslation } from '@arextest/arex-core'; | ||
import { useRequest } from 'ahooks'; | ||
import { App, Button, Form, FormProps, Input } from 'antd'; | ||
import React, { FC } from 'react'; | ||
|
||
import { EMAIL_KEY } from '@/constant'; | ||
import { SystemService } from '@/services'; | ||
import { SystemConfig } from '@/services/SystemService'; | ||
|
||
const CallbackUrl: FC = () => { | ||
const { message } = App.useApp(); | ||
const { t } = useTranslation(); | ||
const email = getLocalStorage<string>(EMAIL_KEY) as string; | ||
const [form] = Form.useForm<SystemConfig>(); | ||
|
||
useRequest(SystemService.getSystemConfig, { | ||
onSuccess(res) { | ||
if (res) { | ||
form.setFieldsValue({ | ||
operator: email, | ||
callbackUrl: res.callbackUrl, | ||
}); | ||
} | ||
}, | ||
}); | ||
|
||
const { run: saveDesensitization } = useRequest(SystemService.saveSystemConfig, { | ||
manual: true, | ||
onSuccess(success) { | ||
success | ||
? message.success(t('message.updateSuccess')) | ||
: message.error(t('message.updateFailed')); | ||
}, | ||
}); | ||
|
||
const handleUploadJar: FormProps<SystemConfig>['onFinish'] = (value) => { | ||
console.log(value); | ||
|
||
if (value.callbackUrl) { | ||
saveDesensitization({ | ||
systemConfig: { | ||
operator: value.operator, | ||
callbackUrl: value.callbackUrl, | ||
}, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Form<SystemConfig> | ||
name='system-setting-callbackUrl-form' | ||
form={form} | ||
labelCol={{ span: 4 }} | ||
wrapperCol={{ span: 20 }} | ||
onFinish={handleUploadJar} | ||
> | ||
<Form.Item hidden name='operator'> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t('systemSetting.replayCallbackUrl', { ns: 'components' })} | ||
name='callbackUrl' | ||
> | ||
<Input allowClear style={{ width: '400px' }} /> | ||
</Form.Item> | ||
|
||
{/* form submit button */} | ||
<Form.Item wrapperCol={{ span: 14, offset: 4 }}> | ||
<Button type='primary' htmlType='submit'> | ||
Save | ||
</Button> | ||
</Form.Item> | ||
</Form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CallbackUrl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { request } from '@/utils'; | ||
|
||
import { SystemConfig } from './saveSystemConfig'; | ||
|
||
export async function getSystemConfig() { | ||
const res = await request.get<SystemConfig>(`/report/system/config/list`); | ||
return res.body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './getSystemConfig'; | ||
export * from './saveSystemConfig'; |
11 changes: 11 additions & 0 deletions
11
packages/arex/src/services/SystemService/saveSystemConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { request } from '@/utils'; | ||
|
||
export interface SystemConfig { | ||
operator: string; | ||
callbackUrl: string; | ||
} | ||
|
||
export async function saveSystemConfig(params: { systemConfig: SystemConfig }) { | ||
const res = await request.post<boolean>(`/report/system/config/save`, params); | ||
return res.body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters