Skip to content

Commit

Permalink
feat: hide create new thesis button from the program overview thesis …
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
HRemonen committed Dec 16, 2024
1 parent 4f1bb51 commit b6ff2e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/client/components/ProgramOverview/ProgramOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const ProgramOverview = () => {
<ThesesPage
filteringProgramId={selectedProgram.id}
noOwnThesesSwitch
noAddThesisButton
/>
</Stack>
</>
Expand Down
8 changes: 7 additions & 1 deletion src/client/components/ThesisPage/ThesesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement>(null)
const { t, i18n } = useTranslation()
Expand Down Expand Up @@ -367,6 +372,7 @@ const ThesesPage = ({ filteringProgramId, noOwnThesesSwitch }: Props) => {
setShowOnlyOwnTheses((prev) => !prev),
showOnlyOwnTheses,
noOwnThesesSwitch,
noAddThesisButton,
},
footer: {
footerRef,
Expand Down
31 changes: 17 additions & 14 deletions src/client/components/ThesisPage/ThesisToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => {
toggleShowOnlyOwnTheses,
showOnlyOwnTheses,
noOwnThesesSwitch,
noAddThesisButton,
} = props

const handleNewThesis = () => {
Expand All @@ -39,20 +40,22 @@ const ThesisToolbar = (props: GridSlotProps['toolbar']) => {
sx={{ p: 2, alignItems: 'center', justifyContent: 'space-between' }}
>
<Box sx={{ display: 'flex', gap: 2, alignItems: 'center' }}>
<Button
variant="contained"
size="small"
sx={{
fontSize: '12px',
height: 24,
px: 2,
borderRadius: '1rem',
fontWeight: 700,
}}
onClick={handleNewThesis}
>
{t('thesesTableToolbar:newThesisButton')}
</Button>
{!noAddThesisButton && (
<Button
variant="contained"
size="small"
sx={{
fontSize: '12px',
height: 24,
px: 2,
borderRadius: '1rem',
fontWeight: 700,
}}
onClick={handleNewThesis}
>
{t('thesesTableToolbar:newThesisButton')}
</Button>
)}
{!noOwnThesesSwitch && user?.isAdmin && (
<FormControlLabel
control={
Expand Down

0 comments on commit b6ff2e3

Please sign in to comment.