diff --git a/webui/package-lock.json b/webui/package-lock.json index d5d48178b51..bcebc12c487 100644 --- a/webui/package-lock.json +++ b/webui/package-lock.json @@ -20,7 +20,6 @@ "lodash": "^4.17.21", "p-map": "^6.0.0", "prismjs": "^1.29.0", - "query-string": "^7.1.1", "react": "^18.2.0", "react-bootstrap": "^2.8.0", "react-diff-viewer-continued": "^3.2.3", @@ -4165,14 +4164,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/decode-uri-component": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", - "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", - "engines": { - "node": ">=0.10" - } - }, "node_modules/deep-eql": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", @@ -5316,14 +5307,6 @@ "node": ">=8" } }, - "node_modules/filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -8938,23 +8921,6 @@ "node": ">=6" } }, - "node_modules/query-string": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.1.tgz", - "integrity": "sha512-MplouLRDHBZSG9z7fpuAAcI7aAYjDLhtsiVZsevsfaHWDS2IDdORKbSd1kWUA+V4zyva/HZoSfpwnYMMQDhb0w==", - "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", @@ -9875,14 +9841,6 @@ "node": "^12.20.0 || >=14" } }, - "node_modules/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==", - "engines": { - "node": ">=6" - } - }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -9931,14 +9889,6 @@ "node": ">=10" } }, - "node_modules/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=", - "engines": { - "node": ">=4" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -14456,11 +14406,6 @@ } } }, - "decode-uri-component": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", - "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==" - }, "deep-eql": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", @@ -15322,11 +15267,6 @@ "to-regex-range": "^5.0.1" } }, - "filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=" - }, "find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -17871,17 +17811,6 @@ "dev": true, "peer": true }, - "query-string": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.1.tgz", - "integrity": "sha512-MplouLRDHBZSG9z7fpuAAcI7aAYjDLhtsiVZsevsfaHWDS2IDdORKbSd1kWUA+V4zyva/HZoSfpwnYMMQDhb0w==", - "requires": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - } - }, "querystringify": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", @@ -18534,11 +18463,6 @@ } } }, - "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==" - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -18580,11 +18504,6 @@ "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-3.0.1.tgz", "integrity": "sha512-EWZT9XOceBPlVJRrYcykW8jyRSZYbkb/0ZK36uLEmoWVO5gxBOnntNTseNzfREsqxqdfEGQrD8SXQ3QWbBmq8A==" }, - "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=" - }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", diff --git a/webui/package.json b/webui/package.json index a5be3807a44..06ce776e3fc 100644 --- a/webui/package.json +++ b/webui/package.json @@ -26,7 +26,6 @@ "lodash": "^4.17.21", "p-map": "^6.0.0", "prismjs": "^1.29.0", - "query-string": "^7.1.1", "react": "^18.2.0", "react-bootstrap": "^2.8.0", "react-diff-viewer-continued": "^3.2.3", diff --git a/webui/src/lib/api/index.js b/webui/src/lib/api/index.js index d8aaf2aa2fe..ccd789890fd 100644 --- a/webui/src/lib/api/index.js +++ b/webui/src/lib/api/index.js @@ -1,5 +1,3 @@ -import queryString from "query-string" - export const API_ENDPOINT = '/api/v1'; export const DEFAULT_LISTING_AMOUNT = 100; @@ -26,6 +24,11 @@ class LocalCache { const cache = new LocalCache(); +export const qs = (queryParts) => { + const parts = Object.keys(queryParts).map(key => [key, queryParts[key]]); + return new URLSearchParams(parts).toString(); +}; + export const linkToPath = (repoId, branchId, path, presign = false) => { const query = qs({ path, @@ -34,11 +37,6 @@ export const linkToPath = (repoId, branchId, path, presign = false) => { return `${API_ENDPOINT}/repositories/${repoId}/refs/${branchId}/objects?${query}`; }; -export const qs = (queryParts) => { - const parts = Object.keys(queryParts).map(key => [key, queryParts[key]]); - return new URLSearchParams(parts).toString(); -}; - export const extractError = async (response) => { let body; if (response.headers.get('Content-Type') === 'application/json') { @@ -751,18 +749,11 @@ class Commits { return response.json(); } - async commit(repoId, branchId, message, metadata = {}, source_metarange = "") { - const requestURL = queryString.stringifyUrl({ - url: `/repositories/${repoId}/branches/${branchId}/commits`, - query: {source_metarange: source_metarange} - }); - const parsedURL = queryString.exclude(requestURL, (name, value) => value === "", {parseNumbers: true}); - const response = await apiRequest(parsedURL, { - + async commit(repoId, branchId, message, metadata = {}) { + const response = await apiRequest(`/repositories/${repoId}/branches/${branchId}/commits`, { method: 'POST', body: JSON.stringify({message, metadata}), }); - if (response.status !== 201) { throw new Error(await extractError(response)); }