mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Append appSubUrl to links if present (#38069)
* append appSubUrl if present * remove null check
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import { DataSourceInstanceSettings, GrafanaTheme2, PanelData, urlUtil } from '@grafana/data';
|
import { DataSourceInstanceSettings, GrafanaTheme2, PanelData, urlUtil } from '@grafana/data';
|
||||||
import { getDataSourceSrv, PanelRenderer } from '@grafana/runtime';
|
import { config, getDataSourceSrv, PanelRenderer } from '@grafana/runtime';
|
||||||
import { Alert, CodeEditor, LinkButton, useStyles2, useTheme2 } from '@grafana/ui';
|
import { Alert, CodeEditor, LinkButton, useStyles2, useTheme2 } from '@grafana/ui';
|
||||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||||
import { PanelOptions } from 'app/plugins/panel/table/models.gen';
|
import { PanelOptions } from 'app/plugins/panel/table/models.gen';
|
||||||
@@ -101,7 +101,7 @@ function createExploreLink(settings: DataSourceInstanceSettings, query: AlertQue
|
|||||||
const { refId, ...rest } = query.model;
|
const { refId, ...rest } = query.model;
|
||||||
const queryParams = { ...rest, datasource: name };
|
const queryParams = { ...rest, datasource: name };
|
||||||
|
|
||||||
return urlUtil.renderUrl('/explore', {
|
return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {
|
||||||
left: JSON.stringify(['now-1h', 'now', name, queryParams]),
|
left: JSON.stringify(['now-1h', 'now', name, queryParams]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const RuleDetailsActionButtons: FC<Props> = ({ rule, rulesSource }) => {
|
|||||||
const buildShareUrl = () => {
|
const buildShareUrl = () => {
|
||||||
if (isCloudRulesSource(rulesSource)) {
|
if (isCloudRulesSource(rulesSource)) {
|
||||||
const ruleUrl = `${encodeURIComponent(rulesSource.name)}/${encodeURIComponent(rule.name)}`;
|
const ruleUrl = `${encodeURIComponent(rulesSource.name)}/${encodeURIComponent(rule.name)}`;
|
||||||
return `${config.appUrl}${config.appSubUrl ? '/' + config.appSubUrl : ''}alerting/${ruleUrl}/find`;
|
return `${config.appUrl}${config.appSubUrl}/alerting/${ruleUrl}/find`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.location.href.split('?')[0];
|
return window.location.href.split('?')[0];
|
||||||
@@ -142,9 +142,12 @@ export const RuleDetailsActionButtons: FC<Props> = ({ rule, rulesSource }) => {
|
|||||||
const sourceName = getRulesSourceName(rulesSource);
|
const sourceName = getRulesSourceName(rulesSource);
|
||||||
const identifier = ruleId.fromRulerRule(sourceName, namespace.name, group.name, rulerRule);
|
const identifier = ruleId.fromRulerRule(sourceName, namespace.name, group.name, rulerRule);
|
||||||
|
|
||||||
const editURL = urlUtil.renderUrl(`/alerting/${encodeURIComponent(ruleId.stringifyIdentifier(identifier))}/edit`, {
|
const editURL = urlUtil.renderUrl(
|
||||||
returnTo,
|
`${config.appSubUrl}/alerting/${encodeURIComponent(ruleId.stringifyIdentifier(identifier))}/edit`,
|
||||||
});
|
{
|
||||||
|
returnTo,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (isViewMode) {
|
if (isViewMode) {
|
||||||
rightButtons.push(
|
rightButtons.push(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { urlUtil, UrlQueryMap } from '@grafana/data';
|
import { urlUtil, UrlQueryMap } from '@grafana/data';
|
||||||
|
import { config } from '@grafana/runtime';
|
||||||
import { CombinedRule, FilterState, RulesSource } from 'app/types/unified-alerting';
|
import { CombinedRule, FilterState, RulesSource } from 'app/types/unified-alerting';
|
||||||
import { ALERTMANAGER_NAME_QUERY_KEY } from './constants';
|
import { ALERTMANAGER_NAME_QUERY_KEY } from './constants';
|
||||||
import { getRulesSourceName } from './datasource';
|
import { getRulesSourceName } from './datasource';
|
||||||
@@ -10,11 +11,11 @@ export function createViewLink(ruleSource: RulesSource, rule: CombinedRule, retu
|
|||||||
const paramId = encodeURIComponent(ruleId.stringifyIdentifier(identifier));
|
const paramId = encodeURIComponent(ruleId.stringifyIdentifier(identifier));
|
||||||
const paramSource = encodeURIComponent(sourceName);
|
const paramSource = encodeURIComponent(sourceName);
|
||||||
|
|
||||||
return urlUtil.renderUrl(`/alerting/${paramSource}/${paramId}/view`, { returnTo });
|
return urlUtil.renderUrl(`${config.appSubUrl}/alerting/${paramSource}/${paramId}/view`, { returnTo });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createExploreLink(dataSourceName: string, query: string) {
|
export function createExploreLink(dataSourceName: string, query: string) {
|
||||||
return urlUtil.renderUrl('explore', {
|
return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {
|
||||||
left: JSON.stringify([
|
left: JSON.stringify([
|
||||||
'now-1h',
|
'now-1h',
|
||||||
'now',
|
'now',
|
||||||
|
|||||||
Reference in New Issue
Block a user