@antelopejs/dms-lang 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,9 +55,9 @@ pnpm test
55
55
 
56
56
  The backend registers `frontend-vue/dms.frontend.ts` through `AddFrontendModule` with the Vue 3 renderer. The module declares `componentPrefix: "DmsLang"` and registers every component of `app/components` and `app/build/components` under it; the backend pages name them (`CustomComponent("DmsLangTranslationMatrix")`). `dms.frontend.build.ts` declares `app/composables`, `app/utils` and `app/types` for auto-import; `app/build/` is private and imported by path. Nuxt is not required; `@nuxt/ui` provides its Vue components through the adapter's Vite integration.
57
57
 
58
- The module compiles against the published `@antelopejs/interface-dms` package, its only DMS runtime dependency. The `@antelopejs/dms` backend and the `@antelopejs/dms-frontend` adapter are development dependencies, needed to run the tests and the playground. Run `pnpm install`, `pnpm build` and `pnpm test` here.
58
+ Its pages read the data they render with the DMS's `useApiData`, which a server render reads and hands to the browser with the page; the dialogs that ask the server for their wording read it when they open. The module requires `@antelopejs/dms` 0.9, `@antelopejs/interface-dms` 0.7 and `@antelopejs/dms-frontend` 0.6. The public language files (`/i18n/**`) are declared to the frontend server as a backend prefix without a session (`backendProxies`), so the DMS's own origin serves them. It compiles against the published `@antelopejs/interface-dms` package, its only DMS runtime dependency. The `@antelopejs/dms` backend and the `@antelopejs/dms-frontend` adapter are development dependencies, needed to run the tests and the playground. Run `pnpm install`, `pnpm build` and `pnpm test` here.
59
59
 
60
- `pnpm test:unit` checks locale discovery, the coverage, placeholder and message helpers of the frontend and the locale files. The backend tests (`src/test`: keys, workspaces, validation, coverage, summaries) run with `pnpm test` only: every backend file reaches an AntelopeJS interface (`@antelopejs/interface-api` for the errors, `@antelopejs/interface-dms` for the pages), and an interface refuses to load outside the AntelopeJS runtime. `pnpm test:frontend` compiles the module alongside the published core DMS frontend with the adapter's source verifier.
60
+ `pnpm test:unit` checks locale discovery, the coverage, placeholder and message helpers of the frontend and the locale files, and renders the workspace composables on a server with the installed adapter and `useApiData` (`tests/frontend-runtime.mjs`). The backend tests (`src/test`: keys, workspaces, validation, coverage, summaries) run with `pnpm test` only: every backend file reaches an AntelopeJS interface (`@antelopejs/interface-api` for the errors, `@antelopejs/interface-dms` for the pages), and an interface refuses to load outside the AntelopeJS runtime. `pnpm test:frontend` compiles the module alongside the published core DMS frontend with the adapter's source verifier.
61
61
 
62
62
  Run `pnpm dev` for the backend and `pnpm frontend:dev` for the Inertia workspace. The playground connects to MongoDB at `mongodb://localhost:27017`; set `MONGO_URL` to use another instance. The frontend workspace uses the `ajs dms` commands for development, preparation and production builds. Use `pnpm typecheck` for the backend; run `pnpm typecheck` in the generated Vite workspace for frontend types. The adapter owns the generated aliases, auto-import declarations and Vue compiler configuration.
63
63
 
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ exports.start = start;
22
22
  const node_path_1 = __importDefault(require("node:path"));
23
23
  const page_1 = require("@antelopejs/interface-dms/page");
24
24
  const config_1 = require("./utils/config");
25
+ const constants_1 = require("./utils/constants");
25
26
  const registry_1 = require("./utils/registry");
26
27
  __exportStar(require("./pages"), exports);
27
28
  __exportStar(require("./routes"), exports);
@@ -38,6 +39,7 @@ async function construct(config = {}) {
38
39
  renderer: { name: "vue", version: "3" },
39
40
  configKey: "dmsLang",
40
41
  priority: 0,
42
+ backendProxies: [{ path: `${constants_1.PUBLIC_PATH}/**`, auth: "none" }],
41
43
  });
42
44
  }
43
45
  async function start() {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,8BAgBC;AAED,sBAEC;AAhCD,0DAA6B;AAC7B,yDAAmE;AACnE,2CAAsD;AACtD,+CAA4D;AAE5D,0CAAwB;AACxB,2CAAyB;AAMlB,KAAK,UAAU,SAAS,CAAC,SAAwB,EAAE;IACxD,MAAM,UAAU,GAAG,mBAAI,CA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S;QACpB,QAAQ,EAAE,CAAC;QACX,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,uBAAW,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KAC9D,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,KAAK;IACzB,MAAM,IAAA,mCAAwB,GAAE,CAAC;AACnC,CAAC"}
@@ -13,7 +13,7 @@ const BASE = { field: "isBase", equals: true };
13
13
  const EDITABLE_BASE = { and: [BASE, { field: "canEdit", equals: true }] };
14
14
  const TARGET = { field: "isBase", equals: false };
15
15
  const MANAGEABLE = { and: [TARGET, { field: "canManage", equals: true }] };
16
- const LANGUAGE_URL = `${constants_1.LANG_API}/languages/{workspace}/{code}`;
16
+ const LANGUAGE_URL = `${constants_1.LANG_API}/languages/{{row.workspace}}/{{row.code}}`;
17
17
  const columns = {
18
18
  name: {
19
19
  name: `${TEXTS}.column_language`,
@@ -51,7 +51,7 @@ const PAGE_LINKS = [
51
51
  icon: "i-ph-translate",
52
52
  target: {
53
53
  type: "page",
54
- url: `${constants_1.PAGES_URL}/language?workspace={workspace}&locale={code}`,
54
+ url: `${constants_1.PAGES_URL}/language?workspace={{row.workspace}}&locale={{row.code}}`,
55
55
  },
56
56
  rule: TARGET,
57
57
  isVisible: true,
@@ -64,7 +64,7 @@ const PAGE_LINKS = [
64
64
  icon: "i-ph-table",
65
65
  target: {
66
66
  type: "page",
67
- url: `${constants_1.PAGES_URL}/translations?workspace={workspace}`,
67
+ url: `${constants_1.PAGES_URL}/translations?workspace={{row.workspace}}`,
68
68
  },
69
69
  rule: EDITABLE_BASE,
70
70
  isVisible: true,
@@ -1 +1 @@
1
- {"version":3,"file":"languages-table.js","sourceRoot":"","sources":["../../src/pages/languages-table.ts"],"names":[],"mappings":";;AAwHA,wCAYC;AApID,wEAA4E;AAE5E,2FAA2F;AAC3F,0EAGmD;AAEnD,kDAAyD;AACzD,qCAA+C;AAE/C,MAAM,KAAK,GAAG,qBAAqB,CAAC;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;QAClC,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC,EAAE;KAC5E,CAAC,CAAC;AACL,CAAC"}
@@ -12,13 +12,13 @@ const public_url_1 = require("./public-url");
12
12
  const resolve_1 = require("./resolve");
13
13
  const LISTED_KEYS = 20;
14
14
  const SHOWN_KEYS = 5;
15
- const LANGUAGE_FILE = "{code}.json";
15
+ const LANGUAGE_FILE = "{{row.code}}.json";
16
16
  const DOWNLOAD_LANGUAGE = {
17
17
  label: `$${constants_1.LANG_TEXTS}.language_remove.download`,
18
18
  icon: "i-ph-download-simple",
19
19
  target: {
20
20
  type: "download",
21
- url: `${constants_1.PUBLIC_PATH}/{workspace}/${LANGUAGE_FILE}`,
21
+ url: `${constants_1.PUBLIC_PATH}/{{row.workspace}}/${LANGUAGE_FILE}`,
22
22
  filename: LANGUAGE_FILE,
23
23
  },
24
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dialogs.js","sourceRoot":"","sources":["../../src/utils/dialogs.ts"],"names":[],"mappings":";;AAoDA,wCAoCC;AAwBD,kCAkBC;AAlID,kFAAuF;AAOvF,uCAA0C;AAC1C,2CAAsD;AACtD,qCAAgC;AAChC,2CAAyC;AACzC,iDAA4C;AAC5C,6CAA+C;AAC/C,uCAAuE;AAEvE,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,aAAa,GAAG,aAAa,CAAC;AAGpC,MAAM,iBAAiB,GAAiC;IACtD,KAAK,EAAE,IAAI,sBAAU,2BAA2B;IAChD,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,GAAG,uBAAW,gBAAgB,aAAa,EAAE;QAClD,QAAQ,EAAE,aAAa;KACxB;CACF,CAAC;AASF,SAAS,W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CAAC;AACZ,CAAC;AAOD,SAAgB,WAAW,CAAC,SAAiB,EAAE,SAAiB;IAC9D,MAAM,IAAI,GAAG,IAAA,qBAAW,EAAC,IAAA,uBAAa,EAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,sBAAY,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,IAAA,uCAAsB,EAAC;QACpC,KAAK,EAAE,IAAI,sBAAU,8BAA8B;QACnD,WAAW,EAAE,OAAO;YAClB,CAAC,CAAC,IAAI,sBAAU,gCAAgC;YAChD,CAAC,CAAC,IAAI,sBAAU,iCAAiC;QACnD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,sBAAU,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE;QAChE,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,IAAI,sBAAU,+BAA+B;QAC3D,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;KACjC,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC"}
@@ -126,27 +126,24 @@ function useFilterQuery() {
126
126
  function useColumnOrder() {
127
127
  const { selectedWorkspace } = useI18nWorkspaces()
128
128
  const { flat } = useWorkspaceFlat()
129
- const order = ref<string[]>([])
130
129
  const stored = useStorage<Partial<StoredColumns> | null>(
131
130
  () => `${COLUMNS_STORAGE}${selectedWorkspace.value}`,
132
131
  null,
133
132
  undefined,
134
133
  { serializer: StorageSerializers.object },
135
134
  )
136
- watch(
137
- () => `${selectedWorkspace.value}|${flat.value.locales.join(',')}`,
138
- () => {
139
- const { locales, defaultLocale } = flat.value
140
- order.value = restoredOrder(
141
- locales,
142
- defaultLocale,
143
- columnsOf(stored.value),
144
- )
145
- },
146
- { immediate: true },
135
+ const isMounted = ref(false)
136
+ onMounted(() => {
137
+ isMounted.value = true
138
+ })
139
+ const order = computed(() =>
140
+ restoredOrder(
141
+ flat.value.locales,
142
+ flat.value.defaultLocale,
143
+ isMounted.value ? columnsOf(stored.value) : null,
144
+ ),
147
145
  )
148
146
  function saveOrder(next: string[]) {
149
- order.value = next
150
147
  stored.value = {
151
148
  shown: next,
152
149
  hidden: flat.value.locales.filter((code) => !next.includes(code)),
@@ -159,7 +156,8 @@ function useColumnOrder() {
159
156
  * The view of the matrix a user chose: the filters live in the URL (a link
160
157
  * or a refresh shows the same keys, Back undoes a filter change made by a
161
158
  * link) and the columns shown, in their order, are remembered per workspace
162
- * in this browser.
159
+ * in this browser and applied once the page is mounted: a server render
160
+ * shows every language, as the browser's first render does.
163
161
  */
164
162
  export function useMatrixView() {
165
163
  const { flat } = useWorkspaceFlat()
@@ -9,6 +9,7 @@ import {
9
9
  } from '../utils/workspaces'
10
10
  import type { WorkspaceSort } from '../utils/workspaces'
11
11
  import LocaleTile from '../build/components/LocaleTile.vue'
12
+ import { useWorkspaceSummary } from '../composables/translation/useI18nWorkspaces'
12
13
 
13
14
  interface WorkspaceStat {
14
15
  id: string
@@ -42,8 +43,7 @@ const SORT_LABELS: Record<WorkspaceSort, string> = {
42
43
 
43
44
  const { t } = useI18n()
44
45
  const { formatCount } = useLangFormat()
45
- const { fetchSummary, selectedWorkspace, editable, fetchWorkspaces } =
46
- useI18nWorkspaces()
46
+ const { selectedWorkspace, editable } = useI18nWorkspaces()
47
47
  const { createWorkspace, importWorkspace } = useWorkspaceActions()
48
48
  const { typeIcon, typeLabel, kindIcon } = useWorkspaceTypes()
49
49
  const { pageAction, clearPageAction, selectWorkspace } = useWorkspaceRoute()
@@ -53,10 +53,17 @@ const { getPreference, setPreference } = usePreferences()
53
53
 
54
54
  const canCreate = computed(() => editable.value && allows('createWorkspace'))
55
55
 
56
- const summary = ref<WorkspaceStats[]>([])
57
- const isLoaded = ref(false)
58
- const hasError = ref(false)
59
- const isLoading = ref(false)
56
+ // The workspaces' figures, read with the page.
57
+ const summaryRead = useWorkspaceSummary()
58
+ const summary = computed<WorkspaceStats[]>(
59
+ () => summaryRead.data.value?.workspaces ?? [],
60
+ )
61
+ const isLoaded = computed(() => summaryRead.data.value !== null)
62
+ const isLoading = computed(() => summaryRead.pending.value)
63
+ // A failure kept while it is tried again still shows the skeleton.
64
+ const hasError = computed(
65
+ () => summaryRead.error.value != null && !isLoading.value,
66
+ )
60
67
  const search = ref('')
61
68
  const sort = computed<WorkspaceSort>({
62
69
  get: () => {
@@ -88,19 +95,8 @@ function isWorkspaceSort(value: unknown): value is WorkspaceSort {
88
95
  return typeof value === 'string' && Object.hasOwn(SORT_LABELS, value)
89
96
  }
90
97
 
91
- async function load() {
92
- isLoading.value = true
93
- try {
94
- const response = await fetchSummary()
95
- summary.value = response.workspaces
96
- editable.value = response.editable
97
- hasError.value = false
98
- isLoaded.value = true
99
- } catch {
100
- hasError.value = true
101
- } finally {
102
- isLoading.value = false
103
- }
98
+ function load() {
99
+ void summaryRead.refresh()
104
100
  }
105
101
 
106
102
  function statsOf(workspace: WorkspaceStats): WorkspaceStat[] {
@@ -212,10 +208,6 @@ watch(
212
208
  { immediate: true },
213
209
  )
214
210
 
215
- onMounted(() => {
216
- load()
217
- fetchWorkspaces()
218
- })
219
211
  </script>
220
212
 
221
213
  <template>
@@ -1,6 +1,5 @@
1
1
  <script setup lang="ts">
2
2
  import { useLangChanges } from '../composables/translation/useWorkspaceFlat'
3
- import { useDmsRouter, useDmsState } from '#dms/frontend-module'
4
3
  import type { DropdownMenuItem } from '@nuxt/ui'
5
4
  import type { WorkspaceSummary } from '../types/lang'
6
5
  import LocaleTile from '../build/components/LocaleTile.vue'
@@ -13,8 +12,7 @@ const MENU_FILTER_FIELDS = ['label', 'description', 'workspaceId', 'summary']
13
12
 
14
13
  const { t } = useI18n()
15
14
  const { formatCount } = useLangFormat()
16
- const { workspaces, editable, isLoaded, selectedWorkspace } =
17
- useI18nWorkspaces()
15
+ const { workspaces, editable, isLoaded, whenLoaded } = useI18nWorkspaces()
18
16
  const {
19
17
  current,
20
18
  isEditable,
@@ -25,14 +23,12 @@ const {
25
23
  } = useWorkspaceContext()
26
24
  useLangChanges()
27
25
  const {
28
- route,
29
26
  switchLink,
30
27
  queryWorkspace,
31
28
  pageAction,
32
29
  clearPageAction,
33
30
  currentPage,
34
31
  } = useWorkspaceRoute()
35
- const router = useDmsRouter()
36
32
 
37
33
  /** What the bar says about the workspace shown, from the workspace list. */
38
34
  const scope = computed(() => ({
@@ -178,44 +174,10 @@ const firstRunActions = computed(() => [
178
174
  },
179
175
  ])
180
176
 
181
- /**
182
- * The workspace a page opened without `?workspace=` was given: the one
183
- * remembered, or the project files once that one turns out to be gone.
184
- */
185
- const filledFromMemory = useDmsState<string>(
186
- 'dms-lang-workspace-filled',
187
- () => '',
188
- )
189
-
190
- function fillWorkspace(workspace: string): void {
191
- void router.replace(linkWithQuery(route.path, { ...route.query, workspace }))
177
+ if (import.meta.env.SSR && !queryWorkspace.value && !pageAction.value) {
178
+ await whenLoaded()
192
179
  }
193
-
194
- watch(
195
- [queryWorkspace, pageAction],
196
- ([workspace, action]) => {
197
- if (import.meta.env.SSR || workspace || action) return
198
- const isKnown = workspaces.value.some(
199
- (entry) => entry.id === selectedWorkspace.value,
200
- )
201
- const fallback =
202
- isKnown || !isLoaded.value ? selectedWorkspace.value : DEFAULT_WORKSPACE
203
- filledFromMemory.value = fallback
204
- fillWorkspace(fallback)
205
- },
206
- { immediate: true },
207
- )
208
-
209
- watch(
210
- [isUnknown, queryWorkspace],
211
- ([unknown, workspace]) => {
212
- if (import.meta.env.SSR || !unknown) return
213
- if (!workspace || workspace !== filledFromMemory.value) return
214
- filledFromMemory.value = ''
215
- fillWorkspace(DEFAULT_WORKSPACE)
216
- },
217
- { immediate: true },
218
- )
180
+ useWorkspaceFill()
219
181
 
220
182
  watch(
221
183
  [pageAction, isResolved],
@@ -1,7 +1,6 @@
1
1
  import { useDmsCookie, useDmsState } from '#dms/frontend-module'
2
2
  import type {
3
3
  FlatCounts,
4
- FlatTranslations,
5
4
  KeyRowResponse,
6
5
  ScopedWorkspace,
7
6
  WorkspaceDetails,
@@ -34,7 +33,7 @@ type KeyValues = Record<string, unknown>
34
33
  /** The routes of the module's API. */
35
34
  export const LANG_API = '/api/lang/translations'
36
35
  const API_BASE = LANG_API
37
- const ENDPOINTS = {
36
+ export const ENDPOINTS = {
38
37
  workspaces: `${API_BASE}/workspaces`,
39
38
  flat: `${API_BASE}/flat`,
40
39
  row: `${API_BASE}/row`,
@@ -86,23 +85,10 @@ function useWorkspacesState() {
86
85
  const lastWorkspace = useLastWorkspace()
87
86
  return {
88
87
  lastWorkspace,
89
- workspaces: useDmsState<ScopedWorkspace[]>(
90
- 'dms-lang-workspaces',
91
- () => [],
92
- ),
93
- editable: useDmsState<boolean>('dms-lang-workspaces-editable', () => false),
94
- permissions: useDmsState<WorkspacePermissionIds | null>(
95
- 'dms-lang-workspaces-permissions',
96
- () => null,
97
- ),
98
- publicBaseUrl: useDmsState<string>('dms-lang-public-base-url', () => ''),
99
- isLoading: useDmsState<boolean>('dms-lang-workspaces-loading', () => false),
100
- isLoaded: useDmsState<boolean>('dms-lang-workspaces-loaded', () => false),
101
88
  selectedWorkspace: useDmsState<string>(
102
89
  'dms-lang-selected-workspace',
103
90
  () => lastWorkspace.value || DEFAULT_WORKSPACE,
104
91
  ),
105
- requestSeq: useDmsState<number>('dms-lang-workspaces-seq', () => 0),
106
92
  }
107
93
  }
108
94
 
@@ -172,55 +158,70 @@ function useWorkspaceWrites() {
172
158
  }
173
159
  }
174
160
 
175
- function useWorkspaceReads() {
161
+ /** The backup file a download saves: a file the user keeps, not data a page shows. */
162
+ function useWorkspaceDownloads() {
176
163
  const { $authFetch } = useAuthFetch()
177
164
  return {
178
- fetchSummary: () => $authFetch<SummaryResponse>(ENDPOINTS.summary),
179
165
  fetchBackup: (workspace: string) =>
180
166
  $authFetch<WorkspaceBackup>(ENDPOINTS.backup, { query: { workspace } }),
181
- fetchFlat: (workspace: string) =>
182
- $authFetch<FlatTranslations>(ENDPOINTS.flat, { query: { workspace } }),
183
- fetchRow: (workspace: string, key: string) =>
184
- $authFetch<KeyRowResponse>(ENDPOINTS.row, { query: { workspace, key } }),
185
167
  }
186
168
  }
187
169
 
170
+ /** The workspaces with their figures, for the workspace list page. */
171
+ export const useWorkspaceSummary = () =>
172
+ useApiData<SummaryResponse>(ENDPOINTS.summary)
173
+
188
174
  /**
189
175
  * The workspaces of the module, the one selected for every page, and the
190
- * routes that read and change them. The selection follows the page URL
191
- * (`?workspace=`, see useWorkspaceRoute): a workspace the URL names but the
192
- * list lacks stays selected, so the page can say it does not exist.
176
+ * routes that read and change them. The list is read with the page, once for
177
+ * every block showing it: a server render hands it to the browser. The
178
+ * selection follows the page URL (`?workspace=`, see useWorkspaceRoute): a
179
+ * workspace the URL names but the list lacks stays selected, so the page can
180
+ * say it does not exist.
193
181
  */
194
182
  export const useI18nWorkspaces = () => {
195
- const { $authFetch } = useAuthFetch()
196
183
  const state = useWorkspacesState()
184
+ const list = useApiData<WorkspacesResponse>(ENDPOINTS.workspaces)
185
+ const workspaces = computed(() => list.data.value?.workspaces ?? [])
197
186
 
198
187
  function canUseWorkspaceId(id: string): boolean {
199
188
  return (
200
189
  isValidWorkspaceId(id) &&
201
- !state.workspaces.value.some((workspace) => workspace.id === id)
190
+ !workspaces.value.some((workspace) => workspace.id === id)
202
191
  )
203
192
  }
204
193
 
205
- function applyResponse(response: WorkspacesResponse): void {
206
- state.editable.value = response.editable
207
- state.workspaces.value = response.workspaces
208
- state.permissions.value = response.permissions
209
- state.publicBaseUrl.value = response.publicBaseUrl
210
- state.isLoaded.value = true
194
+ function mapWorkspace(
195
+ id: string,
196
+ change: (workspace: ScopedWorkspace) => ScopedWorkspace,
197
+ ): void {
198
+ const current = list.data.value
199
+ if (!current) return
200
+ list.data.value = {
201
+ ...current,
202
+ workspaces: current.workspaces.map((workspace) =>
203
+ workspace.id === id ? change(workspace) : workspace,
204
+ ),
205
+ }
211
206
  }
212
207
 
213
208
  /** Takes the figures a key write answered into the workspace list (the scope bar). */
214
209
  function patchCounts(id: string, counts: FlatCounts): void {
215
- state.workspaces.value = state.workspaces.value.map((workspace) =>
216
- workspace.id === id
217
- ? {
218
- ...workspace,
219
- totalKeys: counts.totalKeys,
220
- baseMissing: counts.baseMissing,
221
- }
222
- : workspace,
223
- )
210
+ mapWorkspace(id, (workspace) => ({
211
+ ...workspace,
212
+ totalKeys: counts.totalKeys,
213
+ baseMissing: counts.baseMissing,
214
+ }))
215
+ }
216
+
217
+ /** Takes the workspace a details write answered into the list, its figures kept. */
218
+ function patchSummary(summary: WorkspaceSummary): void {
219
+ mapWorkspace(summary.id, (workspace) => ({
220
+ ...summary,
221
+ totalKeys: workspace.totalKeys,
222
+ baseMissing: workspace.baseMissing,
223
+ translatedStrings: workspace.translatedStrings,
224
+ }))
224
225
  }
225
226
 
226
227
  /** Remembers the workspace a page without `?workspace=` opens on (a new tab, a menu link). */
@@ -228,37 +229,31 @@ export const useI18nWorkspaces = () => {
228
229
  if (state.lastWorkspace.value !== id) state.lastWorkspace.value = id
229
230
  }
230
231
 
232
+ /** Reads the list again, after a write or a change heard from elsewhere. */
231
233
  async function fetchWorkspaces(): Promise<ScopedWorkspace[]> {
232
- state.requestSeq.value += 1
233
- const sequence = state.requestSeq.value
234
- state.isLoading.value = true
235
- try {
236
- const response = await $authFetch<WorkspacesResponse>(
237
- ENDPOINTS.workspaces,
238
- )
239
- if (sequence !== state.requestSeq.value) return state.workspaces.value
240
- applyResponse(response)
241
- return state.workspaces.value
242
- } catch {
243
- return state.workspaces.value
244
- } finally {
245
- if (sequence === state.requestSeq.value) state.isLoading.value = false
246
- }
234
+ await list.refresh()
235
+ return workspaces.value
247
236
  }
248
237
 
249
238
  return {
250
- workspaces: state.workspaces,
251
- editable: state.editable,
252
- permissions: readonly(state.permissions),
253
- publicBaseUrl: readonly(state.publicBaseUrl),
239
+ workspaces,
240
+ editable: computed(() => list.data.value?.editable ?? false),
241
+ permissions: computed(() => list.data.value?.permissions ?? null),
242
+ publicBaseUrl: computed(() => list.data.value?.publicBaseUrl ?? ''),
254
243
  selectedWorkspace: state.selectedWorkspace,
255
- isLoading: readonly(state.isLoading),
256
- isLoaded: readonly(state.isLoaded),
244
+ isLoading: computed(() => list.pending.value),
245
+ /** The list was read once: the page can tell a workspace it lacks. */
246
+ isLoaded: computed(() => list.data.value !== null),
247
+ /** Resolves once the list was read: what a server render waits for. */
248
+ whenLoaded: async (): Promise<void> => {
249
+ await list
250
+ },
257
251
  fetchWorkspaces,
258
252
  patchCounts,
253
+ patchSummary,
259
254
  canUseWorkspaceId,
260
255
  rememberWorkspace,
261
- ...useWorkspaceReads(),
256
+ ...useWorkspaceDownloads(),
262
257
  ...useWorkspaceWrites(),
263
258
  ...useKeyWrites(),
264
259
  }
@@ -42,7 +42,7 @@ async function moduleRows(
42
42
  context: KeyActionsContext,
43
43
  ): Promise<FlatTranslationRow[]> {
44
44
  if (!context.isDefault.value) return []
45
- return (await context.translations.load(MODULES_WORKSPACE)).rows
45
+ return (await context.translations.loadModules()).rows
46
46
  }
47
47
 
48
48
  async function addKey(context: KeyActionsContext): Promise<string[]> {
@@ -8,7 +8,7 @@ interface LanguageActionsContext {
8
8
  t: ReturnType<typeof useI18n>['t']
9
9
  toast: ReturnType<typeof useToast>
10
10
  overlay: ReturnType<typeof useOverlay>
11
- confirmServed: ReturnType<typeof useServedConfirm>
11
+ confirmFrom: ReturnType<typeof useConfirmFrom>['confirmFrom']
12
12
  formatCount: ReturnType<typeof useLangFormat>['formatCount']
13
13
  workspaces: ReturnType<typeof useI18nWorkspaces>
14
14
  translations: ReturnType<typeof useWorkspaceFlat>
@@ -99,10 +99,11 @@ async function removeLanguage(
99
99
  ): Promise<boolean> {
100
100
  const workspace = context.workspaces.selectedWorkspace.value
101
101
  const route = languageRoute(context, code)
102
- const removed = await context.confirmServed(
103
- `${route}/${REMOVAL_CONFIRM}`,
104
- () => context.workspaces.removeLocale(workspace, code),
105
- )
102
+ const removed = await context.confirmFrom(`${route}/${REMOVAL_CONFIRM}`, {
103
+ onConfirm: async () => {
104
+ await context.workspaces.removeLocale(workspace, code)
105
+ },
106
+ })
106
107
  if (!removed) return false
107
108
  notify(context, context.t('dms_lang.language_remove.done'))
108
109
  await dialogsLeft(context)
@@ -122,9 +123,11 @@ async function makeBase(
122
123
  ): Promise<boolean> {
123
124
  const workspace = context.workspaces.selectedWorkspace.value
124
125
  const route = languageRoute(context, code)
125
- const confirmed = await context.confirmServed(`${route}/${BASE_CONFIRM}`, () =>
126
- context.workspaces.setDefaultLocale(workspace, code),
127
- )
126
+ const confirmed = await context.confirmFrom(`${route}/${BASE_CONFIRM}`, {
127
+ onConfirm: async () => {
128
+ await context.workspaces.setDefaultLocale(workspace, code)
129
+ },
130
+ })
128
131
  if (!confirmed) return false
129
132
  await context.translations.refresh()
130
133
  notify(
@@ -141,7 +144,7 @@ export const useLanguageActions = () => {
141
144
  t: useI18n().t,
142
145
  toast: useToast(),
143
146
  overlay: useOverlay(),
144
- confirmServed: useServedConfirm(),
147
+ confirmFrom: useConfirmFrom().confirmFrom,
145
148
  formatCount: useLangFormat().formatCount,
146
149
  workspaces: useI18nWorkspaces(),
147
150
  translations: useWorkspaceFlat(),
@@ -146,13 +146,11 @@ async function updateDetails(
146
146
  id: string,
147
147
  change: DetailsChange,
148
148
  ): Promise<boolean> {
149
- const ok = await context.failures.tryMutate(
150
- () => context.workspaces.updateWorkspace(id, change),
149
+ const { workspaces } = context
150
+ return context.failures.tryMutate(
151
+ async () => workspaces.patchSummary(await workspaces.updateWorkspace(id, change)),
151
152
  { title: context.t('dms_lang.workspace_details.save_failed') },
152
153
  )
153
- if (!ok) return false
154
- await context.workspaces.fetchWorkspaces()
155
- return true
156
154
  }
157
155
 
158
156
  async function downloadBackup(
@@ -0,0 +1,50 @@
1
+ import { useDmsRouter, useDmsState } from '#dms/frontend-module'
2
+
3
+ /**
4
+ * Gives a page opened without `?workspace=` (a menu link, a new tab) the
5
+ * workspace remembered, or the project files once that one turns out to be
6
+ * gone. A server render redirects to it, so the page renders its data at
7
+ * once; call it once the workspace list is in, which a server render awaits.
8
+ */
9
+ export const useWorkspaceFill = () => {
10
+ const router = useDmsRouter()
11
+ const { workspaces, isLoaded, selectedWorkspace } = useI18nWorkspaces()
12
+ const { isUnknown } = useWorkspaceContext()
13
+ const { route, queryWorkspace, pageAction } = useWorkspaceRoute()
14
+ const filledFromMemory = useDmsState<string>(
15
+ 'dms-lang-workspace-filled',
16
+ () => '',
17
+ )
18
+
19
+ function fillWorkspace(workspace: string): void {
20
+ void router.replace(
21
+ linkWithQuery(route.path, { ...route.query, workspace }),
22
+ )
23
+ }
24
+
25
+ watch(
26
+ [queryWorkspace, pageAction],
27
+ ([workspace, action]) => {
28
+ if (workspace || action) return
29
+ const isKnown = workspaces.value.some(
30
+ (entry) => entry.id === selectedWorkspace.value,
31
+ )
32
+ const fallback =
33
+ isKnown || !isLoaded.value ? selectedWorkspace.value : DEFAULT_WORKSPACE
34
+ filledFromMemory.value = fallback
35
+ fillWorkspace(fallback)
36
+ },
37
+ { immediate: true },
38
+ )
39
+
40
+ watch(
41
+ [isUnknown, queryWorkspace],
42
+ ([unknown, workspace]) => {
43
+ if (import.meta.env.SSR || !unknown) return
44
+ if (!workspace || workspace !== filledFromMemory.value) return
45
+ filledFromMemory.value = ''
46
+ fillWorkspace(DEFAULT_WORKSPACE)
47
+ },
48
+ { immediate: true },
49
+ )
50
+ }