Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cfa6394

Browse files
committedNov 18, 2023
mapParams - replace mapPageToOffset calls with mapParams to also include sort
1 parent bdc78dd commit cfa6394

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed
 

‎src/api/base.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export class BaseAPI {
4747
return params;
4848
}
4949

50+
public mapParams(params) {
51+
return {
52+
params: this.mapSort(
53+
this.mapPageToOffset ? this.mapPageToOffset(params) : params,
54+
),
55+
};
56+
}
57+
5058
// The api uses sort/ordering/order_by for sort
5159
// the UI uses sort and maps to whatever the api expects
5260
// (set sortParam)
@@ -60,11 +68,7 @@ export class BaseAPI {
6068
}
6169

6270
list(params?: object, apiPath?: string) {
63-
return this.http.get(this.getPath(apiPath), {
64-
params: this.mapSort(
65-
this.mapPageToOffset ? this.mapPageToOffset(params) : params,
66-
),
67-
});
71+
return this.http.get(this.getPath(apiPath), this.mapParams(params));
6872
}
6973

7074
get(id: string, apiPath?: string) {

‎src/api/collection-version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class API extends HubAPI {
3333
getUsedDependenciesByCollection(namespace, collection, params = {}) {
3434
return this.http.get(
3535
this.apiPath + `?dependency=${namespace}.${collection}`,
36-
{ params: this.mapPageToOffset(params) },
36+
this.mapParams(params),
3737
);
3838
}
3939

‎src/api/collection.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class API extends HubAPI {
147147
getUsedDependenciesByCollection(namespace, collection, params = {}) {
148148
return this.http.get(
149149
`_ui/v1/collection-versions/?dependency=${namespace}.${collection}`,
150-
{ params: this.mapPageToOffset(params) },
150+
this.mapParams(params),
151151
);
152152
}
153153

‎src/api/execution-environment.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ class API extends HubAPI {
1212
}
1313

1414
images(name, params) {
15-
return this.http.get(this.apiPath + `${name}/_content/images/`, {
16-
params: this.mapPageToOffset(params),
17-
});
15+
return this.http.get(
16+
this.apiPath + `${name}/_content/images/`,
17+
this.mapParams(params),
18+
);
1819
}
1920

2021
image(name, digest) {
2122
return this.http.get(this.apiPath + `${name}/_content/images/${digest}/`);
2223
}
2324

2425
tags(name, params) {
25-
return this.http.get(this.apiPath + `${name}/_content/tags/`, {
26-
params: this.mapPageToOffset(params),
27-
});
26+
return this.http.get(
27+
this.apiPath + `${name}/_content/tags/`,
28+
this.mapParams(params),
29+
);
2830
}
2931

3032
deleteImage(name, manifest) {

0 commit comments

Comments
 (0)
Please sign in to comment.