Skip to content

Commit

Permalink
feat: show different table menu depending on resource type
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Jul 16, 2024
1 parent 6654900 commit 17bbe66
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ const columns = [
columnsHelper.display({
id: "resource_menu",
header: () => <TableHeader>Actions</TableHeader>,
cell: ({ row }) => <ResourceTableMenu resourceId={row.original.id} />,
cell: ({ row }) => (
<ResourceTableMenu
resourceId={row.original.id}
type={row.original.type}
/>
),
size: 24,
}),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {
BiTrash,
} from "react-icons/bi"

import type { ResourceTableData } from "./types"
import { MenuItem } from "~/components/Menu"

export const ResourceTableMenu = ({
resourceId: _resourceId,
}: {
resourceId: string
}) => {
interface ResourceTableMenuProps {
resourceId: ResourceTableData["id"]
type: ResourceTableData["type"]
}

export const ResourceTableMenu = ({ type }: ResourceTableMenuProps) => {
return (
<Menu isLazy size="sm">
<MenuButton
Expand All @@ -26,10 +28,20 @@ export const ResourceTableMenu = ({
/>
<MenuList>
{/* TODO: Open edit modal depending on resource */}
<MenuItem icon={<BiCog fontSize="1rem" />}>Edit page settings</MenuItem>
<MenuItem icon={<BiDuplicate fontSize="1rem" />}>
Duplicate page
</MenuItem>
{type === "page" ? (
<>
<MenuItem icon={<BiCog fontSize="1rem" />}>
Edit page settings
</MenuItem>
<MenuItem icon={<BiDuplicate fontSize="1rem" />}>
Duplicate page
</MenuItem>
</>
) : (
<MenuItem icon={<BiCog fontSize="1rem" />}>
Edit folder settings
</MenuItem>
)}
<MenuItem icon={<BiFolderOpen fontSize="1rem" />}>Move to...</MenuItem>
<MenuItem colorScheme="critical" icon={<BiTrash fontSize="1rem" />}>
Delete
Expand Down

0 comments on commit 17bbe66

Please sign in to comment.