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

Merge branch '306-allow-unpublish-for-users' into 'master'

Resolve "Allow unpublish for users"

Closes #306

See merge request !242
parents b2281a97 de107424
......@@ -195,6 +195,8 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
}
const license = dataset.rights && AVAILABLE_LICENSES.find((e) => e.code === dataset.rights);
const oneDay = 24 * 60 * 60 * 1000;
const oneDayPassed = dataset && (dataset.lastModifiedDate.getTime() <= (new Date()).getTime() - oneDay);
return (
<div className={ classes.root }>
......@@ -220,9 +222,12 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
{ publishDataset && (dataset._permissions.write || dataset._permissions.delete) && (
<CardActions>
{ dataset.published ?
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
dataset._permissions.manage && !oneDayPassed ?
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
:
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
:
<Button onClick={ this.onPublish } type="button">Publish</Button>
}
......
......@@ -103,6 +103,8 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
const {uuid, descriptor, descriptorExtra} = this.props;
const stillLoading: boolean = (! descriptor || (uuid && (descriptor.uuid !== uuid)));
const oneDay = 24 * 60 * 60 * 1000;
const oneDayPassed = descriptor && (descriptor.lastModifiedDate.getTime() <= (new Date()).getTime() - oneDay);
// const terms: VocabularyTerm[] = descriptor ? (descriptor.terms || (descriptor.vocabulary ? descriptor.vocabulary.terms : null)) : null;
// <PropertiesItem title="Publisher:">{ descriptor.publisher || <i>Not specified</i> }</PropertiesItem>
......@@ -131,11 +133,14 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
</CardContent>
{ (descriptor._permissions.write || descriptor._permissions.delete) && (
<CardActions>
<CardActions>
{ descriptor.published ?
<Authorize role="ROLE_ADMINISTRATOR">
descriptor._permissions.manage && !oneDayPassed ?
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
:
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
:
<Button onClick={ this.onPublish } type="button">Publish</Button>
}
......
......@@ -152,6 +152,9 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
public render() {
const {classes, descriptorList, review} = this.props;
const oneDay = 24 * 60 * 60 * 1000;
const oneDayPassed = descriptorList && (descriptorList.lastModifiedDate.getTime() <= (new Date()).getTime() - oneDay);
return (
<div>
<Grid container className={ classes.contentContainer }>
......@@ -191,9 +194,12 @@ class DetailInfo extends React.Component<IDetailInfoProps, any> {
<CardActions>
{ ! descriptorList.published && descriptorList._permissions.write && <DescriptorListLink edit to={ descriptorList }><Button>Edit</Button></DescriptorListLink> }
{ descriptorList.published ?
<Authorize role="ROLE_ADMINISTRATOR">
descriptorList._permissions.manage && !oneDayPassed ?
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
:
<Authorize role="ROLE_ADMINISTRATOR">
<Button onClick={ this.onUnpublish } type="button">Un-publish</Button>
</Authorize>
:
<Button onClick={ this.onPublish } type="button">Publish</Button>
}
......
Supports Markdown
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