Skip to content

Commit

Permalink
ref(rr): refactor for new backend shape
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Mar 22, 2023
1 parent fea3192 commit 7ddd13f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ const ICON_STYLE_PROPS = {
fill: "icon.alt",
}

const getIcon = (iconTypes: EditedItemProps["type"]): JSX.Element => {
const iconType = iconTypes[0]
const getIcon = (iconType: EditedItemProps["type"]): JSX.Element => {
switch (iconType) {
case "nav": {
return <Icon {...ICON_STYLE_PROPS} as={BiWorld} />
Expand Down Expand Up @@ -353,26 +352,38 @@ export const RequestOverview = ({
// NOTE: Pass `undefined` to avoid users being able to click
// despite being visually disabled.
href={
row.original.fileUrl
row.original.type === "page" && row.original.fileUrl
? // NOTE: Permalinks are enforced to start with a `/` by our CMS
row.original.fileUrl
: undefined
}
isExternal
>
<IconButton
isDisabled={!row.original.fileUrl}
isDisabled={
!(row.original.type === "page" && row.original.fileUrl)
}
icon={<BiEditAlt />}
aria-label="edit file"
variant="link"
/>
</Link>
)}
<Link href={row.original.stagingUrl}>
<Link
href={
row.original.type === "page" && row.original.stagingUrl
? // NOTE: Permalinks are enforced to start with a `/` by our CMS
row.original.stagingUrl
: undefined
}
>
<IconButton
icon={<BiGitCompare />}
aria-label="view file on staging"
variant="link"
isDisabled={
!(row.original.type === "page" && row.original.fileUrl)
}
/>
</Link>
<IconButton
Expand Down
27 changes: 23 additions & 4 deletions src/types/reviewRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,35 @@ export interface User {

type FileType = "page" | "nav" | "setting" | "file" | "image"

export interface EditedItemProps {
type: FileType[]
export interface BaseEditedItemDto {
name: string
path: string[]
stagingUrl: string
fileUrl: string
type: FileType
}

export type WithEditMeta<T> = T & {
lastEditedBy: string
lastEditedTime: number
}

export interface EditedPageDto extends BaseEditedItemDto {
type: "page"
stagingUrl: string
fileUrl: string
}

export interface EditedConfigDto extends BaseEditedItemDto {
type: "nav" | "setting"
}

export interface EditedMediaDto extends BaseEditedItemDto {
type: "file" | "image"
}

export type EditedItemProps = WithEditMeta<
EditedPageDto | EditedConfigDto | EditedMediaDto
>

export interface ReviewRequestInfo {
title: string
description?: string
Expand Down

0 comments on commit 7ddd13f

Please sign in to comment.