Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FE): version manager #1157

Merged
merged 17 commits into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const PluginDetail: React.FC<Props> = ({
visible,
readonly = false,
initialData = {},
onClose = () => { },
onChange = () => { },
onClose = () => {},
onChange = () => {},
}) => {
const { formatMessage } = useIntl();
const [form] = Form.useForm();
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const PluginPage: React.FC<Props> = ({
initialData = {},
schemaType = 'route',
type = 'scoped',
onChange = () => { },
onChange = () => {},
}) => {
const [pluginList, setPluginList] = useState<PluginComponent.Meta[]>([]);
const [name, setName] = useState<string>(NEVER_EXIST_PLUGIN_FLAG);
Expand Down
2 changes: 1 addition & 1 deletion web/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export const codeMessage = {
504: '网关超时。',
};

export const DEFAULT_GLOBAL_RULE_ID = "1"
export const DEFAULT_GLOBAL_RULE_ID = '1';
2 changes: 1 addition & 1 deletion web/src/hooks/useForceIntl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const useForceIntl = () => {
}

const { locale } = getIntl();
if (locale === 'zh-cn') {
if (locale === 'zh-CN') {
return;
}

Expand Down
1 change: 1 addition & 0 deletions web/src/locales/en-US/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
'component.global.add': 'Add',
'component.global.save': 'Save',
'component.global.edit': 'Edit',
'component.global.manage': 'Manage',
'component.global.update': 'Update',
'component.global.get': 'Get',
'component.global.edit.plugin': 'Edit plugin',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh-CN/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
'component.global.add': '新建',
'component.global.save': '保存',
'component.global.edit': '编辑',
'component.global.manage': '管理',
'component.global.update': '更新',
'component.global.get': '获取',
'component.global.edit.plugin': '编辑插件',
Expand Down
26 changes: 14 additions & 12 deletions web/src/pages/Consumer/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { fetchItem, create, update, fetchPlugList } from './service';
const Page: React.FC = (props) => {
const [step, setStep] = useState(1);
const [plugins, setPlugins] = useState<PluginComponent.Data>({});
const [pluginList, setPluginList] = useState<PluginComponent.Meta[]>([])
const [pluginList, setPluginList] = useState<PluginComponent.Meta[]>([]);
const [form1] = Form.useForm();
const { formatMessage } = useIntl();

Expand All @@ -52,12 +52,13 @@ const Page: React.FC = (props) => {
(username ? update(username, data) : create(data))
.then(() => {
notification.success({
message: `${username
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })} ${formatMessage({
id: 'component.status.success',
})}`,
message: `${
username
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })} ${formatMessage({
id: 'component.status.success',
})}`,
});
history.push('/consumer/list');
})
Expand All @@ -76,7 +77,7 @@ const Page: React.FC = (props) => {
if (
!Object.keys(plugins).filter(
(name) =>
(pluginList.find(item => item.name === name)!.type === 'auth') &&
pluginList.find((item) => item.name === name)!.type === 'auth' &&
!plugins[name].disable,
).length
) {
Expand All @@ -98,10 +99,11 @@ const Page: React.FC = (props) => {
return (
<>
<PageContainer
title={`${(props as any).match.params.id
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })}`}
title={`${
(props as any).match.params.id
? formatMessage({ id: 'component.global.edit' })
: formatMessage({ id: 'component.global.create' })
} ${formatMessage({ id: 'menu.consumer' })}`}
>
<Card bordered={false}>
<Steps current={step - 1} style={{ marginBottom: 30 }}>
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Plugin/PluginMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ const PluginMarket: React.FC = () => {
...pluginsData,
},
}).then(() => {
// TODO:
// TODO:
window.location.reload();
})
});
}}
/>
</Card>
Expand Down
16 changes: 0 additions & 16 deletions web/src/pages/Plugin/components/Step1.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion web/src/pages/Plugin/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ declare namespace PluginModule {
type GlobalRule = {
id: string;
plugins: Record<string, object>;
}
};
}
4 changes: 2 additions & 2 deletions web/src/pages/Route/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const Page: React.FC<Props> = (props) => {
if (action === 'advancedMatchingRulesChange') {
setAdvancedMatchingRules(data);
}
if (action === 'labelsChange') {
form1.setFieldsValue({ ...form1.getFieldsValue(), labels: data });
if (action === 'custom_normal_labels') {
form1.setFieldsValue({ custom_normal_labels: data });
}
}}
isEdit={props.route.path.indexOf('edit') > 0}
Expand Down
59 changes: 31 additions & 28 deletions web/src/pages/Route/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,36 +172,36 @@ const Page: React.FC = () => {
render: (_, record) => (
<>
<Space align="baseline">
<Button
type="primary"
onClick={() => history.push(`/routes/${record.id}/edit`)}
style={{ marginRight: 10 }}
>
{!record.status ? (
<Button
type="primary"
onClick={() => {
handlePublishOffline(record.id, RouteStatus.Publish);
}}
>
{formatMessage({ id: 'page.route.publish' })}
</Button>
) : null}
{record.status ? (
<Popconfirm
title={formatMessage({ id: 'page.route.popconfirm.title.offline' })}
onConfirm={() => {
handlePublishOffline(record.id, RouteStatus.Offline);
}}
okButtonProps={{
danger: true,
}}
okText={formatMessage({ id: 'component.global.confirm' })}
cancelText={formatMessage({ id: 'component.global.cancel' })}
>
<Button type="primary" danger disabled={Boolean(!record.status)}>
{formatMessage({ id: 'page.route.offline' })}
</Button>
</Popconfirm>
) : null}
<Button type="primary" onClick={() => history.push(`/routes/${record.id}/edit`)}>
{formatMessage({ id: 'component.global.edit' })}
</Button>
<Button
type="primary"
onClick={() => {
handlePublishOffline(record.id, RouteStatus.Publish);
}}
style={{ marginRight: 10 }}
disabled={Boolean(record.status)}
>
{formatMessage({ id: 'page.route.publish' })}
</Button>
<Popconfirm
title={formatMessage({ id: 'page.route.popconfirm.title.offline' })}
onConfirm={() => {
handlePublishOffline(record.id, RouteStatus.Offline);
}}
okText={formatMessage({ id: 'component.global.confirm' })}
cancelText={formatMessage({ id: 'component.global.cancel' })}
disabled={Boolean(!record.status)}
>
<Button type="primary" danger disabled={Boolean(!record.status)}>
{formatMessage({ id: 'page.route.offline' })}
</Button>
</Popconfirm>
<Popconfirm
title={formatMessage({ id: 'component.global.popconfirm.title.delete' })}
onConfirm={() => {
Expand All @@ -213,6 +213,9 @@ const Page: React.FC = () => {
);
});
}}
okButtonProps={{
danger: true,
}}
okText={formatMessage({ id: 'component.global.confirm' })}
cancelText={formatMessage({ id: 'component.global.cancel' })}
>
Expand Down
22 changes: 14 additions & 8 deletions web/src/pages/Route/components/Step1/LabelsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ import { useIntl } from 'umi';
import { transformLableValueToKeyValue } from '../../transform';
import { fetchLabelList } from '../../service';

interface Props extends Pick<RouteModule.Step1PassProps, 'onChange'> {
labelsDataSource: string[];
type Props = {
title?: string;
labelPrefix?: string;
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved
actionName: string;
dataSource: string[];
disabled: boolean;
onClose(): void;
}
} & Pick<RouteModule.Step1PassProps, 'onChange'>;

const LabelList = (disabled: boolean, labelList: RouteModule.LabelList) => {
const { formatMessage } = useIntl();
Expand Down Expand Up @@ -108,12 +111,14 @@ const LabelList = (disabled: boolean, labelList: RouteModule.LabelList) => {
};

const LabelsDrawer: React.FC<Props> = ({
disabled,
labelsDataSource,
title = 'Label Manager',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i18n

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update in another PR :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*i18n

actionName = '',
disabled = false,
dataSource = [],
onClose,
onChange = () => {},
}) => {
const transformLabel = transformLableValueToKeyValue(labelsDataSource);
const transformLabel = transformLableValueToKeyValue(dataSource);

const { formatMessage } = useIntl();
const [form] = Form.useForm();
Expand All @@ -126,12 +131,13 @@ const LabelsDrawer: React.FC<Props> = ({

return (
<Drawer
title="Edit labels"
title={title}
placement="right"
width={512}
visible
closable
onClose={onClose}
maskClosable={false}
footer={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<Button onClick={onClose}>{formatMessage({ id: 'component.global.cancel' })}</Button>
Expand All @@ -152,7 +158,7 @@ const LabelsDrawer: React.FC<Props> = ({
}

onChange({
action: 'labelsChange',
action: actionName,
data,
});
onClose();
Expand Down
Loading