Files
summercms/admin/src/app/pageTitle.ts
Jakub Zych 143eca5a1f feat(cabana): add the My account page with subtitle and password change
- lagoon: 202610090001_backend_users_metadata adds WinterCMS's nullable
  jsonable backend_users.metadata column (TEXT); rollback drops only it
- cabana.BackendUser.Metadata and Subtitle read metadata.subtitle leniently
  (NULL, blank, null, [], invalid JSON and non-strings read as empty)
- GET /auth/me returns subtitle; PUT /account edits the signed-in admin's
  own names, email and subtitle, and the password with current_password;
  any other key is a 422 and nothing is written
- email: required, valid, 6-255 chars, unique against other admins' email
  and login ignoring case (soft-deleted included); a unique-index race is 422
- a password change sets tokens_valid_after, revokes the presented token and
  gives a cookie session a fresh cookie
- swag annotation, regenerated admin.json and schema.d.ts; route inventories,
  CSRF walk (27) and OpenAPI conformance learn the route
- SPA: My account item in the user menu opens /account (AccountView), which
  saves through PUT /account and updates the top bar via setCurrentUser
- backend::lang.myaccount strings (en, pl), rebuilt boardwalk dist
- cabana and lagoon READMEs, users-and-permissions and admin-spa docs
2026-10-09 17:38:04 +02:00

46 lines
1.8 KiB
TypeScript

import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { controllerIdFromPath } from './controllerRoutes'
import { t } from './i18n'
import { recordCrumb } from '../state/useBreadcrumbs'
import { activeEntry } from '../state/useNavigation'
import { settingsEntry, settingsLinkFor } from '../state/useSettings'
const PRODUCT_TITLE = 'SummerCMS'
/** The visible page indicator used before the SummerCMS product name. */
export function pageIndicator(route: RouteLocationNormalizedLoaded): string {
if (route.name === 'login') {
return t('backend::lang.auth.title')
}
if (route.name === 'settings') {
return t('backend::lang.settings.title')
}
if (route.name === 'account') {
return t('backend::lang.myaccount.menu_label')
}
if (route.name === 'settings-form') {
return settingsEntry(String(route.params.code ?? ''))?.label ?? String(route.params.code ?? '')
}
if (route.name === 'home') {
return t('backend::lang.nav.empty')
}
if (route.name === 'not-found') {
return t('backend::lang.page.not_found')
}
const plugin = activeEntry(String(route.params.vendor ?? ''), String(route.params.plugin ?? ''))
const controller = controllerIdFromPath(route.path)
const section = plugin?.sideMenu.find((item) => item.controller === controller)
const controllerLabel = section?.label ?? plugin?.label ?? settingsLinkFor(controller)?.label ?? ''
if (route.name === 'create' || route.name === 'record' || route.name === 'preview') {
return recordCrumb.value || controllerLabel
}
return controllerLabel
}
/** Browser title matching WinterCMS's "Current page | Product" pattern. */
export function documentTitleForRoute(route: RouteLocationNormalizedLoaded): string {
const indicator = pageIndicator(route).trim()
return indicator === '' ? PRODUCT_TITLE : `${indicator} | ${PRODUCT_TITLE}`
}