Skip to content

Commit 0ed641e

Browse files
authored
feat(slo): Add enable/disable actions (#205518)
1 parent a8579bb commit 0ed641e

28 files changed

+746
-78
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { EuiConfirmModal } from '@elastic/eui';
9+
import { i18n } from '@kbn/i18n';
10+
import { SLODefinitionResponse, SLOWithSummaryResponse } from '@kbn/slo-schema';
11+
import React from 'react';
12+
13+
export interface Props {
14+
slo: SLOWithSummaryResponse | SLODefinitionResponse;
15+
onCancel: () => void;
16+
onConfirm: () => void;
17+
isLoading?: boolean;
18+
}
19+
20+
export function SloDisableConfirmationModal({ slo, onCancel, onConfirm, isLoading }: Props) {
21+
const { name } = slo;
22+
return (
23+
<EuiConfirmModal
24+
buttonColor="primary"
25+
data-test-subj="sloDisableConfirmationModal"
26+
title={i18n.translate('xpack.slo.disableConfirmationModal.title', {
27+
defaultMessage: 'Disable {name}?',
28+
values: { name },
29+
})}
30+
cancelButtonText={i18n.translate('xpack.slo.disableConfirmationModal.cancelButtonLabel', {
31+
defaultMessage: 'Cancel',
32+
})}
33+
confirmButtonText={i18n.translate('xpack.slo.disableConfirmationModal.disableButtonLabel', {
34+
defaultMessage: 'Disable',
35+
})}
36+
onCancel={onCancel}
37+
onConfirm={onConfirm}
38+
isLoading={isLoading}
39+
>
40+
{i18n.translate('xpack.slo.disableConfirmationModal.descriptionText', {
41+
defaultMessage: 'Disabling this SLO will stop generating data until it is enabled again.',
42+
})}
43+
</EuiConfirmModal>
44+
);
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { EuiConfirmModal } from '@elastic/eui';
9+
import { i18n } from '@kbn/i18n';
10+
import { SLODefinitionResponse, SLOWithSummaryResponse } from '@kbn/slo-schema';
11+
import React from 'react';
12+
13+
export interface Props {
14+
slo: SLOWithSummaryResponse | SLODefinitionResponse;
15+
onCancel: () => void;
16+
onConfirm: () => void;
17+
isLoading?: boolean;
18+
}
19+
20+
export function SloEnableConfirmationModal({ slo, onCancel, onConfirm, isLoading }: Props) {
21+
const { name } = slo;
22+
return (
23+
<EuiConfirmModal
24+
buttonColor="primary"
25+
data-test-subj="sloEnableConfirmationModal"
26+
title={i18n.translate('xpack.slo.enableConfirmationModal.title', {
27+
defaultMessage: 'Enable {name}?',
28+
values: { name },
29+
})}
30+
cancelButtonText={i18n.translate('xpack.slo.enableConfirmationModal.cancelButtonLabel', {
31+
defaultMessage: 'Cancel',
32+
})}
33+
confirmButtonText={i18n.translate('xpack.slo.enableConfirmationModal.enableButtonLabel', {
34+
defaultMessage: 'Enable',
35+
})}
36+
onCancel={onCancel}
37+
onConfirm={onConfirm}
38+
isLoading={isLoading}
39+
>
40+
{i18n.translate('xpack.slo.enableConfirmationModal.descriptionText', {
41+
defaultMessage: 'Enabling this SLO will generate the missing data since it was disabled.',
42+
})}
43+
</EuiConfirmModal>
44+
);
45+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
*/
77

88
export { SloStatusBadge } from './slo_status_badge';
9+
export { SloActiveAlertsBadge } from './slo_active_alerts_badge';
10+
export { SloStateBadge } from './slo_state_badge';
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import React from 'react';
9+
import { EuiBadge, EuiFlexItem, EuiToolTip } from '@elastic/eui';
10+
import { i18n } from '@kbn/i18n';
11+
import { SLOWithSummaryResponse } from '@kbn/slo-schema';
12+
13+
export interface Props {
14+
slo: SLOWithSummaryResponse;
15+
}
16+
17+
export function SloStateBadge({ slo }: Props) {
18+
const isEnabled = slo.enabled;
19+
if (isEnabled) {
20+
return null;
21+
}
22+
23+
return (
24+
<EuiFlexItem grow={false}>
25+
<EuiToolTip
26+
position="top"
27+
content={i18n.translate('xpack.slo.sloStateBadge.disabled.tooltip', {
28+
defaultMessage: 'This SLO is disabled. Enable it to start processing data.',
29+
})}
30+
>
31+
<EuiBadge color="default">
32+
{i18n.translate('xpack.slo.sloStateBadge.disabled.label', {
33+
defaultMessage: 'Disabled',
34+
})}
35+
</EuiBadge>
36+
</EuiToolTip>
37+
</EuiFlexItem>
38+
);
39+
}

x-pack/solutions/observability/plugins/slo/public/embeddable/slo/overview/slo_overview.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export function SloOverview({ sloId, sloInstanceId, remoteName, reloadSubject }:
9595
const rules = rulesBySlo?.[slo?.id];
9696
const activeAlerts = activeAlertsBySlo.get(slo);
9797

98-
const hasGroupBy = Boolean(slo.groupBy && slo.groupBy !== ALL_VALUE);
99-
10098
const historicalSummary = historicalSummaries.find(
10199
(histSummary) =>
102100
histSummary.sloId === slo.id && histSummary.instanceId === (slo.instanceId ?? ALL_VALUE)
@@ -112,14 +110,7 @@ export function SloOverview({ sloId, sloInstanceId, remoteName, reloadSubject }:
112110
onClick={() => {
113111
setSelectedSlo(slo);
114112
}}
115-
badges={
116-
<SloCardItemBadges
117-
slo={slo}
118-
rules={rules}
119-
activeAlerts={activeAlerts}
120-
hasGroupBy={hasGroupBy}
121-
/>
122-
}
113+
badges={<SloCardItemBadges slo={slo} rules={rules} activeAlerts={activeAlerts} />}
123114
/>
124115
<SloOverviewDetails slo={selectedSlo} setSelectedSlo={setSelectedSlo} />
125116
</div>

x-pack/solutions/observability/plugins/slo/public/embeddable/slo/overview/slo_overview_grid.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export function SloCardChartList({ sloId }: { sloId: string }) {
125125

126126
const rules = rulesBySlo?.[slo?.id];
127127
const activeAlerts = activeAlertsBySlo.get(slo);
128-
const hasGroupBy = Boolean(slo.groupBy && slo.groupBy !== ALL_VALUE);
129128

130129
const data = getSloChartData({
131130
slo,
@@ -141,7 +140,6 @@ export function SloCardChartList({ sloId }: { sloId: string }) {
141140
rules={rules}
142141
activeAlerts={activeAlerts}
143142
handleCreateRule={() => {}}
144-
hasGroupBy={hasGroupBy}
145143
/>
146144
);
147145
chartsData[chartsData.length - 1].push(data);

0 commit comments

Comments
 (0)