-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathControlTableActionButtons.tsx
48 lines (46 loc) · 1.45 KB
/
ControlTableActionButtons.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from "react";
import { useTranslation } from "react-i18next";
import { controlsWriteScopes, RBAC, RBAC_TYPE } from "@app/rbac";
import { ActionsColumn, Td } from "@patternfly/react-table";
import { Button, OverflowMenu, Tooltip } from "@patternfly/react-core";
import { PencilAltIcon } from "@patternfly/react-icons";
export interface ControlTableActionButtonsProps {
isDeleteEnabled?: boolean;
deleteTooltipMessage?: string;
onEdit: () => void;
onDelete: () => void;
}
export const ControlTableActionButtons: React.FC<
ControlTableActionButtonsProps
> = ({
isDeleteEnabled = false,
deleteTooltipMessage = "",
onEdit,
onDelete,
}) => {
const { t } = useTranslation();
return (
<RBAC allowedPermissions={controlsWriteScopes} rbacType={RBAC_TYPE.Scope}>
<Td isActionCell id="action">
<OverflowMenu breakpoint="sm">
<Tooltip content={t("actions.edit")}>
<Button variant="plain" icon={<PencilAltIcon />} onClick={onEdit} />
</Tooltip>
<ActionsColumn
items={[
{
isAriaDisabled: isDeleteEnabled,
tooltipProps: {
content: isDeleteEnabled ? deleteTooltipMessage : "",
},
isDanger: isDeleteEnabled == false,
title: t("actions.delete"),
onClick: onDelete,
},
]}
/>
</OverflowMenu>
</Td>
</RBAC>
);
};