Commit 956fc1a9 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov

Fix: Data on the list of datasets aren`t changed dynamically;

- simplified behavior to simple list reload
parent 0ab6eca0
......@@ -11,7 +11,7 @@ import {
CREATE_DATASET,
DASHBOARD_APPEND_DATASET_PAGE,
DASHBOARD_RECEIVE_DATASET,
DASHBOARD_APPEND_ACCESSIONS_PAGE,
DASHBOARD_APPEND_ACCESSIONS_PAGE, DASHBOARD_REFRESH_DATASETS,
} from 'datasets/constants';
// Models
import Dataset from 'model/catalog/Dataset';
......@@ -102,7 +102,13 @@ function unpublishDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return dataset.state !== PublishState.DRAFT &&
dispatch(apiRejectDataset(dataset.uuid, dataset.version));
dispatch(apiRejectDataset(dataset.uuid, dataset.version))
.then((saved) => {
if (!dataset.current) {
return;
}
dispatch({type: DASHBOARD_REFRESH_DATASETS});
});
};
}
......@@ -110,7 +116,14 @@ function approveDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = getOneFromStateByUUID(datasetUuid, getState());
return dataset.state === PublishState.REVIEWING &&
dispatch(apiApproveDataset(dataset.uuid, dataset.version));
dispatch(apiApproveDataset(dataset.uuid, dataset.version))
.then((saved) => {
if (!dataset.currentVersion) {
return;
}
dispatch({type: DASHBOARD_REFRESH_DATASETS});
});
};
}
......
......@@ -12,6 +12,7 @@ export const CLEAR_DATASET = 'App/CLEAR_DATASET';
// dashboard
export const DASHBOARD_RECEIVE_DATASET = 'App/DASHBOARD_RECEIVE_DATASET';
export const DASHBOARD_REMOVE_DATASET = 'dataset/dashboard/REMOVE_DATASET';
export const DASHBOARD_REFRESH_DATASETS = 'dataset/dashboard/DASHBOARD_REFRESH_DATASETS';
export const DASHBOARD_RECEIVE_DATASET_PAGE = 'dataset/dashboard/RECEIVE_DATASET_PAGE';
export const DASHBOARD_APPEND_DATASET_PAGE = 'dataset/dashboard/APPEND_DATASET_PAGE';
export const DASHBOARD_RECEIVE_ACCESSIONS_PAGE = 'dataset/dashboard/RECEIVE_ACCESSIONS_PAGE';
......
......@@ -2,9 +2,10 @@ import update from 'immutability-helper';
import { log } from 'utilities/debug';
import * as _ from 'lodash';
import { CREATE_DATASET, ADD_CREATOR_TO_DATASET, REMOVE_CREATOR_FROM_DATASET, UPDATE_DATASET_CREATOR, ADD_LOCATION,
import {
CREATE_DATASET, ADD_CREATOR_TO_DATASET, REMOVE_CREATOR_FROM_DATASET, UPDATE_DATASET_CREATOR, ADD_LOCATION,
RECEIVE_LOCATION, REMOVE_LOCATION, DASHBOARD_REMOVE_DATASET, DASHBOARD_RECEIVE_DATASET,
DASHBOARD_APPEND_DATASET_PAGE , DASHBOARD_APPEND_ACCESSIONS_PAGE,
DASHBOARD_APPEND_DATASET_PAGE, DASHBOARD_APPEND_ACCESSIONS_PAGE, DASHBOARD_REFRESH_DATASETS,
} from 'datasets/constants';
import Dataset from 'model/catalog/Dataset';
......@@ -69,6 +70,12 @@ const datasetsDashboard = (state = INITIAL_STATE, action: { type?: string, paylo
}
}
case DASHBOARD_REFRESH_DATASETS: {
return update(state, {
paged: {$set: null},
});
}
case DASHBOARD_APPEND_ACCESSIONS_PAGE: {
const {apiCall: {loading, error, timestamp, data}} = action.payload;
return update(state, {
......
......@@ -23,6 +23,7 @@ class Dataset implements IUserPermissions {
public createdDate: Date;
public creators: DatasetCreator[];
public crops: string[];
public current: boolean;
public currentVersion: string;
public description: string;
public descriptorCount: number;
......
......@@ -21,6 +21,7 @@ class Subset implements IUserPermissions {
public creators: SubsetCreator[];
public createdBy: number;
public createdDate: Date;
public current: boolean;
public currentVersion: string;
public dateCreated: string;
public description: string;
......
......@@ -2,7 +2,7 @@
// Constants
import {
DASHBOARD_APPEND_SUBSETS, DASHBOARD_RECEIVE_SUBSET, DASHBOARD_REMOVE_SUBSET,
DASHBOARD_RECEIVE_ACCESSIONS, DASHBOARD_APPEND_ACCESSIONS,
DASHBOARD_RECEIVE_ACCESSIONS, DASHBOARD_APPEND_ACCESSIONS, DASHBOARD_REFRESH_SUBSETS,
} from 'subsets/constants';
// Model
......@@ -99,14 +99,27 @@ export const unpublishSubset = (subsetUuid: string) => (dispatch, getState) => {
const subset = getOneFromStateByUUID(subsetUuid, getState());
return subset.state !== PublishState.DRAFT &&
dispatch(apiRejectSubset(subset.uuid, subset.version))
.then(() => dispatch(clearSubset()));
.then((saved) => {
dispatch(clearSubset());
if (!subset.current) {
return;
}
dispatch({type: DASHBOARD_REFRESH_SUBSETS});
});
};
export const approveSubset = (subsetUuid: string) => (dispatch, getState) => {
const subset = getOneFromStateByUUID(subsetUuid, getState());
return subset.state === PublishState.REVIEWING &&
dispatch(apiApproveSubset(subset.uuid, subset.version))
.then(() => dispatch(clearSubset()));
.then((saved) => {
dispatch(clearSubset());
if (!subset.currentVersion) {
return;
}
dispatch({type: DASHBOARD_REFRESH_SUBSETS});
});
};
export const deleteSubset = (subsetUuid: string) => (dispatch, getState) => {
......
......@@ -6,6 +6,7 @@ export const APPEND_SUBSET_ACCESSIONS = 'subsets/APPEND_SUBSET_ACCESSIONS';
export const APPEND_SUBSETS_WITH_SUGGESTIONS = 'subsets/APPEND_SUBSETS_WITH_SUGGESTIONS';
export const DASHBOARD_APPEND_SUBSETS = 'subsets/dashboard/APPEND_SUBSETS';
export const DASHBOARD_REFRESH_SUBSETS = 'subsets/dashboard/DASHBOARD_REFRESH_SUBSETS';
export const DASHBOARD_RECEIVE_SUBSET = 'subsets/dashboard/RECEIVE_SUBSET';
export const DASHBOARD_REMOVE_SUBSET = 'subsets/dashboard/REMOVE_SUBSET';
export const DASHBOARD_RECEIVE_ACCESSIONS = 'subsets/DASHBOARD_RECEIVE_ACCESSIONS';
......
......@@ -2,8 +2,10 @@ import update from 'immutability-helper';
import * as _ from 'lodash';
import { IReducerAction } from 'model/common.model';
import {DASHBOARD_RECEIVE_SUBSET, DASHBOARD_REMOVE_SUBSET, DASHBOARD_APPEND_SUBSETS, ADD_CREATOR_TO_SUBSET,
REMOVE_CREATOR_FROM_SUBSET, UPDATE_SUBSET_CREATOR, DASHBOARD_APPEND_ACCESSIONS} from 'subsets/constants';
import {
DASHBOARD_RECEIVE_SUBSET, DASHBOARD_REMOVE_SUBSET, DASHBOARD_APPEND_SUBSETS, ADD_CREATOR_TO_SUBSET,
REMOVE_CREATOR_FROM_SUBSET, UPDATE_SUBSET_CREATOR, DASHBOARD_APPEND_ACCESSIONS, DASHBOARD_REFRESH_SUBSETS,
} from 'subsets/constants';
import FilteredPage from 'model/FilteredPage';
import ApiCall from 'model/ApiCall';
......@@ -57,6 +59,12 @@ const dashboardSubsets = (state = INITIAL_STATE, action: IReducerAction) => {
}
}
case DASHBOARD_REFRESH_SUBSETS: {
return update(state, {
paged: { $set: null },
});
}
case DASHBOARD_APPEND_ACCESSIONS: {
const {apiCall: {loading, error, timestamp, data}} = action.payload;
return update(state, {
......
......@@ -91,6 +91,10 @@ class BaseMyDataPage<T> extends React.Component<IDataPublishedContainerProps<T>,
const { filterCode: prevFilterCode, location: prevLocation } = prevProps;
const { filterCode, applyFilters, apiCall, location } = this.props;
if (!apiCall) {
return applyFilters(filterCode || '', this.makeSearchParams(location));
}
if (filterCode !== prevFilterCode) {
if (apiCall && !apiCall.loading && apiCall.data && apiCall.data.filterCode !== filterCode) {
applyFilters(filterCode || '', this.makeSearchParams(location));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment