mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
ReturnToPrevious: Check the state of the RTP feature toggle in the hook (#83087)
This commit is contained in:
parent
5431c51490
commit
c237a39020
@ -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', {
|
||||
|
@ -135,14 +135,15 @@ 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 ? (
|
||||
<LinkButton
|
||||
size="sm"
|
||||
key="dashboard"
|
||||
variant="primary"
|
||||
icon="apps"
|
||||
target={isReturnToPreviousEnabled ? undefined : '_blank'}
|
||||
href={`d/${encodeURIComponent(dashboardUID)}`}
|
||||
onClick={() => {
|
||||
setReturnToPrevious(rule.name);
|
||||
@ -150,18 +151,6 @@ export const RuleDetailsActionButtons = ({ rule, rulesSource, isViewMode }: Prop
|
||||
>
|
||||
Go to dashboard
|
||||
</LinkButton>
|
||||
) : (
|
||||
<LinkButton
|
||||
size="sm"
|
||||
key="dashboard"
|
||||
variant="primary"
|
||||
icon="apps"
|
||||
target="_blank"
|
||||
href={`d/${encodeURIComponent(dashboardUID)}`}
|
||||
>
|
||||
Go to dashboard
|
||||
</LinkButton>
|
||||
)
|
||||
);
|
||||
const panelId = rule.annotations[Annotation.panelID];
|
||||
if (panelId) {
|
||||
|
Loading…
Reference in New Issue
Block a user