Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 5x 1x 1x 1x 1x 1x 1x | // @implements UC-SPACE-009.1
/** The member endpoints of the space pages (flows-api space-pages/*.js) */
import api from '@/services/api'
import type {
LocalizedText,
PageVisibility,
SpaceBlock,
SpacePageDraft,
SpacePageMenuEntry,
SpacePageSummary
} from '@/utils/spacePages'
import { toBlockInput } from '@/utils/spacePages'
export interface SpacePageList {
canEdit: boolean
pages: SpacePageSummary[]
menu: SpacePageMenuEntry[]
maxPages?: number
}
export interface SpacePageInput {
title: LocalizedText
blocks: SpaceBlock[]
visibility: PageVisibility
showInMenu: boolean
menuOrder: number
/** The menu icon, any Font Awesome free solid name; null for the default one */
icon?: string | null
slug?: string
expectedUpdatedAt?: string
}
const pagesPath = (flowId: string, pageSlug?: string) =>
`/v1/flows/${encodeURIComponent(flowId)}/pages${pageSlug ? `/${encodeURIComponent(pageSlug)}` : ''}`
export async function listSpacePages(flowId: string): Promise<SpacePageList> {
return (await api.get(pagesPath(flowId))).data
}
export async function getSpacePageDraft(flowId: string, pageSlug: string): Promise<SpacePageDraft> {
return (await api.get(pagesPath(flowId, pageSlug), { params: { version: 'draft' } })).data
}
export async function saveSpacePage(
flowId: string,
pageSlug: string,
input: SpacePageInput
): Promise<SpacePageDraft> {
const body = { ...input, blocks: input.blocks.map(toBlockInput) }
return (await api.put(pagesPath(flowId, pageSlug), body)).data
}
export async function publishSpacePage(
flowId: string,
pageSlug: string,
publish: boolean
): Promise<SpacePageDraft> {
return (await api.post(`${pagesPath(flowId, pageSlug)}/publish`, { publish })).data
}
/** Orders the space menu: each page named gets its index as menuOrder */
export async function orderSpacePages(flowId: string, order: string[]): Promise<void> {
await api.put(pagesPath(flowId), { order })
}
export async function deleteSpacePage(flowId: string, pageSlug: string): Promise<void> {
await api.delete(pagesPath(flowId, pageSlug))
}
|