Skip to content

Commit

Permalink
Add "under approval" and "unpublished" labels (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
luorlandini authored Aug 13, 2021
1 parent 43ca230 commit 923f9ca
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { getResourceTypesInfo } from '@js/utils/ResourceUtils';
import debounce from 'lodash/debounce';
import CopyToClipboardCmp from 'react-copy-to-clipboard';
import { TextEditable, ThumbnailEditable } from '@js/components/ContentsEditable/';
import ResourceStatus from '@js/components/ResourceStatus/';


const CopyToClipboard = tooltip(CopyToClipboardCmp);

Expand Down Expand Up @@ -172,7 +174,6 @@ function DetailsPanel({
const embedUrl = resource?.embed_url && formatEmbedUrl(resource);
const detailUrl = resource?.pk && formatDetailUrl(resource);
const documentDownloadUrl = (resource?.href && resource?.href.includes('download')) ? resource?.href : undefined;

const attributeSet = resource?.attribute_set;
const infoField = [
{
Expand Down Expand Up @@ -423,7 +424,14 @@ function DetailsPanel({


</div>

{
(!resource?.is_approved || !resource?.is_published) &&
<p>
<ResourceStatus
isApproved={resource?.is_approved}
isPublished={resource?.is_published}/>
</p>
}

{<p>
{resource?.owner && <><a href={formatHref({
Expand All @@ -435,6 +443,7 @@ function DetailsPanel({
&& <>{' '}/{' '}{moment(resource.date).format('MMMM Do YYYY')}</>}
</p>
}

<EditAbstract disabled={!activeEditMode} tagName="span" abstract={resource?.abstract} onEdit={editAbstract} />
<p>
{resource?.category?.identifier && <div>
Expand All @@ -446,7 +455,6 @@ function DetailsPanel({
})}>{resource.category.identifier}</a>
</div>}
</p>

</div>
</div>
{editTitle && <div className="gn-details-panel-info"><Tabs itemsTab={itemsTab} /></div>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Dropdown from '@js/components/Dropdown';
import Spinner from '@js/components/Spinner';
import { getUserName } from '@js/utils/SearchUtils';
import { getResourceTypesInfo } from '@js/utils/ResourceUtils';
import ResourceStatus from '@js/components/ResourceStatus/';

function ALink({ href, readOnly, children }) {
return readOnly ? children : <a href={href}>{children}</a>;
Expand All @@ -32,7 +33,6 @@ const ResourceCard = forwardRef(({
className,
loading
}, ref) => {

const res = data;
const types = getTypesInfo();
const { icon } = types[res.subtype] || types[res.resource_type] || {};
Expand Down Expand Up @@ -74,6 +74,13 @@ const ResourceCard = forwardRef(({
{res.title}
</ALink>
</div>
{
(!res?.is_approved || !res?.is_published) &&
<p><ResourceStatus
isApproved={res?.is_approved}
isPublished={res?.is_published}/>
</p>
}
<p
className="card-text gn-card-description"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2021, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Message from '@mapstore/framework/components/I18N/Message';
import PropTypes from 'prop-types';

const ResourceStatus = ({isApproved, isPublished}) => {

const itemStatus = (!isApproved) ?
({messageId: "gnviewer.underApproval", className: "underApproval" }) :
((isApproved && !isPublished) ?
({messageId: "gnviewer.unpublish", className: "unpublish" }) : undefined);

return (
<>
{itemStatus && <span className={itemStatus?.className} >
<Message msgId={itemStatus?.messageId} />
</span>
}
</>
);
};

ResourceStatus.propTypes = {
isApproved: PropTypes.bool,
isPublished: PropTypes.bool
};

ResourceStatus.defaultProps = {
isApproved: true,
isPublished: true
};


export default ResourceStatus;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ResourceStatus';
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
"embed": "Einbetten",
"deleteResourceTitle": "{count, plural, =1 {Möchten Sie diese Ressource wirklich löschen?} other {Möchten Sie diese Ressourcen wirklich löschen?}}",
"deleteResourceNo": "{count, plural, =1 {Nein, nicht löschen} other {Nein, lösche sie nicht}}",
"deleteResourceYes": "Ja, ich bin sicher"
"deleteResourceYes": "Ja, ich bin sicher",
"underApproval": "In Genehmigung",
"unpublish": "Nicht veröffentlicht"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@
"embed": "Embed",
"deleteResourceTitle": "{count, plural, =1 {Are you sure you want to delete this resource?} other {Are you sure you want to delete these resources?}}",
"deleteResourceNo": "{count, plural, =1 {No, don't delete it} other {No, don't delete them}}",
"deleteResourceYes": "Yes, I am sure"
"deleteResourceYes": "Yes, I am sure",
"underApproval": "Under approval",
"unpublish": "Unpublish"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
"embed": "Insertar",
"deleteResourceTitle": "{count, plural, =1 {¿Estás seguro de que deseas eliminar este recurso?} other {¿Está seguro de que desea eliminar estos recursos?}}",
"deleteResourceNo": "{count, plural, =1 {No, no lo borres} other {No, no los borres}}",
"deleteResourceYes": "Sí, estoy seguro"
"deleteResourceYes": "Sí, estoy seguro",
"underApproval": "Bajo aprobación",
"unpublish": "No publicado"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
"embed": "Intégrer",
"deleteResourceTitle": "{count, plural, =1 {Voulez-vous vraiment supprimer cette ressource?} other {Voulez-vous vraiment supprimer ces ressources?}}",
"deleteResourceNo": "{count, plural, =1 {Non, ne le supprime pas} other {Non, ne les supprime pas}}",
"deleteResourceYes": "Oui, je suis sûr"
"deleteResourceYes": "Oui, je suis sûr",
"underApproval": "En cours d'approbation",
"unpublish": "Dépublier"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@
"embed": "Incorpora",
"deleteResourceTitle": "{count, plural, =1 {Sei sicuro di voler eliminare questa risorsa?} other {Sei sicuro di voler eliminare queste risorse?}}",
"deleteResourceNo": "{count, plural, =1 {No, non eliminarlo} other {No, non eliminarli}}",
"deleteResourceYes": "Sì, sono sicuro"
"deleteResourceYes": "Sì, sono sicuro",
"underApproval": "In approvazione",
"unpublish": "Non pubblicato"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
width: 100%;
min-height: 100vh;
}
h3 {
h3 {
margin-left: 1rem;
margin-top: 1rem;
font-weight: 600;
Expand Down Expand Up @@ -97,8 +97,13 @@
object-fit: cover;
}
}
.underApproval, .unpublish {
padding: 0.2em 0.5em;
border-radius: 2px;
}
}


.gn-fixed-card-grid {
display: flex;
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@
}
}
}
.gn-details-panel-content-text, .gn-card-grid {
.underApproval {
.background-color-var(@theme-vars[warning]);
.color-var(@theme-vars[warning-contrast]);
}
.unpublish {
.background-color-var(@theme-vars[danger]);
.color-var(@theme-vars[danger-contrast]);
}
}

}

// **************
Expand Down Expand Up @@ -130,6 +141,10 @@
p{
margin-left: 0.2rem;
}
.underApproval, .unpublish {
padding: 0.5em;
border-radius: 2px;
}
}
.gn-details-panel-info{
.tabs-info {
Expand Down

0 comments on commit 923f9ca

Please sign in to comment.