Add inputs form to second step form
[arvados-workbench2.git] / src / store / favorite-panel / favorite-panel-middleware-service.ts
index 96f666479dc644b85bd4bd3adf3270f544897db2..acdc12b4d3c6b90e112bb5fc1e384f274fbd9f6f 100644 (file)
@@ -16,7 +16,7 @@ import { OrderBuilder, OrderDirection } from "~/services/api/order-builder";
 import { LinkResource } from "~/models/link";
 import { GroupContentsResource, GroupContentsResourcePrefix } from "~/services/groups-service/groups-service";
 import { resourcesActions } from "~/store/resources/resources-actions";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
 import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions.ts';
 import { getDataExplorer } from "~/store/data-explorer/data-explorer-reducer";
 import { loadMissingProcessesInformation } from "~/store/project-panel/project-panel-middleware-service";
@@ -50,7 +50,7 @@ export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareServic
                     .addOrder(direction, "name", GroupContentsResourcePrefix.PROJECT);
             }
             try {
-                api.dispatch(progressIndicatorActions.START(this.getId()));
+                api.dispatch(progressIndicatorActions.START_WORKING(this.getId()));
                 const response = await this.services.favoriteService
                     .list(this.services.authService.getUuid()!, {
                         limit: dataExplorer.rowsPerPage,
@@ -62,7 +62,7 @@ export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareServic
                             .addILike("name", dataExplorer.searchValue)
                             .getFilters()
                     });
-                api.dispatch(progressIndicatorActions.PERSIST_STOP(this.getId()));
+                api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
                 api.dispatch(resourcesActions.SET_RESOURCES(response.items));
                 await api.dispatch<any>(loadMissingProcessesInformation(response.items));
                 api.dispatch(favoritePanelActions.SET_ITEMS({
@@ -73,13 +73,14 @@ export class FavoritePanelMiddlewareService extends DataExplorerMiddlewareServic
                 }));
                 api.dispatch<any>(updateFavorites(response.items.map(item => item.uuid)));
             } catch (e) {
-                api.dispatch(progressIndicatorActions.PERSIST_STOP(this.getId()));
+                api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
                 api.dispatch(favoritePanelActions.SET_ITEMS({
                     items: [],
                     itemsAvailable: 0,
                     page: 0,
                     rowsPerPage: dataExplorer.rowsPerPage
                 }));
+                api.dispatch(couldNotFetchFavoritesContents());
             }
         }
     }
@@ -89,3 +90,9 @@ const favoritesPanelDataExplorerIsNotSet = () =>
     snackbarActions.OPEN_SNACKBAR({
         message: 'Favorites panel is not ready.'
     });
+
+const couldNotFetchFavoritesContents = () =>
+    snackbarActions.OPEN_SNACKBAR({
+        message: 'Could not fetch favorites contents.',
+        kind: SnackbarKind.ERROR
+    });