diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx index 3266eceb..352af9f9 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx @@ -154,7 +154,7 @@ const RotationForm: FC = observer((props) => { rolling_users: userGroups, interval: repeatEveryValue, frequency: repeatEveryPeriod, - by_day: (repeatEveryPeriod === 0 && repeatEveryValue === 1) || repeatEveryPeriod === 1 ? selectedDays : null, + by_day: repeatEveryPeriod === 0 || repeatEveryPeriod === 1 ? selectedDays : null, priority_level: shiftId === 'new' ? layerPriority : shift?.priority_level, }), [ @@ -343,7 +343,7 @@ const RotationForm: FC = observer((props) => { /> - {((repeatEveryPeriod === 0 && repeatEveryValue === 1) || repeatEveryPeriod === 1) && ( + {(repeatEveryPeriod === 0 || repeatEveryPeriod === 1) && ( { {disabled ? ( - + + + ) : ( {
{ + if (disabled) { + return; + } this.handleAddLayer(nextPriority, startMoment); }} > - + Add rotations layer + + Add rotations layer
)} diff --git a/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx b/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx index a0eff285..c0cc6a85 100644 --- a/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx +++ b/grafana-plugin/src/containers/Rotations/ScheduleOverrides.tsx @@ -10,10 +10,12 @@ import Text from 'components/Text/Text'; import TimelineMarks from 'components/TimelineMarks/TimelineMarks'; import Rotation from 'containers/Rotation/Rotation'; import ScheduleOverrideForm from 'containers/RotationForm/ScheduleOverrideForm'; +import { WithPermissionControl } from 'containers/WithPermissionControl/WithPermissionControl'; import { getOverrideColor, getOverridesFromStore } from 'models/schedule/schedule.helpers'; import { Schedule, Shift, ShiftEvents } from 'models/schedule/schedule.types'; import { Timezone } from 'models/timezone/timezone.types'; import { WithStoreProps } from 'state/types'; +import { UserAction } from 'state/userAction'; import { withMobXProviderContext } from 'state/withStore'; import { DEFAULT_TRANSITION_TIMEOUT } from './Rotations.config'; @@ -78,9 +80,11 @@ class ScheduleOverrides extends Component - + + +
diff --git a/grafana-plugin/src/models/base_store.ts b/grafana-plugin/src/models/base_store.ts index f20c4d6b..766cb698 100644 --- a/grafana-plugin/src/models/base_store.ts +++ b/grafana-plugin/src/models/base_store.ts @@ -3,7 +3,7 @@ import { action } from 'mobx'; import { makeRequest } from 'network'; import { RootStore } from 'state'; -import { openErrorNotification } from 'utils'; +import { openWarningNotification } from 'utils'; export default class BaseStore { protected rootStore: RootStore; @@ -26,7 +26,7 @@ export default class BaseStore { : Object.keys(payload) .map((key) => `${sentenceCase(key)}: ${payload[key]}`) .join('\n'); - openErrorNotification(text); + openWarningNotification(text); } throw error; diff --git a/grafana-plugin/src/pages/schedule/Schedule.tsx b/grafana-plugin/src/pages/schedule/Schedule.tsx index 38287d13..779d7bdb 100644 --- a/grafana-plugin/src/pages/schedule/Schedule.tsx +++ b/grafana-plugin/src/pages/schedule/Schedule.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { AppRootProps } from '@grafana/data'; import { getLocationSrv } from '@grafana/runtime'; -import { Button, HorizontalGroup, VerticalGroup, IconButton, ToolbarButton, Icon, Modal } from '@grafana/ui'; +import { Button, HorizontalGroup, Icon, IconButton, Modal, ToolbarButton, VerticalGroup } from '@grafana/ui'; import cn from 'classnames/bind'; import dayjs from 'dayjs'; import { omit } from 'lodash-es'; @@ -22,11 +22,13 @@ import UsersTimezones from 'containers/UsersTimezones/UsersTimezones'; import { Schedule, ScheduleType, Shift } from 'models/schedule/schedule.types'; import { Timezone } from 'models/timezone/timezone.types'; import { WithStoreProps } from 'state/types'; +import { UserAction } from 'state/userAction'; import { withMobXProviderContext } from 'state/withStore'; import { getStartOfWeek } from './Schedule.helpers'; import styles from './Schedule.module.css'; + const cx = cn.bind(styles); interface SchedulePageProps extends AppRootProps, WithStoreProps {} @@ -101,7 +103,11 @@ class SchedulePage extends React.Component const users = store.userStore.getSearchResult().results; const schedule = scheduleStore.items[scheduleId]; - const disabled = schedule?.type !== ScheduleType.API || shiftIdToShowRotationForm || shiftIdToShowOverridesForm; + const disabled = + !store.isUserActionAllowed(UserAction.UpdateSchedules) || + schedule?.type !== ScheduleType.API || + shiftIdToShowRotationForm || + shiftIdToShowOverridesForm; return ( <> diff --git a/grafana-plugin/src/pages/schedules/Schedules.tsx b/grafana-plugin/src/pages/schedules/Schedules.tsx index 1e45e43a..ca5a373a 100644 --- a/grafana-plugin/src/pages/schedules/Schedules.tsx +++ b/grafana-plugin/src/pages/schedules/Schedules.tsx @@ -146,9 +146,11 @@ class SchedulesPage extends React.Component )} - + + +