dataExplorerToListParams,
getDataExplorerColumnFilters,
listResultsToDataExplorerItemsMeta
-} from '../data-explorer/data-explorer-middleware-service';
-import { ProjectPanelColumnNames, ProjectPanelFilter } from "~/views/project-panel/project-panel";
-import { RootState } from "../store";
+} from '~/store/data-explorer/data-explorer-middleware-service';
+import { ProjectPanelColumnNames } from "~/views/project-panel/project-panel";
+import { RootState } from "~/store/store";
import { DataColumns } from "~/components/data-table/data-table";
import { ServiceRepository } from "~/services/services";
import { SortDirection } from "~/components/data-table/data-column";
import { OrderBuilder, OrderDirection } from "~/services/api/order-builder";
import { FilterBuilder, joinFilters } from "~/services/api/filter-builder";
import { GroupContentsResource, GroupContentsResourcePrefix } from "~/services/groups-service/groups-service";
-import { updateFavorites } from "../favorites/favorites-actions";
-import { PROJECT_PANEL_CURRENT_UUID, IS_PROJECT_PANEL_TRASHED, projectPanelActions } from './project-panel-action';
+import { updateFavorites } from "~/store/favorites/favorites-actions";
+import { IS_PROJECT_PANEL_TRASHED, projectPanelActions, getProjectPanelCurrentUuid } from '~/store/project-panel/project-panel-action';
import { Dispatch, MiddlewareAPI } from "redux";
import { ProjectResource } from "~/models/project";
import { updateResources } from "~/store/resources/resources-actions";
import { getProperty } from "~/store/properties/properties";
-import { snackbarActions, SnackbarKind } from '../snackbar/snackbar-actions';
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions.ts';
-import { DataExplorer, getDataExplorer } from '../data-explorer/data-explorer-reducer';
-import { ListResults } from '~/services/common-service/common-resource-service';
-import { loadContainers } from '../processes/processes-actions';
+import { DataExplorer, getDataExplorer } from '~/store/data-explorer/data-explorer-reducer';
+import { ListResults } from '~/services/common-service/common-service';
+import { loadContainers } from '~/store/processes/processes-actions';
import { ResourceKind } from '~/models/resource';
-import { getResource } from "~/store/resources/resources";
-import { CollectionResource } from "~/models/collection";
-import { resourcesDataActions } from "~/store/resources-data/resources-data-actions";
import { getSortColumn } from "~/store/data-explorer/data-explorer-reducer";
-import { serializeResourceTypeFilters } from '../resource-type-filters/resource-type-filters';
+import { serializeResourceTypeFilters, ProcessStatusFilter } from '~/store/resource-type-filters/resource-type-filters';
+import { updatePublicFavorites } from '~/store/public-favorites/public-favorites-actions';
export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService {
constructor(private services: ServiceRepository, id: string) {
async requestItems(api: MiddlewareAPI<Dispatch, RootState>) {
const state = api.getState();
const dataExplorer = getDataExplorer(state.dataExplorer, this.getId());
- const projectUuid = getProperty<string>(PROJECT_PANEL_CURRENT_UUID)(state.properties);
+ const projectUuid = getProjectPanelCurrentUuid(state);
const isProjectTrashed = getProperty<string>(IS_PROJECT_PANEL_TRASHED)(state.properties);
if (!projectUuid) {
api.dispatch(projectPanelCurrentUuidIsNotSet());
api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
const resourceUuids = response.items.map(item => item.uuid);
api.dispatch<any>(updateFavorites(resourceUuids));
+ api.dispatch<any>(updatePublicFavorites(resourceUuids));
api.dispatch(updateResources(response.items));
- api.dispatch<any>(updateResourceData(resourceUuids));
await api.dispatch<any>(loadMissingProcessesInformation(response.items));
api.dispatch(setItems(response));
} catch (e) {
}
};
-export const updateResourceData = (resourceUuids: string[]) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- resourceUuids.map(async uuid => {
- const resource = getResource<CollectionResource>(uuid)(getState().resources);
- if (resource && resource.kind === ResourceKind.COLLECTION) {
- const files = await services.collectionService.files(uuid);
- if (files) {
- dispatch(resourcesDataActions.SET_FILES({ uuid, files }));
- }
- }
- });
- };
-
export const setItems = (listResults: ListResults<GroupContentsResource>) =>
projectPanelActions.SET_ITEMS({
...listResultsToDataExplorerItemsMeta(listResults),
export const getFilters = (dataExplorer: DataExplorer) => {
const columns = dataExplorer.columns as DataColumns<string>;
const typeFilters = serializeResourceTypeFilters(getDataExplorerColumnFilters(columns, ProjectPanelColumnNames.TYPE));
+ const statusColumnFilters = getDataExplorerColumnFilters(columns, 'Status');
+ const activeStatusFilter = Object.keys(statusColumnFilters).find(
+ filterName => statusColumnFilters[filterName].selected
+ );
// TODO: Extract group contents name filter
const nameFilters = new FilterBuilder()
.addILike("name", dataExplorer.searchValue, GroupContentsResourcePrefix.PROJECT)
.getFilters();
+ // Filter by container status
+ const fb = new FilterBuilder();
+ switch (activeStatusFilter) {
+ case ProcessStatusFilter.COMPLETED: {
+ fb.addEqual('container.state', 'Complete', GroupContentsResourcePrefix.PROCESS);
+ fb.addEqual('container.exit_code', '0', GroupContentsResourcePrefix.PROCESS);
+ break;
+ }
+ case ProcessStatusFilter.FAILED: {
+ fb.addEqual('container.state', 'Complete', GroupContentsResourcePrefix.PROCESS);
+ fb.addDistinct('container.exit_code', '0', GroupContentsResourcePrefix.PROCESS);
+ break;
+ }
+ case ProcessStatusFilter.CANCELLED:
+ case ProcessStatusFilter.FAILED:
+ case ProcessStatusFilter.LOCKED:
+ case ProcessStatusFilter.QUEUED:
+ case ProcessStatusFilter.RUNNING: {
+ fb.addEqual('container.state', activeStatusFilter, GroupContentsResourcePrefix.PROCESS);
+ break;
+ }
+ }
+ const statusFilters = fb.getFilters();
+
return joinFilters(
+ statusFilters,
typeFilters,
nameFilters,
);
- // TODO: Restore process status filters
- // const statusFilters = getDataExplorerColumnFilters(columns, ProjectPanelColumnNames.STATUS);
};
export const getOrder = (dataExplorer: DataExplorer) => {
const projectPanelCurrentUuidIsNotSet = () =>
snackbarActions.OPEN_SNACKBAR({
- message: 'Project panel is not opened.'
+ message: 'Project panel is not opened.',
+ kind: SnackbarKind.ERROR
});
const couldNotFetchProjectContents = () =>
const projectPanelDataExplorerIsNotSet = () =>
snackbarActions.OPEN_SNACKBAR({
- message: 'Project panel is not ready.'
+ message: 'Project panel is not ready.',
+ kind: SnackbarKind.ERROR
});