From 53556bd98b332e7096af9b2b3e3c32900c4e014a Mon Sep 17 00:00:00 2001 From: Dominik Broj Date: Wed, 24 Jul 2024 07:14:02 +0200 Subject: [PATCH] show chatops proxy error (#4719) # What this PR does show chatops proxy error if present in query params ## Which issue(s) this PR closes Related to https://github.com/grafana/oncall-gateway/issues/255 ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes. --- .../pages/settings/tabs/ChatOps/ChatOps.helpers.ts | 11 +++++++++++ .../src/pages/settings/tabs/ChatOps/ChatOps.tsx | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts new file mode 100644 index 00000000..4313ec5f --- /dev/null +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.helpers.ts @@ -0,0 +1,11 @@ +import { LocationHelper } from 'utils/LocationHelper'; +import { openErrorNotification } from 'utils/utils'; + +export const handleChatOpsQueryParamError = () => { + const error = LocationHelper.getQueryParam('error'); + + if (error) { + openErrorNotification(error); + LocationHelper.update({ error: undefined }, 'partial'); + } +}; diff --git a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx index b43e7510..1441017b 100644 --- a/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx +++ b/grafana-plugin/src/pages/settings/tabs/ChatOps/ChatOps.tsx @@ -15,6 +15,8 @@ import { useStore } from 'state/useStore'; import { withMobXProviderContext } from 'state/withStore'; import { LocationHelper } from 'utils/LocationHelper'; +import { handleChatOpsQueryParamError } from './ChatOps.helpers'; + import styles from './ChatOps.module.css'; const cx = cn.bind(styles); @@ -38,6 +40,7 @@ export class _ChatOpsPage extends React.Component { componentDidMount() { const tab = LocationHelper.getQueryParam('chatOpsTab'); + handleChatOpsQueryParamError(); this.handleChatopsTabChange(tab || ChatOpsTab.Slack); }