import {avatarTemplate, escapeText} from "fwtoolkit" interface Contact { id: number | string type: string name: string } interface CollaboratorHolder { id: number | string type: string name: string } interface Collaborator { holder: CollaboratorHolder rights: string count?: number } interface ShareToken { id: number | string expires_at?: string note?: string rights: string share_url: string } export const peopleTabTemplate = ({ contacts, collaborators }: { contacts: Contact[] collaborators: Collaborator[] }) => `

${gettext("My contacts")}

${contactsTemplate({contacts})}
${gettext("Contacts")}

${gettext("My collaborators")}

${collaboratorsTemplate({collaborators})}
${gettext("Collaborators")} ${gettext("Rights")} ${gettext("Delete")}
` export const shareLinkTabTemplate = () => `

${gettext("Loading…")}

` /** The list of active share-link tokens for a single document */ export const shareTokenListTemplate = ({tokens}: {tokens: ShareToken[]}) => { if (!tokens.length) { return `

${gettext("No active share links yet.")}

` } return tokens.map(token => shareTokenRowTemplate({token})).join("") } /** A single share-link token row */ export const shareTokenRowTemplate = ({token}: {token: ShareToken}) => { const expiry = token.expires_at ? escapeText(token.expires_at.slice(0, 10)) : gettext("never") const note = token.note ? escapeText(token.note) : "" return `
${note ? `` : ""}
` } /** Sub-dialog for creating a new share link */ export const createShareTokenDialogTemplate = ( e2ee = false, documentPassword = "" ) => ` ${ e2ee ? `` : "" }

${gettext("If you enter the password above, it will be embedded in the link (after #). Anyone with the link can open the document. Only share such links through secure channels.")}

` /** The template for an individual row in the left hand side list of users (all contacts) of the access rights dialogue. */ export const contactsTemplate = ({contacts}: {contacts: Contact[]}) => contacts .map( contact => ` ${avatarTemplate({user: contact})} ${ contact.type === "userinvite" ? `${gettext("Invite")}: ` : "" } ${escapeText(contact.name || "")} ` ) .join("") /** The template for the right hand side list of users (the collaborators of the current document) of the access rights dialogue. */ export const collaboratorsTemplate = ({ collaborators }: { collaborators: Collaborator[] }) => collaborators .map( collaborator => ` ${avatarTemplate({user: collaborator.holder})} ${ collaborator.holder.type === "userinvite" ? `${gettext("Invite")}: ` : "" }${escapeText(collaborator.holder.name || "")}
` ) .join("")