Commit e85a0349 authored by Matija Obreza's avatar Matija Obreza
Browse files

Updated models and services to new code

- Dataset updated
- DescriptorList updated
- Descriptor updated
- Removed ui-design
- AccessionIdentifier moved
- ApiInfo updated
- Licenses updated
- DatasetLocation and DatasetCreator upgraded
- LocationService merged into DatasetService
- CreatorService merged into DatasetService
- RepositoryFile upgraded
- Vocabulary upgraded
- Partner upgraded
- Crop upgraded
- Permissions upgraded

- model/acl
- PermissionService
- removed ACL stuff from common.model
[8451685] Sort fixed
parent bc4984b4
import {push} from 'react-router-redux';
import {Crop} from 'model/crop.model';
import {CropService} from 'service/CropService';
import Crop from 'model/genesys/Crop';
import CropService from 'service/CropService';
import {LIST_CROPS_CACHE_IDLE, CREATE_CROP, GET_CROP, RECEIVE_CROP, RECEIVE_CROPS} from 'constants/crop';
import {IReducerAction} from 'model/common.model';
import {log} from 'utilities/debug';
......@@ -21,11 +21,9 @@ const receiveCrops = (crops: Crop[]): IReducerAction => ({
});
export const loadCrop = (shortName: string) => (dispatch, getState) => {
const token = getState().login.access_token;
dispatch({type: GET_CROP, payload: shortName});
return CropService.getCrop(token, shortName)
return CropService.getCrop(shortName)
.then((crop) => {
return dispatch(receiveCrop(crop));
}).catch((error) => {
......@@ -49,7 +47,7 @@ export const listCrops = (forceReload: boolean = false) => (dispatch, getState)
const isDataStale = Date.now() - timeSinceLastFetch > LIST_CROPS_CACHE_IDLE;
if (isDataStale || forceReload) {
return CropService.listCrops(getState().login.access_token)
return CropService.listCrops()
.then((list) => {
dispatch(receiveCrops(list));
})
......@@ -61,7 +59,7 @@ export const listCrops = (forceReload: boolean = false) => (dispatch, getState)
export const saveCrop = (crop: Crop) => (dispatch, getState) => {
return CropService.saveCrop(getState().login.access_token, crop)
return CropService.saveCrop(crop)
.then((saved) => {
dispatch(receiveCrop(saved));
dispatch(listCrops(true));
......@@ -72,7 +70,7 @@ export const saveCrop = (crop: Crop) => (dispatch, getState) => {
};
export const deleteCrop = (crop: Crop) => (dispatch, getState) => {
return CropService.deleteCrop(getState().login.access_token, crop.shortName)
return CropService.deleteCrop(crop.shortName)
.then((crop) => {
dispatch(push('/crops'));
})
......
// constants
import {ADD_TO_EDIT_LIST, REMOVE_FROM_EDIT_LIST, RECEIVE_IS_EDIT_MODE, SELECT_ALL, UNSELECT_ALL} from 'constants/dashboard';
import { ADD_TO_EDIT_LIST, REMOVE_FROM_EDIT_LIST, RECEIVE_IS_EDIT_MODE, SELECT_ALL, UNSELECT_ALL } from 'constants/dashboard';
// Models
import {Dataset} from 'model/dataset.model';
import {Descriptor, DescriptorList} from 'model/descriptor.model';
import Dataset from 'model/catalog/Dataset';
import Descriptor from 'model/catalog/Descriptor';
import DescriptorList from 'model/catalog/DescriptorList';
export const setEditMode = (payload: boolean) => (dispatch) => {
......
import {PermissionService} from 'service/PermissionService';
import PermissionService from 'service/PermissionService';
import {log} from 'utilities/debug';
import {SidPermissions} from 'model/acl.model';
import SidPermissions from 'model/acl/SidPermissions';
export const permissions = (clazz: string, id: number) => (dispatch, getState) => {
return PermissionService.permissions(getState().login.access_token, clazz, id)
return PermissionService.permissions(clazz, id)
.catch((error) => {
log('Error', error);
});
......@@ -12,7 +12,7 @@ export const permissions = (clazz: string, id: number) => (dispatch, getState) =
export const addPermission = (clazz: string, id: number, sidPermissions: SidPermissions) => (dispatch, getState) => {
return PermissionService.addPermission(getState().login.access_token, clazz, id, sidPermissions)
return PermissionService.addPermission(clazz, id, sidPermissions)
.catch((error) => {
log('Error', error);
});
......@@ -20,7 +20,7 @@ export const addPermission = (clazz: string, id: number, sidPermissions: SidPerm
export const autocomplete = (term: string) => (dispatch, getState) => {
return PermissionService.autocomplete(getState().login.access_token, term)
return PermissionService.acSid(term)
.catch((error) => {
log('Error', error);
});
......
import { RepositoryFile } from 'model/repositoryFile.model';
import { RepositoryFileService } from 'service/RepositoryFileService';
import RepositoryFile from 'model/repository/RepositoryFile';
import RepositoryService from 'service/RepositoryService';
import {log} from 'utilities/debug';
import { log } from 'utilities/debug';
import * as UUIDv4 from 'uuid/v4';
export const uploadMarkdownAttachment = (file: File) => (dispatch, getState) => {
const token = getState().login.access_token;
return RepositoryFileService.uploadMarkdownAttachment(token, file)
const metadata: RepositoryFile = new RepositoryFile();
const dummy: string = UUIDv4().replace(/\-/g, '');
metadata.originalFilename = `${dummy}_${file.name}`;
metadata.contentType = file.type;
console.log(`Uploading Markdown`, metadata);
return RepositoryService.uploadFile('/content/markdown', file, metadata)
.then((repoFile: RepositoryFile) => {
return repoFile;
}).catch((error) => {
......
import { SearchService } from 'service/SearchService';
import {DescriptorService} from 'service/DescriptorService';
import {DatasetService} from 'service/DatasetService';
import {DescriptorListService} from 'service/DescriptorListService';
import {Descriptor, DescriptorList} from 'model/descriptor.model';
import {Page} from 'model/common.model';
import {Dataset} from 'model/dataset.model';
import SearchService from 'service/SearchService';
import DescriptorService from 'service/DescriptorService';
import DatasetService from 'service/DatasetService';
import DescriptorListService from 'service/DescriptorListService';
import DescriptorList from 'model/catalog/DescriptorList';
import Descriptor from 'model/catalog/Descriptor';
import { Page } from 'model/common.model';
import Dataset from 'model/catalog/Dataset';
import {
SEARCH_DATASET_PAGE,
SEARCH_DESCRIPTOR_PAGE,
......@@ -12,7 +14,7 @@ import {
NEW_SEARCH,
SEARCH_DATASET_SUGGESTIONS,
} from 'constants/search';
import {log} from 'utilities/debug';
import { log } from 'utilities/debug';
const search = (search: string) => ({
type: NEW_SEARCH,
......@@ -41,9 +43,9 @@ const searchDatasetsSuggestions = (suggestions: any) => ({
export function datasetSuggestions(searchQuery, filter?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
if (searchQuery && searchQuery.trim() !== '') {
return SearchService.datasetSuggestions(token, searchQuery, filter)
return SearchService.datasets(searchQuery, filter)
.then((data) => {
return dispatch(searchDatasetsSuggestions(data));
})
......@@ -57,13 +59,13 @@ export function datasetSuggestions(searchQuery, filter?) {
};
}
export function searchDatasets(page?, results?, sortBy?, filter?, order?) {
export function searchDatasets(page?, results?, sortBy?: string[], filter?, order?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
dispatch(search(filter._text));
return DatasetService.listDatasets(token, page, results, sortBy, filter, order)
return DatasetService.datasetList(filter, { page, size: results, properties: sortBy, direction: order })
.then((paged) => {
return dispatch(searchDatasetPage(paged));
})
......@@ -75,11 +77,10 @@ export function searchDatasets(page?, results?, sortBy?, filter?, order?) {
export function searchDescriptors(page?, results?, sortBy?, filter?, order?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
dispatch(search(filter._text));
return DescriptorService.listDescriptors(token, page, results, sortBy, filter, order)
return DescriptorService.listDescriptors(filter, { page, size: results, properties: sortBy, direction: order })
.then((paged) => {
return dispatch(searchDescriptorPage(paged));
})
......@@ -89,13 +90,13 @@ export function searchDescriptors(page?, results?, sortBy?, filter?, order?) {
};
}
export function searchDescriptorLists(page?, results?, sortBy?, filter?, order?) {
export function searchDescriptorLists(page?, results?, sortBy?: string[], filter?, order?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
dispatch(search(filter._text));
return DescriptorListService.listDescriptorLists(token, page, results, sortBy, filter, order)
return DescriptorListService.listDescriptorLists(filter, { page, size: results, properties: sortBy, direction: order })
.then((paged) => {
return dispatch(searchDescriptorListPage(paged));
})
......
import * as Constants from 'constants/serverInfo';
import {log} from 'utilities/debug';
import {InfoService} from 'service/InfoService';
import {ServerInfo} from 'model/serverinfo.model';
import { log } from 'utilities/debug';
import ApiInfoService from 'service/ApiInfoService';
import ServerApiInfo from 'model/ServerApiInfo';
export const serverInfoRequest = () => (dispatch, getState): Promise<ServerInfo> => {
const token = getState().login.access_token;
export const serverInfoRequest = () => (dispatch, getState): Promise<ServerApiInfo> => {
return InfoService.getServerInfo(token)
return ApiInfoService.apiInfo()
.then((data) => dispatch(getServerInfo(data)))
.catch((error) => log('Error', error));
};
const getServerInfo = (info: ServerInfo) => ({
const getServerInfo = (info: ServerApiInfo) => ({
type: Constants.GET_SERVER_INFO,
payload: { info },
});
import { UserProfileService } from 'service/UserProfileService';
import {log} from 'utilities/debug';
import { log } from 'utilities/debug';
import { SubmissionError } from 'redux-form';
import * as _ from 'lodash';
import { showSnackbar } from 'actions/snackbar';
import { RECEIVE_USER_PROFILE } from 'constants/userProfile';
import {User} from 'model/user.model';
import User from 'model/user/User';
import { IReducerAction } from 'model/common.model';
const receiveUserProfile = (user: User): IReducerAction => ({
......@@ -12,8 +12,7 @@ const receiveUserProfile = (user: User): IReducerAction => ({
});
export const loadUserProfile = () => (dispatch, getState) => {
const token = getState().login.access_token;
return UserProfileService.getProfile(token)
return UserProfileService.getProfile()
// receive the current user profile
.then((userProfile) => {
return dispatch(receiveUserProfile(userProfile));
......@@ -24,7 +23,7 @@ export const loadUserProfile = () => (dispatch, getState) => {
};
export const changePassword = (newPassword: string, oldPassword: string) => (dispatch, getState) => {
return UserProfileService.changePassword(getState().login.access_token, newPassword, oldPassword)
return UserProfileService.changePassword(newPassword, oldPassword)
.then(() => {
dispatch(showSnackbar('Password was changed successfully'));
}).catch((error) => {
......
import * as _ from 'lodash';
import {Partner} from 'model/partner.model';
import {DescriptorList} from 'model/descriptor.model';
import Partner from 'model/genesys/Partner';
import DescriptorList from 'model/catalog/DescriptorList';
import {RECEIVE_UUID_LABELS} from 'constants/uuidDecoder';
import { RECEIVE_UUID_LABELS } from 'constants/uuidDecoder';
const receiveUuidLabels = (labels) => ({
type: RECEIVE_UUID_LABELS,
......
......@@ -9,46 +9,11 @@ export const VERIFY_GOOGLE_TOKEN_URL = `${API_ROOT}/google/verify-token`;
export const APIv0_BASE_URL = `${API_ROOT}/api/v0`;
export const APIv1_BASE_URL = `${API_ROOT}/api/v1`;
export const SERVER_INFO_URL = `${APIv1_BASE_URL}/info/version`;
// Me API
const ME_API = `${APIv0_BASE_URL}/me`;
export const MY_PARTNERS_LIST_URL = `${ME_API}/partners`;
export const MY_DATASETS_LIST_URL = `${ME_API}/datasets`;
export const MY_DESCRIPTORS_LIST_URL = `${ME_API}/descriptors`;
export const MY_LIST_DESCRIPTORSLISTS_URL = `${ME_API}/descriptorlists`;
export const GET_USER_PROFILE_URL = `${ME_API}/profile`;
export const CHANGE_USER_PASSWORD_URL = `${ME_API}/password`;
// Descriptor List API
const DESCRIPTORLIST_API = `${APIv0_BASE_URL}/descriptorlist`;
export const AUTOCOMPLETE_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/autocomplete`;
export const GET_DESCRIPTORLIST_URL = DESCRIPTORLIST_API;
export const LIST_DESCRIPTORLISTS_URL = `${DESCRIPTORLIST_API}/list`;
// -- these require proper permissions
export const REMOVE_DESCRIPTORLIST_URL = DESCRIPTORLIST_API;
export const CREATE_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/create`;
export const UPDATE_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/update`;
export const REVIEW_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/for-review`;
export const REJECT_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/reject`;
export const APPROVE_DESCRIPTORLIST_URL = `${DESCRIPTORLIST_API}/approve`;
export const ADD_DESCRIPTORLIST_DESCRIPTOR_URL = `${DESCRIPTORLIST_API}/add-descriptors`;
export const SET_DESCRIPTORLIST_DESCRIPTORS_URL = `${DESCRIPTORLIST_API}/set-descriptors`;
export const REMOVE_DESCRIPTORLIST_DESCRIPTOR_URL = `${DESCRIPTORLIST_API}/remove-descriptors`;
// Descriptors API
const DESCRIPTOR_API = `${APIv0_BASE_URL}/descriptor`;
export const GET_DESCRIPTOR_URL = DESCRIPTOR_API;
export const LIST_DESCRIPTORS_URL = `${DESCRIPTOR_API}/list`;
export const GET_DESCRIPTOR_CATEGORIES_URL = `${DESCRIPTOR_API}/categories`;
export const CREATE_DESCRIPTOR_URL = `${DESCRIPTOR_API}/create`;
export const COPY_DESCRIPTOR_URL = `${DESCRIPTOR_API}/copy`;
export const UPDATE_DESCRIPTOR_URL = `${DESCRIPTOR_API}/update`;
export const REMOVE_DESCRIPTOR_URL = `${DESCRIPTOR_API}`;
export const REVIEW_DESCRIPTOR_URL = `${DESCRIPTOR_API}/for-review`;
export const REJECT_DESCRIPTOR_URL = `${DESCRIPTOR_API}/reject`;
export const APPROVE_DESCRIPTOR_URL = `${DESCRIPTOR_API}/approve`;
export const SEARCH_MATCHING_DESCRIPTORS_URL = `${DESCRIPTOR_API}/search-matching`;
// Partner API
const PARTNER_API = `${APIv0_BASE_URL}/partner`;
......@@ -57,49 +22,4 @@ export const REMOVE_PARTNER_URL = `${PARTNER_API}`;
export const CREATE_PARTNER_URL = `${PARTNER_API}/create`;
export const UPDATE_PARTNER_URL = `${PARTNER_API}/update`;
export const LIST_PARTNER_URL = `${PARTNER_API}/list`;
// Dataset API
const DATASET_API = `${APIv0_BASE_URL}/dataset`;
export const GET_DATASET_URL = `${DATASET_API}`;
export const CREATE_DATASET_URL = `${DATASET_API}/create`;
export const UPDATE_DATASET_URL = `${DATASET_API}/update`;
export const DELETE_DATASET_URL = `${DATASET_API}`;
export const LIST_DATASET_URL = `${DATASET_API}/list`;
export const REVIEW_DATASET_URL = `${DATASET_API}/for-review`;
export const REJECT_DATASET_URL = `${DATASET_API}/reject`;
export const APPROVE_DATASET_URL = `${DATASET_API}/approve`;
export const UPDATE_DATASET_ACCESSIONS_URL = `${DATASET_API}/upsertaccessions`;
export const ADD_DESCRIPTORS_TO_DATASET_URL = `${DATASET_API}/add-descriptors`;
export const SET_DESCRIPTORS_TO_DATASET_URL = `${DATASET_API}/set-descriptors`;
export const REMOVE_DESCRIPTORS_FROM_DATASET_URL = `${DATASET_API}/remove-descriptors`;
// RepositoryFile API. Note: starts from 'GET_DATASET_URL'
// FIXME base on DATASET_API
export const UPLOAD_REPOSITORY_FILE_URL = '/files/add';
export const UPDATE_REPOSITORY_FILE_URL = '/files/update';
export const LIST_REPOSITORY_FILE_URL = '/files/list';
export const REMOVE_REPOSITORY_FILE_URL = '/files/delete';
const REPOSITORY_API_URL = `${APIv0_BASE_URL}/repository`;
export const REPOSITORY_ADDFILE_URL = `${REPOSITORY_API_URL}/add`;
export const REPOSITORY_GETFILE_URL = `${REPOSITORY_API_URL}`;
export const REPOSITORY_DOWNLOADFILE_URL = `/proxy/uploads`;
// Location API. Note: starts from 'GET_DATASET_URL'
// FIXME base on DATASET_API
export const GET_LOCATION_URL = '/location';
export const LIST_LOCATION_URL = '/location/list';
export const CREATE_LOCATION_URL = '/location/create';
export const UPDATE_LOCATION_URL = '/location/update';
export const REMOVE_LOCATION_URL = '/location/delete';
// Geonames API.
export const API_GEONAMES = `${origin}/api/geonames`;
export const GET_GEONAMES_COUNTRY_URL = `${API_GEONAMES}/countryCodeJSON`;
export const GET_GEONAMES_DETAIL_INFO_URL = `${API_GEONAMES}/findNearbyPlaceNameJSON`;
// Dataset CREATOR API
// FIXME base on DATASET_API
export const MAIN_URL_PART_CREATOR_URL = `${DATASET_API}`;
export const CREATE_CREATOR_URL = '/datasetcreator/create';
export const DELETE_CREATOR_URL = '/datasetcreator/delete';
export const UPDTATE_CREATOR_URL = '/datasetcreator/update';
......@@ -6,7 +6,7 @@ import { translate } from 'react-i18next';
import Grid from '@material-ui/core/Grid';
import { listCrops, createCrop } from 'actions/crop';
import { Crop } from 'model/crop.model';
import Crop from 'model/genesys/Crop';
import Authorize from 'ui/common/authorized/Authorize';
import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
......
......@@ -7,7 +7,7 @@ import Paper from '@material-ui/core/Paper';
import {log} from 'utilities/debug';
import { loadCrop, saveCrop, deleteCrop } from 'actions/crop';
import { Crop } from 'model/crop.model';
import Crop from 'model/genesys/Crop';
import confirm from 'utilities/confirmAlert';
import CropForm from './c/CropForm';
......
import * as React from 'react';
import { Crop } from 'model/crop.model';
import Crop from 'model/genesys/Crop';
import { Link } from 'react-router-dom';
import Card, {CardHeader, CardContent} from 'ui/common/Card';
......
......@@ -2,7 +2,7 @@ import * as React from 'react';
import {connect} from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import {Crop} from 'model/crop.model';
import Crop from 'model/genesys/Crop';
interface ICropChipsProps extends React.ClassAttributes<any> {
crops: string[];
......
import * as React from 'react';
import { connect } from 'react-redux';
import { Crop } from 'model/crop.model';
import Crop from 'model/genesys/Crop';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
......
......@@ -10,7 +10,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
import Checkbox from '@material-ui/core/Checkbox';
import Radio from '@material-ui/core/Radio';
import {Crop} from 'model/crop.model';
import Crop from 'model/genesys/Crop';
interface ICropSelectorProps extends React.ClassAttributes<any> {
t: any;
......
import { push } from 'react-router-redux';
// Actions
import {addFilterCode} from 'actions/filterCode';
import { addFilterCode } from 'actions/filterCode';
// Constants
import {DASHBOARD_REMOVE_DATASET, DASHBOARD_RECEIVE_DATASET_PAGE, CREATE_DATASET, DASHBOARD_APPEND_DATASET_PAGE, RECEIVE_DATASET} from 'datasets/constants';
import { DASHBOARD_REMOVE_DATASET, DASHBOARD_RECEIVE_DATASET_PAGE, CREATE_DATASET, DASHBOARD_APPEND_DATASET_PAGE, RECEIVE_DATASET } from 'datasets/constants';
// Models
import {Dataset, IDatasetFilter} from 'model/dataset.model';
import {Page, PublishState} from 'model/common.model';
import Dataset from 'model/catalog/Dataset';
import DatasetFilter from 'model/catalog/DatasetFilter';
import { Page, PublishState } from 'model/common.model';
// Service
import {DatasetService} from 'service/DatasetService';
import DatasetService from 'service/DatasetService';
// Utility
import {log} from 'utilities/debug';
import { log } from 'utilities/debug';
const removeDataset = (dataset: Dataset) => ({
type: DASHBOARD_REMOVE_DATASET, payload: dataset,
......@@ -23,12 +24,12 @@ const receiveDataset = (dataset: Dataset) => ({
type: RECEIVE_DATASET, payload: dataset,
});
const appendDatasetPage = (paged: Page<Dataset>, page, results, sortBy, filter: string | IDatasetFilter, order) => ({
const appendDatasetPage = (paged: Page<Dataset>, page, results, sortBy, filter: string | DatasetFilter, order) => ({
type: DASHBOARD_APPEND_DATASET_PAGE,
payload: { paged, query: { page, results, sortBy, filter, order } },
});
const receiveDatasetPage = (paged: Page<Dataset>, page, results, sortBy, filter: string | IDatasetFilter, order) => ({
const receiveDatasetPage = (paged: Page<Dataset>, page, results, sortBy, filter: string | DatasetFilter, order) => ({
type: DASHBOARD_RECEIVE_DATASET_PAGE,
payload: { paged, query: { page, results, sortBy, filter, order } },
});
......@@ -41,11 +42,10 @@ const createDataset = () => (dispatch) => {
export {createDataset};
function listMyDatasets(page?, results?, sortBy?, filter?: string | IDatasetFilter, order?) {
function listMyDatasets(page?, results?, sortBy?: string[], filter?: string | DatasetFilter, order?) {
return (dispatch, getState) => {
const token = getState().login.access_token;
return DatasetService.listMyDatasets(token, page, results, sortBy, filter, order)
return DatasetService.myDatasets(filter, { page, size: results, properties: sortBy, direction: order })
.then((paged) => {
if (paged.number === 0) {
dispatch(receiveDatasetPage(paged, page, results, sortBy, filter, order));
......@@ -62,15 +62,15 @@ function listMyDatasets(page?, results?, sortBy?, filter?: string | IDatasetFilt
export {listMyDatasets};
const getOneFromStateByUUID = (uuid: string) => (dispatch, getState) => {
return getState().datasets.dashboard.paged.content.find((dataset) => dataset.uuid === uuid);
const getOneFromStateByUUID = (uuid: string, state): Dataset => {
return state.datasets.dashboard.paged.content.find((dataset) => dataset.uuid === uuid);
};
function publishDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid));
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
return dataset.state === PublishState.DRAFT &&
DatasetService.updatePublishState(getState().login.access_token, dataset, PublishState.REVIEWING)
DatasetService.reviewDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
.catch((error) => {
log('Error', error);
......@@ -80,9 +80,9 @@ function publishDataset(datasetUuid: string) {
function unpublishDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid));
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
return dataset.state !== PublishState.DRAFT &&
DatasetService.updatePublishState(getState().login.access_token, dataset, PublishState.DRAFT)
DatasetService.rejectDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
.catch((error) => {
log('Error', error);
......@@ -92,9 +92,9 @@ function unpublishDataset(datasetUuid: string) {
function approveDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid));
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
return dataset.state === PublishState.REVIEWING &&
DatasetService.updatePublishState(getState().login.access_token, dataset, PublishState.PUBLISHED)
DatasetService.approveDataset(dataset.uuid, dataset.version)
.then((dataset) => dispatch(receiveDataset(dataset)))
.catch((error) => {
log('Error', error);
......@@ -104,10 +104,9 @@ function approveDataset(datasetUuid: string) {
function deleteDataset(datasetUuid: string) {
return (dispatch, getState) => {
const dataset = dispatch(getOneFromStateByUUID(datasetUuid));
const token = getState().login.access_token;
const dataset = dispatch(getOneFromStateByUUID(datasetUuid, getState()));
return DatasetService.deleteDataset(token, dataset)
return DatasetService.deleteDataset(dataset.uuid, dataset.version)
.then((deleted) => {
dispatch(removeDataset(deleted));
return deleted;
......
......@@ -2,26 +2,23 @@ import { push } from 'react-router-redux';
import * as _ from 'lodash';
// Actions
import {navigateTo} from 'actions/navigation';
import { navigateTo } from 'actions/navigation';
// Constants
import {ADD_CREATOR_TO_DATASET, ADD_LOCATION, RECEIVE_LOCATION, REMOVE_CREATOR_FROM_DATASET, REMOVE_LOCATION, UPDATE_DATASET_CREATOR, RECEIVE_DATASET, DASHBOARD_REMOVE_DATASET} from 'datasets/constants';
import { ADD_CREATOR_TO_DATASET, ADD_LOCATION, RECEIVE_LOCATION, REMOVE_CREATOR_FROM_DATASET, REMOVE_LOCATION, UPDATE_DATASET_CREATOR, RECEIVE_DATASET, DASHBOARD_REMOVE_DATASET } from 'datasets/constants';
// Models
import {AccessionRef, Dataset} from 'model/dataset.model';
import {RepositoryFile} from 'model/repositoryFile.model';
import {Creator} from 'model/creator.model';
import {Location} from 'model/location.model';
import {PublishState} from 'model/common.model';
import Dataset from 'model/catalog/Dataset';
import AccessionRef from 'model/accession/AccessionRef';
import RepositoryFile from 'model/repository/RepositoryFile';
import DatasetCreator from 'model/catalog/DatasetCreator';
import DatasetLocation from 'model/catalog/DatasetLocation';
// Service
import {DatasetService} from 'service/DatasetService';