From b6ff2e30c3bd7011be2d26c70865eaebf7bcb5bd Mon Sep 17 00:00:00 2001 From: Henri Remonen Date: Mon, 16 Dec 2024 12:49:02 +0200 Subject: [PATCH] feat: hide create new thesis button from the program overview thesis table --- .../ProgramOverview/ProgramOverview.tsx | 1 + .../components/ThesisPage/ThesesPage.tsx | 8 ++++- .../components/ThesisPage/ThesisToolbar.tsx | 31 ++++++++++--------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/client/components/ProgramOverview/ProgramOverview.tsx b/src/client/components/ProgramOverview/ProgramOverview.tsx index 678346f..318527a 100644 --- a/src/client/components/ProgramOverview/ProgramOverview.tsx +++ b/src/client/components/ProgramOverview/ProgramOverview.tsx @@ -167,6 +167,7 @@ const ProgramOverview = () => { diff --git a/src/client/components/ThesisPage/ThesesPage.tsx b/src/client/components/ThesisPage/ThesesPage.tsx index edbeff3..3cd6d5a 100644 --- a/src/client/components/ThesisPage/ThesesPage.tsx +++ b/src/client/components/ThesisPage/ThesesPage.tsx @@ -49,8 +49,13 @@ const PAGE_SIZE = 25 interface Props { filteringProgramId?: string noOwnThesesSwitch?: boolean + noAddThesisButton?: boolean } -const ThesesPage = ({ filteringProgramId, noOwnThesesSwitch }: Props) => { +const ThesesPage = ({ + filteringProgramId, + noOwnThesesSwitch, + noAddThesisButton, +}: Props) => { const apiRef = useGridApiRef() const footerRef = useRef(null) const { t, i18n } = useTranslation() @@ -367,6 +372,7 @@ const ThesesPage = ({ filteringProgramId, noOwnThesesSwitch }: Props) => { setShowOnlyOwnTheses((prev) => !prev), showOnlyOwnTheses, noOwnThesesSwitch, + noAddThesisButton, }, footer: { footerRef, diff --git a/src/client/components/ThesisPage/ThesisToolbar.tsx b/src/client/components/ThesisPage/ThesisToolbar.tsx index 4764cbd..c4dd8a9 100644 --- a/src/client/components/ThesisPage/ThesisToolbar.tsx +++ b/src/client/components/ThesisPage/ThesisToolbar.tsx @@ -22,6 +22,7 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => { toggleShowOnlyOwnTheses, showOnlyOwnTheses, noOwnThesesSwitch, + noAddThesisButton, } = props const handleNewThesis = () => { @@ -39,20 +40,22 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => { sx={{ p: 2, alignItems: 'center', justifyContent: 'space-between' }} > - + {!noAddThesisButton && ( + + )} {!noOwnThesesSwitch && user?.isAdmin && (