From 34f5ce004162b45d09bb9d5272f473aa83f29ddc Mon Sep 17 00:00:00 2001 From: asalem Date: Thu, 24 Oct 2019 06:36:04 -0700 Subject: [PATCH] fix(actions/checks): made suggested changes to actions" --- ui/src/alerting/actions/checks.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ui/src/alerting/actions/checks.ts b/ui/src/alerting/actions/checks.ts index 865dcd9ac05..a5fbe24ff89 100644 --- a/ui/src/alerting/actions/checks.ts +++ b/ui/src/alerting/actions/checks.ts @@ -1,6 +1,7 @@ // Libraries import {Dispatch} from 'react' import {push} from 'react-router-redux' +import {get} from 'lodash' // Constants import * as copy from 'src/shared/copy/notifications' @@ -151,16 +152,12 @@ export const saveCheckFromTimeMachine = () => async ( alerting: {check}, } = getActiveTimeMachine(state) + const labels = get(check, 'labels', []) const checkWithOrg = { ...check, query: draftQueries[0], orgID, - labels: - (check && - check.labels && - Array.isArray(check.labels) && - check.labels.map(l => l.id)) || - [], + labels: labels.map(l => l.id), } as PostCheck const resp = check.id @@ -258,10 +255,11 @@ export const cloneCheck = (check: Check) => async ( const allCheckNames = list.map(c => c.name) const clonedName = incrementCloneName(allCheckNames, check.name) + const labels = get(check, 'labels', []) const data = { ...check, name: clonedName, - labels: check.labels.map(l => l.id), + labels: labels.map(l => l.id), } as PostCheck const resp = await api.postCheck({data})