Skip to content

Commit d363905

Browse files
fix(alert): keep alert description saved after an alert is edited (#4436)
* fix(alert): add alert description in api.putCheck data * test(alderBuilder): add description in mock state
1 parent 78e00f4 commit d363905

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/alerting/reducers/alertBuilder.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const mockState = (): AlertBuilderState => ({
5959
level: 'OK',
6060
thresholds: [],
6161
status: RemoteDataState.Done,
62+
description: 'mock test',
6263
})
6364

6465
describe('alertBuilderReducer', () => {

src/alerting/reducers/alertBuilder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from 'src/alerting/constants'
1818

1919
type FromBase = Required<
20-
Pick<CheckBase, 'name' | 'id' | 'activeStatus' | 'status'>
20+
Pick<CheckBase, 'name' | 'id' | 'activeStatus' | 'status' | 'description'>
2121
>
2222

2323
type FromThreshold = Required<
@@ -53,6 +53,7 @@ export const initialState = (): AlertBuilderState => ({
5353
staleTime: '10m',
5454
level: DEFAULT_DEADMAN_LEVEL,
5555
thresholds: [],
56+
description: '',
5657
})
5758

5859
export default (
@@ -73,7 +74,7 @@ export default (
7374
}
7475

7576
case 'SET_ALERT_BUILDER_CHECK': {
76-
const {id, type, name, query} = action.payload.check
77+
const {id, type, name, query, description} = action.payload.check
7778

7879
const newState = {
7980
...initialState(),
@@ -82,6 +83,7 @@ export default (
8283
name,
8384
query: {...query},
8485
type,
86+
description,
8587
}
8688

8789
if (action.payload.check.type === 'custom') {

src/checks/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const validateBuilder = (alertBuilder: AlertBuilder) => {
112112
}
113113

114114
const genCheckBase = (state: AppState): Check => {
115-
const {type, id, status, activeStatus, name} = state.alertBuilder
115+
const {type, id, status, activeStatus, name, description} = state.alertBuilder
116116
const {draftQueries} = getActiveTimeMachine(state)
117117
const {id: orgID} = getOrg(state)
118118

@@ -125,5 +125,6 @@ const genCheckBase = (state: AppState): Check => {
125125
query: draftQueries[0],
126126
orgID,
127127
labels: [],
128+
description,
128129
} as Check
129130
}

0 commit comments

Comments
 (0)