Skip to content

Commit

Permalink
feat(plugin): add basic
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdmomo committed Jul 24, 2021
1 parent 0b5196f commit ff10080
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const PluginDetail: React.FC<Props> = ({
const [UIForm] = Form.useForm();
const data = initialData[name] || {};
const pluginType = pluginList.find((item) => item.name === name)?.originType;
const pluginSchema = pluginList.find((item) => item.name === name)?.schema;
const [content, setContent] = useState<string>(JSON.stringify(data, null, 2));
const [monacoMode, setMonacoMode] = useState<PluginComponent.MonacoLanguage>(monacoModeList.JSON);
const modeOptions: { label: string; value: string }[] = [
Expand Down Expand Up @@ -411,7 +412,7 @@ const PluginDetail: React.FC<Props> = ({
</Button>
]}
/>
{Boolean(monacoMode === monacoModeList.UIForm) && <PluginForm name={name} form={UIForm} renderForm={!(pluginType === 'auth' && schemaType !== 'consumer')} />}
{Boolean(monacoMode === monacoModeList.UIForm) && <PluginForm name={name} schema={pluginSchema} form={UIForm} renderForm={!(pluginType === 'auth' && schemaType !== 'consumer')} />}
<div style={{ display: monacoMode === monacoModeList.UIForm ? 'none' : 'unset' }}>
<Editor
value={content}
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/Plugin/UI/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import Cors from './cors';

type Props = {
name: string,
schema: Record<string, any> | undefined,
form: FormInstance,
renderForm: boolean
}

export const PLUGIN_UI_LIST = ['api-breaker', 'basic-auth', 'cors', 'limit-req', 'limit-conn', 'proxy-mirror', 'referer-restriction', 'limit-count'];

export const PluginForm: React.FC<Props> = ({ name, renderForm, form }) => {
export const PluginForm: React.FC<Props> = ({ name, schema, renderForm, form }) => {

const { formatMessage } = useIntl();

Expand Down

0 comments on commit ff10080

Please sign in to comment.