Skip to content

Commit

Permalink
Adding ability to restrict tab visibility
Browse files Browse the repository at this point in the history
responsively
  • Loading branch information
monotasker committed Nov 8, 2023
1 parent c1ebda5 commit 0a9bc96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 5 additions & 4 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ APP_RDM_DETAIL_SIDEBAR_SECTIONS_RIGHT = [
},
{"section": _("Download"),
"component_name": "SidebarDownloadSection",
"props": ["activeTab",
"defaultPreviewFile",
"props": ["defaultPreviewFile",
"files",
"fileTabIndex",
"hasFiles",
Expand Down Expand Up @@ -583,7 +582,8 @@ APP_RDM_DETAIL_MAIN_SECTIONS = [
}
],
"tab": True,
"props": []
"props": [],
"show": "tablet computer only"
},
{"section": "Files",
"component_name": "DetailMainTab",
Expand Down Expand Up @@ -623,7 +623,8 @@ APP_RDM_DETAIL_MAIN_SECTIONS = [
}
],
"tab": True,
"props": []
"props": [],
"show": "tablet computer only"
}
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { Tab } from "semantic-ui-react";
import { Menu, Tab } from "semantic-ui-react";
import { DetailMainTab } from "./DetailMainTab";
import { DetailRightSidebar } from "./DetailRightSidebar";
import { DetailLeftSidebar } from "./DetailLeftSidebar";
Expand Down Expand Up @@ -113,7 +113,7 @@ const DetailContent = (rawProps) => {
const topLevelProps = { ...rawProps, ...extraProps };

const panes = tabbedSections.map(
({ section, component_name, subsections, props }) => {
({ section, component_name, subsections, props, show }) => {
// Because can't import DetailMainTab in componentsMap (circular)
if (component_name === "DetailMainTab") {
component_name = undefined;
Expand All @@ -135,9 +135,16 @@ const DetailContent = (rawProps) => {
subsections: subsections,
};
return {
menuItem: section,
menuItem: (
<Menu.Item key={section} className={show}>
{section}
</Menu.Item>
),
render: () => (
<Tab.Pane key={section} className={`record-details-tab ${section}`}>
<Tab.Pane
key={section}
className={`record-details-tab ${section} ${show}`}
>
<TabComponent {...passedProps} key={section} />
</Tab.Pane>
),
Expand Down

0 comments on commit 0a9bc96

Please sign in to comment.