-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Update business services table to use ActionsColumn (#1921)
Related to #1318 ![image](https://github.com/konveyor/tackle2-ui/assets/60384172/c8a51e2e-171d-4637-865b-2f784b213f89) OR ![image](https://github.com/konveyor/tackle2-ui/assets/60384172/cff3f0bf-99dc-41f2-b578-6e119e3b4d9c) --------- Signed-off-by: Maayan Hadasi <[email protected]> Signed-off-by: Scott Dickerson <[email protected]> Co-authored-by: Scott Dickerson <[email protected]>
- Loading branch information
Showing
3 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
client/src/app/pages/controls/ControlTableActionButtons.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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, 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="pencil-action"> | ||
<Tooltip content={t("actions.edit")}> | ||
<Button variant="plain" icon={<PencilAltIcon />} onClick={onEdit} /> | ||
</Tooltip> | ||
</Td> | ||
<Td isActionCell id="row-actions"> | ||
<ActionsColumn | ||
items={[ | ||
{ | ||
isAriaDisabled: isDeleteEnabled, | ||
tooltipProps: { | ||
content: isDeleteEnabled ? deleteTooltipMessage : "", | ||
}, | ||
isDanger: isDeleteEnabled == false, | ||
title: t("actions.delete"), | ||
onClick: onDelete, | ||
}, | ||
]} | ||
/> | ||
</Td> | ||
</RBAC> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters