From 7bf1cf97f349bc460c796e6cce1e4c271c6e3cd8 Mon Sep 17 00:00:00 2001 From: seaerchin Date: Mon, 27 Mar 2023 12:17:20 +0800 Subject: [PATCH] chore(rr): update naming; fixed constants --- .../components/ResourceCard.tsx | 5 ++- .../RequestOverview/RequestOverview.tsx | 10 ++--- src/mocks/constants.ts | 38 +++++-------------- src/types/reviewRequest.ts | 2 +- 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/src/layouts/ResourceCategory/components/ResourceCard.tsx b/src/layouts/ResourceCategory/components/ResourceCard.tsx index b6a24ce89e..d919f17e0d 100644 --- a/src/layouts/ResourceCategory/components/ResourceCard.tsx +++ b/src/layouts/ResourceCategory/components/ResourceCard.tsx @@ -7,8 +7,6 @@ import { HStack, Box, } from "@chakra-ui/react" -import { Card, CardBody, CardFooter } from "components/Card" -import { ContextMenu } from "components/ContextMenu" import { BiChevronRight, BiEditAlt, @@ -20,6 +18,9 @@ import { } from "react-icons/bi" import { Link as RouterLink, useRouteMatch } from "react-router-dom" +import { Card, CardBody, CardFooter } from "components/Card" +import { ContextMenu } from "components/ContextMenu" + import { BxFileArchiveSolid } from "assets" import { ResourcePageData } from "types/directory" import { prettifyDate } from "utils" diff --git a/src/layouts/ReviewRequest/components/RequestOverview/RequestOverview.tsx b/src/layouts/ReviewRequest/components/RequestOverview/RequestOverview.tsx index 9eab4958d4..0781ba304b 100644 --- a/src/layouts/ReviewRequest/components/RequestOverview/RequestOverview.tsx +++ b/src/layouts/ReviewRequest/components/RequestOverview/RequestOverview.tsx @@ -347,16 +347,16 @@ export const RequestOverview = ({ // NOTE: Pass `undefined` to avoid users being able to click // despite being visually disabled. href={ - row.original.type === "page" && row.original.fileUrl + row.original.type === "page" && row.original.cmsFileUrl ? // NOTE: Permalinks are enforced to start with a `/` by our CMS - row.original.fileUrl + row.original.cmsFileUrl : undefined } isExternal > } aria-label="edit file" @@ -377,7 +377,7 @@ export const RequestOverview = ({ aria-label="view file on staging" variant="link" isDisabled={ - !(row.original.type === "page" && row.original.fileUrl) + !(row.original.type === "page" && row.original.cmsFileUrl) } /> @@ -421,7 +421,7 @@ export const RequestOverview = ({ ref={inputRef} onSearchIconClick={handleExpansion} isExpanded={isExpanded} - onSearch={table.getColumn("itemName").setFilterValue} + onSearch={table.getColumn("itemName")!.setFilterValue} onBlur={handleCollapse} /> diff --git a/src/mocks/constants.ts b/src/mocks/constants.ts index 5e8e7792f5..e3a8582b8b 100644 --- a/src/mocks/constants.ts +++ b/src/mocks/constants.ts @@ -239,34 +239,30 @@ export const MOCK_SITE_DASHBOARD_INFO: SiteDashboardInfo = { export const MOCK_ITEMS: EditedItemProps[] = [ { - type: ["page"], + type: "page", name: "A page", path: ["some", "thing"], stagingUrl: "www.google.com", - fileUrl: "www.google.com", + cmsFileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 129823104094, }, { - type: ["nav"], + type: "nav", name: "A nav", path: ["some", "thing"], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 823104823094, }, { - type: ["file"], + type: "file", name: "a file", path: ["some", "thing"], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 129823104823094, }, { - type: ["setting"], + type: "setting", name: "A setting with an extremely long title that probably can't fit into a single line and we have to truncate this somehow. so we will hopefully display an ellipsis over it", // NOTE: We don't have arbitrary nested folders. @@ -276,37 +272,20 @@ export const MOCK_ITEMS: EditedItemProps[] = [ "might not be able to fit into a single line", "so we have to truncate it to show an ellipsis at the end", ], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 129823094, }, { - type: ["setting"], + type: "setting", name: "a normal setting", path: ["some", "thing"], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 12123498294, }, { - type: ["image"], + type: "image", name: "some file", path: ["some", "thing"], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", - lastEditedBy: "asdf", - lastEditedTime: 129823094, - }, - { - // NOTE: This has 2 types - we tiebreak by using the first item in the array for the icon. - // For the filtering, it should appear in both. - type: ["nav", "setting"], - name: "a file with two types", - path: ["another", "path"], - stagingUrl: "www.google.com", - fileUrl: "www.google.com", lastEditedBy: "asdf", lastEditedTime: 129823094, }, @@ -448,10 +427,11 @@ export const MOCK_COMMENTS_DATA: CommentData[] = [ ] const MOCK_EDITED_ITEM: EditedItemProps = { - type: ["file"], + type: "page", name: "mock item", path: ["some", "path"], stagingUrl: "isomer.sg", + cmsFileUrl: "localhost:3000", lastEditedBy: "a user", lastEditedTime: Date.now(), } diff --git a/src/types/reviewRequest.ts b/src/types/reviewRequest.ts index 2af5cd395c..7fbf6736b9 100644 --- a/src/types/reviewRequest.ts +++ b/src/types/reviewRequest.ts @@ -28,7 +28,7 @@ export type WithEditMeta = T & { export interface EditedPageDto extends BaseEditedItemDto { type: "page" stagingUrl: string - fileUrl: string + cmsFileUrl: string } export interface EditedConfigDto extends BaseEditedItemDto {