Skip to content

Commit

Permalink
feat!: implement commentsEnabledUntil config
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `projectInformation.newCommentsOpenUtil` config value has been renamed to `commentsEnabledUntil`.

Fixes #66
  • Loading branch information
stdavis committed Aug 24, 2022
1 parent 1690b31 commit 048a663
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"personName": "PersonName",
"personOrg": "PersonOrg"
},
"newCommentsOpenUntil": "9999-01-31T00:00:00.000Z"
"commentsEnabledUntil": "2030-01-31T00:00:00.000Z"
},
"sherlock": {
"placeHolder": "trans:searchPlaceholder",
Expand Down
8 changes: 4 additions & 4 deletions public/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
"description": "Configuration options for the project information widget",
"type": "object",
"additionalProperties": false,
"required": ["commentsEnabled", "commentsTableUrl", "fieldNames", "newCommentsOpenUntil"],
"required": ["commentsEnabled", "commentsTableUrl", "fieldNames", "commentsEnabledUntil"],
"properties": {
"commentsEnabled": {
"title": "Comments Enabled",
Expand Down Expand Up @@ -379,9 +379,9 @@
}
}
},
"newCommentsOpenUntil": {
"title": "New Comments Open Until",
"description": "The date after which new comments will no longer be accepted.",
"commentsEnabledUntil": {
"title": "Comments Enabled Until",
"description": "The date after which comments will be shown.",
"type": "string"
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/components/Details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ export default function Details({ graphic, highlightGraphic }) {
};
}, [graphic]);

const showComments =
config.projectInformation.commentsEnabled &&
featureWidgetGraphic &&
new Date() < new Date(config.projectInformation.commentsEnabledUntil) &&
Object.keys(featureWidgetGraphic.attributes).some((name) => name === config.projectInformation.fieldNames.globalId);

return (
<div className="details" onMouseEnter={() => highlightGraphic(graphic)} onMouseLeave={() => highlightGraphic()}>
<div className="title" onClick={toggle}>
{title}
</div>
<Collapse isOpen={!collapsed}>
<div ref={containerRef}></div>
{config.projectInformation.commentsEnabled &&
featureWidgetGraphic &&
Object.keys(featureWidgetGraphic.attributes).some(
(name) => name === config.projectInformation.fieldNames.globalId
) && <Comments globalId={featureWidgetGraphic.attributes[config.projectInformation.fieldNames.globalId]} />}
{showComments && (
<Comments globalId={featureWidgetGraphic.attributes[config.projectInformation.fieldNames.globalId]} />
)}
</Collapse>
</div>
);
Expand Down

0 comments on commit 048a663

Please sign in to comment.