diff --git a/.vscode/settings.json b/.vscode/settings.json index e52b4d4b3ea..05bdc24a80d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -21,4 +21,4 @@ "[sql]": { "editor.defaultFormatter": "inferrinizzard.prettier-sql-vscode" } -} +} \ No newline at end of file diff --git a/adminSiteClient/PostsIndexPage.tsx b/adminSiteClient/PostsIndexPage.tsx index 1b464c8f666..723d1d728a1 100644 --- a/adminSiteClient/PostsIndexPage.tsx +++ b/adminSiteClient/PostsIndexPage.tsx @@ -8,6 +8,7 @@ import { buildSearchWordsFromSearchString, filterFunctionForSearchWords, SearchWord, + uniq, } from "@ourworldindata/utils" import { AdminLayout } from "./AdminLayout.js" import { SearchField, FieldsRow, Timeago } from "./Forms.js" @@ -23,6 +24,11 @@ import { faRecycle, } from "@fortawesome/free-solid-svg-icons" +interface GDocSlugSuccessor { + id: string + published: boolean +} + interface PostIndexMeta { id: number title: string @@ -31,12 +37,15 @@ interface PostIndexMeta { authors: string[] slug: string updatedAtInWordpress: string - tags: ChartTagJoin[] + tags: ChartTagJoin[] | null gdocSuccessorId: string | undefined + gdocSuccessorPublished: boolean + gdocSlugSuccessors: GDocSlugSuccessor[] | null } enum GdocStatus { - "MISSING" = "MISSING", + "MISSING_NO_SLUG_SUCCESSOR" = "MISSING_NO_SLUG_SUCCESSOR", + "MISSING_WITH_SLUG_SUCCESSOR" = "MISSING_WITH_SLUG_SUCCESSOR", "CONVERTING" = "CONVERTING", "CONVERTED" = "CONVERTED", } @@ -51,13 +60,17 @@ class PostRow extends React.Component { static contextType = AdminAppContext context!: AdminAppContextType - @observable private postGdocStatus: GdocStatus = GdocStatus.MISSING + @observable private postGdocStatus: GdocStatus = + GdocStatus.MISSING_NO_SLUG_SUCCESSOR constructor(props: PostRowProps) { super(props) this.postGdocStatus = props.post.gdocSuccessorId ? GdocStatus.CONVERTED - : GdocStatus.MISSING + : props.post.gdocSlugSuccessors && + props.post.gdocSlugSuccessors.length > 0 + ? GdocStatus.MISSING_WITH_SLUG_SUCCESSOR + : GdocStatus.MISSING_NO_SLUG_SUCCESSOR } async saveTags(tags: ChartTagJoin[]) { @@ -111,7 +124,11 @@ class PostRow extends React.Component { {}, "POST" ) - this.postGdocStatus = GdocStatus.MISSING + this.postGdocStatus = + this.props.post.gdocSlugSuccessors && + this.props.post.gdocSlugSuccessors.length > 0 + ? GdocStatus.MISSING_WITH_SLUG_SUCCESSOR + : GdocStatus.MISSING_NO_SLUG_SUCCESSOR this.props.post.gdocSuccessorId = undefined } } @@ -120,28 +137,54 @@ class PostRow extends React.Component { const { post, availableTags } = this.props const { postGdocStatus } = this const gdocElement = match(postGdocStatus) - .with(GdocStatus.MISSING, () => ( + .with(GdocStatus.MISSING_NO_SLUG_SUCCESSOR, () => ( )) + .with(GdocStatus.MISSING_WITH_SLUG_SUCCESSOR, () => ( + <> + {uniq(post.gdocSlugSuccessors).map((gdocSlugSuccessor) => ( + + <> + Preview + {gdocSlugSuccessor.published ? ( + + ) : ( + <> + )} + + + ))} + + )) .with(GdocStatus.CONVERTING, () => Converting...) .with(GdocStatus.CONVERTED, () => ( <> <> Preview + {post.gdocSuccessorPublished ? ( + + ) : ( + <> + )}