Commit 05622bbc authored by Viacheslav Pavlov's avatar Viacheslav Pavlov
Browse files

Dataset/Subset display page: rematchAccessions

parent 7af39e83
......@@ -1100,6 +1100,7 @@
},
"datasetDisplay": {
"accessionsEvaluated": "Accessions evaluated",
"rematch": "Rematch accessions",
"contact": "Data provider contact information",
"creators": "Dataset creators",
"dataAndResources": "Data and resources",
......@@ -1179,6 +1180,7 @@
"endDate": "Experiment end date"
}
}
,"descriptorlists": {
"common": {
"modelName": "Descriptor list",
......@@ -1993,7 +1995,8 @@
"source": "Source"
},
"subsetDisplay": {
"subsetCreators": "Subset creators"
"subsetCreators": "Subset creators",
"rematch": "Rematch accessions"
}
},
"f": {
......
......@@ -151,6 +151,7 @@
},
"datasetDisplay": {
"accessionsEvaluated": "Accessions evaluated",
"rematch": "Rematch accessions",
"contact": "Data provider contact information",
"creators": "Dataset creators",
"dataAndResources": "Data and resources",
......@@ -229,4 +230,4 @@
"startDate": "Experiment start date",
"endDate": "Experiment end date"
}
}
\ No newline at end of file
}
......@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import { translate } from 'react-i18next';
import { deleteDataset, publishDataset, rejectDataset, approveDataset } from 'datasets/actions/editor';
import { rematchDatasetAccessions, deleteDataset, publishDataset, rejectDataset, approveDataset } from 'datasets/actions/editor';
import {loadMoreAccessions, loadDataset} from 'datasets/actions/public';
import Dataset from 'model/catalog/Dataset';
import { AccessionRef } from 'model/accession/AccessionRef';
......@@ -34,6 +34,7 @@ interface IDatasetDetailProps extends React.ClassAttributes<any> {
approveDataset: (dataset: Dataset) => void;
rejectDataset: (dataset: Dataset, needToRedirect?: boolean) => void;
loadMoreAccessions: (uuid: string, page?: Page<AccessionRef>) => any;
rematchDatasetAccessions: (dataset: Dataset) => void;
mapLayers: MapLayer[];
}
......@@ -66,7 +67,7 @@ class DatasetDetail extends React.Component<IDatasetDetailProps, any> {
}
public render() {
const { t, classes, loading, error, dataset, publishDataset, rejectDataset, approveDataset, deleteDataset, mapLayers } = this.props;
const { t, classes, loading, error, dataset, publishDataset, rejectDataset, approveDataset, deleteDataset, rematchDatasetAccessions, mapLayers } = this.props;
return (
<PageLayout>
......@@ -87,6 +88,7 @@ class DatasetDetail extends React.Component<IDatasetDetailProps, any> {
approveDataset={ approveDataset }
deleteDataset={ deleteDataset }
loadAccessions={ this.loadMoreAccessions }
rematchDatasetAccessions={ rematchDatasetAccessions }
accessionRefs={ this.props.accessionRefs }
mapLayers={ mapLayers }
/>
......@@ -120,6 +122,7 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
rejectDataset,
approveDataset,
loadMoreAccessions,
rematchDatasetAccessions,
}, dispatch);
export default translate()(connect(mapStateToProps, mapDispatchToProps)((withStyles as any)(styles)(DatasetDetail)));
......@@ -140,6 +140,7 @@ interface IDetailInfoProps extends React.ClassAttributes<any> {
rejectDataset?: (dataset: Dataset, needToRedirect?: boolean) => void;
deleteDataset?: (dataset: Dataset) => any;
loadAccessions: (page: Page<AccessionRef>) => any;
rematchDatasetAccessions: (dataset: Dataset) => void;
accessionRefs: Page<AccessionRef>;
mapLayers: MapLayer[];
}
......@@ -213,6 +214,14 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
rejectDataset(dataset, true);
}
private onRematch = (e) => {
e.preventDefault();
const {rematchDatasetAccessions, dataset} = this.props;
log('Rematching Accessions for dataset', dataset);
rematchDatasetAccessions(dataset);
}
private onDelete = (e) => {
const { dataset, deleteDataset, t } = this.props;
......@@ -314,6 +323,11 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
<Button onClick={ this.onDelete } type="button">{ t('common:action.delete') }</Button>
}
{ dataset._permissions.manage && <Permissions clazz={ Dataset.clazz } id={ dataset.id }/> }
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onRematch } type="button">
{ t('datasets.public.c.datasetDisplay.rematch') }
</Button>
</Authorize>
</CardActions>
) }
</Card>
......
......@@ -22,6 +22,7 @@ import {AccessionRef} from 'model/accession/AccessionRef';
const apiListSubsets = createApiCaller(SubsetService.list, APPEND_SUBSETS);
const apiListSubsetAccessions = createApiCaller(SubsetService.listAccessions, APPEND_SUBSET_ACCESSIONS);
const apiLoadSubset = createApiCaller(SubsetService.get, RECEIVE_SUBSET);
const apiRematchAccessions = createApiCaller(SubsetService.rematchAccessions, RECEIVE_SUBSET);
export const loadMoreSubsets = (paged: FilteredPage<Subset>) => (dispatch, getState) => {
return dispatch(apiListSubsets(paged ? paged.filterCode : '', Page.nextPage(paged)))
......@@ -50,6 +51,16 @@ export const applyFilters = (filters: string | SubsetFilter, page: IPageRequest
});
};
export const rematchSubsetAccessions = (subset: Subset) => {
return (dispatch, getState) => {
return dispatch(apiRematchAccessions(subset.uuid, subset.version))
.then((saved) => {
dispatch(loadMoreAccessions(saved.uuid));
return saved;
});
};
};
export const loadSubset = (uuid: string) => (dispatch) => {
return dispatch(apiLoadSubset(uuid));
};
......
......@@ -10,7 +10,8 @@
"source": "Source"
},
"subsetDisplay": {
"subsetCreators": "Subset creators"
"subsetCreators": "Subset creators",
"rematch": "Rematch accessions"
}
},
"f": {
......
......@@ -3,7 +3,7 @@ import { translate } from 'react-i18next';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
// Actions
import {loadMoreAccessions, loadSubset} from 'subsets/actions/public';
import {rematchSubsetAccessions, loadMoreAccessions, loadSubset} from 'subsets/actions/public';
import {unpublishSubset} from 'subsets/actions/editor';
import navigateTo from 'actions/navigation';
// Models
......@@ -29,6 +29,7 @@ interface IDisplayPageProps extends React.ClassAttributes<any> {
navigateTo: any;
unpublishSubset: (subset: Subset) => void;
loadMoreAccessions: (uuid: string, page?: Page<AccessionRef>) => any;
rematchSubsetAccessions: (subset: Subset) => void;
accessionRefs: Page<AccessionRef>;
t: any;
}
......@@ -70,7 +71,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
}
public render() {
const { error, subset, loading, userRole, t, accessionRefs } = this.props;
const { error, subset, loading, userRole, t, accessionRefs, rematchSubsetAccessions } = this.props;
const isActionsActive: boolean = userRole.findIndex((role) => role === 'ROLE_ADMINISTRATOR') !== -1 || (subset && subset.state === PublishState.REVIEWING);
return (
......@@ -92,6 +93,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
subset={ subset }
accessions={ accessionRefs }
loadAccessions={ this.loadMoreAccessions }
rematchSubsetAccessions={ rematchSubsetAccessions }
/>
}
</div>
......@@ -116,6 +118,7 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
navigateTo,
unpublishSubset,
loadMoreAccessions,
rematchSubsetAccessions,
}, dispatch);
......
......@@ -19,6 +19,9 @@ import Loading from 'ui/common/Loading';
import PagedLoader from 'ui/common/PagedLoader';
import AccessionRefCard from 'accessions/ui/c/AccessionRefCard';
import DownloadDialog from 'ui/common/download-dialog';
import ButtonBar from 'ui/common/buttons/ButtonBar';
import {Button} from '@material-ui/core';
import Authorize from 'ui/common/authorized/Authorize';
const styles = (theme) => ({
accessionSection: {
......@@ -37,6 +40,7 @@ interface IDetailInfoProps extends React.ClassAttributes<any> {
unpublishSubset?: (subset: Subset) => any;
deleteSubset?: (subset: Subset) => any;
loadAccessions: (page: Page<AccessionRef>) => any;
rematchSubsetAccessions: (subset: Subset) => void;
accessions: Page<AccessionRef>;
userRoles: string[];
}
......@@ -53,6 +57,13 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
this.setState({authenticated});
}
private onRematch = (e) => {
e.preventDefault();
const {subset, rematchSubsetAccessions} = this.props;
rematchSubsetAccessions(subset);
}
public render() {
const {classes, subset, t, accessions, loadAccessions} = this.props;
......@@ -73,11 +84,19 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
<SubsetCard complete subset={ subset }
actions={
this.state.authenticated &&
<DownloadDialog downloadUrl={ `/proxy/api/v1/subset/${subset.uuid}/download` }
slug="download-authenticated"
postParams={ { mcpd: 'mcpd' } }
buttonTitle={ `${t('common:action.download')} ${t('subsets.public.p.display.MCPD')}` }
/>
<ButtonBar>
<DownloadDialog
downloadUrl={ `/proxy/api/v1/subset/${subset.uuid}/download` }
slug="download-authenticated"
postParams={ {mcpd: 'mcpd'} }
buttonTitle={ `${t('common:action.download')} ${t('subsets.public.p.display.MCPD')}` }
/>
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onRematch } type="button">
{ t('subsets.public.c.subsetDisplay.rematch') }
</Button>
</Authorize>
</ButtonBar>
}
/>
<Grid container spacing={ 16 } className={ classes.accessionSection } justify={ 'space-between' }>
......
......@@ -8,14 +8,17 @@ import StepperTemplate from 'ui/common/stepper/StepperTemplate';
// model
import Page from 'model/Page';
import Subset from 'model/subset/Subset';
import {AccessionRef} from 'model/accession/AccessionRef';
// actions
import {loadMoreAccessions} from 'subsets/actions/dashboard';
import {rematchSubsetAccessions} from 'subsets/actions/editor';
interface IReviewAndPublishStepProps extends React.ClassAttributes<any> {
loadMore: (uuid: string, page?: Page<AccessionRef>) => any;
accessionRefs: Page<AccessionRef>;
rematchSubsetAccessions: (subset: Subset) => void;
uuid: string;
}
......@@ -43,6 +46,7 @@ class ReviewAndPublishStep extends StepperTemplate<IReviewAndPublishStepProps> {
<SubsetDisplay
subset={ this.props.item }
accessions={ this.props.accessionRefs }
rematchSubsetAccessions={ this.props.rematchSubsetAccessions }
loadAccessions={ this.loadMoreAccessions }
/>
)
......@@ -54,6 +58,7 @@ const mapStateToProps = (state, ownProps) => ({
const mapDispatchToProps = (dispatch) => bindActionCreators({
loadMore: loadMoreAccessions,
rematchSubsetAccessions,
}, dispatch);
export default connect(mapStateToProps, mapDispatchToProps)(ReviewAndPublishStep);
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