Skip to content

Commit

Permalink
feat: use type column from db for resource list table
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Jul 19, 2024
1 parent de4412b commit 18b87e9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const columns = [
<TitleCell
title={row.original.title}
permalink={`/${row.original.permalink}`}
type={row.original.mainBlobId ? "page" : "folder"}
type={row.original.type}
/>
),
}),
Expand All @@ -38,7 +38,7 @@ const columns = [
<ResourceTableMenu
title={row.original.title}
resourceId={row.original.id}
type={row.original.mainBlobId ? "page" : "folder"}
type={row.original.type}
/>
),
size: 24,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
} from "react-icons/bi"

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

interface ResourceTableMenuProps {
title: ResourceTableData["title"]
resourceId: ResourceTableData["id"]
type: ResourceType
type: ResourceTableData["type"]
}

export const ResourceTableMenu = ({ title, type }: ResourceTableMenuProps) => {
Expand All @@ -31,7 +30,7 @@ export const ResourceTableMenu = ({ title, type }: ResourceTableMenuProps) => {
<Portal>
<MenuList>
{/* TODO: Open edit modal depending on resource */}
{type === "page" ? (
{type === "Page" ? (
<>
<MenuItem icon={<BiCog fontSize="1rem" />}>
Edit page settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { HStack, Icon, Text, VStack } from "@chakra-ui/react"
import { BiFileBlank, BiFolder } from "react-icons/bi"

import type { ResourceTableData } from "./types"
import type { ResourceType } from "~/utils/resource"

export interface TitleCellProps {
title: ResourceTableData["title"]
permalink?: ResourceTableData["permalink"]
type: ResourceType
}
export type TitleCellProps = Pick<
ResourceTableData,
"title" | "permalink" | "type"
>

export const TitleCell = ({
title,
Expand All @@ -19,7 +17,7 @@ export const TitleCell = ({
<HStack align="center" spacing="0.625rem">
<Icon
fontSize="1.25rem"
as={type === "page" ? BiFileBlank : BiFolder}
as={type === "Page" ? BiFileBlank : BiFolder}
color="base.content.strong"
/>
<VStack spacing="0.25rem" align="start">
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/server/modules/page/page.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const pageRouter = router({
"Resource.title",
"Resource.mainBlobId",
"Resource.draftBlobId",
"Resource.type",
])
.execute()
}),
Expand Down
4 changes: 0 additions & 4 deletions apps/studio/src/utils/resource.ts

This file was deleted.

3 changes: 3 additions & 0 deletions apps/studio/tests/msw/handlers/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ const pageListQuery = (wait?: DelayMode | number) => {
title: "Test page 1",
mainBlobId: 3,
draftBlobId: null,
type: "Page",
},
{
id: 5,
permalink: "test-page-2",
title: "Test page 2",
mainBlobId: 4,
draftBlobId: null,
type: "Page",
},
{
id: 6,
permalink: "folder",
title: "Test folder 1",
mainBlobId: null,
draftBlobId: null,
type: "Folder",
},
]
})
Expand Down

0 comments on commit 18b87e9

Please sign in to comment.