|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; |
|
|
|
|
import { Button, HorizontalGroup, IconButton } from '@grafana/ui'; |
|
|
|
|
import { Button, ConfirmModal, HorizontalGroup, IconButton } from '@grafana/ui'; |
|
|
|
|
import { AmRouteReceiver, FormAmRoute } from '../../types/amroutes'; |
|
|
|
|
import { prepareItems } from '../../utils/dynamicTable'; |
|
|
|
|
import { DynamicTable, DynamicTableColumnProps, DynamicTableItemProps } from '../DynamicTable'; |
|
|
|
@ -75,6 +75,7 @@ export const AmRoutesTable: FC<AmRoutesTableProps> = ({ |
|
|
|
|
alertManagerSourceName, |
|
|
|
|
}) => { |
|
|
|
|
const [editMode, setEditMode] = useState(false); |
|
|
|
|
const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false); |
|
|
|
|
const [expandedId, setExpandedId] = useState<string | number>(); |
|
|
|
|
const permissions = getNotificationsPermissions(alertManagerSourceName); |
|
|
|
|
const canEditRoutes = contextSrv.hasPermission(permissions.update); |
|
|
|
@ -135,27 +136,40 @@ export const AmRoutesTable: FC<AmRoutesTableProps> = ({ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<HorizontalGroup> |
|
|
|
|
<Button |
|
|
|
|
aria-label="Edit route" |
|
|
|
|
icon="pen" |
|
|
|
|
onClick={expandWithCustomContent} |
|
|
|
|
size="sm" |
|
|
|
|
type="button" |
|
|
|
|
variant="secondary" |
|
|
|
|
> |
|
|
|
|
Edit |
|
|
|
|
</Button> |
|
|
|
|
<IconButton |
|
|
|
|
aria-label="Delete route" |
|
|
|
|
name="trash-alt" |
|
|
|
|
onClick={() => { |
|
|
|
|
<> |
|
|
|
|
<HorizontalGroup> |
|
|
|
|
<Button |
|
|
|
|
aria-label="Edit route" |
|
|
|
|
icon="pen" |
|
|
|
|
onClick={expandWithCustomContent} |
|
|
|
|
size="sm" |
|
|
|
|
type="button" |
|
|
|
|
variant="secondary" |
|
|
|
|
> |
|
|
|
|
Edit |
|
|
|
|
</Button> |
|
|
|
|
<IconButton |
|
|
|
|
aria-label="Delete route" |
|
|
|
|
name="trash-alt" |
|
|
|
|
onClick={() => { |
|
|
|
|
setShowDeleteModal(true); |
|
|
|
|
}} |
|
|
|
|
type="button" |
|
|
|
|
/> |
|
|
|
|
</HorizontalGroup> |
|
|
|
|
<ConfirmModal |
|
|
|
|
isOpen={showDeleteModal} |
|
|
|
|
title="Delete notification policy" |
|
|
|
|
body="Deleting this notification policy will permanently remove it. Are you sure you want to delete this policy?" |
|
|
|
|
confirmText="Yes, delete" |
|
|
|
|
icon="exclamation-triangle" |
|
|
|
|
onConfirm={() => { |
|
|
|
|
const newRoutes = deleteRoute(routes, item.data); |
|
|
|
|
onChange(newRoutes); |
|
|
|
|
}} |
|
|
|
|
type="button" |
|
|
|
|
onDismiss={() => setShowDeleteModal(false)} |
|
|
|
|
/> |
|
|
|
|
</HorizontalGroup> |
|
|
|
|
</> |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
size: '100px', |
|
|
|
|