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) => {
|
public setReturnToPrevious = (returnToPrevious: ReturnToPreviousProps) => {
|
||||||
|
const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious;
|
||||||
|
if (!isReturnToPreviousEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const previousPage = this.state.getValue().returnToPrevious;
|
const previousPage = this.state.getValue().returnToPrevious;
|
||||||
reportInteraction('grafana_return_to_previous_button_created', {
|
reportInteraction('grafana_return_to_previous_button_created', {
|
||||||
page: returnToPrevious.href,
|
page: returnToPrevious.href,
|
||||||
@ -101,6 +105,10 @@ export class AppChromeService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public clearReturnToPrevious = (interactionAction: 'clicked' | 'dismissed' | 'auto_dismissed') => {
|
public clearReturnToPrevious = (interactionAction: 'clicked' | 'dismissed' | 'auto_dismissed') => {
|
||||||
|
const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious;
|
||||||
|
if (!isReturnToPreviousEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const existingRtp = this.state.getValue().returnToPrevious;
|
const existingRtp = this.state.getValue().returnToPrevious;
|
||||||
if (existingRtp) {
|
if (existingRtp) {
|
||||||
reportInteraction('grafana_return_to_previous_button_dismissed', {
|
reportInteraction('grafana_return_to_previous_button_dismissed', {
|
||||||
|
@ -135,33 +135,22 @@ export const RuleDetailsActionButtons = ({ rule, rulesSource, isViewMode }: Prop
|
|||||||
}
|
}
|
||||||
if (rule.annotations[Annotation.dashboardUID]) {
|
if (rule.annotations[Annotation.dashboardUID]) {
|
||||||
const dashboardUID = rule.annotations[Annotation.dashboardUID];
|
const dashboardUID = rule.annotations[Annotation.dashboardUID];
|
||||||
|
const isReturnToPreviousEnabled = config.featureToggles.returnToPrevious;
|
||||||
if (dashboardUID) {
|
if (dashboardUID) {
|
||||||
buttons.push(
|
buttons.push(
|
||||||
config.featureToggles.returnToPrevious ? (
|
<LinkButton
|
||||||
<LinkButton
|
size="sm"
|
||||||
size="sm"
|
key="dashboard"
|
||||||
key="dashboard"
|
variant="primary"
|
||||||
variant="primary"
|
icon="apps"
|
||||||
icon="apps"
|
target={isReturnToPreviousEnabled ? undefined : '_blank'}
|
||||||
href={`d/${encodeURIComponent(dashboardUID)}`}
|
href={`d/${encodeURIComponent(dashboardUID)}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setReturnToPrevious(rule.name);
|
setReturnToPrevious(rule.name);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Go to dashboard
|
Go to dashboard
|
||||||
</LinkButton>
|
</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];
|
const panelId = rule.annotations[Annotation.panelID];
|
||||||
if (panelId) {
|
if (panelId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user