Skip to content

Commit c770a1a

Browse files
authored
chore: remove routing policies feature flag (#9249)
1 parent 101b366 commit c770a1a

File tree

12 files changed

+44
-175
lines changed

12 files changed

+44
-175
lines changed

frontend/src/container/CreateAlertV2/AlertCondition/AlertCondition.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ import APIError from 'types/api/error';
1313
import { useCreateAlertState } from '../context';
1414
import AdvancedOptions from '../EvaluationSettings/AdvancedOptions';
1515
import Stepper from '../Stepper';
16-
import { showCondensedLayout } from '../utils';
1716
import AlertThreshold from './AlertThreshold';
1817
import AnomalyThreshold from './AnomalyThreshold';
1918
import { ANOMALY_TAB_TOOLTIP, THRESHOLD_TAB_TOOLTIP } from './constants';
2019

2120
function AlertCondition(): JSX.Element {
2221
const { alertType, setAlertType } = useCreateAlertState();
23-
const showCondensedLayoutFlag = showCondensedLayout();
2422

2523
const {
2624
data,
@@ -108,11 +106,9 @@ function AlertCondition(): JSX.Element {
108106
refreshChannels={refreshChannels}
109107
/>
110108
)}
111-
{showCondensedLayoutFlag ? (
112-
<div className="condensed-advanced-options-container">
113-
<AdvancedOptions />
114-
</div>
115-
) : null}
109+
<div className="condensed-advanced-options-container">
110+
<AdvancedOptions />
111+
</div>
116112
</div>
117113
);
118114
}

frontend/src/container/CreateAlertV2/AlertCondition/AlertThreshold.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
THRESHOLD_OPERATOR_OPTIONS,
1919
} from '../context/constants';
2020
import EvaluationSettings from '../EvaluationSettings/EvaluationSettings';
21-
import { showCondensedLayout } from '../utils';
2221
import ThresholdItem from './ThresholdItem';
2322
import { AnomalyAndThresholdProps, UpdateThreshold } from './types';
2423
import {
@@ -43,8 +42,6 @@ function AlertThreshold({
4342
setNotificationSettings,
4443
} = useCreateAlertState();
4544

46-
const showCondensedLayoutFlag = showCondensedLayout();
47-
4845
const { currentQuery } = useQueryBuilder();
4946

5047
const queryNames = getQueryNames(currentQuery);
@@ -163,17 +160,12 @@ function AlertThreshold({
163160
}),
164161
);
165162

166-
const evaluationWindowContext = showCondensedLayoutFlag ? (
167-
<EvaluationSettings />
168-
) : (
169-
<strong>Evaluation Window.</strong>
170-
);
171-
172163
return (
173164
<div
174-
className={classNames('alert-threshold-container', {
175-
'condensed-alert-threshold-container': showCondensedLayoutFlag,
176-
})}
165+
className={classNames(
166+
'alert-threshold-container',
167+
'condensed-alert-threshold-container',
168+
)}
177169
>
178170
{/* Main condition sentence */}
179171
<div className="alert-condition-sentences">
@@ -219,7 +211,7 @@ function AlertThreshold({
219211
options={matchTypeOptionsWithTooltips}
220212
/>
221213
<Typography.Text className="sentence-text">
222-
during the {evaluationWindowContext}
214+
during the <EvaluationSettings />
223215
</Typography.Text>
224216
</div>
225217
</div>

frontend/src/container/CreateAlertV2/AlertCondition/__tests__/AlertThreshold.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ jest.mock('container/NewWidget/RightContainer/alertFomatCategories', () => ({
110110

111111
jest.mock('container/CreateAlertV2/utils', () => ({
112112
...jest.requireActual('container/CreateAlertV2/utils'),
113-
showCondensedLayout: jest.fn().mockReturnValue(false),
114113
}));
115114

116115
const TEST_STRINGS = {
@@ -159,7 +158,9 @@ describe('AlertThreshold', () => {
159158
expect(screen.getByText('Send a notification when')).toBeInTheDocument();
160159
expect(screen.getByText('the threshold(s)')).toBeInTheDocument();
161160
expect(screen.getByText('during the')).toBeInTheDocument();
162-
expect(screen.getByText('Evaluation Window.')).toBeInTheDocument();
161+
expect(
162+
screen.getByTestId('condensed-evaluation-settings-container'),
163+
).toBeInTheDocument();
163164
});
164165

165166
it('renders query selection dropdown', async () => {

frontend/src/container/CreateAlertV2/CreateAlertV2.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import AlertCondition from './AlertCondition';
88
import { CreateAlertProvider } from './context';
99
import { buildInitialAlertDef } from './context/utils';
1010
import CreateAlertHeader from './CreateAlertHeader';
11-
import EvaluationSettings from './EvaluationSettings';
1211
import Footer from './Footer';
1312
import NotificationSettings from './NotificationSettings';
1413
import QuerySection from './QuerySection';
1514
import { CreateAlertV2Props } from './types';
16-
import { showCondensedLayout, Spinner } from './utils';
15+
import { Spinner } from './utils';
1716

1817
function CreateAlertV2({ alertType }: CreateAlertV2Props): JSX.Element {
1918
const queryToRedirect = buildInitialAlertDef(alertType);
@@ -23,16 +22,13 @@ function CreateAlertV2({ alertType }: CreateAlertV2Props): JSX.Element {
2322

2423
useShareBuilderUrl({ defaultValue: currentQueryToRedirect });
2524

26-
const showCondensedLayoutFlag = showCondensedLayout();
27-
2825
return (
2926
<CreateAlertProvider initialAlertType={alertType}>
3027
<Spinner />
3128
<div className="create-alert-v2-container">
3229
<CreateAlertHeader />
3330
<QuerySection />
3431
<AlertCondition />
35-
{!showCondensedLayoutFlag ? <EvaluationSettings /> : null}
3632
<NotificationSettings />
3733
</div>
3834
<Footer />

frontend/src/container/CreateAlertV2/EvaluationSettings/EvaluationSettings.tsx

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
import './styles.scss';
22

3-
import { Button, Popover, Typography } from 'antd';
3+
import { Button, Popover } from 'antd';
44
import { ChevronDown, ChevronUp } from 'lucide-react';
55
import { useState } from 'react';
6-
import { AlertTypes } from 'types/api/alerts/alertTypes';
76

87
import { useCreateAlertState } from '../context';
9-
import Stepper from '../Stepper';
10-
import { showCondensedLayout } from '../utils';
11-
import AdvancedOptions from './AdvancedOptions';
128
import EvaluationWindowPopover from './EvaluationWindowPopover';
139
import { getEvaluationWindowTypeText, getTimeframeText } from './utils';
1410

1511
function EvaluationSettings(): JSX.Element {
16-
const {
17-
alertType,
18-
evaluationWindow,
19-
setEvaluationWindow,
20-
} = useCreateAlertState();
12+
const { evaluationWindow, setEvaluationWindow } = useCreateAlertState();
2113
const [
2214
isEvaluationWindowPopoverOpen,
2315
setIsEvaluationWindowPopoverOpen,
2416
] = useState(false);
25-
const showCondensedLayoutFlag = showCondensedLayout();
2617

2718
const popoverContent = (
2819
<Popover
@@ -57,33 +48,12 @@ function EvaluationSettings(): JSX.Element {
5748
</Popover>
5849
);
5950

60-
// Layout consists of only the evaluation window popover
61-
if (showCondensedLayoutFlag) {
62-
return (
63-
<div
64-
className="condensed-evaluation-settings-container"
65-
data-testid="condensed-evaluation-settings-container"
66-
>
67-
{popoverContent}
68-
</div>
69-
);
70-
}
71-
72-
// Layout consists of
73-
// - Stepper header
74-
// - Evaluation window popover
75-
// - Advanced options
7651
return (
77-
<div className="evaluation-settings-container">
78-
<Stepper stepNumber={3} label="Evaluation settings" />
79-
{alertType !== AlertTypes.ANOMALY_BASED_ALERT && (
80-
<div className="evaluate-alert-conditions-container">
81-
<Typography.Text>Check conditions using data from</Typography.Text>
82-
<div className="evaluate-alert-conditions-separator" />
83-
{popoverContent}
84-
</div>
85-
)}
86-
<AdvancedOptions />
52+
<div
53+
className="condensed-evaluation-settings-container"
54+
data-testid="condensed-evaluation-settings-container"
55+
>
56+
{popoverContent}
8757
</div>
8858
);
8959
}
Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { render, screen } from '@testing-library/react';
22
import * as alertState from 'container/CreateAlertV2/context';
3-
import * as utils from 'container/CreateAlertV2/utils';
4-
import { AlertTypes } from 'types/api/alerts/alertTypes';
53

64
import EvaluationSettings from '../EvaluationSettings';
75
import { createMockAlertContextState } from './testUtils';
86

97
jest.mock('container/CreateAlertV2/utils', () => ({
108
...jest.requireActual('container/CreateAlertV2/utils'),
11-
showCondensedLayout: jest.fn().mockReturnValue(false),
129
}));
1310

1411
const mockSetEvaluationWindow = jest.fn();
@@ -18,52 +15,14 @@ jest.spyOn(alertState, 'useCreateAlertState').mockReturnValue(
1815
}),
1916
);
2017

21-
jest.mock('../AdvancedOptions', () => ({
22-
__esModule: true,
23-
default: (): JSX.Element => (
24-
<div data-testid="advanced-options">AdvancedOptions</div>
25-
),
26-
}));
27-
28-
const EVALUATION_SETTINGS_TEXT = 'Evaluation settings';
29-
const CHECK_CONDITIONS_USING_DATA_FROM_TEXT =
30-
'Check conditions using data from';
31-
3218
describe('EvaluationSettings', () => {
33-
it('should render the default evaluation settings layout', () => {
34-
render(<EvaluationSettings />);
35-
expect(screen.getByText(EVALUATION_SETTINGS_TEXT)).toBeInTheDocument();
36-
expect(
37-
screen.getByText(CHECK_CONDITIONS_USING_DATA_FROM_TEXT),
38-
).toBeInTheDocument();
39-
expect(screen.getByTestId('advanced-options')).toBeInTheDocument();
40-
});
41-
42-
it('should not render evaluation window for anomaly based alert', () => {
43-
jest.spyOn(alertState, 'useCreateAlertState').mockReturnValueOnce(
44-
createMockAlertContextState({
45-
alertType: AlertTypes.ANOMALY_BASED_ALERT,
46-
}),
47-
);
48-
render(<EvaluationSettings />);
49-
expect(screen.getByText(EVALUATION_SETTINGS_TEXT)).toBeInTheDocument();
50-
expect(
51-
screen.queryByText(CHECK_CONDITIONS_USING_DATA_FROM_TEXT),
52-
).not.toBeInTheDocument();
53-
});
54-
5519
it('should render the condensed evaluation settings layout', () => {
56-
jest.spyOn(utils, 'showCondensedLayout').mockReturnValueOnce(true);
5720
render(<EvaluationSettings />);
58-
// Header, check conditions using data from and advanced options should be hidden
59-
expect(screen.queryByText(EVALUATION_SETTINGS_TEXT)).not.toBeInTheDocument();
60-
expect(
61-
screen.queryByText(CHECK_CONDITIONS_USING_DATA_FROM_TEXT),
62-
).not.toBeInTheDocument();
63-
expect(screen.queryByTestId('advanced-options')).not.toBeInTheDocument();
64-
// Only evaluation window popover should be visible
6521
expect(
6622
screen.getByTestId('condensed-evaluation-settings-container'),
6723
).toBeInTheDocument();
24+
// Verify that default option is selected
25+
expect(screen.getByText('Rolling')).toBeInTheDocument();
26+
expect(screen.getByText('Last 5 minutes')).toBeInTheDocument();
6827
});
6928
});

frontend/src/container/CreateAlertV2/NotificationSettings/NotificationSettings.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ import {
99
} from '../context/constants';
1010
import AdvancedOptionItem from '../EvaluationSettings/AdvancedOptionItem';
1111
import Stepper from '../Stepper';
12-
import { showCondensedLayout } from '../utils';
1312
import MultipleNotifications from './MultipleNotifications';
1413
import NotificationMessage from './NotificationMessage';
1514

1615
function NotificationSettings(): JSX.Element {
17-
const showCondensedLayoutFlag = showCondensedLayout();
18-
1916
const {
2017
notificationSettings,
2118
setNotificationSettings,
@@ -82,10 +79,7 @@ function NotificationSettings(): JSX.Element {
8279

8380
return (
8481
<div className="notification-settings-container">
85-
<Stepper
86-
stepNumber={showCondensedLayoutFlag ? 3 : 4}
87-
label="Notification settings"
88-
/>
82+
<Stepper stepNumber={3} label="Notification settings" />
8983
<NotificationMessage />
9084
<div className="notification-settings-content">
9185
<MultipleNotifications />

frontend/src/container/CreateAlertV2/NotificationSettings/__tests__/NotificationSettings.test.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { fireEvent, render, screen } from '@testing-library/react';
22
import * as createAlertContext from 'container/CreateAlertV2/context';
33
import { createMockAlertContextState } from 'container/CreateAlertV2/EvaluationSettings/__tests__/testUtils';
4-
import * as utils from 'container/CreateAlertV2/utils';
54

65
import NotificationSettings from '../NotificationSettings';
76

@@ -26,7 +25,6 @@ jest.mock(
2625

2726
jest.mock('container/CreateAlertV2/utils', () => ({
2827
...jest.requireActual('container/CreateAlertV2/utils'),
29-
showCondensedLayout: jest.fn().mockReturnValue(false),
3028
}));
3129

3230
const initialNotificationSettings = createMockAlertContextState()
@@ -42,10 +40,10 @@ const REPEAT_NOTIFICATIONS_TEXT = 'Repeat notifications';
4240
const ENTER_TIME_INTERVAL_TEXT = 'Enter time interval...';
4341

4442
describe('NotificationSettings', () => {
45-
it('renders the notification settings tab with step number 4 and default values', () => {
43+
it('renders the notification settings tab with step number 3 and default values', () => {
4644
render(<NotificationSettings />);
4745
expect(screen.getByText('Notification settings')).toBeInTheDocument();
48-
expect(screen.getByText('4')).toBeInTheDocument();
46+
expect(screen.getByText('3')).toBeInTheDocument();
4947
expect(screen.getByTestId('multiple-notifications')).toBeInTheDocument();
5048
expect(screen.getByTestId('notification-message')).toBeInTheDocument();
5149
expect(screen.getByText(REPEAT_NOTIFICATIONS_TEXT)).toBeInTheDocument();
@@ -56,15 +54,6 @@ describe('NotificationSettings', () => {
5654
).toBeInTheDocument();
5755
});
5856

59-
it('renders the notification settings tab with step number 3 in condensed layout', () => {
60-
jest.spyOn(utils, 'showCondensedLayout').mockReturnValueOnce(true);
61-
render(<NotificationSettings />);
62-
expect(screen.getByText('Notification settings')).toBeInTheDocument();
63-
expect(screen.getByText('3')).toBeInTheDocument();
64-
expect(screen.getByTestId('multiple-notifications')).toBeInTheDocument();
65-
expect(screen.getByTestId('notification-message')).toBeInTheDocument();
66-
});
67-
6857
describe('Repeat notifications', () => {
6958
it('renders the repeat notifications with inputs hidden when the repeat notifications switch is off', () => {
7059
render(<NotificationSettings />);

frontend/src/container/CreateAlertV2/utils.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ import {
2727
import { EVALUATION_WINDOW_TIMEFRAME } from './EvaluationSettings/constants';
2828
import { GetCreateAlertLocalStateFromAlertDefReturn } from './types';
2929

30-
// UI side feature flag
31-
export const showNewCreateAlertsPage = (): boolean =>
32-
localStorage.getItem('showNewCreateAlertsPage') === 'true';
33-
34-
// UI side FF to switch between the 2 layouts of the create alert page
35-
// Layout 1 - Default layout
36-
// Layout 2 - Condensed layout
37-
export const showCondensedLayout = (): boolean =>
38-
localStorage.getItem('hideCondensedLayout') !== 'true';
39-
4030
export function Spinner(): JSX.Element | null {
4131
const { isCreatingAlertRule, isUpdatingAlertRule } = useCreateAlertState();
4232

frontend/src/container/EditAlertV2/EditAlertV2.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { PostableAlertRuleV2 } from 'types/api/alerts/alertTypesV2';
88

99
import AlertCondition from '../CreateAlertV2/AlertCondition';
1010
import { buildInitialAlertDef } from '../CreateAlertV2/context/utils';
11-
import EvaluationSettings from '../CreateAlertV2/EvaluationSettings';
1211
import Footer from '../CreateAlertV2/Footer';
1312
import NotificationSettings from '../CreateAlertV2/NotificationSettings';
1413
import QuerySection from '../CreateAlertV2/QuerySection';
15-
import { showCondensedLayout, Spinner } from '../CreateAlertV2/utils';
14+
import { Spinner } from '../CreateAlertV2/utils';
1615

1716
interface EditAlertV2Props {
1817
alertType?: AlertTypes;
@@ -33,15 +32,12 @@ function EditAlertV2({
3332

3433
useShareBuilderUrl({ defaultValue: currentQueryToRedirect });
3534

36-
const showCondensedLayoutFlag = showCondensedLayout();
37-
3835
return (
3936
<>
4037
<Spinner />
4138
<div className="create-alert-v2-container">
4239
<QuerySection />
4340
<AlertCondition />
44-
{!showCondensedLayoutFlag ? <EvaluationSettings /> : null}
4541
<NotificationSettings />
4642
</div>
4743
<Footer />

0 commit comments

Comments
 (0)