diff --git a/grafana-plugin/src/containers/Rotation/RotationTutorial.tsx b/grafana-plugin/src/containers/Rotation/RotationTutorial.tsx index 3c1c0475..e9042ec9 100644 --- a/grafana-plugin/src/containers/Rotation/RotationTutorial.tsx +++ b/grafana-plugin/src/containers/Rotation/RotationTutorial.tsx @@ -52,7 +52,7 @@ const RotationTutorial: FC = (props) => { const base = 60 * 60 * 24 * days; return firstShiftOffset / base; - }, [events]); + }, [events, startMoment]); return (
diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx index da364a44..3266eceb 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx @@ -17,7 +17,7 @@ import { Schedule, Shift } from 'models/schedule/schedule.types'; import { getTzOffsetString } from 'models/timezone/timezone.helpers'; import { Timezone } from 'models/timezone/timezone.types'; import { User } from 'models/user/user.types'; -import { getDateTime, getUTCString } from 'pages/schedule/Schedule.helpers'; +import { getDateTime, getStartOfWeek, getUTCString } from 'pages/schedule/Schedule.helpers'; import { SelectOption } from 'state/types'; import { useStore } from 'state/useStore'; import { getCoords, waitForElement } from 'utils/DOM'; @@ -58,7 +58,7 @@ const RotationForm: FC = observer((props) => { onDelete, layerPriority, shiftId, - shiftMoment = dayjs().startOf('isoWeek'), + shiftMoment = getStartOfWeek(currentTimezone), shiftColor = '#3D71D9', } = props; @@ -195,7 +195,7 @@ const RotationForm: FC = observer((props) => { const updatePreview = () => { store.scheduleStore .updateRotationPreview(scheduleId, shiftId, getFromString(startMoment), false, params) - .then(() => { + .finally(() => { setIsOpen(true); }); }; diff --git a/grafana-plugin/src/containers/Rotations/Rotations.tsx b/grafana-plugin/src/containers/Rotations/Rotations.tsx index 0caedc09..3bc45121 100644 --- a/grafana-plugin/src/containers/Rotations/Rotations.tsx +++ b/grafana-plugin/src/containers/Rotations/Rotations.tsx @@ -187,7 +187,7 @@ class Rotations extends Component {
{ - this.handleAddLayer(nextPriority); + this.handleAddLayer(nextPriority, startMoment); }} > + Add rotations layer diff --git a/grafana-plugin/src/models/user/user.ts b/grafana-plugin/src/models/user/user.ts index 60972d80..d790ed8e 100644 --- a/grafana-plugin/src/models/user/user.ts +++ b/grafana-plugin/src/models/user/user.ts @@ -65,6 +65,8 @@ export class UserStore extends BaseStore { [response.pk]: { ...response, timezone }, }; + this.rootStore.currentTimezone = timezone; + this.currentUserPk = response.pk; } diff --git a/grafana-plugin/src/state/rootBaseStore.ts b/grafana-plugin/src/state/rootBaseStore.ts index d300a8ac..ff884dd0 100644 --- a/grafana-plugin/src/state/rootBaseStore.ts +++ b/grafana-plugin/src/state/rootBaseStore.ts @@ -125,7 +125,6 @@ export class RootBaseStore { // stores async updateBasicData() { - this.userStore.loadCurrentUser(); this.teamStore.loadCurrentTeam(); this.grafanaTeamStore.updateItems(); this.updateFeatures(); @@ -154,7 +153,14 @@ export class RootBaseStore { } this.backendVersion = get_sync_response.version; this.backendLicense = get_sync_response.license; - this.appLoading = false; + + try { + await this.userStore.loadCurrentUser(); + + this.appLoading = false; + } catch (e) { + this.initializationError = 'OnCall was not able to initialize current user'; + } } handleSyncException(e: any) { @@ -208,8 +214,6 @@ export class RootBaseStore { async setupPlugin(meta: AppPluginMeta) { this.resetStatusToDefault(); - console.log(meta); - if (!meta.jsonData?.onCallApiUrl) { this.pluginIsInitialized = false; return;