From 7b5204917d966fd513644ba6944509069d3c9be3 Mon Sep 17 00:00:00 2001 From: Damian Stasik Date: Sun, 26 Sep 2021 16:06:51 +0200 Subject: [PATCH 1/2] refactor: replace query-string with URLSearchParams --- package-lock.json | 76 +++------------------ package.json | 1 - src/dashboard/Data/Browser/Browser.react.js | 19 +++--- src/dashboard/Push/PushNew.react.js | 7 +- 4 files changed, 20 insertions(+), 83 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1e6a7ff990..01290ae0d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4202,9 +4202,9 @@ "dev": true }, "codemirror": { - "version": "5.62.3", - "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.62.3.tgz", - "integrity": "sha512-zZAyOfN8TU67ngqrxhOgtkSAGV9jSpN1snbl8elPtnh9Z5A11daR405+dhLzLnuXrwX0WCShWlybxPN3QC/9Pg==" + "version": "5.63.0", + "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.63.0.tgz", + "integrity": "sha512-KlLWRPggDg2rBD1Mx7/EqEhaBdy+ybBCVh/efgjBDsPpMeEu6MbTAJzIT4TuCzvmbTEgvKOGzVT6wdBTNusqrg==" }, "codemirror-graphql": { "version": "github:timsuchanek/codemirror-graphql#801ec32683c38d6dc0f8f7bc19014a111edc9ebd", @@ -7656,11 +7656,6 @@ } } }, - "filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=" - }, "finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", @@ -8224,30 +8219,6 @@ "codemirror": "^5.26.0", "codemirror-graphql": "^0.6.11", "markdown-it": "^8.4.0" - }, - "dependencies": { - "codemirror-graphql": { - "version": "0.6.12", - "resolved": "https://registry.npmjs.org/codemirror-graphql/-/codemirror-graphql-0.6.12.tgz", - "integrity": "sha512-7YP956JubbWkmk9QqKy62CZgdGbEulHNJkz2/aUDTpsE1KrQtRrT9WzStJaxAOEX2k4wUOpojUX2ItPxa69kFA==", - "requires": { - "graphql-language-service-interface": "^1.0.16", - "graphql-language-service-parser": "^0.1.14" - } - }, - "graphql-language-service-parser": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/graphql-language-service-parser/-/graphql-language-service-parser-0.1.14.tgz", - "integrity": "sha512-72M4OksONeqT5slfdfODmlPBFlUQQkcnRhjgmPt9H2n8/DUcf4XzDkGXudBWpzNfjVU35+IADYW6x13wKw/fOg==", - "requires": { - "graphql-language-service-types": "^0.1.14" - } - }, - "graphql-language-service-types": { - "version": "0.1.14", - "resolved": "https://registry.npmjs.org/graphql-language-service-types/-/graphql-language-service-types-0.1.14.tgz", - "integrity": "sha512-77KP83gvK0gWswvGY/+jx/GpsOfKuwWQ1AYnyPT2GDGG3//1QxQTObaZMAEevNTxJtO8T26YXxoUlqkvET7iEg==" - } } }, "graphql": { @@ -8370,14 +8341,6 @@ "zen-observable": "^0.7.1" }, "dependencies": { - "codemirror-graphql": { - "version": "github:timsuchanek/codemirror-graphql#801ec32683c38d6dc0f8f7bc19014a111edc9ebd", - "from": "github:timsuchanek/codemirror-graphql#details-fix", - "requires": { - "graphql-language-service-interface": "^1.0.18", - "graphql-language-service-parser": "^1.0.18" - } - }, "graphql": { "version": "0.11.7", "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.11.7.tgz", @@ -8409,16 +8372,6 @@ "isarray": "0.0.1" } }, - "query-string": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", - "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", - "requires": { - "decode-uri-component": "^0.2.0", - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" - } - }, "react-helmet": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-5.2.1.tgz", @@ -15088,21 +15041,13 @@ "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, "query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", "requires": { "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "dependencies": { - "strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" - } + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" } }, "querystring": { @@ -17081,11 +17026,6 @@ "through": "2" } }, - "split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==" - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", diff --git a/package.json b/package.json index f3d13c2d1d..90522747ab 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "prismjs": "1.25.0", "prop-types": "15.7.2", "qrcode": "1.4.4", - "query-string": "6.14.1", "react": "16.14.0", "react-ace": "9.4.3", "react-dnd": "10.0.2", diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index 031ad71cff..e85edb50d4 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -34,7 +34,6 @@ import stringCompare from 'lib/stringCompare'; import styles from 'dashboard/Data/Browser/Browser.scss'; import subscribeTo from 'lib/subscribeTo'; import * as ColumnPreferences from 'lib/ColumnPreferences'; -import * as queryString from 'query-string'; import { Helmet } from 'react-helmet'; import PropTypes from 'lib/PropTypes'; import ParseApp from 'lib/ParseApp'; @@ -213,9 +212,9 @@ class Browser extends DashboardView { if (!props || !props.location || !props.location.search) { return filters; } - const query = queryString.parse(props.location.search); - if (query.filters) { - const queryFilters = JSON.parse(query.filters); + const query = new URLSearchParams(props.location.search); + if (query.has('filters')) { + const queryFilters = JSON.parse(query.get('filters')); queryFilters.forEach((filter) => filters = filters.push(new Map(filter))); } return filters; @@ -397,7 +396,7 @@ class Browser extends DashboardView { if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) { return; } - if (!!required) { + if (required) { requiredCols.push(name); } if (className === '_User' && (name === 'username' || name === 'password')) { @@ -414,7 +413,7 @@ class Browser extends DashboardView { for (let idx = 0; idx < requiredCols.length; idx++) { const name = requiredCols[idx]; if (!obj.get(name)) { - this.showNote("Please enter all required fields", true); + this.showNote('Please enter all required fields', true); this.setState({ markRequiredFieldRow: -1 }); @@ -452,7 +451,7 @@ class Browser extends DashboardView { }); }, error => { - let msg = typeof error === "string" ? error : error.message; + let msg = typeof error === 'string' ? error : error.message; if (msg) { msg = msg[0].toUpperCase() + msg.substr(1); } @@ -472,7 +471,7 @@ class Browser extends DashboardView { this.setState(state); }, error => { - let msg = typeof error === "string" ? error : error.message; + let msg = typeof error === 'string' ? error : error.message; if (msg) { msg = msg[0].toUpperCase() + msg.substr(1); } @@ -501,7 +500,7 @@ class Browser extends DashboardView { if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) { return; } - if (!!required) { + if (required) { requiredCols.push(name); } if (className === '_User' && (name === 'username' || name === 'password')) { @@ -518,7 +517,7 @@ class Browser extends DashboardView { for (let idx = 0; idx < requiredCols.length; idx++) { const name = requiredCols[idx]; if (!obj.get(name)) { - this.showNote("Please enter all required fields", true); + this.showNote('Please enter all required fields', true); this.setState({ markRequiredFieldRow: rowIndex }); diff --git a/src/dashboard/Push/PushNew.react.js b/src/dashboard/Push/PushNew.react.js index e75704644b..ad5ecc2171 100644 --- a/src/dashboard/Push/PushNew.react.js +++ b/src/dashboard/Push/PushNew.react.js @@ -36,7 +36,6 @@ import Toggle from 'components/Toggle/Toggle.react'; import Toolbar from 'components/Toolbar/Toolbar.react'; import { Directions } from 'lib/Constants'; import { extractExpiration, extractPushTime } from 'lib/extractTime'; -import * as queryString from 'query-string'; const PARSE_SERVER_SUPPORTS_AB_TESTING = false; @@ -148,11 +147,11 @@ class PushNew extends DashboardView { componentWillMount() { this.props.schema.dispatch(SchemaStore.ActionTypes.FETCH); let options = { xhrKey: XHR_KEY }; - const query = queryString.parse(this.props.location.search); - if (query.audienceId) { + const query = new URLSearchParams(this.props.location.search); + if (query.has('audienceId')) { options.limit = PushConstants.SHOW_MORE_LIMIT; options.min = PushConstants.INITIAL_PAGE_SIZE; - this.setState({ initialAudienceId: query.audienceId }); + this.setState({ initialAudienceId: query.get('audienceId') }); } this.props.pushaudiences.dispatch(PushAudiencesStore.ActionTypes.FETCH, options).then(() => { From 449fac365a4933825ad0a05d2fdac40d9b0645e0 Mon Sep 17 00:00:00 2001 From: Damian Stasik Date: Mon, 4 Oct 2021 17:47:00 +0200 Subject: [PATCH 2/2] chore: revert eslint changes --- src/dashboard/Data/Browser/Browser.react.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dashboard/Data/Browser/Browser.react.js b/src/dashboard/Data/Browser/Browser.react.js index e85edb50d4..b6e91ea62c 100644 --- a/src/dashboard/Data/Browser/Browser.react.js +++ b/src/dashboard/Data/Browser/Browser.react.js @@ -396,7 +396,7 @@ class Browser extends DashboardView { if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) { return; } - if (required) { + if (!!required) { requiredCols.push(name); } if (className === '_User' && (name === 'username' || name === 'password')) { @@ -413,7 +413,7 @@ class Browser extends DashboardView { for (let idx = 0; idx < requiredCols.length; idx++) { const name = requiredCols[idx]; if (!obj.get(name)) { - this.showNote('Please enter all required fields', true); + this.showNote("Please enter all required fields", true); this.setState({ markRequiredFieldRow: -1 }); @@ -451,7 +451,7 @@ class Browser extends DashboardView { }); }, error => { - let msg = typeof error === 'string' ? error : error.message; + let msg = typeof error === "string" ? error : error.message; if (msg) { msg = msg[0].toUpperCase() + msg.substr(1); } @@ -471,7 +471,7 @@ class Browser extends DashboardView { this.setState(state); }, error => { - let msg = typeof error === 'string' ? error : error.message; + let msg = typeof error === "string" ? error : error.message; if (msg) { msg = msg[0].toUpperCase() + msg.substr(1); } @@ -500,7 +500,7 @@ class Browser extends DashboardView { if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) { return; } - if (required) { + if (!!required) { requiredCols.push(name); } if (className === '_User' && (name === 'username' || name === 'password')) { @@ -517,7 +517,7 @@ class Browser extends DashboardView { for (let idx = 0; idx < requiredCols.length; idx++) { const name = requiredCols[idx]; if (!obj.get(name)) { - this.showNote('Please enter all required fields', true); + this.showNote("Please enter all required fields", true); this.setState({ markRequiredFieldRow: rowIndex });