Skip to content

Commit

Permalink
UI remove query-string package and unused commit arg
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Dec 8, 2023
1 parent 0fbd104 commit 1406e41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 98 deletions.
81 changes: 0 additions & 81 deletions webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 7 additions & 16 deletions webui/src/lib/api/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import queryString from "query-string"

export const API_ENDPOINT = '/api/v1';
export const DEFAULT_LISTING_AMOUNT = 100;

Expand All @@ -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,
Expand All @@ -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') {
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 1406e41

Please sign in to comment.