This is an automated email from the ASF dual-hosted git repository.
liuxiran 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 5198854 fix: delete null value in request body (#2042)
5198854 is described below
commit 5198854d5dc47f5181326e469d2e1bd86234a978
Author: Baoyuan <[email protected]>
AuthorDate: Sat Aug 7 16:41:49 2021 -0500
fix: delete null value in request body (#2042)
---
web/cypress/integration/route/search-route.spec.js | 2 +-
.../upstream/create_and_delete_upstream.spec.js | 2 ++
web/src/app.tsx | 15 +++++++++++++++
web/src/components/Upstream/locales/en-US.ts | 1 +
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/web/cypress/integration/route/search-route.spec.js
b/web/cypress/integration/route/search-route.spec.js
index 77b5def..167e0b2 100644
--- a/web/cypress/integration/route/search-route.spec.js
+++ b/web/cypress/integration/route/search-route.spec.js
@@ -95,7 +95,7 @@ context('Create and Search Route', () => {
});
});
- cy.contains('Next').click();
+ cy.contains('button', 'Next').should('not.be.disabled').click();
cy.get(selector.nodes_0_host).type(data.host2, {
timeout,
});
diff --git
a/web/cypress/integration/upstream/create_and_delete_upstream.spec.js
b/web/cypress/integration/upstream/create_and_delete_upstream.spec.js
index 31aba9f..5e6cd92 100644
--- a/web/cypress/integration/upstream/create_and_delete_upstream.spec.js
+++ b/web/cypress/integration/upstream/create_and_delete_upstream.spec.js
@@ -58,6 +58,8 @@ context('Create and Delete Upstream', () => {
cy.get(selector.nodes_0_host).type(data.ip1);
cy.get(selector.nodes_0_port).clear().type('7000');
cy.get(selector.nodes_0_weight).clear().type(1);
+ cy.get('#custom_checks_active').click();
+ cy.get('#checks_active_port').clear();
cy.contains('Next').click();
cy.get(selector.input).should('be.disabled');
cy.contains('Submit').click();
diff --git a/web/src/app.tsx b/web/src/app.tsx
index a152e33..421febe 100644
--- a/web/src/app.tsx
+++ b/web/src/app.tsx
@@ -18,6 +18,7 @@ import React from 'react';
import { history } from 'umi';
import type { RequestConfig } from 'umi';
import type { Settings as LayoutSettings } from '@ant-design/pro-layout';
+import { isPlainObject } from 'lodash';
import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer';
@@ -55,6 +56,17 @@ export const layout = ({ initialState }: { initialState: {
settings?: LayoutSett
};
};
+/* eslint no-param-reassign: ["error", { "props": true,
"ignorePropertyModificationsFor": ["obj"] }] */
+const nullValueFilter = (obj: Record<string, any>) => {
+ Object.entries(obj).forEach(([key, value]) => {
+ if (isPlainObject(value)) {
+ nullValueFilter(value);
+ } else if ([null, undefined].includes(value)) {
+ delete obj[key];
+ }
+ });
+};
+
export const request: RequestConfig = {
prefix: '/apisix/admin',
errorHandler,
@@ -62,6 +74,9 @@ export const request: RequestConfig = {
requestInterceptors: [
(url, options) => {
const newOptions = { ...options };
+ if (newOptions.data) {
+ nullValueFilter(newOptions.data);
+ }
newOptions.headers = {
...options.headers,
Authorization: localStorage.getItem('token') || '',
diff --git a/web/src/components/Upstream/locales/en-US.ts
b/web/src/components/Upstream/locales/en-US.ts
index 6bb9cb6..f865624 100644
--- a/web/src/components/Upstream/locales/en-US.ts
+++ b/web/src/components/Upstream/locales/en-US.ts
@@ -60,6 +60,7 @@ export default {
'component.upstream.fields.checks.active.http_path': 'HTTP Path',
'component.upstream.fields.checks.active.http_path.tooltip':
'The path that should be used when issuing the HTTP GET request to the
target. The default value is /.',
+ 'component.upstream.fields.checks.active.http_path.placeholder': 'Please
enter HTTP path',
'component.upstream.fields.checks.active.https_verify_certificate': 'Verify
HTTPs Certificate',
'component.upstream.fields.checks.active.https_verify_certificate.tooltip':