@antelopejs/dms-lang 0.0.6 → 0.1.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.
Files changed (245) hide show
  1. package/README.md +12 -6
  2. package/dist/pages/actions.d.ts +7 -0
  3. package/dist/pages/actions.js +15 -0
  4. package/dist/pages/actions.js.map +1 -0
  5. package/dist/pages/component-action.d.ts +2 -0
  6. package/dist/pages/component-action.js +10 -0
  7. package/dist/pages/component-action.js.map +1 -0
  8. package/dist/pages/header-actions.d.ts +9 -0
  9. package/dist/pages/header-actions.js +146 -0
  10. package/dist/pages/header-actions.js.map +1 -0
  11. package/dist/pages/index.d.ts +6 -0
  12. package/dist/pages/index.js +6 -0
  13. package/dist/pages/index.js.map +1 -1
  14. package/dist/pages/language.d.ts +10 -0
  15. package/dist/pages/language.js +89 -0
  16. package/dist/pages/language.js.map +1 -0
  17. package/dist/pages/languages-table.d.ts +2 -0
  18. package/dist/pages/languages-table.js +120 -0
  19. package/dist/pages/languages-table.js.map +1 -0
  20. package/dist/pages/module.d.ts +7 -1
  21. package/dist/pages/module.js +28 -2
  22. package/dist/pages/module.js.map +1 -1
  23. package/dist/pages/overview.d.ts +2 -1
  24. package/dist/pages/overview.js +83 -8
  25. package/dist/pages/overview.js.map +1 -1
  26. package/dist/pages/page-actions.d.ts +6 -0
  27. package/dist/pages/page-actions.js +10 -0
  28. package/dist/pages/page-actions.js.map +1 -0
  29. package/dist/pages/quick-actions.d.ts +1 -0
  30. package/dist/pages/quick-actions.js +56 -0
  31. package/dist/pages/quick-actions.js.map +1 -0
  32. package/dist/pages/translations.d.ts +7 -1
  33. package/dist/pages/translations.js +47 -10
  34. package/dist/pages/translations.js.map +1 -1
  35. package/dist/pages/workspace-guard.d.ts +1 -0
  36. package/dist/pages/workspace-guard.js +35 -0
  37. package/dist/pages/workspace-guard.js.map +1 -0
  38. package/dist/pages/workspace.d.ts +18 -0
  39. package/dist/pages/workspace.js +162 -0
  40. package/dist/pages/workspace.js.map +1 -0
  41. package/dist/pages/workspaces.d.ts +14 -0
  42. package/dist/pages/workspaces.js +88 -0
  43. package/dist/pages/workspaces.js.map +1 -0
  44. package/dist/routes/publicLocales.d.ts +3 -2
  45. package/dist/routes/publicLocales.js +39 -18
  46. package/dist/routes/publicLocales.js.map +1 -1
  47. package/dist/routes/translations.d.ts +59 -63
  48. package/dist/routes/translations.js +400 -119
  49. package/dist/routes/translations.js.map +1 -1
  50. package/dist/utils/announce.d.ts +9 -0
  51. package/dist/utils/announce.js +29 -0
  52. package/dist/utils/announce.js.map +1 -0
  53. package/dist/utils/blocks.d.ts +8 -0
  54. package/dist/utils/blocks.js +213 -0
  55. package/dist/utils/blocks.js.map +1 -0
  56. package/dist/utils/body.d.ts +1 -0
  57. package/dist/utils/body.js +21 -0
  58. package/dist/utils/body.js.map +1 -0
  59. package/dist/utils/cache.d.ts +3 -0
  60. package/dist/utils/cache.js +32 -0
  61. package/dist/utils/cache.js.map +1 -0
  62. package/dist/utils/catalog.d.ts +7 -0
  63. package/dist/utils/catalog.js +62 -0
  64. package/dist/utils/catalog.js.map +1 -0
  65. package/dist/utils/constants.d.ts +6 -0
  66. package/dist/utils/constants.js +10 -0
  67. package/dist/utils/constants.js.map +1 -0
  68. package/dist/utils/coverage.d.ts +2 -0
  69. package/dist/utils/coverage.js +11 -0
  70. package/dist/utils/coverage.js.map +1 -0
  71. package/dist/utils/dialogs.d.ts +7 -0
  72. package/dist/utils/dialogs.js +103 -0
  73. package/dist/utils/dialogs.js.map +1 -0
  74. package/dist/utils/errors.d.ts +40 -0
  75. package/dist/utils/errors.js +60 -0
  76. package/dist/utils/errors.js.map +1 -0
  77. package/dist/utils/export.d.ts +17 -0
  78. package/dist/utils/export.js +129 -0
  79. package/dist/utils/export.js.map +1 -0
  80. package/dist/utils/json.d.ts +10 -1
  81. package/dist/utils/json.js +127 -19
  82. package/dist/utils/json.js.map +1 -1
  83. package/dist/utils/key-stores.d.ts +3 -0
  84. package/dist/utils/key-stores.js +24 -0
  85. package/dist/utils/key-stores.js.map +1 -0
  86. package/dist/utils/keys.d.ts +23 -0
  87. package/dist/utils/keys.js +252 -0
  88. package/dist/utils/keys.js.map +1 -0
  89. package/dist/utils/languages.d.ts +27 -0
  90. package/dist/utils/languages.js +121 -0
  91. package/dist/utils/languages.js.map +1 -0
  92. package/dist/utils/locale-codes.d.ts +5 -0
  93. package/dist/utils/locale-codes.js +56 -0
  94. package/dist/utils/locale-codes.js.map +1 -0
  95. package/dist/utils/locale-discovery.d.ts +1 -0
  96. package/dist/utils/locale-discovery.js +19 -1
  97. package/dist/utils/locale-discovery.js.map +1 -1
  98. package/dist/utils/message-check.d.ts +1 -0
  99. package/dist/utils/message-check.js +93 -0
  100. package/dist/utils/message-check.js.map +1 -0
  101. package/dist/utils/message-syntax.d.ts +6 -0
  102. package/dist/utils/message-syntax.js +38 -0
  103. package/dist/utils/message-syntax.js.map +1 -0
  104. package/dist/utils/namespaces.d.ts +12 -0
  105. package/dist/utils/namespaces.js +52 -0
  106. package/dist/utils/namespaces.js.map +1 -0
  107. package/dist/utils/notices.d.ts +4 -0
  108. package/dist/utils/notices.js +60 -0
  109. package/dist/utils/notices.js.map +1 -0
  110. package/dist/utils/own.d.ts +2 -3
  111. package/dist/utils/own.js +17 -57
  112. package/dist/utils/own.js.map +1 -1
  113. package/dist/utils/public-url.d.ts +8 -0
  114. package/dist/utils/public-url.js +87 -0
  115. package/dist/utils/public-url.js.map +1 -0
  116. package/dist/utils/registry.d.ts +3 -1
  117. package/dist/utils/registry.js +26 -10
  118. package/dist/utils/registry.js.map +1 -1
  119. package/dist/utils/resolve.d.ts +18 -15
  120. package/dist/utils/resolve.js +98 -151
  121. package/dist/utils/resolve.js.map +1 -1
  122. package/dist/utils/review.d.ts +5 -0
  123. package/dist/utils/review.js +64 -0
  124. package/dist/utils/review.js.map +1 -0
  125. package/dist/utils/snippets.d.ts +7 -0
  126. package/dist/utils/snippets.js +129 -0
  127. package/dist/utils/snippets.js.map +1 -0
  128. package/dist/utils/summary.d.ts +23 -0
  129. package/dist/utils/summary.js +65 -0
  130. package/dist/utils/summary.js.map +1 -0
  131. package/dist/utils/tree.d.ts +2 -17
  132. package/dist/utils/tree.js +21 -126
  133. package/dist/utils/tree.js.map +1 -1
  134. package/dist/utils/workspaces.d.ts +45 -15
  135. package/dist/utils/workspaces.js +256 -164
  136. package/dist/utils/workspaces.js.map +1 -1
  137. package/dist/validation/key.schema.d.ts +71 -0
  138. package/dist/validation/key.schema.js +67 -0
  139. package/dist/validation/key.schema.js.map +1 -0
  140. package/dist/validation/query.schema.d.ts +17 -0
  141. package/dist/validation/query.schema.js +44 -0
  142. package/dist/validation/query.schema.js.map +1 -0
  143. package/dist/validation/validate.d.ts +2 -0
  144. package/dist/validation/validate.js +24 -0
  145. package/dist/validation/validate.js.map +1 -0
  146. package/dist/validation/workspace.schema.d.ts +145 -0
  147. package/dist/validation/workspace.schema.js +83 -0
  148. package/dist/validation/workspace.schema.js.map +1 -0
  149. package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
  150. package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
  151. package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
  152. package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
  153. package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
  154. package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
  155. package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
  156. package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
  157. package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
  158. package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
  159. package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
  160. package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
  161. package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
  162. package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
  163. package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
  164. package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
  165. package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
  166. package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
  167. package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
  168. package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
  169. package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
  170. package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
  171. package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
  172. package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
  173. package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
  174. package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
  175. package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
  176. package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
  177. package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
  178. package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
  179. package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
  180. package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
  181. package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
  182. package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
  183. package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
  184. package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
  185. package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
  186. package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
  187. package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
  188. package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
  189. package/frontend-vue/app/components/TranslationQueue.vue +212 -0
  190. package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
  191. package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
  192. package/frontend-vue/app/components/WorkspaceList.vue +454 -0
  193. package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
  194. package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
  195. package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
  196. package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
  197. package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
  198. package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
  199. package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
  200. package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
  201. package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
  202. package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
  203. package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
  204. package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
  205. package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
  206. package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
  207. package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
  208. package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
  209. package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
  210. package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
  211. package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
  212. package/frontend-vue/app/types/lang.ts +130 -0
  213. package/frontend-vue/app/utils/boundedCache.ts +22 -0
  214. package/frontend-vue/app/utils/download.ts +16 -0
  215. package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
  216. package/frontend-vue/app/utils/keySaves.ts +108 -0
  217. package/frontend-vue/app/utils/languages.ts +272 -0
  218. package/frontend-vue/app/utils/matrixExport.ts +47 -0
  219. package/frontend-vue/app/utils/queueDrafts.ts +115 -0
  220. package/frontend-vue/app/utils/queuePass.ts +145 -0
  221. package/frontend-vue/app/utils/queueView.ts +22 -0
  222. package/frontend-vue/app/utils/shortcuts.ts +75 -0
  223. package/frontend-vue/app/utils/translations.ts +756 -0
  224. package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
  225. package/frontend-vue/app/utils/workspaces.ts +45 -0
  226. package/frontend-vue/dms.frontend.build.ts +5 -0
  227. package/frontend-vue/dms.frontend.ts +9 -20
  228. package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
  229. package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
  230. package/frontend-vue/package.json +10 -5
  231. package/package.json +10 -8
  232. package/dist/utils/mutations.d.ts +0 -3
  233. package/dist/utils/mutations.js +0 -35
  234. package/dist/utils/mutations.js.map +0 -1
  235. package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
  236. package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
  237. package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
  238. package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
  239. package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
  240. package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
  241. package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
  242. package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
  243. package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
  244. package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
  245. package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
@@ -0,0 +1,454 @@
1
+ <script setup lang="ts">
2
+ import UButton from '@nuxt/ui/components/Button.vue'
3
+ import type { WorkspaceKind, WorkspaceStats } from '../types/lang'
4
+ import { COVERAGE_TEXT_CLASSES, coverageTone } from '../utils/translations'
5
+ import {
6
+ PUBLIC_URL_METHOD,
7
+ matchesWorkspace,
8
+ sortWorkspaces,
9
+ } from '../utils/workspaces'
10
+ import type { WorkspaceSort } from '../utils/workspaces'
11
+ import LocaleTile from '../build/components/LocaleTile.vue'
12
+
13
+ interface WorkspaceStat {
14
+ id: string
15
+ label: string
16
+ value: string
17
+ tone?: string
18
+ }
19
+
20
+ interface WorkspacePill {
21
+ tone: 'neutral' | 'warning'
22
+ icon?: string
23
+ label: string
24
+ }
25
+
26
+ const EDITABLE_CONFIG = `"dms-lang": {\n config: { editable: true },\n}`
27
+ /** Below this many workspaces, searching and sorting them is noise. */
28
+ const TOOLBAR_THRESHOLD = 4
29
+ /** The sort picked last, a user preference the server render reads too. */
30
+ const SORT_PREFERENCE = 'dms-lang.workspaceSort'
31
+ const DEFAULT_SORT: WorkspaceSort = 'kind'
32
+ const OPEN_LABELS: Record<WorkspaceKind, string> = {
33
+ default: 'dms_lang.workspaces.switch',
34
+ added: 'dms_lang.workspaces.switch',
35
+ modules: 'dms_lang.workspaces.browse',
36
+ }
37
+ const SORT_LABELS: Record<WorkspaceSort, string> = {
38
+ kind: 'dms_lang.workspaces.sort_kind',
39
+ name: 'dms_lang.workspaces.sort_name',
40
+ coverage: 'dms_lang.workspaces.sort_coverage',
41
+ }
42
+
43
+ const { t } = useI18n()
44
+ const { formatCount } = useLangFormat()
45
+ const { fetchSummary, selectedWorkspace, editable, fetchWorkspaces } =
46
+ useI18nWorkspaces()
47
+ const { createWorkspace, importWorkspace } = useWorkspaceActions()
48
+ const { typeIcon, typeLabel, kindIcon } = useWorkspaceTypes()
49
+ const { pageAction, clearPageAction, selectWorkspace } = useWorkspaceRoute()
50
+ const { allows } = useWorkspaceContext()
51
+ const links = useLangLinks()
52
+ const { getPreference, setPreference } = usePreferences()
53
+
54
+ const canCreate = computed(() => editable.value && allows('createWorkspace'))
55
+
56
+ const summary = ref<WorkspaceStats[]>([])
57
+ const isLoaded = ref(false)
58
+ const hasError = ref(false)
59
+ const isLoading = ref(false)
60
+ const search = ref('')
61
+ const sort = computed<WorkspaceSort>({
62
+ get: () => {
63
+ const stored = getPreference<unknown>(SORT_PREFERENCE)
64
+ return isWorkspaceSort(stored) ? stored : DEFAULT_SORT
65
+ },
66
+ set: (value) => setPreference(SORT_PREFERENCE, value),
67
+ })
68
+
69
+ const sortItems = computed(() =>
70
+ (Object.keys(SORT_LABELS) as WorkspaceSort[]).map((value) => ({
71
+ value,
72
+ label: t(SORT_LABELS[value]),
73
+ })),
74
+ )
75
+ const hasToolbar = computed(
76
+ () => isLoaded.value && summary.value.length >= TOOLBAR_THRESHOLD,
77
+ )
78
+ const shown = computed(() =>
79
+ sortWorkspaces(
80
+ summary.value.filter((workspace) =>
81
+ matchesWorkspace(workspace, search.value, labelsOf(workspace)),
82
+ ),
83
+ sort.value,
84
+ ),
85
+ )
86
+
87
+ function isWorkspaceSort(value: unknown): value is WorkspaceSort {
88
+ return typeof value === 'string' && Object.hasOwn(SORT_LABELS, value)
89
+ }
90
+
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
+ }
104
+ }
105
+
106
+ function statsOf(workspace: WorkspaceStats): WorkspaceStat[] {
107
+ const last =
108
+ workspace.kind === 'added'
109
+ ? {
110
+ id: 'missing',
111
+ label: t('dms_lang.workspaces.stat_missing'),
112
+ value: formatCount(workspace.missing),
113
+ tone: workspace.missing ? 'text-warning' : undefined,
114
+ }
115
+ : {
116
+ id: 'overrides',
117
+ label: t(
118
+ `dms_lang.workspaces.stat_${workspace.kind === 'modules' ? 'overridden' : 'overrides'}`,
119
+ ),
120
+ value: formatCount(workspace.overrides),
121
+ }
122
+ return [
123
+ {
124
+ id: 'languages',
125
+ label: t('dms_lang.workspaces.stat_languages'),
126
+ value: formatCount(workspace.locales.length),
127
+ },
128
+ {
129
+ id: 'keys',
130
+ label: t('dms_lang.workspaces.stat_keys'),
131
+ value: formatCount(workspace.totalKeys),
132
+ },
133
+ {
134
+ id: 'coverage',
135
+ label: t('dms_lang.workspaces.stat_coverage'),
136
+ value: `${formatCount(workspace.coverage)}%`,
137
+ },
138
+ last,
139
+ ]
140
+ }
141
+
142
+ function kindPill(workspace: WorkspaceStats): WorkspacePill {
143
+ if (workspace.type) {
144
+ return {
145
+ tone: 'neutral',
146
+ icon: typeIcon(workspace.type),
147
+ label: typeLabel(workspace.type),
148
+ }
149
+ }
150
+ const isModules = workspace.kind === 'modules'
151
+ return {
152
+ tone: isModules ? 'warning' : 'neutral',
153
+ icon: isModules ? 'i-ph-lock-simple' : undefined,
154
+ label: t(`dms_lang.workspace_kinds.${workspace.kind}.kind`),
155
+ }
156
+ }
157
+
158
+ function labelsOf(workspace: WorkspaceStats): string[] {
159
+ return [
160
+ kindPill(workspace).label,
161
+ t(`dms_lang.workspace_kinds.${workspace.kind}.label`, {
162
+ name: workspace.id,
163
+ }),
164
+ ]
165
+ }
166
+
167
+ function localeCodes(workspace: WorkspaceStats): string[] {
168
+ const codes = workspace.locales.map((entry) => entry.code)
169
+ return [
170
+ ...codes.filter((code) => code === workspace.baseLocale),
171
+ ...codes.filter((code) => code !== workspace.baseLocale),
172
+ ]
173
+ }
174
+
175
+ /** What opening a workspace does: open the one shown, browse the modules, switch to another. */
176
+ function openLabel(workspace: WorkspaceStats): string {
177
+ if (workspace.id === selectedWorkspace.value)
178
+ return t('dms_lang.workspaces.open')
179
+ return t(OPEN_LABELS[workspace.kind])
180
+ }
181
+
182
+ async function open(workspace: WorkspaceStats) {
183
+ await selectWorkspace(workspace.id, {
184
+ page: workspace.kind === 'modules' ? 'translations' : 'overview',
185
+ })
186
+ }
187
+
188
+ function create() {
189
+ return createWorkspace()
190
+ }
191
+
192
+ usePageHeaderActions(() =>
193
+ canCreate.value
194
+ ? h(UButton, {
195
+ label: t('dms_lang.workspace_import.open'),
196
+ icon: 'i-ph-upload-simple',
197
+ color: 'neutral',
198
+ variant: 'outline',
199
+ onClick: importWorkspace,
200
+ })
201
+ : null,
202
+ { order: -1 },
203
+ )
204
+
205
+ watch(
206
+ [pageAction, isLoaded],
207
+ async ([action, loaded]) => {
208
+ if (action !== PAGE_ACTIONS.newWorkspace || !loaded) return
209
+ await clearPageAction()
210
+ if (canCreate.value) await create()
211
+ },
212
+ { immediate: true },
213
+ )
214
+
215
+ onMounted(() => {
216
+ load()
217
+ fetchWorkspaces()
218
+ })
219
+ </script>
220
+
221
+ <template>
222
+ <div class="space-y-4">
223
+ <DmsBanner
224
+ v-if="isLoaded && !editable"
225
+ tone="info"
226
+ icon="i-ph-lock-simple"
227
+ :title="$t('dms_lang.workspaces.read_only_title')"
228
+ :description="$t('dms_lang.workspaces.read_only_description')"
229
+ >
230
+ <template #actions>
231
+ <DmsCopyButton :value="EDITABLE_CONFIG" />
232
+ </template>
233
+ </DmsBanner>
234
+
235
+ <DmsEmptyState
236
+ v-if="hasError && !isLoaded"
237
+ variant="error"
238
+ size="lg"
239
+ hatched
240
+ :title="$t('dms_lang.workspaces.load_error')"
241
+ :description="$t('dms_lang.errors.load_description')"
242
+ :actions="[
243
+ {
244
+ label: $t('dms_lang.actions.retry'),
245
+ icon: 'i-ph-arrow-clockwise',
246
+ color: 'neutral',
247
+ variant: 'outline',
248
+ loading: isLoading,
249
+ onClick: () => load(),
250
+ },
251
+ ]"
252
+ />
253
+
254
+ <div v-if="hasToolbar" class="flex flex-wrap items-center gap-2">
255
+ <UInput
256
+ v-model="search"
257
+ icon="i-ph-magnifying-glass"
258
+ size="sm"
259
+ class="min-w-48 flex-1"
260
+ :placeholder="$t('dms_lang.workspaces.search')"
261
+ :aria-label="$t('dms_lang.workspaces.search')"
262
+ />
263
+ <USelect
264
+ v-model="sort"
265
+ :items="sortItems"
266
+ size="sm"
267
+ class="w-56"
268
+ icon="i-ph-sort-ascending"
269
+ :aria-label="$t('dms_lang.workspaces.sort')"
270
+ />
271
+ </div>
272
+
273
+ <DmsEmptyState
274
+ v-if="isLoaded && summary.length && !shown.length"
275
+ variant="no-result"
276
+ size="lg"
277
+ hatched
278
+ icon="i-ph-magnifying-glass"
279
+ :title="$t('dms_lang.workspaces.no_match', { search: search.trim() })"
280
+ :actions="[
281
+ {
282
+ label: $t('dms_lang.workspaces.clear_search'),
283
+ icon: 'i-ph-x',
284
+ color: 'neutral',
285
+ variant: 'outline',
286
+ onClick: () => (search = ''),
287
+ },
288
+ ]"
289
+ />
290
+
291
+ <div class="grid gap-4 lg:grid-cols-2">
292
+ <template v-if="!isLoaded && !hasError">
293
+ <DmsCard v-for="index in 4" :key="index" padded>
294
+ <div class="space-y-4">
295
+ <USkeleton class="h-6 w-1/2" />
296
+ <USkeleton class="h-10 w-full" />
297
+ <USkeleton class="h-6 w-2/3" />
298
+ </div>
299
+ </DmsCard>
300
+ </template>
301
+
302
+ <DmsCard
303
+ v-for="workspace in shown"
304
+ :key="workspace.id"
305
+ :padded="false"
306
+ :selected="workspace.id === selectedWorkspace"
307
+ >
308
+ <div class="space-y-4 p-4">
309
+ <div class="flex items-start gap-3">
310
+ <DmsIconWell
311
+ :icon="kindIcon(workspace.kind)"
312
+ :tone="workspace.kind === 'modules' ? 'warning' : 'primary'"
313
+ size="lg"
314
+ />
315
+ <div class="min-w-0 flex-1">
316
+ <div class="flex flex-wrap items-center gap-2">
317
+ <h3 class="text-highlighted truncate text-base font-semibold">
318
+ {{
319
+ $t(`dms_lang.workspace_kinds.${workspace.kind}.label`, {
320
+ name: workspace.id,
321
+ })
322
+ }}
323
+ </h3>
324
+ <DmsStatusPill
325
+ dot="none"
326
+ size="sm"
327
+ v-bind="kindPill(workspace)"
328
+ />
329
+ <DmsStatusPill
330
+ dot="none"
331
+ v-if="workspace.id === selectedWorkspace"
332
+ tone="primary"
333
+ size="sm"
334
+ icon="i-ph-check"
335
+ :label="$t('dms_lang.workspaces.current')"
336
+ />
337
+ </div>
338
+ <p class="text-muted mt-0.5 line-clamp-2 text-xs">
339
+ {{
340
+ workspace.description ||
341
+ $t(`dms_lang.workspace_kinds.${workspace.kind}.description`)
342
+ }}
343
+ </p>
344
+ </div>
345
+ <UButton
346
+ size="sm"
347
+ color="neutral"
348
+ variant="outline"
349
+ icon="i-ph-gear-six"
350
+ :label="$t('dms_lang.workspaces.settings')"
351
+ :to="links.workspaceSettings(workspace.id)"
352
+ />
353
+ </div>
354
+
355
+ <dl class="grid grid-cols-4 gap-3">
356
+ <div v-for="stat in statsOf(workspace)" :key="stat.id">
357
+ <DmsEyebrow as="dt" :label="stat.label" size="xs" />
358
+ <dd
359
+ class="text-highlighted font-mono text-lg font-semibold"
360
+ :class="stat.tone"
361
+ >
362
+ {{ stat.value }}
363
+ </dd>
364
+ </div>
365
+ </dl>
366
+
367
+ <div class="flex flex-wrap gap-1.5">
368
+ <span
369
+ v-for="code in localeCodes(workspace)"
370
+ :key="code"
371
+ class="border-default inline-flex items-center gap-1.5 rounded-md border py-0.5 pr-2 pl-0.5 font-mono text-xs"
372
+ >
373
+ <LocaleTile
374
+ :code="code"
375
+ size="sm"
376
+ :is-base="code === workspace.baseLocale"
377
+ />
378
+ {{ code }}
379
+ <span v-if="code === workspace.baseLocale" class="text-dimmed">
380
+ {{ $t('dms_lang.common.base') }}
381
+ </span>
382
+ <span
383
+ v-else
384
+ :class="
385
+ COVERAGE_TEXT_CLASSES[
386
+ coverageTone(workspace.localeProgress[code] ?? 0)
387
+ ]
388
+ "
389
+ >
390
+ {{ Math.round(workspace.localeProgress[code] ?? 0) }}%
391
+ </span>
392
+ </span>
393
+ </div>
394
+ </div>
395
+
396
+ <template #footer>
397
+ <div class="flex items-center gap-2.5">
398
+ <template v-if="workspace.kind === 'added'">
399
+ <DmsStatusPill
400
+ tone="success"
401
+ size="sm"
402
+ :label="PUBLIC_URL_METHOD"
403
+ dot="none"
404
+ />
405
+ <code
406
+ class="text-muted min-w-0 flex-1 truncate font-mono text-xs"
407
+ >
408
+ {{ links.publicLocaleUrl(workspace.id) }}
409
+ </code>
410
+ <DmsCopyButton :value="links.publicLocaleUrl(workspace.id)" />
411
+ </template>
412
+ <p
413
+ v-else
414
+ class="text-dimmed flex min-w-0 flex-1 items-center gap-1.5 text-xs"
415
+ >
416
+ <UIcon
417
+ :name="
418
+ workspace.kind === 'modules' ? 'i-ph-info' : 'i-ph-folder'
419
+ "
420
+ class="size-3.5 shrink-0"
421
+ />
422
+ <span class="truncate">
423
+ {{ $t(`dms_lang.workspace_kinds.${workspace.kind}.source`) }}
424
+ </span>
425
+ </p>
426
+ <UButton
427
+ size="sm"
428
+ color="neutral"
429
+ variant="ghost"
430
+ trailing-icon="i-ph-arrow-right"
431
+ :label="openLabel(workspace)"
432
+ @click="open(workspace)"
433
+ />
434
+ </div>
435
+ </template>
436
+ </DmsCard>
437
+
438
+ <button
439
+ v-if="isLoaded && canCreate"
440
+ type="button"
441
+ class="border-default text-muted hover:border-primary/50 hover:text-highlighted flex min-h-56 flex-col items-center justify-center gap-3 rounded-(--dms-radius-card) border border-dashed p-6 text-center transition-colors"
442
+ @click="create"
443
+ >
444
+ <DmsIconWell icon="i-ph-plus" tone="primary" size="lg" />
445
+ <span class="text-highlighted text-sm font-semibold">
446
+ {{ $t('dms_lang.workspaces.new') }}
447
+ </span>
448
+ <span class="max-w-xs text-xs">
449
+ {{ $t('dms_lang.workspaces.new_hint') }}
450
+ </span>
451
+ </button>
452
+ </div>
453
+ </div>
454
+ </template>