From c237a39020898a3da5d4f8d5a9fc5220892d7758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Tue, 20 Feb 2024 15:05:12 +0100 Subject: [PATCH] ReturnToPrevious: Check the state of the RTP feature toggle in the hook (#83087) --- .../components/AppChrome/AppChromeService.tsx | 8 ++++ .../rules/RuleDetailsActionButtons.tsx | 39 +++++++------------ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/public/app/core/components/AppChrome/AppChromeService.tsx b/public/app/core/components/AppChrome/AppChromeService.tsx index 810ce5336c3..c6bd540245c 100644 --- a/public/app/core/components/AppChrome/AppChromeService.tsx +++ b/public/app/core/components/AppChrome/AppChromeService.tsx @@ -90,6 +90,10 @@ export class AppChromeService { } public setReturnToPrevious = (returnToPrevious: ReturnToPreviousProps) => { + const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious; + if (!isReturnToPreviousEnabled) { + return; + } const previousPage = this.state.getValue().returnToPrevious; reportInteraction('grafana_return_to_previous_button_created', { page: returnToPrevious.href, @@ -101,6 +105,10 @@ export class AppChromeService { }; public clearReturnToPrevious = (interactionAction: 'clicked' | 'dismissed' | 'auto_dismissed') => { + const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious; + if (!isReturnToPreviousEnabled) { + return; + } const existingRtp = this.state.getValue().returnToPrevious; if (existingRtp) { reportInteraction('grafana_return_to_previous_button_dismissed', { diff --git a/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx b/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx index 48bbf056030..ca3fed1f825 100644 --- a/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx +++ b/public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx @@ -135,33 +135,22 @@ export const RuleDetailsActionButtons = ({ rule, rulesSource, isViewMode }: Prop } if (rule.annotations[Annotation.dashboardUID]) { const dashboardUID = rule.annotations[Annotation.dashboardUID]; + const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious; if (dashboardUID) { buttons.push( - config.featureToggles.returnToPrevious ? ( - { - setReturnToPrevious(rule.name); - }} - > - Go to dashboard - - ) : ( - - Go to dashboard - - ) + { + setReturnToPrevious(rule.name); + }} + > + Go to dashboard + ); const panelId = rule.annotations[Annotation.panelID]; if (panelId) {