From 63d916c572913f6236c3b239cb70b52707f0ef67 Mon Sep 17 00:00:00 2001 From: Aleksandr Tereshchenko Date: Thu, 12 Dec 2024 16:55:59 +0200 Subject: [PATCH] Hide 'onlyMyTheses' switch in program overview page, show all theses of the program by default --- .../ProgramOverview/ProgramOverview.tsx | 5 ++++- src/client/components/ThesisPage/ThesesPage.tsx | 6 ++++-- .../components/ThesisPage/ThesisToolbar.tsx | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/client/components/ProgramOverview/ProgramOverview.tsx b/src/client/components/ProgramOverview/ProgramOverview.tsx index d5d328be..678346f2 100644 --- a/src/client/components/ProgramOverview/ProgramOverview.tsx +++ b/src/client/components/ProgramOverview/ProgramOverview.tsx @@ -164,7 +164,10 @@ const ProgramOverview = () => { {t('theses')} - + )} diff --git a/src/client/components/ThesisPage/ThesesPage.tsx b/src/client/components/ThesisPage/ThesesPage.tsx index 27824db2..99630bbe 100644 --- a/src/client/components/ThesisPage/ThesesPage.tsx +++ b/src/client/components/ThesisPage/ThesesPage.tsx @@ -44,8 +44,9 @@ const PAGE_SIZE = 25 interface Props { filteringProgramId?: string + noOwnThesesSwitch?: boolean } -const ThesesPage = ({ filteringProgramId }: Props) => { +const ThesesPage = ({ filteringProgramId, noOwnThesesSwitch }: Props) => { const apiRef = useGridApiRef() const footerRef = useRef(null) const { t, i18n } = useTranslation() @@ -65,7 +66,7 @@ const ThesesPage = ({ filteringProgramId }: Props) => { const [editedTesis, setEditedThesis] = useState(null) const [deletedThesis, setDeletedThesis] = useState(null) const [newThesis, setNewThesis] = useState(null) - const [showOnlyOwnTheses, setShowOnlyOwnTheses] = useState(true) + const [showOnlyOwnTheses, setShowOnlyOwnTheses] = useState(!noOwnThesesSwitch) const { theses, @@ -304,6 +305,7 @@ const ThesesPage = ({ filteringProgramId }: Props) => { toggleShowOnlyOwnTheses: () => setShowOnlyOwnTheses((prev) => !prev), showOnlyOwnTheses, + noOwnThesesSwitch, }, footer: { footerRef, diff --git a/src/client/components/ThesisPage/ThesisToolbar.tsx b/src/client/components/ThesisPage/ThesisToolbar.tsx index a6140ea5..e18f6499 100644 --- a/src/client/components/ThesisPage/ThesisToolbar.tsx +++ b/src/client/components/ThesisPage/ThesisToolbar.tsx @@ -17,7 +17,13 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => { const { mutateAsync: applyFilters } = useUserThesesTableFilterMutation() - const { createNewThesis, toggleShowOnlyOwnTheses, showOnlyOwnTheses } = props + const { + createNewThesis, + toggleShowOnlyOwnTheses, + showOnlyOwnTheses, + noOwnThesesSwitch, + } = props + console.log(noOwnThesesSwitch) const handleNewThesis = () => { createNewThesis() @@ -48,7 +54,7 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => { > {t('thesesTableToolbar:newThesisButton')} - {user?.isAdmin && ( + {!noOwnThesesSwitch && user?.isAdmin && ( { label={t('thesesTableToolbar:showAllThesesSwitch')} /> )} - {Boolean(!user?.isAdmin && user?.managedProgramIds?.length) && ( + {Boolean( + !noOwnThesesSwitch && + !user?.isAdmin && + user?.managedProgramIds?.length + ) && (