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AAA,EAAAA,IAAUC,EAAAA,IAC9B,OAAIG,GAAsC,iBAAhBA,GAA4BV,EAAwBU,IAC5EN,EAAOM,GACA,CAACA,EAAaN,IAGnBJ,EAAwBK,EAAAA,IACnB,CAACA,EAAAA,GAA2BD,GAG9B,MAACrK,EAAWqK,K,0DC7Dd,SAAShF,EAA6BuF,GAC3C,OAAOxE,EAAAA,EAAAA,UAAQ,KAAMyE,EAAAA,EAAAA,IAAuCD,IAAa,CAACA","sources":["webpack://grafana/./public/app/features/alerting/unified/utils/mute-timings.ts","webpack://grafana/./public/app/features/alerting/unified/components/amroutes/MuteTimingTimeRange.tsx","webpack://grafana/./public/app/features/alerting/unified/components/amroutes/MuteTimingTimeInterval.tsx","webpack://grafana/./public/app/features/alerting/unified/components/amroutes/MuteTimingForm.tsx","webpack://grafana/./public/app/features/alerting/unified/MuteTimings.tsx","webpack://grafana/./public/app/features/alerting/unified/components/AlertingPageWrapper.tsx","webpack://grafana/./public/app/features/alerting/unified/hooks/useAlertManagerSourceName.ts","webpack://grafana/./public/app/features/alerting/unified/hooks/useAlertManagerSources.ts"],"sourcesContent":["import { omitBy, isUndefined } from 'lodash';\n\nimport { MuteTimeInterval, TimeInterval } from 'app/plugins/datasource/alertmanager/types';\n\nimport { MuteTimingFields, MuteTimingIntervalFields } from '../types/mute-timing-form';\n\nexport const DAYS_OF_THE_WEEK = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];\n\nexport const MONTHS = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n];\n\nexport const defaultTimeInterval: MuteTimingIntervalFields = {\n times: [{ start_time: '', end_time: '' }],\n weekdays: '',\n days_of_month: '',\n months: '',\n years: '',\n};\n\nexport const validateArrayField = (value: string, validateValue: (input: string) => boolean, invalidText: string) => {\n if (value) {\n return (\n value\n .split(',')\n .map((x) => x.trim())\n .every((entry) => entry.split(':').every(validateValue)) || invalidText\n );\n } else {\n return true;\n }\n};\n\nconst convertStringToArray = (str: string) => {\n return str ? str.split(',').map((s) => s.trim()) : undefined;\n};\n\nexport const createMuteTiming = (fields: MuteTimingFields): MuteTimeInterval => {\n const timeIntervals: TimeInterval[] = fields.time_intervals.map(\n ({ times, weekdays, days_of_month, months, years }) => {\n const interval = {\n times: times.filter(({ start_time, end_time }) => !!start_time && !!end_time),\n weekdays: convertStringToArray(weekdays)?.map((v) => v.toLowerCase()),\n days_of_month: convertStringToArray(days_of_month),\n months: convertStringToArray(months),\n years: convertStringToArray(years),\n };\n\n return omitBy(interval, isUndefined);\n }\n );\n\n return {\n name: fields.name,\n time_intervals: timeIntervals,\n };\n};\n","import { css } from '@emotion/css';\nimport React, { FC } from 'react';\nimport { useFieldArray, useFormContext } from 'react-hook-form';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Field, InlineFieldRow, InlineField, Input, Button, IconButton, useStyles2 } from '@grafana/ui';\n\nimport { MuteTimingFields } from '../../types/mute-timing-form';\n\ninterface Props {\n intervalIndex: number;\n}\n\nexport const MuteTimingTimeRange: FC = ({ intervalIndex }) => {\n const styles = useStyles2(getStyles);\n const { register, formState } = useFormContext();\n\n const {\n fields: timeRanges,\n append: addTimeRange,\n remove: removeTimeRange,\n } = useFieldArray({\n name: `time_intervals.${intervalIndex}.times`,\n });\n\n const validateTime = (timeString: string) => {\n if (!timeString) {\n return true;\n }\n const [hour, minutes] = timeString.split(':').map((x) => parseInt(x, 10));\n const isHourValid = hour >= 0 && hour < 25;\n const isMinuteValid = minutes > -1 && minutes < 60;\n const isTimeValid = hour === 24 ? minutes === 0 : isHourValid && isMinuteValid;\n\n return isTimeValid || 'Time is invalid';\n };\n\n const formErrors = formState.errors.time_intervals?.[intervalIndex];\n const timeRangeInvalid = formErrors?.times?.some((value) => value?.start_time || value?.end_time) ?? false;\n\n return (\n
\n \n <>\n {timeRanges.map((timeRange, index) => {\n return (\n
\n \n \n \n \n \n \n \n {\n e.preventDefault();\n removeTimeRange(index);\n }}\n />\n \n
\n );\n })}\n \n \n addTimeRange({ start_time: '', end_time: '' })}\n >\n Add another time range\n \n
\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n field: css`\n margin-bottom: 0;\n `,\n timeRange: css`\n margin-bottom: ${theme.spacing(1)};\n `,\n timeRangeInput: css`\n width: 120px;\n `,\n deleteTimeRange: css`\n margin: ${theme.spacing(1)} 0 0 ${theme.spacing(0.5)};\n `,\n addTimeRange: css`\n margin-bottom: ${theme.spacing(2)};\n `,\n});\n","import { css } from '@emotion/css';\nimport React from 'react';\nimport { useFormContext, useFieldArray } from 'react-hook-form';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Button, Input, Field, FieldSet, useStyles2 } from '@grafana/ui';\n\nimport { MuteTimingFields } from '../../types/mute-timing-form';\nimport { DAYS_OF_THE_WEEK, MONTHS, validateArrayField, defaultTimeInterval } from '../../utils/mute-timings';\n\nimport { MuteTimingTimeRange } from './MuteTimingTimeRange';\n\nexport const MuteTimingTimeInterval = () => {\n const styles = useStyles2(getStyles);\n const { formState, register } = useFormContext();\n const {\n fields: timeIntervals,\n append: addTimeInterval,\n remove: removeTimeInterval,\n } = useFieldArray({\n name: 'time_intervals',\n });\n\n return (\n
\n <>\n

\n A time interval is a definition for a moment in time. All fields are lists, and at least one list element must\n be satisfied to match the field. If a field is left blank, any moment of time will match the field. For an\n instant of time to match a complete time interval, all fields must match. A mute timing can contain multiple\n time intervals.\n

\n {timeIntervals.map((timeInterval, timeIntervalIndex) => {\n const errors = formState.errors;\n return (\n
\n \n \n \n validateArrayField(\n value,\n (day) => DAYS_OF_THE_WEEK.includes(day.toLowerCase()),\n 'Invalid day of the week'\n ),\n })}\n className={styles.input}\n data-testid=\"mute-timing-weekdays\"\n // @ts-ignore react-hook-form doesn't handle nested field arrays well\n defaultValue={timeInterval.weekdays}\n placeholder=\"Example: monday, tuesday:thursday\"\n />\n \n \n \n validateArrayField(\n value,\n (day) => {\n const parsedDay = parseInt(day, 10);\n return (parsedDay > -31 && parsedDay < 0) || (parsedDay > 0 && parsedDay < 32);\n },\n 'Invalid day'\n ),\n })}\n className={styles.input}\n // @ts-ignore react-hook-form doesn't handle nested field arrays well\n defaultValue={timeInterval.days_of_month}\n placeholder=\"Example: 1, 14:16, -1\"\n data-testid=\"mute-timing-days\"\n />\n \n \n \n validateArrayField(\n value,\n (month) => MONTHS.includes(month) || (parseInt(month, 10) < 13 && parseInt(month, 10) > 0),\n 'Invalid month'\n ),\n })}\n className={styles.input}\n placeholder=\"Example: 1:3, may:august, december\"\n // @ts-ignore react-hook-form doesn't handle nested field arrays well\n defaultValue={timeInterval.months}\n data-testid=\"mute-timing-months\"\n />\n \n \n validateArrayField(value, (year) => /^\\d{4}$/.test(year), 'Invalid year'),\n })}\n className={styles.input}\n placeholder=\"Example: 2021:2022, 2030\"\n // @ts-ignore react-hook-form doesn't handle nested field arrays well\n defaultValue={timeInterval.years}\n data-testid=\"mute-timing-years\"\n />\n \n removeTimeInterval(timeIntervalIndex)}\n >\n Remove time interval\n \n
\n );\n })}\n {\n addTimeInterval(defaultTimeInterval);\n }}\n icon=\"plus\"\n >\n Add another time interval\n \n \n
\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n input: css`\n width: 400px;\n `,\n timeIntervalLegend: css`\n legend {\n font-size: 1.25rem;\n }\n `,\n timeIntervalSection: css`\n background-color: ${theme.colors.background.secondary};\n padding: ${theme.spacing(1)};\n margin-bottom: ${theme.spacing(1)};\n `,\n removeTimeIntervalButton: css`\n margin-top: ${theme.spacing(1)};\n `,\n});\n","import { css } from '@emotion/css';\nimport React, { useMemo } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { useDispatch } from 'react-redux';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { Alert, Field, FieldSet, Input, Button, LinkButton, useStyles2 } from '@grafana/ui';\nimport {\n AlertmanagerConfig,\n AlertManagerCortexConfig,\n MuteTimeInterval,\n} from 'app/plugins/datasource/alertmanager/types';\n\nimport { useAlertManagerSourceName } from '../../hooks/useAlertManagerSourceName';\nimport { useAlertManagersByPermission } from '../../hooks/useAlertManagerSources';\nimport { useUnifiedAlertingSelector } from '../../hooks/useUnifiedAlertingSelector';\nimport { updateAlertManagerConfigAction } from '../../state/actions';\nimport { MuteTimingFields } from '../../types/mute-timing-form';\nimport { renameMuteTimings } from '../../utils/alertmanager';\nimport { makeAMLink } from '../../utils/misc';\nimport { createMuteTiming, defaultTimeInterval } from '../../utils/mute-timings';\nimport { initialAsyncRequestState } from '../../utils/redux';\nimport { AlertManagerPicker } from '../AlertManagerPicker';\nimport { AlertingPageWrapper } from '../AlertingPageWrapper';\n\nimport { MuteTimingTimeInterval } from './MuteTimingTimeInterval';\n\ninterface Props {\n muteTiming?: MuteTimeInterval;\n showError?: boolean;\n}\n\nconst useDefaultValues = (muteTiming?: MuteTimeInterval): MuteTimingFields => {\n return useMemo(() => {\n const defaultValues = {\n name: '',\n time_intervals: [defaultTimeInterval],\n };\n\n if (!muteTiming) {\n return defaultValues;\n }\n\n const intervals = muteTiming.time_intervals.map((interval) => ({\n times: interval.times ?? defaultTimeInterval.times,\n weekdays: interval?.weekdays?.join(', ') ?? defaultTimeInterval.weekdays,\n days_of_month: interval?.days_of_month?.join(', ') ?? defaultTimeInterval.days_of_month,\n months: interval?.months?.join(', ') ?? defaultTimeInterval.months,\n years: interval?.years?.join(', ') ?? defaultTimeInterval.years,\n }));\n\n return {\n name: muteTiming.name,\n time_intervals: intervals,\n };\n }, [muteTiming]);\n};\n\nconst MuteTimingForm = ({ muteTiming, showError }: Props) => {\n const dispatch = useDispatch();\n const alertManagers = useAlertManagersByPermission('notification');\n const [alertManagerSourceName, setAlertManagerSourceName] = useAlertManagerSourceName(alertManagers);\n const styles = useStyles2(getStyles);\n\n const defaultAmCortexConfig = { alertmanager_config: {}, template_files: {} };\n const amConfigs = useUnifiedAlertingSelector((state) => state.amConfigs);\n const { result = defaultAmCortexConfig, loading } =\n (alertManagerSourceName && amConfigs[alertManagerSourceName]) || initialAsyncRequestState;\n\n const config: AlertmanagerConfig = result?.alertmanager_config ?? {};\n const defaultValues = useDefaultValues(muteTiming);\n const formApi = useForm({ defaultValues });\n\n const onSubmit = (values: MuteTimingFields) => {\n const newMuteTiming = createMuteTiming(values);\n\n const muteTimings = muteTiming\n ? config?.mute_time_intervals?.filter(({ name }) => name !== muteTiming.name)\n : config.mute_time_intervals;\n\n const newConfig: AlertManagerCortexConfig = {\n ...result,\n alertmanager_config: {\n ...config,\n route:\n muteTiming && newMuteTiming.name !== muteTiming.name\n ? renameMuteTimings(newMuteTiming.name, muteTiming.name, config.route ?? {})\n : config.route,\n mute_time_intervals: [...(muteTimings || []), newMuteTiming],\n },\n };\n\n dispatch(\n updateAlertManagerConfigAction({\n newConfig,\n oldConfig: result,\n alertManagerSourceName: alertManagerSourceName!,\n successMessage: 'Mute timing saved',\n redirectPath: '/alerting/routes/',\n })\n );\n };\n\n return (\n \n \n {result && !loading && (\n \n
\n {showError && }\n
\n \n {\n if (!muteTiming) {\n const existingMuteTiming = config?.mute_time_intervals?.find(({ name }) => value === name);\n return existingMuteTiming ? `Mute timing already exists for \"${value}\"` : true;\n }\n return value.length > 0 || 'Name is required';\n },\n })}\n className={styles.input}\n data-testid={'mute-timing-name'}\n />\n \n \n \n Cancel\n \n \n
\n \n
\n )}\n
\n );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n input: css`\n width: 400px;\n `,\n submitButton: css`\n margin-left: ${theme.spacing(1)};\n `,\n});\n\nexport default MuteTimingForm;\n","import React, { useCallback, useEffect } from 'react';\nimport { useDispatch } from 'react-redux';\nimport { Route, Redirect, Switch } from 'react-router-dom';\n\nimport { Alert, LoadingPlaceholder } from '@grafana/ui';\nimport { useQueryParams } from 'app/core/hooks/useQueryParams';\nimport { MuteTimeInterval } from 'app/plugins/datasource/alertmanager/types';\n\nimport MuteTimingForm from './components/amroutes/MuteTimingForm';\nimport { useAlertManagerSourceName } from './hooks/useAlertManagerSourceName';\nimport { useAlertManagersByPermission } from './hooks/useAlertManagerSources';\nimport { useUnifiedAlertingSelector } from './hooks/useUnifiedAlertingSelector';\nimport { fetchAlertManagerConfigAction } from './state/actions';\nimport { initialAsyncRequestState } from './utils/redux';\n\nconst MuteTimings = () => {\n const [queryParams] = useQueryParams();\n const dispatch = useDispatch();\n const alertManagers = useAlertManagersByPermission('notification');\n const [alertManagerSourceName] = useAlertManagerSourceName(alertManagers);\n\n const amConfigs = useUnifiedAlertingSelector((state) => state.amConfigs);\n\n const fetchConfig = useCallback(() => {\n if (alertManagerSourceName) {\n dispatch(fetchAlertManagerConfigAction(alertManagerSourceName));\n }\n }, [alertManagerSourceName, dispatch]);\n\n useEffect(() => {\n fetchConfig();\n }, [fetchConfig]);\n\n const { result, error, loading } =\n (alertManagerSourceName && amConfigs[alertManagerSourceName]) || initialAsyncRequestState;\n\n const config = result?.alertmanager_config;\n\n const getMuteTimingByName = useCallback(\n (id: string): MuteTimeInterval | undefined => {\n return config?.mute_time_intervals?.find(({ name }: MuteTimeInterval) => name === id);\n },\n [config]\n );\n\n return (\n <>\n {loading && }\n {error && !loading && (\n \n {error.message || 'Unknown error.'}\n \n )}\n {result && !error && (\n \n \n \n \n \n {() => {\n if (queryParams['muteName']) {\n const muteTiming = getMuteTimingByName(String(queryParams['muteName']));\n return ;\n }\n return ;\n }}\n \n \n )}\n \n );\n};\n\nexport default MuteTimings;\n","import React, { FC } from 'react';\nimport { useSelector } from 'react-redux';\n\nimport Page from 'app/core/components/Page/Page';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { StoreState } from 'app/types/store';\n\ninterface Props {\n pageId: string;\n isLoading?: boolean;\n}\n\nexport const AlertingPageWrapper: FC = ({ children, pageId, isLoading }) => {\n const navModel = getNavModel(\n useSelector((state: StoreState) => state.navIndex),\n pageId\n );\n\n return (\n \n {children}\n \n );\n};\n","import { useCallback } from 'react';\n\nimport { useQueryParams } from 'app/core/hooks/useQueryParams';\nimport store from 'app/core/store';\n\nimport { ALERTMANAGER_NAME_LOCAL_STORAGE_KEY, ALERTMANAGER_NAME_QUERY_KEY } from '../utils/constants';\nimport { AlertManagerDataSource, GRAFANA_RULES_SOURCE_NAME } from '../utils/datasource';\n\nfunction useIsAlertManagerAvailable(availableAlertManagers: AlertManagerDataSource[]) {\n return useCallback(\n (alertManagerName: string) => {\n const availableAlertManagersNames = availableAlertManagers.map((am) => am.name);\n return availableAlertManagersNames.includes(alertManagerName);\n },\n [availableAlertManagers]\n );\n}\n\n/* This will return am name either from query params or from local storage or a default (grafana).\n * Due to RBAC permissions Grafana Managed Alert manager or external alert managers may not be available\n * In the worst case neihter GMA nor external alert manager is available\n */\nexport function useAlertManagerSourceName(\n availableAlertManagers: AlertManagerDataSource[]\n): [string | undefined, (alertManagerSourceName: string) => void] {\n const [queryParams, updateQueryParams] = useQueryParams();\n const isAlertManagerAvailable = useIsAlertManagerAvailable(availableAlertManagers);\n\n const update = useCallback(\n (alertManagerSourceName: string) => {\n if (!isAlertManagerAvailable(alertManagerSourceName)) {\n return;\n }\n if (alertManagerSourceName === GRAFANA_RULES_SOURCE_NAME) {\n store.delete(ALERTMANAGER_NAME_LOCAL_STORAGE_KEY);\n updateQueryParams({ [ALERTMANAGER_NAME_QUERY_KEY]: null });\n } else {\n store.set(ALERTMANAGER_NAME_LOCAL_STORAGE_KEY, alertManagerSourceName);\n updateQueryParams({ [ALERTMANAGER_NAME_QUERY_KEY]: alertManagerSourceName });\n }\n },\n [updateQueryParams, isAlertManagerAvailable]\n );\n\n const querySource = queryParams[ALERTMANAGER_NAME_QUERY_KEY];\n\n if (querySource && typeof querySource === 'string') {\n if (isAlertManagerAvailable(querySource)) {\n return [querySource, update];\n } else {\n // non existing alertmanager\n return [undefined, update];\n }\n }\n\n const storeSource = store.get(ALERTMANAGER_NAME_LOCAL_STORAGE_KEY);\n if (storeSource && typeof storeSource === 'string' && isAlertManagerAvailable(storeSource)) {\n update(storeSource);\n return [storeSource, update];\n }\n\n if (isAlertManagerAvailable(GRAFANA_RULES_SOURCE_NAME)) {\n return [GRAFANA_RULES_SOURCE_NAME, update];\n }\n\n return [undefined, update];\n}\n","import { useMemo } from 'react';\n\nimport { getAlertManagerDataSourcesByPermission } from '../utils/datasource';\n\nexport function useAlertManagersByPermission(accessType: 'instance' | 'notification') {\n return useMemo(() => getAlertManagerDataSourcesByPermission(accessType), [accessType]);\n}\n"],"names":["DAYS_OF_THE_WEEK","MONTHS","defaultTimeInterval","times","start_time","end_time","weekdays","days_of_month","months","years","validateArrayField","value","validateValue","invalidText","split","map","x","trim","every","entry","convertStringToArray","str","s","undefined","MuteTimingTimeRange","intervalIndex","styles","useStyles2","getStyles","register","formState","useFormContext","fields","timeRanges","append","addTimeRange","remove","removeTimeRange","useFieldArray","name","validateTime","timeString","hour","minutes","parseInt","formErrors","errors","time_intervals","timeRangeInvalid","some","Field","className","field","label","description","invalid","error","timeRange","index","InlineFieldRow","InlineField","Input","validate","timeRangeInput","defaultValue","placeholder","IconButton","deleteTimeRange","title","type","onClick","e","preventDefault","id","Button","variant","icon","theme","css","spacing","MuteTimingTimeInterval","timeIntervals","addTimeInterval","removeTimeInterval","FieldSet","timeIntervalLegend","timeInterval","timeIntervalIndex","timeIntervalSection","message","day","includes","toLowerCase","input","parsedDay","month","year","test","removeTimeIntervalButton","colors","background","secondary","submitButton","muteTiming","showError","dispatch","useDispatch","alertManagers","useAlertManagersByPermission","alertManagerSourceName","setAlertManagerSourceName","useAlertManagerSourceName","defaultAmCortexConfig","alertmanager_config","template_files","amConfigs","useUnifiedAlertingSelector","state","result","loading","initialAsyncRequestState","config","defaultValues","useMemo","intervals","interval","join","useDefaultValues","formApi","useForm","AlertingPageWrapper","pageId","AlertManagerPicker","current","onChange","disabled","dataSources","onSubmit","handleSubmit","values","newMuteTiming","filter","v","omitBy","isUndefined","createMuteTiming","muteTimings","mute_time_intervals","newConfig","route","renameMuteTimings","updateAlertManagerConfigAction","oldConfig","successMessage","redirectPath","Alert","required","find","length","LinkButton","href","makeAMLink","queryParams","useQueryParams","fetchConfig","useCallback","fetchAlertManagerConfigAction","useEffect","getMuteTimingByName","LoadingPlaceholder","text","severity","exact","path","String","to","children","isLoading","navModel","getNavModel","useSelector","navIndex","availableAlertManagers","updateQueryParams","isAlertManagerAvailable","alertManagerName","am","useIsAlertManagerAvailable","update","GRAFANA_RULES_SOURCE_NAME","store","ALERTMANAGER_NAME_LOCAL_STORAGE_KEY","ALERTMANAGER_NAME_QUERY_KEY","querySource","storeSource","accessType","getAlertManagerDataSourcesByPermission"],"sourceRoot":""}