Alerting: temporarily add old ng routes (#32770)

This commit is contained in:
Domas 2021-04-08 12:52:43 +03:00 committed by GitHub
parent bba4d9bd7f
commit 33a4cfde51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 7 deletions

View File

@ -121,7 +121,7 @@ export class AlertRuleListUnconnected extends PureComponent<Props> {
</div> </div>
<div className="page-action-bar__spacer" /> <div className="page-action-bar__spacer" />
{config.featureToggles.ngalert && ( {config.featureToggles.ngalert && (
<LinkButton variant="primary" href="alerting/new"> <LinkButton variant="primary" href="alerting/ng/new">
Add NG Alert Add NG Alert
</LinkButton> </LinkButton>
)} )}

View File

@ -98,7 +98,7 @@ class NextGenAlertingPageUnconnected extends PureComponent<Props> {
}; };
onDiscard = () => { onDiscard = () => {
locationService.replace(`${config.appSubUrl}/alerting/list`); locationService.replace(`${config.appSubUrl}/alerting/ng/list`);
}; };
onTest = () => { onTest = () => {

View File

@ -4,6 +4,7 @@ import Highlighter from 'react-highlight-words';
import { FeatureState } from '@grafana/data'; import { FeatureState } from '@grafana/data';
import { Card, FeatureBadge, Icon, LinkButton } from '@grafana/ui'; import { Card, FeatureBadge, Icon, LinkButton } from '@grafana/ui';
import { AlertDefinition } from 'app/types'; import { AlertDefinition } from 'app/types';
import { config } from '@grafana/runtime';
interface Props { interface Props {
alertDefinition: AlertDefinition; alertDefinition: AlertDefinition;
@ -23,7 +24,16 @@ export const AlertDefinitionItem: FC<Props> = ({ alertDefinition, search }) => {
</Card.Meta> </Card.Meta>
<Card.Actions> <Card.Actions>
{[ {[
<LinkButton key="edit" variant="secondary" href={`/alerting/${alertDefinition.uid}/edit`} icon="cog"> <LinkButton
key="edit"
variant="secondary"
href={
config.featureToggles.ngalert
? `/alerting/ng/${alertDefinition.uid}/edit`
: `/alerting/${alertDefinition.uid}/edit`
}
icon="cog"
>
Edit alert Edit alert
</LinkButton>, </LinkButton>,
]} ]}

View File

@ -123,7 +123,7 @@ export function createAlertDefinition(): ThunkResult<void> {
const alertDefinition = await buildAlertDefinition(getStore().alertDefinition); const alertDefinition = await buildAlertDefinition(getStore().alertDefinition);
await getBackendSrv().post(`/api/alert-definitions`, alertDefinition); await getBackendSrv().post(`/api/alert-definitions`, alertDefinition);
appEvents.emit(AppEvents.alertSuccess, ['Alert definition created']); appEvents.emit(AppEvents.alertSuccess, ['Alert definition created']);
locationService.push('/alerting/list'); locationService.push('/alerting/ng/list');
}; };
} }

View File

@ -347,7 +347,13 @@ export function getAppRoutes(): RouteDescriptor[] {
{ {
path: '/alerting/list', path: '/alerting/list',
component: SafeDynamicImport( component: SafeDynamicImport(
() => import(/* webpackChunkName: "AlertRuleList" */ 'app/features/alerting/AlertRuleListIndex') () => import(/* webpackChunkName: "AlertRuleListIndex" */ 'app/features/alerting/AlertRuleListIndex')
),
},
{
path: '/alerting/ng/list',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "AlertRuleList" */ 'app/features/alerting/AlertRuleList')
), ),
}, },
{ {
@ -383,20 +389,34 @@ export function getAppRoutes(): RouteDescriptor[] {
component: SafeDynamicImport( component: SafeDynamicImport(
() => () =>
import( import(
/* webpackChunkName: "NgAlertingPage"*/ 'app/features/alerting/unified/components/rule-editor/AlertRuleForm' /* webpackChunkName: "AlertingRuleForm"*/ 'app/features/alerting/unified/components/rule-editor/AlertRuleForm'
) )
), ),
}, },
{
path: '/alerting/ng/new',
pageClass: 'page-alerting',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "NgAlertingPage"*/ 'app/features/alerting/NextGenAlertingPage')
),
},
{ {
path: '/alerting/:id/edit', path: '/alerting/:id/edit',
pageClass: 'page-alerting', pageClass: 'page-alerting',
component: SafeDynamicImport( component: SafeDynamicImport(
() => () =>
import( import(
/* webpackChunkName: "NgAlertingPage"*/ 'app/features/alerting/unified/components/rule-editor/AlertRuleForm' /* webpackChunkName: "AlertingRuleForm"*/ 'app/features/alerting/unified/components/rule-editor/AlertRuleForm'
) )
), ),
}, },
{
path: '/alerting/ng/:id/edit',
pageClass: 'page-alerting',
component: SafeDynamicImport(
() => import(/* webpackChunkName: "NgAlertingPage"*/ 'app/features/alerting/NextGenAlertingPage')
),
},
{ {
path: '/playlists', path: '/playlists',
component: SafeDynamicImport( component: SafeDynamicImport(