Skip to content

Commit cd1b9ce

Browse files
mihaelabalutoiuDany9966
authored andcommitted
Add support for reload button with marker query parameter
Sends `marker=refresh` query parameter when the reload button is pressed to trigger a refresh of the cached `instance list`. Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
1 parent 6587a9d commit cd1b9ce

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/sources/InstanceSource.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class InstanceSource {
3636
searchText?: string;
3737
env?: any;
3838
cache?: boolean;
39+
refresh?: boolean;
3940
}): Promise<[Instance[], Instance[]]> {
4041
const {
4142
endpointId,
@@ -45,6 +46,7 @@ class InstanceSource {
4546
cancelId,
4647
env,
4748
searchText,
49+
refresh,
4850
} = opts;
4951
let url = `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/endpoints/${endpointId}/instances`;
5052
let queryParams: { [prop: string]: string | number } = {};
@@ -59,6 +61,11 @@ class InstanceSource {
5961
...queryParams,
6062
marker: lastInstanceId,
6163
};
64+
} else if (refresh) {
65+
queryParams = {
66+
...queryParams,
67+
marker: "refresh",
68+
};
6269
}
6370
}
6471

src/stores/InstanceStore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ class InstanceStore {
7777
reload?: boolean;
7878
env?: any;
7979
useCache?: boolean;
80+
refresh?: boolean;
8081
}) {
81-
const { endpoint, vmsPerPage, reload, env, useCache } = options;
82+
const { endpoint, vmsPerPage, reload, env, useCache, refresh } = options;
8283
const usableVmsPerPage = vmsPerPage || 6;
8384

8485
ApiCaller.cancelRequests(`${endpoint.id}-chunk`);
@@ -107,6 +108,7 @@ class InstanceStore {
107108
cancelId: `${endpoint.id}-chunk`,
108109
env,
109110
cache: useCache,
111+
refresh: refresh && !lastEndpointId,
110112
});
111113
if (currentEndpointId !== this.lastEndpointId) {
112114
return;
@@ -272,6 +274,7 @@ class InstanceStore {
272274
vmsPerPage: chunkSize,
273275
reload: true,
274276
env,
277+
refresh: true,
275278
});
276279
}
277280

0 commit comments

Comments
 (0)