From ca95af49403624864114ec55324cd05e52a82ee5 Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Thu, 22 Sep 2022 13:46:22 +0300 Subject: [PATCH] fix for onCallApiUrl not being set --- .../src/containers/ApiTokenSettings/ApiTokenForm.tsx | 6 +++--- grafana-plugin/src/state/rootBaseStore.ts | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx index f0f98b74..cf471d17 100644 --- a/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx +++ b/grafana-plugin/src/containers/ApiTokenSettings/ApiTokenForm.tsx @@ -100,14 +100,14 @@ const ApiTokenForm = observer((props: TokenCreationModalProps) => { return ( - {getCurlExample(token)} + {getCurlExample(token, store.onCallApiUrl)} ); } }); -function getCurlExample(token) { - return `curl -H "Authorization: ${token}" ${getItem('onCallApiUrl')}/api/v1/integrations`; +function getCurlExample(token, onCallApiUrl) { + return `curl -H "Authorization: ${token}" ${onCallApiUrl}/api/v1/integrations`; } export default ApiTokenForm; diff --git a/grafana-plugin/src/state/rootBaseStore.ts b/grafana-plugin/src/state/rootBaseStore.ts index 9f84f384..7a1ee0e6 100644 --- a/grafana-plugin/src/state/rootBaseStore.ts +++ b/grafana-plugin/src/state/rootBaseStore.ts @@ -90,6 +90,9 @@ export class RootBaseStore { @observable incidentsPage: any = this.initialQuery.p ? Number(this.initialQuery.p) : 1; + @observable + onCallApiUrl: string; + // -------------------------- userStore: UserStore = new UserStore(this); @@ -187,6 +190,8 @@ export class RootBaseStore { return; } + this.onCallApiUrl = meta.jsonData.onCallApiUrl; + let syncStartStatus = await this.startSync(); if (syncStartStatus.is_user_anonymous) { this.isUserAnonymous = true;