You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/12/15 06:08:56 UTC
(incubator-devlake) branch main updated: refactor(config-ui): use new ui radio to replace old (#6636)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new bf214f99f refactor(config-ui): use new ui radio to replace old (#6636)
bf214f99f is described below
commit bf214f99fe501ec113b6729b882150134dbab8e9
Author: 青湛 <0x...@gmail.com>
AuthorDate: Fri Dec 15 19:08:52 2023 +1300
refactor(config-ui): use new ui radio to replace old (#6636)
---
.../detail/components/sync-policy/index.tsx | 21 ++++++++++++---------
.../components/connection-form/fields/endpoint.tsx | 12 ++++++------
.../register/azure/connection-fields/base-url.tsx | 6 +++---
.../github/connection-fields/authentication.tsx | 12 +++---------
.../register/jira/connection-fields/auth.tsx | 18 +++++++++---------
.../jira/transformation-fields/cross-domain.tsx | 4 ++--
.../jira/transformation-fields/dev-panel.tsx | 15 +++++++--------
.../opsgenie/connection-fields/endpoint.tsx | 12 +++---------
8 files changed, 45 insertions(+), 55 deletions(-)
diff --git a/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx b/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx
index 1ac196e9e..7844dd457 100644
--- a/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx
+++ b/config-ui/src/pages/blueprint/detail/components/sync-policy/index.tsx
@@ -18,8 +18,9 @@
import { useState, useEffect, useMemo } from 'react';
import dayjs from 'dayjs';
-import { Input } from 'antd';
-import { Tag, Checkbox, Radio, RadioGroup } from '@blueprintjs/core';
+import type { RadioChangeEvent } from 'antd';
+import { Radio, Space, Input } from 'antd';
+import { Tag, Checkbox } from '@blueprintjs/core';
import { TimePrecision } from '@blueprintjs/datetime';
import { DateInput2 } from '@blueprintjs/datetime2';
@@ -80,8 +81,8 @@ export const SyncPolicy = ({
const [mintue, hour, day, month, week] = useMemo(() => cronConfig.split(' '), [cronConfig]);
- const handleChangeFrequency = (e: React.FormEvent<HTMLInputElement>) => {
- const value = (e.target as HTMLInputElement).value;
+ const handleChangeFrequency = (e: RadioChangeEvent) => {
+ const value = e.target.value;
setSelectedValue(value);
if (value === 'Manual') {
onChangeIsManual(true);
@@ -140,11 +141,13 @@ export const SyncPolicy = ({
title="Sync Frequency"
description="Blueprints will run on creation and recurringly based on the schedule."
>
- <RadioGroup selectedValue={selectedValue} onChange={handleChangeFrequency}>
- {cronOpts.map(({ label, subLabel }) => (
- <Radio key={label} label={`${label} ${subLabel}`} value={label} />
- ))}
- </RadioGroup>
+ <Radio.Group value={selectedValue} onChange={handleChangeFrequency}>
+ <Space direction="vertical">
+ {cronOpts.map(({ label, subLabel }) => (
+ <Radio key={label} value={label}>{`${label} ${subLabel}`}</Radio>
+ ))}
+ </Space>
+ </Radio.Group>
{selectedValue === 'Custom' && (
<>
<S.Input>
diff --git a/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx b/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
index fc4e8e486..ff9e45782 100644
--- a/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
+++ b/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
@@ -17,8 +17,8 @@
*/
import { useState, useEffect } from 'react';
-import { Input } from 'antd';
-import { RadioGroup, Radio } from '@blueprintjs/core';
+import type { RadioChangeEvent } from 'antd';
+import { Radio, Input } from 'antd';
import { Block } from '@/components';
@@ -57,8 +57,8 @@ export const ConnectionEndpoint = ({
setError(value ? '' : 'endpoint is required');
}, [value]);
- const handleChange = (e: React.FormEvent<HTMLInputElement>) => {
- const version = (e.target as HTMLInputElement).value as VersionType;
+ const handleChange = (e: RadioChangeEvent) => {
+ const version = e.target.value;
if (version === 'cloud') {
setValue(multipleVersions?.cloud ?? '');
}
@@ -77,12 +77,12 @@ export const ConnectionEndpoint = ({
if (multipleVersions) {
return (
<Block title={name} required>
- <RadioGroup inline selectedValue={version} onChange={handleChange}>
+ <Radio.Group value={version} onChange={handleChange}>
<Radio value="cloud">{name} Cloud</Radio>
<Radio value="server" disabled={!multipleVersions.server}>
{name} Server {multipleVersions.server ? multipleVersions.server : '(to be supported)'}
</Radio>
- </RadioGroup>
+ </Radio.Group>
{version === 'cloud' && (
<p style={{ margin: 0 }}>
If you are using {name} Cloud, you do not need to enter the endpoint URL, which is {multipleVersions.cloud}.
diff --git a/config-ui/src/plugins/register/azure/connection-fields/base-url.tsx b/config-ui/src/plugins/register/azure/connection-fields/base-url.tsx
index 11b94b65f..f60859f61 100644
--- a/config-ui/src/plugins/register/azure/connection-fields/base-url.tsx
+++ b/config-ui/src/plugins/register/azure/connection-fields/base-url.tsx
@@ -16,19 +16,19 @@
*
*/
-import { RadioGroup, Radio } from '@blueprintjs/core';
+import { Radio } from 'antd';
import { Block } from '@/components';
export const BaseURL = () => {
return (
<Block title="Azure DevOps Version" required>
- <RadioGroup inline selectedValue="cloud" onChange={() => {}}>
+ <Radio.Group value="cloud" onChange={() => {}}>
<Radio value="cloud">Azure DevOps Cloud</Radio>
<Radio value="server" disabled>
Azure DevOps Server (not supported)
</Radio>
- </RadioGroup>
+ </Radio.Group>
<p style={{ margin: 0 }}>If you are using Azure DevOps Cloud, you do not need to enter the endpoint URL.</p>
</Block>
);
diff --git a/config-ui/src/plugins/register/github/connection-fields/authentication.tsx b/config-ui/src/plugins/register/github/connection-fields/authentication.tsx
index 18e6c654e..5012db76c 100644
--- a/config-ui/src/plugins/register/github/connection-fields/authentication.tsx
+++ b/config-ui/src/plugins/register/github/connection-fields/authentication.tsx
@@ -17,7 +17,7 @@
*/
import { useEffect } from 'react';
-import { RadioGroup, Radio } from '@blueprintjs/core';
+import { Radio } from 'antd';
import { Block } from '@/components';
@@ -34,16 +34,10 @@ export const Authentication = ({ initialValue, value, setValue }: Props) => {
return (
<Block title="Authentication type" required>
- <RadioGroup
- inline
- selectedValue={value || initialValue}
- onChange={(e) => {
- setValue((e.target as any).value);
- }}
- >
+ <Radio.Group value={value || initialValue} onChange={(e) => setValue(e.target.value)}>
<Radio value="AccessToken">Github Access Token</Radio>
<Radio value="AppKey">Github App</Radio>
- </RadioGroup>
+ </Radio.Group>
</Block>
);
};
diff --git a/config-ui/src/plugins/register/jira/connection-fields/auth.tsx b/config-ui/src/plugins/register/jira/connection-fields/auth.tsx
index 2364a7274..572cf0d5e 100644
--- a/config-ui/src/plugins/register/jira/connection-fields/auth.tsx
+++ b/config-ui/src/plugins/register/jira/connection-fields/auth.tsx
@@ -17,8 +17,8 @@
*/
import { useState, useEffect } from 'react';
-import { Input } from 'antd';
-import { RadioGroup, Radio } from '@blueprintjs/core';
+import type { RadioChangeEvent } from 'antd';
+import { Radio, Input } from 'antd';
import { Block, ExternalLink } from '@/components';
import { DOC_URL } from '@/release';
@@ -70,8 +70,8 @@ export const Auth = ({ initialValues, values, setValues, setErrors }: Props) =>
});
}, [values]);
- const handleChangeVersion = (e: React.FormEvent<HTMLInputElement>) => {
- const version = (e.target as HTMLInputElement).value;
+ const handleChangeVersion = (e: RadioChangeEvent) => {
+ const version = e.target.value;
setValues({
endpoint: '',
@@ -90,7 +90,7 @@ export const Auth = ({ initialValues, values, setValues, setErrors }: Props) =>
});
};
- const handleChangeMethod = (e: React.FormEvent<HTMLInputElement>) => {
+ const handleChangeMethod = (e: RadioChangeEvent) => {
setValues({
authMethod: (e.target as HTMLInputElement).value as Method,
username: undefined,
@@ -120,10 +120,10 @@ export const Auth = ({ initialValues, values, setValues, setErrors }: Props) =>
return (
<>
<Block title="Jira Version" required>
- <RadioGroup inline selectedValue={version} onChange={handleChangeVersion}>
+ <Radio.Group value={version} onChange={handleChangeVersion}>
<Radio value="cloud">Jira Cloud</Radio>
<Radio value="server">Jira Server</Radio>
- </RadioGroup>
+ </Radio.Group>
<Block
style={{ marginTop: 8, marginBottom: 0 }}
@@ -169,10 +169,10 @@ export const Auth = ({ initialValues, values, setValues, setErrors }: Props) =>
{version === 'server' && (
<>
<Block title="Authentication Method" required>
- <RadioGroup inline selectedValue={values.authMethod} onChange={handleChangeMethod}>
+ <Radio.Group value={values.authMethod} onChange={handleChangeMethod}>
<Radio value="BasicAuth">Basic Authentication</Radio>
<Radio value="AccessToken">Using Personal Access Token</Radio>
- </RadioGroup>
+ </Radio.Group>
</Block>
{values.authMethod === 'BasicAuth' && (
<>
diff --git a/config-ui/src/plugins/register/jira/transformation-fields/cross-domain.tsx b/config-ui/src/plugins/register/jira/transformation-fields/cross-domain.tsx
index 5abf1bc66..b020f55b1 100644
--- a/config-ui/src/plugins/register/jira/transformation-fields/cross-domain.tsx
+++ b/config-ui/src/plugins/register/jira/transformation-fields/cross-domain.tsx
@@ -17,8 +17,8 @@
*/
import { useEffect, useState } from 'react';
-import { Button } from 'antd';
-import { Radio, Icon, Collapse } from '@blueprintjs/core';
+import { Radio, Button } from 'antd';
+import { Icon, Collapse } from '@blueprintjs/core';
import { ExternalLink } from '@/components';
import JiraIssueTipsImg from '@/images/jira-issue-tips.png';
diff --git a/config-ui/src/plugins/register/jira/transformation-fields/dev-panel.tsx b/config-ui/src/plugins/register/jira/transformation-fields/dev-panel.tsx
index d01470005..c73d723cd 100644
--- a/config-ui/src/plugins/register/jira/transformation-fields/dev-panel.tsx
+++ b/config-ui/src/plugins/register/jira/transformation-fields/dev-panel.tsx
@@ -17,8 +17,8 @@
*/
import { useEffect, useState } from 'react';
-import { Modal, Input, Button, message } from 'antd';
-import { RadioGroup, Radio, Icon, Collapse } from '@blueprintjs/core';
+import { Modal, Radio, Input, Button, message } from 'antd';
+import { Icon, Collapse } from '@blueprintjs/core';
import API from '@/api';
import { Block } from '@/components';
@@ -157,14 +157,13 @@ export const DevPanel = ({ connectionId, transformation, setTransformation, open
</Block>
{applicationTypes.length > 0 && (
<Block title="Application Type" description="Please choose an application type." required>
- <RadioGroup
- selectedValue={applicationType}
- onChange={(e) => setApplicationType((e.target as HTMLInputElement).value)}
- >
+ <Radio.Group value={applicationType} onChange={(e) => setApplicationType(e.target.value)}>
{applicationTypes.map((at) => (
- <Radio key={at} value={at} label={at} />
+ <Radio key={at} value={at}>
+ {at}
+ </Radio>
))}
- </RadioGroup>
+ </Radio.Group>
</Block>
)}
</>
diff --git a/config-ui/src/plugins/register/opsgenie/connection-fields/endpoint.tsx b/config-ui/src/plugins/register/opsgenie/connection-fields/endpoint.tsx
index ec4e43164..b074da0b9 100644
--- a/config-ui/src/plugins/register/opsgenie/connection-fields/endpoint.tsx
+++ b/config-ui/src/plugins/register/opsgenie/connection-fields/endpoint.tsx
@@ -17,7 +17,7 @@
*/
import { useEffect } from 'react';
-import { RadioGroup, Radio } from '@blueprintjs/core';
+import { Radio } from 'antd';
import { Block } from '@/components';
@@ -34,16 +34,10 @@ export const Endpoint = ({ initialValue, value, setValue }: Props) => {
return (
<Block title="Opsgenie Instance Location (us or eu)" required>
- <RadioGroup
- inline
- selectedValue={value || initialValue}
- onChange={(e) => {
- setValue((e.target as any).value);
- }}
- >
+ <Radio.Group value={value || initialValue} onChange={(e) => setValue(e.target.value)}>
<Radio value="https://api.opsgenie.com/">United States</Radio>
<Radio value="https://api.eu.opsgenie.com/">Europe</Radio>
- </RadioGroup>
+ </Radio.Group>
</Block>
);
};