From 040ae83e2d5511f6dec8439b7a511d16f5c96587 Mon Sep 17 00:00:00 2001 From: Tetiana <98550542+Nelliney@users.noreply.github.com> Date: Fri, 10 Jan 2025 10:23:49 -0800 Subject: [PATCH] Bugfix/hide empty tab (#4969) * Fix: handle empty "Files and Links" tab in patient view --------- Co-authored-by: alisman --- src/pages/patientView/PatientViewPage.tsx | 5 ++ src/pages/patientView/PatientViewPageTabs.tsx | 37 +++++----- .../patientView/resources/ResourcesTab.tsx | 35 ++++++++++ .../components/resources/ResourceTable.tsx | 68 +++++++++++-------- 4 files changed, 99 insertions(+), 46 deletions(-) diff --git a/src/pages/patientView/PatientViewPage.tsx b/src/pages/patientView/PatientViewPage.tsx index 6eac869b2b8..575385709b4 100644 --- a/src/pages/patientView/PatientViewPage.tsx +++ b/src/pages/patientView/PatientViewPage.tsx @@ -277,6 +277,11 @@ export class PatientViewPageInner extends React.Component< @computed get shouldShowResources(): boolean { + const tabId: string = this.urlWrapper.activeTabId; + if (tabId === 'filesAndLinks') { + return true; + } + if (this.pageStore.resourceIdToResourceData.isComplete) { return _.some( this.pageStore.resourceIdToResourceData.result, diff --git a/src/pages/patientView/PatientViewPageTabs.tsx b/src/pages/patientView/PatientViewPageTabs.tsx index 3bb9ec80efa..f8f29d0496e 100644 --- a/src/pages/patientView/PatientViewPageTabs.tsx +++ b/src/pages/patientView/PatientViewPageTabs.tsx @@ -553,24 +553,25 @@ export function tabs( ); - tabs.push( - -
- -
-
- ); + if (pageComponent.shouldShowResources) + tabs.push( + +
+ +
+
+ ); tabs.push( [this.props.store.resourceIdToResourceData], + render: () => { + const shouldShowNoResource = () => { + if (this.props.store.resourceIdToResourceData.isComplete) { + return !_.some( + this.props.store.resourceIdToResourceData.result, + data => data.length > 0 + ); + } + return true; + }; + + if (shouldShowNoResource()) { + return ( +
+

+ Resources for {this.props.store.patientId} +

+ +
+ ); + } else { + return null; + } + }, + }); + render() { return (
@@ -136,6 +170,7 @@ export default class ResourcesTab extends React.Component< {this.patientResources.component} {this.sampleResources.component} {this.studyResources.component} + {this.showNoResource.component}
); diff --git a/src/shared/components/resources/ResourceTable.tsx b/src/shared/components/resources/ResourceTable.tsx index 2dcb073fca6..7ac2e3ead12 100644 --- a/src/shared/components/resources/ResourceTable.tsx +++ b/src/shared/components/resources/ResourceTable.tsx @@ -53,46 +53,58 @@ const ResourceTable = observer( }, })); - return ( + return resourceTable.data.length === 0 ? ( +

There are no resources for this sample.

+ ) : ( {sampleId && } - + {resourceTable.data.length > 0 && } - {resourceTable.data.map(resource => ( + {resourceTable.data.length === 0 ? ( - {sampleId && } - - - - ))} + ) : ( + resourceTable.data.map(resource => ( + + {sampleId && } + + + + + )) + )}
Sample IDResource DescriptionDescription
{sampleId} - openResource(resource)}> - {icon(resource)} - {resource.resourceDefinition.displayName || - resource.url} - - - - - Open in new window - + + There are no results {resource.resourceDefinition.description}
{sampleId} + openResource(resource)}> + {icon(resource)} + {resource.resourceDefinition + .displayName || resource.url} + + + + + Open in new window + + + {resource.resourceDefinition.description} +
);