From 88c5338ea13f4c63930f70108295fc71e327a9d1 Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Fri, 1 Sep 2023 17:40:31 +0300 Subject: [PATCH] Fix cloud plugin install not refreshing (#2932) # What this PR does ## Which issue(s) this PR fixes #2874 ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --- CHANGELOG.md | 7 +++++-- .../src/plugin/GrafanaPluginRootPage.tsx | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f9d1f65c1..e9c322c8e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- Fix for Cloud plugin install not refreshing page after completion ([2974](https://github.com/grafana/oncall/issues/2874)) + ## v1.3.30 (2023-08-31) ### Added @@ -25,8 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix issue with helm chart when specifying `broker.type=rabbitmq` where Redis environment variables were not longer being injected by @joeyorlando ([#2927](https://github.com/grafana/oncall/pull/2927)) - Fix silence for alert groups with empty escalation chain @Ferril ([#2929](https://github.com/grafana/oncall/pull/2929)) -- Fixed NPE when migrating legacy Grafana Alerting integrations - ([#2908](https://github.com/grafana/oncall/issues/2908)) +- Fixed NPE when migrating legacy Grafana Alerting integrations ([#2908](https://github.com/grafana/oncall/issues/2908)) - Fix `IntegrityError` exceptions that occasionally would occur when trying to create `ResolutionNoteSlackMessage` objects by @joeyorlando ([#2933](https://github.com/grafana/oncall/pull/2933)) diff --git a/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx b/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx index 844f697e2c..f04b88660b 100644 --- a/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx +++ b/grafana-plugin/src/plugin/GrafanaPluginRootPage.tsx @@ -73,7 +73,7 @@ export const Root = observer((props: AppRootProps) => { const [basicDataLoaded, setBasicDataLoaded] = useState(false); useEffect(() => { - updateBasicData(); + runQueuedUpdateData(0); }, []); const location = useLocation(); @@ -98,11 +98,6 @@ export const Root = observer((props: AppRootProps) => { }; }, []); - const updateBasicData = async () => { - await store.updateBasicData(); - setBasicDataLoaded(true); - }; - const page = getMatchedPage(location.pathname); const pagePermissionAction = pages[page]?.action; const userHasAccess = pagePermissionAction ? isUserActionAllowed(pagePermissionAction) : true; @@ -206,4 +201,17 @@ export const Root = observer((props: AppRootProps) => { ); + + async function runQueuedUpdateData(attemptCount: number) { + if (attemptCount === 10) { + return; + } + + try { + await store.updateBasicData(); + setBasicDataLoaded(true); + } catch { + setTimeout(() => runQueuedUpdateData(attemptCount + 1), 1000); + } + } });