Skip to content

Commit

Permalink
Hide 'onlyMyTheses' switch in program overview page, show all theses …
Browse files Browse the repository at this point in the history
…of the program by default
  • Loading branch information
AleksTeresh committed Dec 12, 2024
1 parent c3bcd04 commit 63d916c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/client/components/ProgramOverview/ProgramOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ const ProgramOverview = () => {
<Typography component="h1" variant="h4">
{t('theses')}
</Typography>
<ThesesPage filteringProgramId={selectedProgram.id} />
<ThesesPage
filteringProgramId={selectedProgram.id}
noOwnThesesSwitch
/>
</Stack>
</>
)}
Expand Down
6 changes: 4 additions & 2 deletions src/client/components/ThesisPage/ThesesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(null)
const { t, i18n } = useTranslation()
Expand All @@ -65,7 +66,7 @@ const ThesesPage = ({ filteringProgramId }: Props) => {
const [editedTesis, setEditedThesis] = useState<Thesis | null>(null)
const [deletedThesis, setDeletedThesis] = useState<Thesis | null>(null)
const [newThesis, setNewThesis] = useState<Thesis | null>(null)
const [showOnlyOwnTheses, setShowOnlyOwnTheses] = useState(true)
const [showOnlyOwnTheses, setShowOnlyOwnTheses] = useState(!noOwnThesesSwitch)

const {
theses,
Expand Down Expand Up @@ -304,6 +305,7 @@ const ThesesPage = ({ filteringProgramId }: Props) => {
toggleShowOnlyOwnTheses: () =>
setShowOnlyOwnTheses((prev) => !prev),
showOnlyOwnTheses,
noOwnThesesSwitch,
},
footer: {
footerRef,
Expand Down
16 changes: 13 additions & 3 deletions src/client/components/ThesisPage/ThesisToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -48,7 +54,7 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => {
>
{t('thesesTableToolbar:newThesisButton')}
</Button>
{user?.isAdmin && (
{!noOwnThesesSwitch && user?.isAdmin && (
<FormControlLabel
control={
<Switch
Expand All @@ -59,7 +65,11 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => {
label={t('thesesTableToolbar:showAllThesesSwitch')}
/>
)}
{Boolean(!user?.isAdmin && user?.managedProgramIds?.length) && (
{Boolean(
!noOwnThesesSwitch &&
!user?.isAdmin &&
user?.managedProgramIds?.length
) && (
<FormControlLabel
control={
<Switch
Expand Down

0 comments on commit 63d916c

Please sign in to comment.