Skip to content

Commit

Permalink
chore(core): add no permissions message to scheduledPublishing tool
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Sep 17, 2024
1 parent 2455028 commit acadbd8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/sanity/src/core/scheduledPublishing/tool/Tool.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Box, Flex, Text, useTheme} from '@sanity/ui'
import {Box, Container, Flex, Text, useTheme} from '@sanity/ui'
import {parse} from 'date-fns'
import {useEffect, useMemo, useRef} from 'react'
import {type RouterContextValue, useRouter} from 'sanity/router'
Expand All @@ -11,6 +11,7 @@ import {SCHEDULE_FILTERS, TOOL_HEADER_HEIGHT} from '../constants'
import usePollSchedules from '../hooks/usePollSchedules'
import useTimeZone from '../hooks/useTimeZone'
import {type Schedule, type ScheduleState} from '../types'
import {useScheduledPublishingEnabled} from './contexts/ScheduledPublishingEnabledProvider'
import {SchedulesProvider} from './contexts/schedules'
import {ScheduleFilters} from './scheduleFilters'
import {Schedules} from './schedules'
Expand All @@ -32,6 +33,7 @@ export default function Tool() {

const {sanity: theme} = useTheme()
const {error, isInitialLoading, schedules = NO_SCHEDULE} = usePollSchedules()
const {enabled} = useScheduledPublishingEnabled()

const lastScheduleState = useRef<ScheduleState | undefined>()

Expand Down Expand Up @@ -74,6 +76,19 @@ export default function Tool() {
}
}

if (!enabled) {
return (
<Container width={1} paddingTop={4}>
<Box paddingTop={4} paddingX={4}>
<ErrorCallout
description="You do not have permission to edit schedules."
title="Insufficient permissions"
/>
</Box>
</Container>
)
}

return (
<SchedulesProvider value={schedulesContext}>
<Flex direction="column" height="fill" flex={1} overflow="hidden">
Expand Down

0 comments on commit acadbd8

Please sign in to comment.