mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
4ff5a561af
commit
0140dfdddf
@ -300,6 +300,15 @@ export const Components = {
|
|||||||
groupToggle: 'data-testid group-collapse-toggle',
|
groupToggle: 'data-testid group-collapse-toggle',
|
||||||
toggle: 'data-testid collapse-toggle',
|
toggle: 'data-testid collapse-toggle',
|
||||||
expandedContent: 'data-testid expanded-content',
|
expandedContent: 'data-testid expanded-content',
|
||||||
|
previewButton: 'data-testid alert-rule preview-button',
|
||||||
|
ruleNameField: 'data-testid alert-rule name-field',
|
||||||
|
newFolderButton: 'data-testid alert-rule new-folder-button',
|
||||||
|
newFolderNameField: 'data-testid alert-rule name-folder-name-field',
|
||||||
|
newFolderNameCreateButton: 'data-testid alert-rule name-folder-name-create-button',
|
||||||
|
newEvaluationGroupButton: 'data-testid alert-rule new-evaluation-group-button',
|
||||||
|
newEvaluationGroupName: 'data-testid alert-rule new-evaluation-group-name',
|
||||||
|
newEvaluationGroupInterval: 'data-testid alert-rule new-evaluation-group-interval',
|
||||||
|
newEvaluationGroupCreate: 'data-testid alert-rule new-evaluation-group-create-button',
|
||||||
},
|
},
|
||||||
Alert: {
|
Alert: {
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useFormContext } from 'react-hook-form';
|
import { useFormContext } from 'react-hook-form';
|
||||||
|
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Field, Input, Text } from '@grafana/ui';
|
import { Field, Input, Text } from '@grafana/ui';
|
||||||
|
|
||||||
import { RuleFormType, RuleFormValues } from '../../types/rule-form';
|
import { RuleFormType, RuleFormValues } from '../../types/rule-form';
|
||||||
@ -35,6 +36,7 @@ export const AlertRuleNameInput = () => {
|
|||||||
>
|
>
|
||||||
<Field label="Name" error={errors?.name?.message} invalid={!!errors.name?.message}>
|
<Field label="Name" error={errors?.name?.message} invalid={!!errors.name?.message}>
|
||||||
<Input
|
<Input
|
||||||
|
data-testid={selectors.components.AlertRules.ruleNameField}
|
||||||
id="name"
|
id="name"
|
||||||
width={35}
|
width={35}
|
||||||
{...register('name', {
|
{...register('name', {
|
||||||
|
@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { FormProvider, useForm, useFormContext, Controller } from 'react-hook-form';
|
import { FormProvider, useForm, useFormContext, Controller } from 'react-hook-form';
|
||||||
|
|
||||||
import { AppEvents, GrafanaTheme2, SelectableValue } from '@grafana/data';
|
import { AppEvents, GrafanaTheme2, SelectableValue } from '@grafana/data';
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { AsyncSelect, Box, Button, Field, Input, Label, Modal, Stack, Text, useStyles2 } from '@grafana/ui';
|
import { AsyncSelect, Box, Button, Field, Input, Label, Modal, Stack, Text, useStyles2 } from '@grafana/ui';
|
||||||
import appEvents from 'app/core/app_events';
|
import appEvents from 'app/core/app_events';
|
||||||
import { contextSrv } from 'app/core/services/context_srv';
|
import { contextSrv } from 'app/core/services/context_srv';
|
||||||
@ -180,6 +181,7 @@ export function FolderAndGroup({
|
|||||||
fill="outline"
|
fill="outline"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={!contextSrv.hasPermission(AccessControlAction.FoldersCreate)}
|
disabled={!contextSrv.hasPermission(AccessControlAction.FoldersCreate)}
|
||||||
|
data-testid={selectors.components.AlertRules.newFolderButton}
|
||||||
>
|
>
|
||||||
New folder
|
New folder
|
||||||
</Button>
|
</Button>
|
||||||
@ -258,6 +260,7 @@ export function FolderAndGroup({
|
|||||||
fill="outline"
|
fill="outline"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={!folder}
|
disabled={!folder}
|
||||||
|
data-testid={selectors.components.AlertRules.newEvaluationGroupButton}
|
||||||
>
|
>
|
||||||
New evaluation group
|
New evaluation group
|
||||||
</Button>
|
</Button>
|
||||||
@ -309,6 +312,7 @@ function FolderCreationModal({
|
|||||||
invalid={error}
|
invalid={error}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
|
data-testid={selectors.components.AlertRules.newFolderNameField}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
id="folderName"
|
id="folderName"
|
||||||
placeholder="Enter a name"
|
placeholder="Enter a name"
|
||||||
@ -322,7 +326,11 @@ function FolderCreationModal({
|
|||||||
<Button variant="secondary" type="button" onClick={onClose}>
|
<Button variant="secondary" type="button" onClick={onClose}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="submit" disabled={!title || error}>
|
<Button
|
||||||
|
type="submit"
|
||||||
|
disabled={!title || error}
|
||||||
|
data-testid={selectors.components.AlertRules.newFolderNameCreateButton}
|
||||||
|
>
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.ButtonRow>
|
</Modal.ButtonRow>
|
||||||
@ -388,6 +396,7 @@ function EvaluationGroupCreationModal({
|
|||||||
invalid={Boolean(formState.errors.group)}
|
invalid={Boolean(formState.errors.group)}
|
||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
|
data-testid={selectors.components.AlertRules.newEvaluationGroupName}
|
||||||
className={styles.formInput}
|
className={styles.formInput}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
id={'group'}
|
id={'group'}
|
||||||
@ -407,6 +416,7 @@ function EvaluationGroupCreationModal({
|
|||||||
>
|
>
|
||||||
<Stack direction="column">
|
<Stack direction="column">
|
||||||
<Input
|
<Input
|
||||||
|
data-testid={selectors.components.AlertRules.newEvaluationGroupInterval}
|
||||||
className={styles.formInput}
|
className={styles.formInput}
|
||||||
id={evaluateEveryId}
|
id={evaluateEveryId}
|
||||||
placeholder={DEFAULT_GROUP_EVALUATION_INTERVAL}
|
placeholder={DEFAULT_GROUP_EVALUATION_INTERVAL}
|
||||||
@ -421,7 +431,11 @@ function EvaluationGroupCreationModal({
|
|||||||
<Button variant="secondary" type="button" onClick={onCancel}>
|
<Button variant="secondary" type="button" onClick={onCancel}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="submit" disabled={!formState.isValid}>
|
<Button
|
||||||
|
type="submit"
|
||||||
|
disabled={!formState.isValid}
|
||||||
|
data-testid={selectors.components.AlertRules.newEvaluationGroupCreate}
|
||||||
|
>
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.ButtonRow>
|
</Modal.ButtonRow>
|
||||||
|
@ -497,7 +497,13 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!isPreviewLoading && (
|
{!isPreviewLoading && (
|
||||||
<Button icon="sync" type="button" onClick={() => runQueriesPreview()} disabled={emptyQueries}>
|
<Button
|
||||||
|
data-testid={selectors.components.AlertRules.previewButton}
|
||||||
|
icon="sync"
|
||||||
|
type="button"
|
||||||
|
onClick={() => runQueriesPreview()}
|
||||||
|
disabled={emptyQueries}
|
||||||
|
>
|
||||||
Preview
|
Preview
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user