Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun committed Apr 9, 2021
1 parent 23fb278 commit 0755b95
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ context('Delete Plugin List with the Drawer', () => {
});

cy.get(this.domSelector.codeMirrorMode).invoke('text').then(text => {
if (text === 'UIForm') {
if (text === 'Form') {
cy.get(this.domSelector.codeMirrorMode).click();
cy.get(this.domSelector.selectDropdown).should('be.visible');
cy.get(this.domSelector.selectJSON).click();
Expand Down
2 changes: 1 addition & 1 deletion web/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Cypress.Commands.add('configurePlugins', (cases) => {
cy.get(domSelector.drawer).should('exist');

cy.get(domSelector.codeMirrorMode).invoke('text').then(text => {
if (text === 'UIForm') {
if (text === 'Form') {
cy.get(domSelector.codeMirrorMode).click();
cy.get(domSelector.selectDropdown).should('be.visible');
cy.get(domSelector.selectJSON).click();
Expand Down
18 changes: 9 additions & 9 deletions web/src/components/Plugin/PluginDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const PluginDetail: React.FC<Props> = ({
enum codeMirrorModeList {
JSON = 'JSON',
YAML = 'YAML',
UIForm = 'UIForm'
Form = 'Form'
}
const [form] = Form.useForm();
const [UIForm] = Form.useForm();
Expand All @@ -111,7 +111,7 @@ const PluginDetail: React.FC<Props> = ({
];

if (PLUGIN_UI_LIST.includes(name)) {
modeOptions.push({ label: codeMirrorModeList.UIForm, value: codeMirrorModeList.UIForm });
modeOptions.push({ label: codeMirrorModeList.Form, value: codeMirrorModeList.Form });
}

useEffect(() => {
Expand All @@ -120,7 +120,7 @@ const PluginDetail: React.FC<Props> = ({
scope: 'global',
});
if (PLUGIN_UI_LIST.includes(name)) {
setCodeMirrorMode(codeMirrorModeList.UIForm);
setCodeMirrorMode(codeMirrorModeList.Form);
UIForm.setFieldsValue(initialData[name]);
};
}, []);
Expand Down Expand Up @@ -207,7 +207,7 @@ const PluginDetail: React.FC<Props> = ({
break;
}

case codeMirrorModeList.UIForm: {
case codeMirrorModeList.Form: {
if (codeMirrorMode === codeMirrorModeList.JSON) {
UIForm.setFieldsValue(JSON.parse(ref.current.editor.getValue()));
} else {
Expand Down Expand Up @@ -337,7 +337,7 @@ const PluginDetail: React.FC<Props> = ({
<PageHeader
title=""
subTitle={
pluginType === 'auth' && schemaType !== 'consumer' && (codeMirrorMode !== codeMirrorModeList.UIForm) ? (
pluginType === 'auth' && schemaType !== 'consumer' && (codeMirrorMode !== codeMirrorModeList.Form) ? (
<Alert message={formatMessage({ id: 'component.global.noConfigurationRequired' })} type="warning" />
) : null
}
Expand Down Expand Up @@ -366,13 +366,13 @@ const PluginDetail: React.FC<Props> = ({
}}
data-cy='code-mirror-mode'
></Select>,
<Button type="primary" onClick={formatCodes} key={3}>
<Button type="primary" onClick={formatCodes} key={3} disabled={codeMirrorMode === codeMirrorModeList.Form}>
{formatMessage({ id: 'component.global.format' })}
</Button>,
</Button>
]}
/>
{Boolean(codeMirrorMode === codeMirrorModeList.UIForm) && <PluginForm name={name} form={UIForm} renderForm={!(pluginType === 'auth' && schemaType !== 'consumer')} />}
<div style={{ display: codeMirrorMode === codeMirrorModeList.UIForm ? 'none' : 'unset' }}><CodeMirror
{Boolean(codeMirrorMode === codeMirrorModeList.Form) && <PluginForm name={name} form={UIForm} renderForm={!(pluginType === 'auth' && schemaType !== 'consumer')} />}
<div style={{ display: codeMirrorMode === codeMirrorModeList.Form ? 'none' : 'unset' }}><CodeMirror
ref={(codemirror) => {
ref.current = codemirror;
if (codemirror) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Plugin/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ declare namespace PluginComponent {

type ReferPage = '' | 'route' | 'consumer' | 'service' | 'plugin';

type CodeMirrorMode = 'JSON' | 'YAML'| 'UIForm';
type CodeMirrorMode = 'JSON' | 'YAML'| 'Form';
}

0 comments on commit 0755b95

Please sign in to comment.