From 1acb995fd1a9f17acca285fc1ba0b979f0eb9f2a Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 12:41:26 +0800 Subject: [PATCH 01/18] feat: add proxy-mirror form --- web/src/components/Plugin/UI/plugin.tsx | 7 ++- web/src/components/Plugin/UI/proxy-mirror.tsx | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 web/src/components/Plugin/UI/proxy-mirror.tsx diff --git a/web/src/components/Plugin/UI/plugin.tsx b/web/src/components/Plugin/UI/plugin.tsx index f13b31ae16..99bb6c26be 100644 --- a/web/src/components/Plugin/UI/plugin.tsx +++ b/web/src/components/Plugin/UI/plugin.tsx @@ -19,7 +19,8 @@ import { FormInstance } from 'antd/es/form'; import { Empty } from 'antd'; import { useIntl } from 'umi'; -import BasicAuth from './basic-auth' +import BasicAuth from './basic-auth'; +import ProxyMirror from './proxy-mirror'; type Props = { name: string, @@ -27,7 +28,7 @@ type Props = { renderForm: boolean } -export const PLUGIN_UI_LIST = ['basic-auth',]; +export const PLUGIN_UI_LIST = ['basic-auth', 'proxy-mirror']; export const PluginForm: React.FC = ({ name, renderForm, form }) => { @@ -38,6 +39,8 @@ export const PluginForm: React.FC = ({ name, renderForm, form }) => { switch (name) { case 'basic-auth': return + case 'proxy-mirror': + return default: return null; } diff --git a/web/src/components/Plugin/UI/proxy-mirror.tsx b/web/src/components/Plugin/UI/proxy-mirror.tsx new file mode 100644 index 0000000000..136139f2eb --- /dev/null +++ b/web/src/components/Plugin/UI/proxy-mirror.tsx @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import React from 'react'; +import type { FormInstance } from 'antd/es/form'; +import { Form, Input } from 'antd'; + +type Props = { + form: FormInstance; +}; + +const FORM_ITEM_LAYOUT = { + labelCol: { + span: 3, + }, + wrapperCol: { + span: 10 + }, +}; + +const ProxyMirror: React.FC = ({ form }) => { + return ( +
+ + + +
+ ); +} + +export default ProxyMirror; From 8136c156004c1b69dcb4c012f98fdfc80565ed16 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 12:42:39 +0800 Subject: [PATCH 02/18] feat: update --- web/cypress/fixtures/selector.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/fixtures/selector.json b/web/cypress/fixtures/selector.json index 0236d8e1e2..1cee859c78 100644 --- a/web/cypress/fixtures/selector.json +++ b/web/cypress/fixtures/selector.json @@ -85,5 +85,5 @@ "pageTwoActived": ".ant-pagination-item-2.ant-pagination-item-active", "selectDropdown": ".ant-select-dropdown", "codeMirrorMode": "[data-cy='code-mirror-mode']", - "selectJSON":".ant-select-dropdown [label=JSON]" + "selectJSON": ".ant-select-dropdown [label=JSON]" } From 11bf7f9154661591efdd64098ae451dfbb3cb323 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 14:23:11 +0800 Subject: [PATCH 03/18] fix: ci --- web/cypress/support/commands.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index d4433390d3..a0b26944d6 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -72,20 +72,20 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); }); + cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { + if (text === 'Form') { + cy.get(domSelector.codeMirrorMode).click(); + cy.get(domSelector.selectDropdown).should('be.visible'); + cy.get(domSelector.selectJSON).click(); + } + }); + cy.window().then(({ codemirror }) => { if (codemirror) { codemirror.setValue(JSON.stringify(data)); } cy.get(domSelector.drawer).should('exist'); - cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { - if (text === 'Form') { - cy.get(domSelector.codeMirrorMode).click(); - cy.get(domSelector.selectDropdown).should('be.visible'); - cy.get(domSelector.selectJSON).click(); - } - }); - cy.get(domSelector.drawer, { timeout }).within(() => { cy.contains('Submit').click({ force: true, From f02d0c5b583e0f485fb631ec2063591daeb95b01 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 15:12:09 +0800 Subject: [PATCH 04/18] feat: update ci --- web/cypress/support/commands.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index a0b26944d6..8e8918e19b 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -66,11 +66,6 @@ Cypress.Commands.add('configurePlugins', (cases) => { // NOTE: wait for the Drawer to appear on the DOM cy.focused(domSelector.drawer).should('exist'); - cy.get(domSelector.drawer, { timeout }).within(() => { - cy.get(domSelector.switch).click({ - force: true, - }); - }); cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { if (text === 'Form') { @@ -79,6 +74,12 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.get(domSelector.selectJSON).click(); } }); + + cy.get(domSelector.drawer, { timeout }).within(() => { + cy.get(domSelector.switch).click({ + force: true, + }); + }); cy.window().then(({ codemirror }) => { if (codemirror) { From 28ba08f36d7f581bf90afda71b36f187ff04f55f Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 16:39:24 +0800 Subject: [PATCH 05/18] fix: ci --- web/cypress/support/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 8e8918e19b..fad6cf8e68 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -69,6 +69,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { if (text === 'Form') { + cy.get(domSelector.codeMirrorMode).should('be.visible'); cy.get(domSelector.codeMirrorMode).click(); cy.get(domSelector.selectDropdown).should('be.visible'); cy.get(domSelector.selectJSON).click(); From 457dccbb7b3111587cf2979b613dec489f215eb2 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 17:26:50 +0800 Subject: [PATCH 06/18] feat: add proxy-mirror plugin form --- ...te-upstream-with-proxy-mirror-form.spec.js | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js diff --git a/web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js b/web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js new file mode 100644 index 0000000000..5e21b80764 --- /dev/null +++ b/web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* eslint-disable no-undef */ + +context('Create and Delete Consumer', () => { + beforeEach(() => { + cy.login(); + + cy.fixture('selector.json').as('domSelector'); + cy.fixture('data.json').as('data'); + }); + + const selector = { + host: "#host" + } + + const data = { + correctHost: 'http://127.0.0.1', + wrongHost: '127.0.0.1:1999' + } + + it('creates consumer with proxy-mirror form', function () { + cy.visit('/'); + cy.contains('Consumer').click(); + cy.get(this.domSelector.empty).should('be.visible'); + cy.contains('Create').click(); + // basic information + cy.get(this.domSelector.username).type(this.data.consumerName); + cy.get(this.domSelector.description).type(this.data.description); + cy.contains('Next').click(); + + // config auth plugin + cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => { + cy.contains('Enable').click({ + force: true, + }); + }); + cy.focused(this.domSelector.drawer).should('exist'); + cy.get(this.domSelector.disabledSwitcher).click(); + // edit codemirror + cy.get(this.domSelector.codeMirror) + .first() + .then((editor) => { + editor[0].CodeMirror.setValue( + JSON.stringify({ + key: 'test', + }), + ); + cy.contains('button', 'Submit').click(); + }); + + cy.contains(this.domSelector.pluginCard, 'proxy-mirror').within(() => { + cy.contains('Enable').click({ + force: true, + }); + }); + + cy.focused(this.domSelector.drawer).should('exist'); + + // config proxy-mirror form + cy.get(selector.host).type(data.wrongHost); + cy.get(this.domSelector.drawer).within(() => { + cy.contains('Submit').click({ + force: true, + }); + }); + cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data'); + + cy.get(selector.host).clear().type(data.correctHost); + cy.get(this.domSelector.disabledSwitcher).click(); + cy.get(this.domSelector.drawer).within(() => { + cy.contains('Submit').click({ + force: true, + }); + }); + cy.get(this.domSelector.drawer).should('not.exist'); + + cy.contains('button', 'Next').click(); + cy.contains('button', 'Submit').click(); + cy.get(this.domSelector.notification).should('contain', this.data.createConsumerSuccess); + }); + + it('delete the consumer', function () { + cy.visit('/consumer/list'); + cy.contains(this.data.consumerName).should('be.visible').siblings().contains('Delete').click(); + cy.contains('button', 'Confirm').click(); + cy.get(this.domSelector.notification).should('contain', this.data.deleteConsumerSuccess); + }); +}); From 2b743e1aeb8f83c6a68841f727fcf7b00b5d3b76 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 19:28:22 +0800 Subject: [PATCH 07/18] fix: ci --- web/cypress/support/commands.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index fad6cf8e68..8ff1fd71c8 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -69,6 +69,8 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { if (text === 'Form') { + // FIXME: https://github.com/cypress-io/cypress/issues/7306 + cy.wait(500); cy.get(domSelector.codeMirrorMode).should('be.visible'); cy.get(domSelector.codeMirrorMode).click(); cy.get(domSelector.selectDropdown).should('be.visible'); From 2b71a7ef811a532c04168a0a0da598365c6c845f Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 19:29:27 +0800 Subject: [PATCH 08/18] fix: lint --- web/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 8ff1fd71c8..9b8e119f31 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -77,7 +77,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.get(domSelector.selectJSON).click(); } }); - + cy.get(domSelector.drawer, { timeout }).within(() => { cy.get(domSelector.switch).click({ force: true, From f10c60a3112e6e3b1067b016ffb4375dd86087f1 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Fri, 9 Apr 2021 20:40:36 +0800 Subject: [PATCH 09/18] fix: ci --- web/cypress/support/commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index 9b8e119f31..e92f3658d6 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -70,7 +70,7 @@ Cypress.Commands.add('configurePlugins', (cases) => { cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { if (text === 'Form') { // FIXME: https://github.com/cypress-io/cypress/issues/7306 - cy.wait(500); + cy.wait(5000); cy.get(domSelector.codeMirrorMode).should('be.visible'); cy.get(domSelector.codeMirrorMode).click(); cy.get(domSelector.selectDropdown).should('be.visible'); From 0d7b78151b5dc827ed77bba9f036f97ea1291225 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 10:50:41 +0800 Subject: [PATCH 10/18] test: update --- ...orm.spec.js => create-consumer-with-proxy-mirror-form.spec.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web/cypress/integration/consumer/{create-upstream-with-proxy-mirror-form.spec.js => create-consumer-with-proxy-mirror-form.spec.js} (100%) diff --git a/web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js b/web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js similarity index 100% rename from web/cypress/integration/consumer/create-upstream-with-proxy-mirror-form.spec.js rename to web/cypress/integration/consumer/create-consumer-with-proxy-mirror-form.spec.js From 81e1107ff6c381bf52ed2d5654b1d672bf026071 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 14:00:31 +0800 Subject: [PATCH 11/18] fix: ci unstable --- web/cypress.json | 1 - .../create-plugin-template-with-route.spec.js | 4 +++- .../route/create-edit-duplicate-delete-route.spec.js | 1 + web/cypress/support/commands.js | 11 +++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/web/cypress.json b/web/cypress.json index db84cd76b8..88b22c07b4 100644 --- a/web/cypress.json +++ b/web/cypress.json @@ -3,6 +3,5 @@ "viewportHeight": 1080, "baseUrl": "http://localhost:8000", "video": true, - "numTestsKeptInMemory": 0, "videoUploadOnPasses": false } diff --git a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js index 6b673ba47d..75f99f981c 100644 --- a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js +++ b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js @@ -41,7 +41,9 @@ context('Create PluginTemplate Binding To Route', () => { cy.visit('/routes/list'); cy.contains('Create').click(); cy.get(this.domSelector.empty).should('be.visible'); - cy.get(this.domSelector.name).click(); + + // FIXME: https://github.com/cypress-io/cypress/issues/7306 + cy.wait(500); cy.get(this.domSelector.name).type(this.data.routeName); cy.contains('Next').click(); cy.get(this.domSelector.nodes_0_host).type(this.data.ip1); diff --git a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js index 3333832392..6776340eef 100644 --- a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js +++ b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js @@ -166,6 +166,7 @@ context('Create and Delete Route', () => { it('should duplicate the route', function () { cy.visit('/'); cy.contains('Route').click(); + cy.reload(); cy.get(this.domSelector.nameSelector).type(newName); cy.contains('Search').click(); diff --git a/web/cypress/support/commands.js b/web/cypress/support/commands.js index d4433390d3..2f28b64468 100644 --- a/web/cypress/support/commands.js +++ b/web/cypress/support/commands.js @@ -72,6 +72,17 @@ Cypress.Commands.add('configurePlugins', (cases) => { }); }); + cy.get(domSelector.codeMirrorMode).invoke('text').then(text => { + if (text === 'Form') { + // FIXME: https://github.com/cypress-io/cypress/issues/7306 + cy.wait(5000); + cy.get(domSelector.codeMirrorMode).should('be.visible'); + cy.get(domSelector.codeMirrorMode).click(); + cy.get(domSelector.selectDropdown).should('be.visible'); + cy.get(domSelector.selectJSON).click(); + } + }); + cy.window().then(({ codemirror }) => { if (codemirror) { codemirror.setValue(JSON.stringify(data)); From 3f3045cf0878df7312390ccff6812cefe9a105ed Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 15:54:19 +0800 Subject: [PATCH 12/18] fix: ci --- .../route/create-edit-duplicate-delete-route.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js index 6776340eef..618ed33af5 100644 --- a/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js +++ b/web/cypress/integration/route/create-edit-duplicate-delete-route.spec.js @@ -139,7 +139,8 @@ context('Create and Delete Route', () => { cy.contains('Search').click(); cy.contains(name).siblings().contains('Configure').click(); - cy.wait(500); + // NOTE: make sure all components rerender done + cy.get('#status').should('have.class', 'ant-switch-checked'); cy.get(this.domSelector.name).clear().type(newName); cy.get(this.domSelector.description).clear().type(this.data.description2); cy.contains('Next').click(); @@ -173,7 +174,8 @@ context('Create and Delete Route', () => { cy.contains(newName).siblings().contains('More').click(); cy.contains('Duplicate').click(); - cy.wait(500); + // NOTE: make sure all components rerender done + cy.get('#status').should('have.class', 'ant-switch-checked'); cy.get(this.domSelector.name).clear().type(duplicateNewName); cy.get(this.domSelector.description).clear().type(this.data.description2); cy.contains('Next').click(); From 4c59311d242a0608461a10afa36543ff42c7563a Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 16:00:46 +0800 Subject: [PATCH 13/18] fix: ci --- .../route/create-route-with-proxy-rewrite-plugin.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/cypress/integration/route/create-route-with-proxy-rewrite-plugin.spec.js b/web/cypress/integration/route/create-route-with-proxy-rewrite-plugin.spec.js index b051fcea2a..1d8173d086 100644 --- a/web/cypress/integration/route/create-route-with-proxy-rewrite-plugin.spec.js +++ b/web/cypress/integration/route/create-route-with-proxy-rewrite-plugin.spec.js @@ -106,7 +106,9 @@ context('create route with proxy-rewrite plugin', () => { cy.get(this.domSelector.nameSelector).type(this.data.routeName); cy.contains('Search').click(); cy.contains(this.data.routeName).siblings().contains('Configure').click(); - cy.wait(500); + + // NOTE: make sure all components rerender done + cy.get('#status').should('have.class', 'ant-switch-checked'); cy.get(this.domSelector.name).type(this.data.routeName); cy.contains(routeLocaleUS['page.route.form.itemLabel.newPath']).should('be.visible'); From 8143999a0b1bf5781d9d42bab257acc01c19b412 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 16:09:51 +0800 Subject: [PATCH 14/18] fix: ci --- .../pluginTemplate/create-plugin-template-with-route.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js index 75f99f981c..8be0f49d5c 100644 --- a/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js +++ b/web/cypress/integration/pluginTemplate/create-plugin-template-with-route.spec.js @@ -40,10 +40,9 @@ context('Create PluginTemplate Binding To Route', () => { cy.visit('/routes/list'); cy.contains('Create').click(); - cy.get(this.domSelector.empty).should('be.visible'); - // FIXME: https://github.com/cypress-io/cypress/issues/7306 - cy.wait(500); + // NOTE: make sure all components rerender done + cy.contains('Next').click().click(); cy.get(this.domSelector.name).type(this.data.routeName); cy.contains('Next').click(); cy.get(this.domSelector.nodes_0_host).type(this.data.ip1); From 34c99213cf86b0c1ebfc97786483f7d7fa017c5f Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sat, 10 Apr 2021 17:12:41 +0800 Subject: [PATCH 15/18] fix: ci --- web/cypress/integration/route/search-route.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/cypress/integration/route/search-route.spec.js b/web/cypress/integration/route/search-route.spec.js index aed1837096..381b9feb6e 100644 --- a/web/cypress/integration/route/search-route.spec.js +++ b/web/cypress/integration/route/search-route.spec.js @@ -98,9 +98,8 @@ context('Create and Search Route', () => { }); it('should search the route with labels', function () { - cy.visit('/routes/list'); // search one label - cy.contains(data.test0).should('exist'); + cy.reload(); cy.get(this.domSelector.labelSelect_0).click({ timeout }); cy.get(this.domSelector.dropdown).contains(data.value0).should('be.visible').click(); cy.contains('Search').click(); From 54d1ccd80a18b0f4e797cfb6b208cf6e210007f8 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sun, 11 Apr 2021 11:33:24 +0800 Subject: [PATCH 16/18] feat: update i18n --- web/src/components/Plugin/UI/proxy-mirror.tsx | 7 +++++-- web/src/components/Plugin/locales/en-US.ts | 3 +++ web/src/components/Plugin/locales/zh-CN.ts | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/src/components/Plugin/UI/proxy-mirror.tsx b/web/src/components/Plugin/UI/proxy-mirror.tsx index 136139f2eb..29fc6da5b0 100644 --- a/web/src/components/Plugin/UI/proxy-mirror.tsx +++ b/web/src/components/Plugin/UI/proxy-mirror.tsx @@ -17,6 +17,7 @@ import React from 'react'; import type { FormInstance } from 'antd/es/form'; import { Form, Input } from 'antd'; +import { useIntl } from 'umi'; type Props = { form: FormInstance; @@ -24,7 +25,7 @@ type Props = { const FORM_ITEM_LAYOUT = { labelCol: { - span: 3, + span: 4, }, wrapperCol: { span: 10 @@ -32,6 +33,8 @@ const FORM_ITEM_LAYOUT = { }; const ProxyMirror: React.FC = ({ form }) => { + const { formatMessage } = useIntl(); + return (
= ({ form }) => { diff --git a/web/src/components/Plugin/locales/en-US.ts b/web/src/components/Plugin/locales/en-US.ts index dc733d39fe..ffad97d44d 100644 --- a/web/src/components/Plugin/locales/en-US.ts +++ b/web/src/components/Plugin/locales/en-US.ts @@ -21,4 +21,7 @@ export default { 'component.step.select.pluginTemplate.select.option': 'Custom', 'component.plugin.pluginTemplate.tip1': '1. When a route already have plugins field configured, the plugins in the plugin template will be merged into it.', 'component.plugin.pluginTemplate.tip2': '2. The same plugin in the plugin template will override one in the plugins', + + // proxxy-mirror + 'component.pluginForm.proxy-mirror.host.tooltip': 'Specify a mirror service address, e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)', }; diff --git a/web/src/components/Plugin/locales/zh-CN.ts b/web/src/components/Plugin/locales/zh-CN.ts index f563a29330..3eb021181c 100644 --- a/web/src/components/Plugin/locales/zh-CN.ts +++ b/web/src/components/Plugin/locales/zh-CN.ts @@ -21,4 +21,7 @@ export default { 'component.step.select.pluginTemplate.select.option': '手动配置', 'component.plugin.pluginTemplate.tip1': '1. 若路由已配置插件,则插件模板数据将与已配置的插件数据合并。', 'component.plugin.pluginTemplate.tip2': '2. 插件模板相同的插件会覆盖掉原有的插件。', + + // proxxy-mirror + 'component.pluginForm.proxy-mirror.host.tooltip': '指定镜像服务地址,例如:http://127.0.0.1:9797(地址中需要包含 schema :http或https,不能包含 URI 部分)', }; From 814892b0d5f65769f41fd357cff356d4e6c77e63 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Sun, 11 Apr 2021 11:36:16 +0800 Subject: [PATCH 17/18] fix: lint --- web/src/components/Plugin/locales/en-US.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/Plugin/locales/en-US.ts b/web/src/components/Plugin/locales/en-US.ts index ffad97d44d..e8f394096d 100644 --- a/web/src/components/Plugin/locales/en-US.ts +++ b/web/src/components/Plugin/locales/en-US.ts @@ -21,7 +21,7 @@ export default { 'component.step.select.pluginTemplate.select.option': 'Custom', 'component.plugin.pluginTemplate.tip1': '1. When a route already have plugins field configured, the plugins in the plugin template will be merged into it.', 'component.plugin.pluginTemplate.tip2': '2. The same plugin in the plugin template will override one in the plugins', - + // proxxy-mirror 'component.pluginForm.proxy-mirror.host.tooltip': 'Specify a mirror service address, e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)', }; From 53e7ac3c19674025f783dd458c6e09d82b3f9666 Mon Sep 17 00:00:00 2001 From: litesun <7sunmiao@gmail.com> Date: Mon, 12 Apr 2021 22:12:31 +0800 Subject: [PATCH 18/18] feat: add rule tip --- web/src/components/Plugin/UI/proxy-mirror.tsx | 8 ++++++++ web/src/components/Plugin/locales/en-US.ts | 2 ++ web/src/components/Plugin/locales/zh-CN.ts | 3 +++ 3 files changed, 13 insertions(+) diff --git a/web/src/components/Plugin/UI/proxy-mirror.tsx b/web/src/components/Plugin/UI/proxy-mirror.tsx index 29fc6da5b0..6fe6f40315 100644 --- a/web/src/components/Plugin/UI/proxy-mirror.tsx +++ b/web/src/components/Plugin/UI/proxy-mirror.tsx @@ -43,7 +43,15 @@ const ProxyMirror: React.FC = ({ form }) => { diff --git a/web/src/components/Plugin/locales/en-US.ts b/web/src/components/Plugin/locales/en-US.ts index e3c942966a..b8069edc7e 100644 --- a/web/src/components/Plugin/locales/en-US.ts +++ b/web/src/components/Plugin/locales/en-US.ts @@ -24,6 +24,8 @@ export default { // proxxy-mirror 'component.pluginForm.proxy-mirror.host.tooltip': 'Specify a mirror service address, e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)', + 'component.pluginForm.proxy-mirror.host.extra': 'e.g. http://127.0.0.1:9797 (address needs to contain schema: http or https, not URI part)', + 'component.pluginForm.proxy-mirror.host.ruletip': 'address needs to contain schema: http or https, not URI part', // limit-conn 'component.pluginForm.limit-conn.conn.tooltip': 'the maximum number of concurrent requests allowed. Requests exceeding this ratio (and below conn + burst) will get delayed(the latency seconds is configured by default_conn_delay) to conform to this threshold.', diff --git a/web/src/components/Plugin/locales/zh-CN.ts b/web/src/components/Plugin/locales/zh-CN.ts index f82047eaa4..8642439670 100644 --- a/web/src/components/Plugin/locales/zh-CN.ts +++ b/web/src/components/Plugin/locales/zh-CN.ts @@ -24,6 +24,9 @@ export default { // proxxy-mirror 'component.pluginForm.proxy-mirror.host.tooltip': '指定镜像服务地址,例如:http://127.0.0.1:9797(地址中需要包含 schema :http或https,不能包含 URI 部分)', + 'component.pluginForm.proxy-mirror.host.extra': '例如:http://127.0.0.1:9797(地址中需要包含 schema:http或https,不能包含 URI 部分)', + 'component.pluginForm.proxy-mirror.host.ruletip': '地址中需要包含 schema :http或https,不能包含 URI 部分', + // limit-conn 'component.pluginForm.limit-conn.conn.tooltip': '允许的最大并发请求数。超过 conn 的限制、但是低于 conn + burst 的请求,将被延迟处理。', 'component.pluginForm.limit-conn.burst.tooltip': '允许被延迟处理的并发请求数。',