Просмотр исходного кода

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>
Mihaela Balutoiu 6 месяцев назад
Родитель
Сommit
cd1b9ce75a
2 измененных файлов с 11 добавлено и 1 удалено
  1. 7 0
      src/sources/InstanceSource.ts
  2. 4 1
      src/stores/InstanceStore.ts

+ 7 - 0
src/sources/InstanceSource.ts

@@ -36,6 +36,7 @@ class InstanceSource {
     searchText?: string;
     env?: any;
     cache?: boolean;
+    refresh?: boolean;
   }): Promise<[Instance[], Instance[]]> {
     const {
       endpointId,
@@ -45,6 +46,7 @@ class InstanceSource {
       cancelId,
       env,
       searchText,
+      refresh,
     } = opts;
     let url = `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/endpoints/${endpointId}/instances`;
     let queryParams: { [prop: string]: string | number } = {};
@@ -59,6 +61,11 @@ class InstanceSource {
           ...queryParams,
           marker: lastInstanceId,
         };
+      } else if (refresh) {
+        queryParams = {
+          ...queryParams,
+          marker: "refresh",
+        };
       }
     }
 

+ 4 - 1
src/stores/InstanceStore.ts

@@ -77,8 +77,9 @@ class InstanceStore {
     reload?: boolean;
     env?: any;
     useCache?: boolean;
+    refresh?: boolean;
   }) {
-    const { endpoint, vmsPerPage, reload, env, useCache } = options;
+    const { endpoint, vmsPerPage, reload, env, useCache, refresh } = options;
     const usableVmsPerPage = vmsPerPage || 6;
 
     ApiCaller.cancelRequests(`${endpoint.id}-chunk`);
@@ -107,6 +108,7 @@ class InstanceStore {
           cancelId: `${endpoint.id}-chunk`,
           env,
           cache: useCache,
+          refresh: refresh && !lastEndpointId,
         });
       if (currentEndpointId !== this.lastEndpointId) {
         return;
@@ -272,6 +274,7 @@ class InstanceStore {
       vmsPerPage: chunkSize,
       reload: true,
       env,
+      refresh: true,
     });
   }