You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by gu...@apache.org on 2023/03/08 06:06:44 UTC

[apisix-dashboard] branch master updated: fix: change regex template to optional in proxy write (#2762)

This is an automated email from the ASF dual-hosted git repository.

guoqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 80d051f6 fix: change regex template to optional in proxy write (#2762)
80d051f6 is described below

commit 80d051f62dfdb0f6a178c959fca5193a3244bb13
Author: Baoyuan <ba...@gmail.com>
AuthorDate: Wed Mar 8 14:06:37 2023 +0800

    fix: change regex template to optional in proxy write (#2762)
---
 .../create-route-with-proxy-rewrite-plugin.cy.js   | 28 +++++++++++++++++++++-
 .../pages/Route/components/Step1/ProxyRewrite.tsx  |  9 +------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/web/cypress/e2e/route/create-route-with-proxy-rewrite-plugin.cy.js b/web/cypress/e2e/route/create-route-with-proxy-rewrite-plugin.cy.js
index 721d317c..4086a4bc 100644
--- a/web/cypress/e2e/route/create-route-with-proxy-rewrite-plugin.cy.js
+++ b/web/cypress/e2e/route/create-route-with-proxy-rewrite-plugin.cy.js
@@ -15,8 +15,8 @@
  * limitations under the License.
  */
 /* eslint-disable no-undef */
-import menuLocaleUS from '../../../src/locales/en-US/menu';
 import componentLocaleUS from '../../../src/locales/en-US/component';
+import menuLocaleUS from '../../../src/locales/en-US/menu';
 import routeLocaleUS from '../../../src/pages/Route/locales/en-US';
 
 context('create route with proxy-rewrite plugin', () => {
@@ -29,6 +29,7 @@ context('create route with proxy-rewrite plugin', () => {
     deleteAlert: '.ant-modal-body',
     notification: '.ant-notification-notice-message',
     staticUri: '[data-cy=uri-static]',
+    regexUri: '[data-cy=uri-regex]',
     staticHost: '[data-cy=host-static]',
     keepHost: '[data-cy=host-keep]',
     newUri: '#proxyRewrite_uri',
@@ -56,6 +57,7 @@ context('create route with proxy-rewrite plugin', () => {
     rewriteHeaderKey2: 'test2',
     rewriteHeaderValue1: '1',
     rewriteHeaderValue2: '2',
+    regex: '^/iresty/(.)/(.)/(.*)',
   };
 
   beforeEach(() => {
@@ -154,6 +156,30 @@ context('create route with proxy-rewrite plugin', () => {
     cy.contains(data.submitSuccess).should('be.visible');
   });
 
+  it('should use proxy rewrite in regex uri moode without template', () => {
+    cy.visit('/');
+    cy.contains(menuLocaleUS['menu.routes']).click();
+
+    cy.get(selector.nameSelector).type(data.routeName);
+    cy.contains('Search').click();
+    cy.contains(data.routeName).siblings().contains('Configure').click();
+
+    cy.get('#status').should('have.class', 'ant-switch-checked');
+    cy.get(selector.regexUri).click();
+    cy.get(selector.uriRewriteReg).should('be.visible').type(data.regex);
+    cy.get(selector.uriRewriteTemp).should('have.value', '');
+    cy.contains('Next').click();
+    cy.get(selector.nodes_0_host).type(data.host2);
+    cy.get(selector.nodes_0_port).type(data.port);
+    cy.get(selector.nodes_0_weight).type(data.weight);
+    cy.contains('Next').click();
+
+    cy.contains('proxy-rewrite').should('not.exist');
+    cy.contains('Next').click();
+    cy.contains('Submit').click();
+    cy.contains(data.submitSuccess).should('be.visible');
+  });
+
   it('should delete the route', function () {
     cy.visit('/routes/list');
     cy.get(selector.nameSelector).type(data.routeName);
diff --git a/web/src/pages/Route/components/Step1/ProxyRewrite.tsx b/web/src/pages/Route/components/Step1/ProxyRewrite.tsx
index 7770ab21..cbe87384 100644
--- a/web/src/pages/Route/components/Step1/ProxyRewrite.tsx
+++ b/web/src/pages/Route/components/Step1/ProxyRewrite.tsx
@@ -100,14 +100,6 @@ const ProxyRewrite: React.FC<RouteModule.Step1PassProps> = ({ form, disabled })
                         label={formatMessage({ id: 'page.route.form.itemLabel.template' })}
                         name={field.name}
                         key={field.name}
-                        rules={[
-                          {
-                            required: true,
-                            message: `${formatMessage({
-                              id: 'component.global.pleaseEnter',
-                            })} ${formatMessage({ id: 'page.route.form.itemLabel.template' })}`,
-                          },
-                        ]}
                       >
                         <Input
                           placeholder={`${formatMessage({
@@ -206,6 +198,7 @@ const ProxyRewrite: React.FC<RouteModule.Step1PassProps> = ({ form, disabled })
       {
         value: URI_REWRITE_TYPE.REGEXP,
         label: formatMessage({ id: 'page.route.radio.regex' }),
+        dataCypress: 'uri-regex',
       },
     ];