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AOiC,KAI9E,SAASW,IACd,OAAOrB,MAAAA,IACL,MAEMsB,SAFsClB,EAAAA,EAAAA,iBAAgBC,IAAK,yBAExBkB,MAAK,CAACC,EAAIC,IAC7CD,EAAGjG,KAAOkG,EAAGlG,KACR,GAED,IAGV0E,GAASyB,EAAAA,EAAAA,IAAwBJ,KAI9B,SAASK,EAAwBlD,GACtC,OAAOuB,MAAAA,UACCC,EAASoB,KACf,MAAMD,QAA4BhB,EAAAA,EAAAA,iBAAgBC,IAAK,4BAA2B5B,KAClFwB,GAAS2B,EAAAA,EAAAA,GAA0BR","sources":["webpack://grafana/./public/app/features/alerting/AlertHowToModal.tsx","webpack://grafana/./public/app/features/alerting/AlertRuleItem.tsx","webpack://grafana/./public/app/features/alerting/components/DeprecationNotice.tsx","webpack://grafana/./public/app/features/alerting/state/selectors.ts","webpack://grafana/./public/app/features/alerting/AlertRuleList.tsx","webpack://grafana/./public/app/features/alerting/state/actions.ts"],"sourcesContent":["import React from 'react';\n\nimport { Modal, VerticalGroup } from '@grafana/ui';\n\nexport interface AlertHowToModalProps {\n onDismiss: () => void;\n}\n\nexport function AlertHowToModal({ onDismiss }: AlertHowToModalProps): JSX.Element {\n return (\n <Modal title=\"Adding an Alert\" isOpen onDismiss={onDismiss} onClickBackdrop={onDismiss}>\n <VerticalGroup spacing=\"sm\">\n <img src=\"public/img/alert_howto_new.png\" alt=\"link to how to alert image\" />\n <p>\n Alerts are added and configured in the Alert tab of any dashboard graph panel, letting you build and visualize\n an alert using existing queries.\n </p>\n <p>Remember to save the dashboard to persist your alert rule changes.</p>\n </VerticalGroup>\n </Modal>\n );\n}\n","import React, { useCallback } from 'react';\n// @ts-ignore\nimport Highlighter from 'react-highlight-words';\n\nimport { Icon, IconName, Button, LinkButton, Card } from '@grafana/ui';\n\nimport { AlertRule } from '../../types';\n\nexport interface Props {\n rule: AlertRule;\n search: string;\n onTogglePause: () => void;\n}\n\nconst AlertRuleItem = ({ rule, search, onTogglePause }: Props) => {\n const ruleUrl = `${rule.url}?editPanel=${rule.panelId}&tab=alert`;\n const renderText = useCallback(\n (text) => (\n <Highlighter\n key={text}\n highlightClassName=\"highlight-search-match\"\n textToHighlight={text}\n searchWords={[search]}\n />\n ),\n [search]\n );\n\n return (\n <Card>\n <Card.Heading>{renderText(rule.name)}</Card.Heading>\n <Card.Figure>\n <Icon size=\"xl\" name={rule.stateIcon as IconName} className={`alert-rule-item__icon ${rule.stateClass}`} />\n </Card.Figure>\n <Card.Meta>\n <span key=\"state\">\n <span key=\"text\" className={`${rule.stateClass}`}>\n {renderText(rule.stateText)}{' '}\n </span>\n for {rule.stateAge}\n </span>\n {rule.info ? renderText(rule.info) : null}\n </Card.Meta>\n <Card.Actions>\n <Button\n key=\"play\"\n variant=\"secondary\"\n icon={rule.state === 'paused' ? 'play' : 'pause'}\n onClick={onTogglePause}\n >\n {rule.state === 'paused' ? 'Resume' : 'Pause'}\n </Button>\n <LinkButton key=\"edit\" variant=\"secondary\" href={ruleUrl} icon=\"cog\">\n Edit alert\n </LinkButton>\n </Card.Actions>\n </Card>\n );\n};\n\nexport default AlertRuleItem;\n","import React, { FC } from 'react';\n\nimport { Alert } from '@grafana/ui';\n\nexport const LOCAL_STORAGE_KEY = 'grafana.legacyalerting.unifiedalertingpromo';\n\nconst DeprecationNotice: FC<{}> = () => (\n <Alert severity=\"warning\" title=\"Grafana legacy alerting is going away soon\">\n <p>\n You are using Grafana legacy alerting, it has been deprecated and will be removed in the next major version of\n Grafana.\n <br />\n We encourage you to upgrade to the new Grafana alerting experience.\n </p>\n <p>\n See{' '}\n <a href=\"https://grafana.com/docs/grafana/latest/alerting/unified-alerting/difference-old-new/\">\n What’s New with Grafana alerting\n </a>{' '}\n to learn more about what&lsquo;s new or learn{' '}\n <a href=\"https://grafana.com/docs/grafana/latest/alerting/unified-alerting/opt-in/\">\n how to enable the new Grafana alerting feature\n </a>\n .\n </p>\n </Alert>\n);\n\nexport { DeprecationNotice };\n","import { AlertRule, AlertRulesState, NotificationChannelState, StoreState } from 'app/types';\n\nexport const getSearchQuery = (state: AlertRulesState) => state.searchQuery;\n\nexport const getAlertRuleItems = (state: StoreState): AlertRule[] => {\n const regex = new RegExp(state.alertRules.searchQuery, 'i');\n\n return state.alertRules.items.filter((item) => {\n return regex.test(item.name) || regex.test(item.stateText) || regex.test(item.info!);\n });\n};\n\nexport const getNotificationChannel = (state: NotificationChannelState, channelId: number) => {\n if (state.notificationChannel.id === channelId) {\n return state.notificationChannel;\n }\n\n return null;\n};\n","import React, { PureComponent } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport { SelectableValue } from '@grafana/data';\nimport { config, locationService } from '@grafana/runtime';\nimport { Button, FilterInput, LinkButton, Select, VerticalGroup } from '@grafana/ui';\nimport appEvents from 'app/core/app_events';\nimport Page from 'app/core/components/Page/Page';\nimport { GrafanaRouteComponentProps } from 'app/core/navigation/types';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { AlertRule, StoreState } from 'app/types';\n\nimport { ShowModalReactEvent } from '../../types/events';\n\nimport { AlertHowToModal } from './AlertHowToModal';\nimport AlertRuleItem from './AlertRuleItem';\nimport { DeprecationNotice } from './components/DeprecationNotice';\nimport { getAlertRulesAsync, togglePauseAlertRule } from './state/actions';\nimport { setSearchQuery } from './state/reducers';\nimport { getAlertRuleItems, getSearchQuery } from './state/selectors';\n\nfunction mapStateToProps(state: StoreState) {\n return {\n navModel: getNavModel(state.navIndex, 'alert-list'),\n alertRules: getAlertRuleItems(state),\n search: getSearchQuery(state.alertRules),\n isLoading: state.alertRules.isLoading,\n };\n}\n\nconst mapDispatchToProps = {\n getAlertRulesAsync,\n setSearchQuery,\n togglePauseAlertRule,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\ninterface OwnProps extends GrafanaRouteComponentProps<{}, { state: string }> {}\n\nexport type Props = OwnProps & ConnectedProps<typeof connector>;\n\nexport class AlertRuleListUnconnected extends PureComponent<Props> {\n stateFilters = [\n { label: 'All', value: 'all' },\n { label: 'OK', value: 'ok' },\n { label: 'Not OK', value: 'not_ok' },\n { label: 'Alerting', value: 'alerting' },\n { label: 'No data', value: 'no_data' },\n { label: 'Paused', value: 'paused' },\n { label: 'Pending', value: 'pending' },\n ];\n\n componentDidMount() {\n this.fetchRules();\n }\n\n componentDidUpdate(prevProps: Props) {\n if (prevProps.queryParams.state !== this.props.queryParams.state) {\n this.fetchRules();\n }\n }\n\n async fetchRules() {\n await this.props.getAlertRulesAsync({ state: this.getStateFilter() });\n }\n\n getStateFilter(): string {\n return this.props.queryParams.state ?? 'all';\n }\n\n onStateFilterChanged = (option: SelectableValue) => {\n locationService.partial({ state: option.value });\n };\n\n onOpenHowTo = () => {\n appEvents.publish(new ShowModalReactEvent({ component: AlertHowToModal }));\n };\n\n onSearchQueryChange = (value: string) => {\n this.props.setSearchQuery(value);\n };\n\n onTogglePause = (rule: AlertRule) => {\n this.props.togglePauseAlertRule(rule.id, { paused: rule.state !== 'paused' });\n };\n\n alertStateFilterOption = ({ text, value }: { text: string; value: string }) => {\n return (\n <option key={value} value={value}>\n {text}\n </option>\n );\n };\n\n render() {\n const { navModel, alertRules, search, isLoading } = this.props;\n\n return (\n <Page navModel={navModel}>\n <Page.Contents isLoading={isLoading}>\n <div className=\"page-action-bar\">\n <div className=\"gf-form gf-form--grow\">\n <FilterInput placeholder=\"Search alerts\" value={search} onChange={this.onSearchQueryChange} />\n </div>\n <div className=\"gf-form\">\n <label className=\"gf-form-label\" htmlFor=\"alert-state-filter\">\n States\n </label>\n\n <div className=\"width-13\">\n <Select\n inputId={'alert-state-filter'}\n options={this.stateFilters}\n onChange={this.onStateFilterChanged}\n value={this.getStateFilter()}\n />\n </div>\n </div>\n <div className=\"page-action-bar__spacer\" />\n {config.unifiedAlertingEnabled && (\n <LinkButton variant=\"primary\" href=\"alerting/ng/new\">\n Add NG Alert\n </LinkButton>\n )}\n <Button variant=\"secondary\" onClick={this.onOpenHowTo}>\n How to add an alert\n </Button>\n </div>\n <DeprecationNotice />\n <VerticalGroup spacing=\"none\">\n {alertRules.map((rule) => {\n return (\n <AlertRuleItem\n rule={rule as AlertRule}\n key={rule.id}\n search={search}\n onTogglePause={() => this.onTogglePause(rule as AlertRule)}\n />\n );\n })}\n </VerticalGroup>\n </Page.Contents>\n </Page>\n );\n }\n}\n\nexport default connector(AlertRuleListUnconnected);\n","import { getBackendSrv, locationService } from '@grafana/runtime';\nimport { notifyApp } from 'app/core/actions';\nimport { createErrorNotification, createSuccessNotification } from 'app/core/copy/appNotification';\nimport { AlertRuleDTO, NotifierDTO, ThunkResult } from 'app/types';\n\nimport { loadAlertRules, loadedAlertRules, notificationChannelLoaded, setNotificationChannels } from './reducers';\n\nexport function getAlertRulesAsync(options: { state: string }): ThunkResult<void> {\n return async (dispatch) => {\n dispatch(loadAlertRules());\n const rules: AlertRuleDTO[] = await getBackendSrv().get('/api/alerts', options);\n dispatch(loadedAlertRules(rules));\n };\n}\n\nexport function togglePauseAlertRule(id: number, options: { paused: boolean }): ThunkResult<void> {\n return async (dispatch) => {\n await getBackendSrv().post(`/api/alerts/${id}/pause`, options);\n const stateFilter = locationService.getSearchObject().state || 'all';\n dispatch(getAlertRulesAsync({ state: stateFilter.toString() }));\n };\n}\n\nexport function createNotificationChannel(data: any): ThunkResult<Promise<void>> {\n return async (dispatch) => {\n try {\n await getBackendSrv().post(`/api/alert-notifications`, data);\n dispatch(notifyApp(createSuccessNotification('Notification created')));\n locationService.push('/alerting/notifications');\n } catch (error) {\n dispatch(notifyApp(createErrorNotification(error.data.error)));\n }\n };\n}\n\nexport function updateNotificationChannel(data: any): ThunkResult<void> {\n return async (dispatch) => {\n try {\n await getBackendSrv().put(`/api/alert-notifications/${data.id}`, data);\n dispatch(notifyApp(createSuccessNotification('Notification updated')));\n } catch (error) {\n dispatch(notifyApp(createErrorNotification(error.data.error)));\n }\n };\n}\n\nexport function testNotificationChannel(data: any): ThunkResult<void> {\n return async (dispatch, getState) => {\n const channel = getState().notificationChannel.notificationChannel;\n await getBackendSrv().post('/api/alert-notifications/test', { id: channel.id, ...data });\n };\n}\n\nexport function loadNotificationTypes(): ThunkResult<void> {\n return async (dispatch) => {\n const alertNotifiers: NotifierDTO[] = await getBackendSrv().get(`/api/alert-notifiers`);\n\n const notificationTypes = alertNotifiers.sort((o1, o2) => {\n if (o1.name > o2.name) {\n return 1;\n }\n return -1;\n });\n\n dispatch(setNotificationChannels(notificationTypes));\n };\n}\n\nexport function loadNotificationChannel(id: number): ThunkResult<void> {\n return async (dispatch) => {\n await dispatch(loadNotificationTypes());\n const notificationChannel = await getBackendSrv().get(`/api/alert-notifications/${id}`);\n dispatch(notificationChannelLoaded(notificationChannel));\n };\n}\n"],"names":["AlertHowToModal","onDismiss","Modal","title","isOpen","onClickBackdrop","VerticalGroup","spacing","src","alt","rule","search","onTogglePause","ruleUrl","url","panelId","renderText","useCallback","text","highlightClassName","textToHighlight","searchWords","Card","name","Icon","size","stateIcon","className","stateClass","stateText","stateAge","info","Button","variant","icon","state","onClick","LinkButton","href","DeprecationNotice","Alert","severity","getSearchQuery","searchQuery","getAlertRuleItems","regex","RegExp","alertRules","items","filter","item","test","mapDispatchToProps","getAlertRulesAsync","setSearchQuery","togglePauseAlertRule","connector","connect","navModel","getNavModel","navIndex","isLoading","AlertRuleListUnconnected","PureComponent","label","value","option","locationService","appEvents","ShowModalReactEvent","component","this","props","id","paused","componentDidMount","fetchRules","componentDidUpdate","prevProps","queryParams","getStateFilter","render","Page","FilterInput","placeholder","onChange","onSearchQueryChange","htmlFor","Select","inputId","options","stateFilters","onStateFilterChanged","config","onOpenHowTo","map","async","dispatch","loadAlertRules","rules","getBackendSrv","get","loadedAlertRules","post","toString","createNotificationChannel","data","notifyApp","createSuccessNotification","error","createErrorNotification","updateNotificationChannel","put","testNotificationChannel","getState","channel","notificationChannel","loadNotificationTypes","notificationTypes","sort","o1","o2","setNotificationChannels","loadNotificationChannel","notificationChannelLoaded"],"sourceRoot":""}