Skip to content

Commit

Permalink
feat: add tips when plugin type is auth and schemaType is not consumer (
Browse files Browse the repository at this point in the history
#1219)

Co-authored-by: 琚致远 <juzhiyuan@apache.org>
  • Loading branch information
LiteSun and juzhiyuan authored Jan 6, 2021
1 parent 6c6e73b commit 291e321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/
import React, { useEffect, useRef } from 'react';
import { Button, notification, PageHeader, Switch, Form, Select, Divider, Drawer } from 'antd';
import { Button, notification, PageHeader, Switch, Form, Select, Divider, Drawer, Alert } from 'antd';
import { useIntl } from 'umi';
import CodeMirror from '@uiw/react-codemirror';
import { js_beautify } from 'js-beautify';
Expand All @@ -29,6 +29,7 @@ type Props = {
type?: 'global' | 'scoped';
schemaType: PluginComponent.Schema;
initialData: object;
pluginList: PluginComponent.Meta[],
readonly?: boolean;
visible: boolean;
onClose?: () => void;
Expand Down Expand Up @@ -65,15 +66,17 @@ const PluginDetail: React.FC<Props> = ({
type = 'scoped',
schemaType = 'route',
visible,
pluginList = [],
readonly = false,
initialData = {},
onClose = () => {},
onChange = () => {},
onClose = () => { },
onChange = () => { },
}) => {
const { formatMessage } = useIntl();
const [form] = Form.useForm();
const ref = useRef<any>(null);
const data = initialData[name];
const data = initialData[name] || {};
const pluginType = pluginList.find(item => item.name === name)?.type

useEffect(() => {
form.setFieldsValue({ disable: initialData[name] && !initialData[name].disable });
Expand Down Expand Up @@ -149,7 +152,7 @@ const PluginDetail: React.FC<Props> = ({
placement="right"
closable={false}
onClose={onClose}
width={600}
width={700}
footer={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
{' '}
Expand Down Expand Up @@ -204,7 +207,9 @@ const PluginDetail: React.FC<Props> = ({
<Divider orientation="left">Data Editor</Divider>
<PageHeader
title=""
subTitle={`Current Plugin: ${name}`}
subTitle={
(pluginType === 'auth' && schemaType !== 'consumer') ? <Alert message={`${name} does not require configuration`} type="warning" />
: <>Current plugin: {name}</>}
ghost={false}
extra={[
<Button
Expand Down
1 change: 1 addition & 0 deletions web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const PluginPage: React.FC<Props> = ({
visible={name !== NEVER_EXIST_PLUGIN_FLAG}
schemaType={schemaType}
initialData={initialData}
pluginList={pluginList}
onClose={() => {
setName(NEVER_EXIST_PLUGIN_FLAG);
}}
Expand Down

0 comments on commit 291e321

Please sign in to comment.