This is an automated email from the ASF dual-hosted git repository.
juzhiyuan 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 b0dfcb4 fix: websocket enable in route (#2052)
b0dfcb4 is described below
commit b0dfcb4b85c9ab7949fd741acf18d062bdd8ff9f
Author: Baoyuan <[email protected]>
AuthorDate: Mon Aug 9 22:42:03 2021 -0500
fix: websocket enable in route (#2052)
---
...an-skip-upstream-when-select-service-id.spec.js | 3 +++
.../create-edit-route-with-redirect-plugin.spec.js | 6 ++++++
web/src/pages/Route/components/Step1/MetaView.tsx | 23 +++++++++++-----------
web/src/pages/Route/transform.ts | 1 +
4 files changed, 22 insertions(+), 11 deletions(-)
diff --git
a/web/cypress/integration/route/can-skip-upstream-when-select-service-id.spec.js
b/web/cypress/integration/route/can-skip-upstream-when-select-service-id.spec.js
index f53b842..2333ac0 100644
---
a/web/cypress/integration/route/can-skip-upstream-when-select-service-id.spec.js
+++
b/web/cypress/integration/route/can-skip-upstream-when-select-service-id.spec.js
@@ -29,6 +29,7 @@ context('Can select service_id skip upstream in route', () =>
{
serviceSelector: '[title=test_service]',
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
+ enable_websocket: '#enable_websocket',
};
const data = {
@@ -93,6 +94,7 @@ context('Can select service_id skip upstream in route', () =>
{
cy.wait(500);
cy.contains('None').click();
cy.contains(data.serviceName).click();
+ cy.get(selector.enable_websocket).click();
cy.contains('Next').click();
// make sure upstream data can be saved
@@ -116,6 +118,7 @@ context('Can select service_id skip upstream in route', ()
=> {
cy.contains('Search').click();
cy.contains(data.routeName).siblings().contains('Configure').click();
cy.get(selector.serviceSelector).click();
+ cy.get(selector.enable_websocket).should('have.class',
'ant-switch-checked');
cy.contains('None').click();
cy.contains('Next').click();
cy.wait(500);
diff --git
a/web/cypress/integration/route/create-edit-route-with-redirect-plugin.spec.js
b/web/cypress/integration/route/create-edit-route-with-redirect-plugin.spec.js
index 15662dc..bcfbb42 100644
---
a/web/cypress/integration/route/create-edit-route-with-redirect-plugin.spec.js
+++
b/web/cypress/integration/route/create-edit-route-with-redirect-plugin.spec.js
@@ -31,6 +31,8 @@ context('Create Edit and Delete Route with redirect plugin',
() => {
deleteAlert: '.ant-modal-body',
notificationCloseIcon: '.ant-notification-close-icon',
notification: '.ant-notification-notice-message',
+ webSocketSelector: '[title=WebSocket]',
+ enable_websocket_button: '#enable_websocket',
};
const data = {
@@ -59,6 +61,8 @@ context('Create Edit and Delete Route with redirect plugin',
() => {
cy.get(selector.customRedirectLabel).should('be.visible');
cy.get(selector.customRedirectUrI).should('be.visible');
cy.get(selector.customRedirectCode).should('be.visible');
+ cy.get(selector.webSocketSelector).should('not.exist');
+ cy.get(selector.enable_websocket_button).should('not.exist');
// step 2 and step 3 should not be visible
cy.contains(data.step2Title).should('not.exist');
@@ -87,6 +91,8 @@ context('Create Edit and Delete Route with redirect plugin',
() => {
// should not shown set upstream notice
cy.contains(data.setUpstreamNotice).should('not.exist');
cy.get(selector.name).clear().type(newName);
+ cy.get(selector.webSocketSelector).should('not.exist');
+ cy.get(selector.enable_websocket_button).should('not.exist');
cy.contains('Next').click();
cy.contains('Submit').click();
diff --git a/web/src/pages/Route/components/Step1/MetaView.tsx
b/web/src/pages/Route/components/Step1/MetaView.tsx
index 1d56c18..7309f14 100644
--- a/web/src/pages/Route/components/Step1/MetaView.tsx
+++ b/web/src/pages/Route/components/Step1/MetaView.tsx
@@ -185,17 +185,18 @@ const MetaView: React.FC<RouteModule.Step1PassProps> = ({
</Form.Item>
);
- const WebSocket: React.FC = () => (
- <Form.Item label="WebSocket">
- <Row>
- <Col>
- <Form.Item noStyle valuePropName="checked" name="enable_websocket">
- <Switch disabled={disabled} />
- </Form.Item>
- </Col>
- </Row>
- </Form.Item>
- );
+ const WebSocket: React.FC = () =>
+ form.getFieldValue('redirectOption') === 'disabled' ? (
+ <Form.Item label="WebSocket">
+ <Row>
+ <Col>
+ <Form.Item noStyle valuePropName="checked" name="enable_websocket">
+ <Switch disabled={disabled} />
+ </Form.Item>
+ </Col>
+ </Row>
+ </Form.Item>
+ ) : null;
const Redirect: React.FC = () => {
const list = [
diff --git a/web/src/pages/Route/transform.ts b/web/src/pages/Route/transform.ts
index bd9c597..91a3bc6 100644
--- a/web/src/pages/Route/transform.ts
+++ b/web/src/pages/Route/transform.ts
@@ -239,6 +239,7 @@ export const transformStepData = ({
'redirect',
'plugins',
'labels',
+ 'enable_websocket',
data.vars?.length ? 'vars' : '',
service_id.length !== 0 ? 'service_id' : '',
form1Data.hosts.filter(Boolean).length !== 0 ? 'hosts' : '',