Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HP-1525 Feat/disco status icon #1558

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/portal_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ Below is an example, with inline comments describing what each JSON block config
"enabled": false,
"menuText": "Not Accessible"
},
"pending": {...},
"waiting": {...},
"notAvailable": {...}
}
},
Expand Down Expand Up @@ -662,7 +662,7 @@ Below is an example, with inline comments describing what each JSON block config
"minimalFieldMapping": { // maps
"tagsListFieldName": "tags", // required; the field which contains the list of tags (format: [{name: string, category: string}] )
"authzField": "authz", // optional if features.authorization.enabled is false, otherwise required
"dataAvailabilityField": "data_availability", // optional, for checking if a study has data pending to be available
"dataAvailabilityField": "data_availability", // optional, for checking if no data will be made available for a study
"uid": "study_id" // required; a unique identifier for each study. Can be any unique value and does not have to have any special meaning (eg does not need to be a GUID)
},
"tagCategories": [ // configures the categories displayed in the tag selector. If a tag category appears in the `tagsListFieldName` field but is not configured here, it will not be displayed in the tag selector.
Expand Down
2 changes: 1 addition & 1 deletion src/Discovery/Discovery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const initStoreData = {
accessFilters: {
[AccessLevel.ACCESSIBLE]: true,
[AccessLevel.UNACCESSIBLE]: true,
[AccessLevel.PENDING]: true,
[AccessLevel.WAITING]: true,
[AccessLevel.NOT_AVAILABLE]: true,
},
selectedTags: {},
Expand Down
32 changes: 14 additions & 18 deletions src/Discovery/Discovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const accessibleFieldName = '__accessible';
export enum AccessLevel {
ACCESSIBLE = 1,
UNACCESSIBLE = 2,
PENDING = 3,
WAITING = 3,
NOT_AVAILABLE = 4,
OTHER = 5,
}
Expand All @@ -54,6 +54,11 @@ const { Panel } = Collapse;
const ARBORIST_READ_PRIV = 'read';

const setUpMenuItemInfo = (menuItemInfo, supportedValues) => {
if (supportedValues?.waiting?.enabled === true) {
menuItemInfo.push(
[AccessLevel.WAITING, supportedValues.waiting.menuText, <ClockCircleOutlined />],
);
}
if (supportedValues?.accessible?.enabled === true) {
menuItemInfo.push(
[AccessLevel.ACCESSIBLE, supportedValues.accessible.menuText, <UnlockOutlined />],
Expand All @@ -64,11 +69,6 @@ const setUpMenuItemInfo = (menuItemInfo, supportedValues) => {
[AccessLevel.UNACCESSIBLE, supportedValues.unaccessible.menuText, <LockOutlined />],
);
}
if (supportedValues?.pending?.enabled === true) {
menuItemInfo.push(
[AccessLevel.PENDING, supportedValues.pending.menuText, <ClockCircleOutlined />],
);
}
if (supportedValues?.notAvailable?.enabled === true) {
menuItemInfo.push(
[AccessLevel.NOT_AVAILABLE, supportedValues.notAvailable.menuText, <DashOutlined />],
Expand Down Expand Up @@ -493,7 +493,7 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
onClick={() => props.onAccessFilterSet({
[AccessLevel.ACCESSIBLE]: true,
[AccessLevel.NOT_AVAILABLE]: true,
[AccessLevel.PENDING]: true,
[AccessLevel.WAITING]: true,
[AccessLevel.UNACCESSIBLE]: true,
},
)}
Expand Down Expand Up @@ -561,15 +561,15 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
width: '200px',
textWrap: 'word-break',
render: (_, record) => {
if (record[accessibleFieldName] === AccessLevel.PENDING) {
if (record[accessibleFieldName] === AccessLevel.WAITING) {
return (
<Popover
overlayClassName='discovery-popover'
placement='topRight'
arrowPointAtCenter
content={(
<div className='discovery-popover__text'>
This study will have data soon
Data are not yet available for this study
</div>
)}
>
Expand All @@ -585,7 +585,7 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
arrowPointAtCenter
content={(
<div className='discovery-popover__text'>
This study does not have any data yet.
No data will be shared by this study
</div>
)}
>
Expand All @@ -599,7 +599,7 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
overlayClassName='discovery-popover'
placement='topRight'
arrowPointAtCenter
title={'You have access to this data.'}
title={'You have access to these data.'}
content={(
<div className='discovery-popover__text'>
<React.Fragment>You have <code>{ARBORIST_READ_PRIV}</code> access to </React.Fragment>
Expand All @@ -611,22 +611,18 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
</Popover>
);
}
/* Hiding the closed lock for the HEAL project.
This may be useful functionality for other commons.
Keeping the logic for now.
https://ctds-planx.atlassian.net/browse/HP-393
*/
if (record[accessibleFieldName] === AccessLevel.UNACCESSIBLE) {
return (
<Popover
overlayClassName='discovery-popover'
placement='topRight'
arrowPointAtCenter
title={'You do not have access to this data.'}
title={'You do not currently have access to these data.'}
content={(
<div className='discovery-popover__text'>
<React.Fragment>You don&apos;t have <code>{ARBORIST_READ_PRIV}</code> access to </React.Fragment>
<React.Fragment><code>{record[config.minimalFieldMapping.authzField]}</code>.</React.Fragment>
<React.Fragment><code>{record[config.minimalFieldMapping.authzField]}</code>. </React.Fragment>
<React.Fragment>Visit the repository to request access to these data</React.Fragment>
</div>
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const { Panel } = Collapse;
const NonTabbedDiscoveryDetails = ({ props }) => {
const userHasAccess = props.config.features.authorization.enabled
&& props.modalData[accessibleFieldName] !== AccessLevel.NOT_AVAILABLE
&& props.modalData[accessibleFieldName] !== AccessLevel.PENDING
&& props.modalData[accessibleFieldName] !== AccessLevel.WAITING
&& props.modalData[accessibleFieldName] === AccessLevel.ACCESSIBLE;
const userDoesNotHaveAccess = props.config.features.authorization.enabled
&& props.modalData[accessibleFieldName] !== AccessLevel.NOT_AVAILABLE
&& props.modalData[accessibleFieldName] !== AccessLevel.PENDING
&& props.modalData[accessibleFieldName] !== AccessLevel.WAITING
&& props.modalData[accessibleFieldName] !== AccessLevel.ACCESSIBLE;

const showDownloadPanel = props.config.studyPageFields.downloadLinks
Expand Down
4 changes: 2 additions & 2 deletions src/Discovery/__mocks__/mock_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"enabled": false,
"menuText": "Not Accessible"
},
"pending": {
"waiting": {
"enabled": true,
"menuText": "Pending"
"menuText": "Waiting"
},
"notAvailable": {
"enabled": true,
Expand Down
6 changes: 3 additions & 3 deletions src/Discovery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ const DiscoveryWithMDSBackend: React.FC<{
}
const studiesWithAccessibleField = rawStudies.map((study) => {
let accessible: AccessLevel;
if (supportedValues?.pending?.enabled && dataAvailabilityField && study[dataAvailabilityField] === 'pending') {
accessible = AccessLevel.PENDING;
} else if (supportedValues?.notAvailable?.enabled && !study[authzField]) {
if (supportedValues?.notAvailable?.enabled && dataAvailabilityField && study[dataAvailabilityField] === 'not_available') {
accessible = AccessLevel.NOT_AVAILABLE;
} else if (supportedValues?.waiting?.enabled && !study[authzField]) {
accessible = AccessLevel.WAITING;
} else {
let authMapping;
if (isEnabled('discoveryUseAggWTS')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Discovery/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const discovery = (
accessFilters: {
[AccessLevel.ACCESSIBLE]: true,
[AccessLevel.UNACCESSIBLE]: true,
[AccessLevel.PENDING]: true,
[AccessLevel.WAITING]: true,
[AccessLevel.NOT_AVAILABLE]: true,
},
selectedTags: {},
Expand Down
Loading