mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Alerting: Append appSubUrl to links if present (#38069)
* append appSubUrl if present * remove null check
This commit is contained in:
parent
769b7a5865
commit
eba21f3145
@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { css } from '@emotion/css';
|
||||
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 { isExpressionQuery } from 'app/features/expressions/guards';
|
||||
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 queryParams = { ...rest, datasource: name };
|
||||
|
||||
return urlUtil.renderUrl('/explore', {
|
||||
return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {
|
||||
left: JSON.stringify(['now-1h', 'now', name, queryParams]),
|
||||
});
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export const RuleDetailsActionButtons: FC<Props> = ({ rule, rulesSource }) => {
|
||||
const buildShareUrl = () => {
|
||||
if (isCloudRulesSource(rulesSource)) {
|
||||
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];
|
||||
@ -142,9 +142,12 @@ export const RuleDetailsActionButtons: FC<Props> = ({ rule, rulesSource }) => {
|
||||
const sourceName = getRulesSourceName(rulesSource);
|
||||
const identifier = ruleId.fromRulerRule(sourceName, namespace.name, group.name, rulerRule);
|
||||
|
||||
const editURL = urlUtil.renderUrl(`/alerting/${encodeURIComponent(ruleId.stringifyIdentifier(identifier))}/edit`, {
|
||||
returnTo,
|
||||
});
|
||||
const editURL = urlUtil.renderUrl(
|
||||
`${config.appSubUrl}/alerting/${encodeURIComponent(ruleId.stringifyIdentifier(identifier))}/edit`,
|
||||
{
|
||||
returnTo,
|
||||
}
|
||||
);
|
||||
|
||||
if (isViewMode) {
|
||||
rightButtons.push(
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { urlUtil, UrlQueryMap } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { CombinedRule, FilterState, RulesSource } from 'app/types/unified-alerting';
|
||||
import { ALERTMANAGER_NAME_QUERY_KEY } from './constants';
|
||||
import { getRulesSourceName } from './datasource';
|
||||
@ -10,11 +11,11 @@ export function createViewLink(ruleSource: RulesSource, rule: CombinedRule, retu
|
||||
const paramId = encodeURIComponent(ruleId.stringifyIdentifier(identifier));
|
||||
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) {
|
||||
return urlUtil.renderUrl('explore', {
|
||||
return urlUtil.renderUrl(`${config.appSubUrl}/explore`, {
|
||||
left: JSON.stringify([
|
||||
'now-1h',
|
||||
'now',
|
||||
|
Loading…
Reference in New Issue
Block a user