@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.
- package/README.md +12 -6
- package/dist/pages/actions.d.ts +7 -0
- package/dist/pages/actions.js +15 -0
- package/dist/pages/actions.js.map +1 -0
- package/dist/pages/component-action.d.ts +2 -0
- package/dist/pages/component-action.js +10 -0
- package/dist/pages/component-action.js.map +1 -0
- package/dist/pages/header-actions.d.ts +9 -0
- package/dist/pages/header-actions.js +146 -0
- package/dist/pages/header-actions.js.map +1 -0
- package/dist/pages/index.d.ts +6 -0
- package/dist/pages/index.js +6 -0
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/language.d.ts +10 -0
- package/dist/pages/language.js +89 -0
- package/dist/pages/language.js.map +1 -0
- package/dist/pages/languages-table.d.ts +2 -0
- package/dist/pages/languages-table.js +120 -0
- package/dist/pages/languages-table.js.map +1 -0
- package/dist/pages/module.d.ts +7 -1
- package/dist/pages/module.js +28 -2
- package/dist/pages/module.js.map +1 -1
- package/dist/pages/overview.d.ts +2 -1
- package/dist/pages/overview.js +83 -8
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/page-actions.d.ts +6 -0
- package/dist/pages/page-actions.js +10 -0
- package/dist/pages/page-actions.js.map +1 -0
- package/dist/pages/quick-actions.d.ts +1 -0
- package/dist/pages/quick-actions.js +56 -0
- package/dist/pages/quick-actions.js.map +1 -0
- package/dist/pages/translations.d.ts +7 -1
- package/dist/pages/translations.js +47 -10
- package/dist/pages/translations.js.map +1 -1
- package/dist/pages/workspace-guard.d.ts +1 -0
- package/dist/pages/workspace-guard.js +35 -0
- package/dist/pages/workspace-guard.js.map +1 -0
- package/dist/pages/workspace.d.ts +18 -0
- package/dist/pages/workspace.js +162 -0
- package/dist/pages/workspace.js.map +1 -0
- package/dist/pages/workspaces.d.ts +14 -0
- package/dist/pages/workspaces.js +88 -0
- package/dist/pages/workspaces.js.map +1 -0
- package/dist/routes/publicLocales.d.ts +3 -2
- package/dist/routes/publicLocales.js +39 -18
- package/dist/routes/publicLocales.js.map +1 -1
- package/dist/routes/translations.d.ts +59 -63
- package/dist/routes/translations.js +400 -119
- package/dist/routes/translations.js.map +1 -1
- package/dist/utils/announce.d.ts +9 -0
- package/dist/utils/announce.js +29 -0
- package/dist/utils/announce.js.map +1 -0
- package/dist/utils/blocks.d.ts +8 -0
- package/dist/utils/blocks.js +213 -0
- package/dist/utils/blocks.js.map +1 -0
- package/dist/utils/body.d.ts +1 -0
- package/dist/utils/body.js +21 -0
- package/dist/utils/body.js.map +1 -0
- package/dist/utils/cache.d.ts +3 -0
- package/dist/utils/cache.js +32 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/catalog.d.ts +7 -0
- package/dist/utils/catalog.js +62 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/coverage.d.ts +2 -0
- package/dist/utils/coverage.js +11 -0
- package/dist/utils/coverage.js.map +1 -0
- package/dist/utils/dialogs.d.ts +7 -0
- package/dist/utils/dialogs.js +103 -0
- package/dist/utils/dialogs.js.map +1 -0
- package/dist/utils/errors.d.ts +40 -0
- package/dist/utils/errors.js +60 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/export.d.ts +17 -0
- package/dist/utils/export.js +129 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/json.d.ts +10 -1
- package/dist/utils/json.js +127 -19
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/key-stores.d.ts +3 -0
- package/dist/utils/key-stores.js +24 -0
- package/dist/utils/key-stores.js.map +1 -0
- package/dist/utils/keys.d.ts +23 -0
- package/dist/utils/keys.js +252 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/languages.d.ts +27 -0
- package/dist/utils/languages.js +121 -0
- package/dist/utils/languages.js.map +1 -0
- package/dist/utils/locale-codes.d.ts +5 -0
- package/dist/utils/locale-codes.js +56 -0
- package/dist/utils/locale-codes.js.map +1 -0
- package/dist/utils/locale-discovery.d.ts +1 -0
- package/dist/utils/locale-discovery.js +19 -1
- package/dist/utils/locale-discovery.js.map +1 -1
- package/dist/utils/message-check.d.ts +1 -0
- package/dist/utils/message-check.js +93 -0
- package/dist/utils/message-check.js.map +1 -0
- package/dist/utils/message-syntax.d.ts +6 -0
- package/dist/utils/message-syntax.js +38 -0
- package/dist/utils/message-syntax.js.map +1 -0
- package/dist/utils/namespaces.d.ts +12 -0
- package/dist/utils/namespaces.js +52 -0
- package/dist/utils/namespaces.js.map +1 -0
- package/dist/utils/notices.d.ts +4 -0
- package/dist/utils/notices.js +60 -0
- package/dist/utils/notices.js.map +1 -0
- package/dist/utils/own.d.ts +2 -3
- package/dist/utils/own.js +17 -57
- package/dist/utils/own.js.map +1 -1
- package/dist/utils/public-url.d.ts +8 -0
- package/dist/utils/public-url.js +87 -0
- package/dist/utils/public-url.js.map +1 -0
- package/dist/utils/registry.d.ts +3 -1
- package/dist/utils/registry.js +26 -10
- package/dist/utils/registry.js.map +1 -1
- package/dist/utils/resolve.d.ts +18 -15
- package/dist/utils/resolve.js +98 -151
- package/dist/utils/resolve.js.map +1 -1
- package/dist/utils/review.d.ts +5 -0
- package/dist/utils/review.js +64 -0
- package/dist/utils/review.js.map +1 -0
- package/dist/utils/snippets.d.ts +7 -0
- package/dist/utils/snippets.js +129 -0
- package/dist/utils/snippets.js.map +1 -0
- package/dist/utils/summary.d.ts +23 -0
- package/dist/utils/summary.js +65 -0
- package/dist/utils/summary.js.map +1 -0
- package/dist/utils/tree.d.ts +2 -17
- package/dist/utils/tree.js +21 -126
- package/dist/utils/tree.js.map +1 -1
- package/dist/utils/workspaces.d.ts +45 -15
- package/dist/utils/workspaces.js +256 -164
- package/dist/utils/workspaces.js.map +1 -1
- package/dist/validation/key.schema.d.ts +71 -0
- package/dist/validation/key.schema.js +67 -0
- package/dist/validation/key.schema.js.map +1 -0
- package/dist/validation/query.schema.d.ts +17 -0
- package/dist/validation/query.schema.js +44 -0
- package/dist/validation/query.schema.js.map +1 -0
- package/dist/validation/validate.d.ts +2 -0
- package/dist/validation/validate.js +24 -0
- package/dist/validation/validate.js.map +1 -0
- package/dist/validation/workspace.schema.d.ts +145 -0
- package/dist/validation/workspace.schema.js +83 -0
- package/dist/validation/workspace.schema.js.map +1 -0
- package/frontend-vue/app/build/components/KeyAddModal.vue +340 -0
- package/frontend-vue/app/build/components/KeyEditorDrawer.vue +951 -0
- package/frontend-vue/app/build/components/KeyRenameModal.vue +172 -0
- package/frontend-vue/app/build/components/LanguageAddModal.vue +199 -0
- package/frontend-vue/app/build/components/LanguagePicker.vue +233 -0
- package/frontend-vue/app/build/components/LocaleTile.vue +52 -0
- package/frontend-vue/app/build/components/PlaceholderText.vue +42 -0
- package/frontend-vue/app/build/components/ShortcutKbds.vue +22 -0
- package/frontend-vue/app/build/components/WorkspaceCreateModal.vue +193 -0
- package/frontend-vue/app/build/components/WorkspaceRenameModal.vue +107 -0
- package/frontend-vue/app/build/components/form/FormFieldRow.vue +70 -0
- package/frontend-vue/app/build/components/form/FormRows.vue +25 -0
- package/frontend-vue/app/build/components/form/WorkspaceDetailsFields.vue +44 -0
- package/frontend-vue/app/build/components/matrix/MatrixCell.vue +488 -0
- package/frontend-vue/app/build/components/matrix/MatrixColumns.vue +177 -0
- package/frontend-vue/app/build/components/matrix/MatrixGroupHeader.vue +57 -0
- package/frontend-vue/app/build/components/matrix/MatrixKeyCell.vue +83 -0
- package/frontend-vue/app/build/components/matrix/MatrixToolbar.vue +167 -0
- package/frontend-vue/app/build/components/queue/QueueActions.vue +60 -0
- package/frontend-vue/app/build/components/queue/QueueDone.vue +185 -0
- package/frontend-vue/app/build/components/queue/QueueEditor.vue +374 -0
- package/frontend-vue/app/build/components/queue/QueueHeader.vue +162 -0
- package/frontend-vue/app/build/components/queue/QueueUpNext.vue +61 -0
- package/frontend-vue/app/build/composables/useCellEditor.ts +324 -0
- package/frontend-vue/app/build/composables/useCellMoves.ts +155 -0
- package/frontend-vue/app/build/composables/useCellSaves.ts +339 -0
- package/frontend-vue/app/build/composables/useKeyPanel.ts +284 -0
- package/frontend-vue/app/build/composables/useKeySaves.ts +280 -0
- package/frontend-vue/app/build/composables/useMatrixFilters.ts +213 -0
- package/frontend-vue/app/build/composables/useMatrixRows.ts +104 -0
- package/frontend-vue/app/build/composables/useMatrixView.ts +181 -0
- package/frontend-vue/app/build/composables/useQueueContext.ts +31 -0
- package/frontend-vue/app/build/composables/useQueueEditing.ts +53 -0
- package/frontend-vue/app/build/composables/useQueueOrphans.ts +54 -0
- package/frontend-vue/app/build/composables/useQueueSave.ts +290 -0
- package/frontend-vue/app/build/composables/useQueueShortcuts.ts +106 -0
- package/frontend-vue/app/build/composables/useQueueToasts.ts +99 -0
- package/frontend-vue/app/components/LanguageNamespaces.vue +77 -0
- package/frontend-vue/app/components/NamespaceCoverage.vue +222 -0
- package/frontend-vue/app/components/TranslationMatrix.vue +809 -0
- package/frontend-vue/app/components/TranslationQueue.vue +212 -0
- package/frontend-vue/app/components/WorkspaceDangerZone.vue +81 -0
- package/frontend-vue/app/components/WorkspaceGeneral.vue +232 -0
- package/frontend-vue/app/components/WorkspaceList.vue +454 -0
- package/frontend-vue/app/components/WorkspaceScope.vue +384 -0
- package/frontend-vue/app/composables/translation/useFirstRun.ts +8 -0
- package/frontend-vue/app/composables/translation/useI18nWorkspaces.ts +221 -133
- package/frontend-vue/app/composables/translation/useKeyActions.ts +224 -0
- package/frontend-vue/app/composables/translation/useLangFormat.ts +10 -0
- package/frontend-vue/app/composables/translation/useLangLinks.ts +80 -0
- package/frontend-vue/app/composables/translation/useLanguageActions.ts +159 -0
- package/frontend-vue/app/composables/translation/useLanguageQueue.ts +232 -0
- package/frontend-vue/app/composables/translation/useLocaleNames.ts +166 -0
- package/frontend-vue/app/composables/translation/useMutationToast.ts +51 -17
- package/frontend-vue/app/composables/translation/useQueueDrafts.ts +115 -0
- package/frontend-vue/app/composables/translation/useQueueSession.ts +182 -0
- package/frontend-vue/app/composables/translation/useServedConfirm.ts +152 -0
- package/frontend-vue/app/composables/translation/useWorkspaceActions.ts +259 -0
- package/frontend-vue/app/composables/translation/useWorkspaceContext.ts +46 -15
- package/frontend-vue/app/composables/translation/useWorkspaceFlat.ts +322 -70
- package/frontend-vue/app/composables/translation/useWorkspaceNameCheck.ts +55 -0
- package/frontend-vue/app/composables/translation/useWorkspaceRoute.ts +129 -0
- package/frontend-vue/app/config/shortcuts-registry.ts +72 -0
- package/frontend-vue/app/types/lang.ts +130 -0
- package/frontend-vue/app/utils/boundedCache.ts +22 -0
- package/frontend-vue/app/utils/download.ts +16 -0
- package/frontend-vue/app/utils/keySaveErrors.ts +61 -0
- package/frontend-vue/app/utils/keySaves.ts +108 -0
- package/frontend-vue/app/utils/languages.ts +272 -0
- package/frontend-vue/app/utils/matrixExport.ts +47 -0
- package/frontend-vue/app/utils/queueDrafts.ts +115 -0
- package/frontend-vue/app/utils/queuePass.ts +145 -0
- package/frontend-vue/app/utils/queueView.ts +22 -0
- package/frontend-vue/app/utils/shortcuts.ts +75 -0
- package/frontend-vue/app/utils/translations.ts +756 -0
- package/frontend-vue/app/utils/workspaceBackup.ts +119 -0
- package/frontend-vue/app/utils/workspaces.ts +45 -0
- package/frontend-vue/dms.frontend.build.ts +5 -0
- package/frontend-vue/dms.frontend.ts +9 -20
- package/frontend-vue/i18n/locales/lang-en-GB.json +792 -69
- package/frontend-vue/i18n/locales/lang-fr-FR.json +792 -69
- package/frontend-vue/package.json +10 -5
- package/package.json +10 -8
- package/dist/utils/mutations.d.ts +0 -3
- package/dist/utils/mutations.js +0 -35
- package/dist/utils/mutations.js.map +0 -1
- package/frontend-vue/app/build/components/pages/lang/TranslationMatrix.vue +0 -284
- package/frontend-vue/app/components/LanguageAddModal.vue +0 -78
- package/frontend-vue/app/components/WorkspaceEndpoint.vue +0 -29
- package/frontend-vue/app/components/WorkspaceSelector.vue +0 -180
- package/frontend-vue/app/components/WorkspaceStatus.vue +0 -24
- package/frontend-vue/app/composables/translation/useLanguageCatalog.ts +0 -90
- package/frontend-vue/app/composables/translation/useLocaleMeta.ts +0 -18
- package/frontend-vue/app/composables/translation/useTranslationProgress.ts +0 -73
- package/frontend-vue/app/custom-pages/lang/overview.vue +0 -397
- package/frontend-vue/app/custom-pages/lang/translations.vue +0 -498
- package/frontend-vue/app/plugins/workspace-sidebar-widget.ts +0 -12
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { FlatTranslationRow, KeyRowResponse } from '../../types/lang'
|
|
3
|
+
import {
|
|
4
|
+
checkMessage,
|
|
5
|
+
escapeMessage,
|
|
6
|
+
hasBlockingIssue,
|
|
7
|
+
isValidKeyPath,
|
|
8
|
+
keyPathConflict,
|
|
9
|
+
messageIssueText,
|
|
10
|
+
namespaceOf,
|
|
11
|
+
stringValue,
|
|
12
|
+
type KeyPathConflict,
|
|
13
|
+
type MessageIssue,
|
|
14
|
+
type MessageIssueSeverity,
|
|
15
|
+
} from '../../utils/translations'
|
|
16
|
+
import FormFieldRow from './form/FormFieldRow.vue'
|
|
17
|
+
import FormRows from './form/FormRows.vue'
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
workspace: string
|
|
21
|
+
baseLocale: string
|
|
22
|
+
/** Every language of the workspace; the base is listed first whatever its place. */
|
|
23
|
+
locales?: string[]
|
|
24
|
+
existingKeys: string[]
|
|
25
|
+
/** Project files only: the keys the installed modules provide. */
|
|
26
|
+
moduleRows?: FlatTranslationRow[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Emits {
|
|
30
|
+
close: [added: string[]]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const VISIBLE_LOCALES = 3
|
|
34
|
+
const ISSUE_SEPARATOR = ' · '
|
|
35
|
+
|
|
36
|
+
const CONFLICT_LABELS: Record<KeyPathConflict['kind'], string> = {
|
|
37
|
+
exists: 'dms_lang.key_add.path_taken',
|
|
38
|
+
namespace: 'dms_lang.key_add.path_namespace_conflict',
|
|
39
|
+
leafParent: 'dms_lang.key_add.path_parent_conflict',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const MODULE_CONFLICT_LABELS: Record<KeyPathConflict['kind'], string> = {
|
|
43
|
+
exists: 'dms_lang.key_add.module_override',
|
|
44
|
+
namespace: 'dms_lang.key_add.module_namespace',
|
|
45
|
+
leafParent: 'dms_lang.key_add.module_parent',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const props = defineProps<Props>()
|
|
49
|
+
const emit = defineEmits<Emits>()
|
|
50
|
+
|
|
51
|
+
const { t } = useI18n()
|
|
52
|
+
const { errorMessage } = useMutationToast()
|
|
53
|
+
const toast = useToast()
|
|
54
|
+
const { updateKey, createKey } = useI18nWorkspaces()
|
|
55
|
+
const { nativeName } = useLocaleNames()
|
|
56
|
+
const { applyRow } = useWorkspaceFlat()
|
|
57
|
+
|
|
58
|
+
const isOpen = ref(true)
|
|
59
|
+
const path = ref('')
|
|
60
|
+
const values = ref<Record<string, string>>({})
|
|
61
|
+
const addAnother = ref(false)
|
|
62
|
+
const showAll = ref(false)
|
|
63
|
+
const isSubmitting = ref(false)
|
|
64
|
+
const submitError = ref('')
|
|
65
|
+
const added = ref<string[]>([])
|
|
66
|
+
const form = useTemplateRef<HTMLFormElement>('form')
|
|
67
|
+
|
|
68
|
+
const trimmedPath = computed(() => path.value.trim())
|
|
69
|
+
const orderedLocales = computed(() => [
|
|
70
|
+
props.baseLocale,
|
|
71
|
+
...(props.locales ?? []).filter((code) => code !== props.baseLocale),
|
|
72
|
+
])
|
|
73
|
+
const shownLocales = computed(() =>
|
|
74
|
+
showAll.value
|
|
75
|
+
? orderedLocales.value
|
|
76
|
+
: orderedLocales.value.slice(0, VISIBLE_LOCALES),
|
|
77
|
+
)
|
|
78
|
+
const hiddenCount = computed(
|
|
79
|
+
() => orderedLocales.value.length - shownLocales.value.length,
|
|
80
|
+
)
|
|
81
|
+
const moduleRow = computed(() =>
|
|
82
|
+
props.moduleRows?.find((row) => row.key === trimmedPath.value),
|
|
83
|
+
)
|
|
84
|
+
const isOverride = computed(() => Boolean(moduleRow.value))
|
|
85
|
+
const conflict = computed(() =>
|
|
86
|
+
keyPathConflict(trimmedPath.value, [...props.existingKeys, ...added.value]),
|
|
87
|
+
)
|
|
88
|
+
const moduleConflict = computed(() =>
|
|
89
|
+
isOverride.value
|
|
90
|
+
? null
|
|
91
|
+
: keyPathConflict(
|
|
92
|
+
trimmedPath.value,
|
|
93
|
+
(props.moduleRows ?? []).map((row) => row.key),
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
const pathError = computed(() => {
|
|
97
|
+
if (!trimmedPath.value) return ''
|
|
98
|
+
if (!isValidKeyPath(trimmedPath.value))
|
|
99
|
+
return t('dms_lang.key_add.path_invalid')
|
|
100
|
+
if (conflict.value) return conflictText(conflict.value, CONFLICT_LABELS)
|
|
101
|
+
if (moduleConflict.value)
|
|
102
|
+
return conflictText(moduleConflict.value, MODULE_CONFLICT_LABELS)
|
|
103
|
+
return submitError.value
|
|
104
|
+
})
|
|
105
|
+
const pathHelp = computed(() => {
|
|
106
|
+
if (!trimmedPath.value) return t('dms_lang.key_add.path_help')
|
|
107
|
+
if (isOverride.value)
|
|
108
|
+
return t('dms_lang.key_add.module_override', { path: trimmedPath.value })
|
|
109
|
+
const namespace = namespaceOf(trimmedPath.value)
|
|
110
|
+
const siblings = props.existingKeys.filter(
|
|
111
|
+
(key) => namespaceOf(key) === namespace,
|
|
112
|
+
).length
|
|
113
|
+
return t(
|
|
114
|
+
'dms_lang.key_add.path_namespace',
|
|
115
|
+
{ namespace, count: siblings },
|
|
116
|
+
siblings,
|
|
117
|
+
)
|
|
118
|
+
})
|
|
119
|
+
const written = computed(() =>
|
|
120
|
+
Object.fromEntries(
|
|
121
|
+
orderedLocales.value
|
|
122
|
+
.map((code) => [code, valueOf(code).trim() ? valueOf(code) : ''])
|
|
123
|
+
.filter(([code, value]) => value && value !== moduleTextOf(code)),
|
|
124
|
+
),
|
|
125
|
+
)
|
|
126
|
+
const hasBlockedValue = computed(() =>
|
|
127
|
+
orderedLocales.value.some((code) => hasBlockingIssue(issuesOf(code))),
|
|
128
|
+
)
|
|
129
|
+
const isValid = computed(
|
|
130
|
+
() =>
|
|
131
|
+
Boolean(trimmedPath.value) &&
|
|
132
|
+
!pathError.value &&
|
|
133
|
+
Object.keys(written.value).length > 0 &&
|
|
134
|
+
!hasBlockedValue.value,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
watch(trimmedPath, () => (submitError.value = ''))
|
|
138
|
+
|
|
139
|
+
function conflictText(
|
|
140
|
+
found: KeyPathConflict,
|
|
141
|
+
labels: Record<KeyPathConflict['kind'], string>,
|
|
142
|
+
): string {
|
|
143
|
+
return t(
|
|
144
|
+
labels[found.kind],
|
|
145
|
+
{
|
|
146
|
+
path: trimmedPath.value,
|
|
147
|
+
parent: found.keys[0],
|
|
148
|
+
example: found.keys[0],
|
|
149
|
+
count: found.keys.length,
|
|
150
|
+
},
|
|
151
|
+
found.keys.length,
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function moduleTextOf(code: string): string {
|
|
156
|
+
return stringValue(moduleRow.value?.values[code])
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function valueOf(code: string): string {
|
|
160
|
+
return values.value[code] ?? moduleTextOf(code)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function setValue(code: string, value: string) {
|
|
164
|
+
values.value = { ...values.value, [code]: value }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function issuesOf(code: string): MessageIssue[] {
|
|
168
|
+
const base = code === props.baseLocale ? '' : valueOf(props.baseLocale)
|
|
169
|
+
return checkMessage(base, valueOf(code))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function issueText(code: string, severity: MessageIssueSeverity): string {
|
|
173
|
+
return issuesOf(code)
|
|
174
|
+
.filter((issue) => issue.severity === severity)
|
|
175
|
+
.map((issue) => messageIssueText(issue, t))
|
|
176
|
+
.join(ISSUE_SEPARATOR)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function valueHelp(code: string, index: number): string | undefined {
|
|
180
|
+
const warnings = issueText(code, 'warning')
|
|
181
|
+
if (warnings) return warnings
|
|
182
|
+
const needsText = index === 0 && !Object.keys(written.value).length
|
|
183
|
+
return needsText ? t('dms_lang.key_add.texts_required') : undefined
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function close() {
|
|
187
|
+
isOpen.value = false
|
|
188
|
+
emit('close', added.value)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function resetForNext() {
|
|
192
|
+
path.value = ''
|
|
193
|
+
values.value = {}
|
|
194
|
+
nextTick(() => form.value?.querySelector('input')?.focus())
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function write(key: string): Promise<KeyRowResponse> {
|
|
198
|
+
if (isOverride.value)
|
|
199
|
+
return updateKey(props.workspace, key, written.value)
|
|
200
|
+
return createKey(props.workspace, key, written.value)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function submit() {
|
|
204
|
+
if (!isValid.value || isSubmitting.value) return
|
|
205
|
+
isSubmitting.value = true
|
|
206
|
+
const key = trimmedPath.value
|
|
207
|
+
try {
|
|
208
|
+
applyRow(props.workspace, key, await write(key))
|
|
209
|
+
} catch (error) {
|
|
210
|
+
submitError.value = errorMessage(error)
|
|
211
|
+
return
|
|
212
|
+
} finally {
|
|
213
|
+
isSubmitting.value = false
|
|
214
|
+
}
|
|
215
|
+
added.value = [...added.value, key]
|
|
216
|
+
toast.add({
|
|
217
|
+
title: t('dms_lang.key_add.added', { key }),
|
|
218
|
+
color: 'success',
|
|
219
|
+
icon: 'i-ph-check-circle',
|
|
220
|
+
})
|
|
221
|
+
if (addAnother.value) resetForNext()
|
|
222
|
+
else close()
|
|
223
|
+
}
|
|
224
|
+
</script>
|
|
225
|
+
|
|
226
|
+
<template>
|
|
227
|
+
<UModal
|
|
228
|
+
v-model:open="isOpen"
|
|
229
|
+
:title="$t('dms_lang.key_add.title')"
|
|
230
|
+
:description="
|
|
231
|
+
$t('dms_lang.key_add.description', { workspace: props.workspace })
|
|
232
|
+
"
|
|
233
|
+
:ui="{ content: 'sm:max-w-lg' }"
|
|
234
|
+
@update:open="(open: boolean) => !open && close()"
|
|
235
|
+
>
|
|
236
|
+
<template #body>
|
|
237
|
+
<form ref="form" novalidate @submit.prevent="submit">
|
|
238
|
+
<FormRows has-required>
|
|
239
|
+
<FormFieldRow
|
|
240
|
+
:label="$t('dms_lang.key_add.path')"
|
|
241
|
+
:help="pathError ? undefined : pathHelp"
|
|
242
|
+
:error="pathError || null"
|
|
243
|
+
required
|
|
244
|
+
>
|
|
245
|
+
<template #default="{ id }">
|
|
246
|
+
<DmsInputText
|
|
247
|
+
:id="id"
|
|
248
|
+
v-model="path"
|
|
249
|
+
autofocus
|
|
250
|
+
class="w-full"
|
|
251
|
+
:ui="{ base: 'font-mono' }"
|
|
252
|
+
placeholder="checkout.coupon.invalid"
|
|
253
|
+
/>
|
|
254
|
+
</template>
|
|
255
|
+
</FormFieldRow>
|
|
256
|
+
<FormFieldRow
|
|
257
|
+
v-for="(code, index) in shownLocales"
|
|
258
|
+
:key="code"
|
|
259
|
+
:label="nativeName(code)"
|
|
260
|
+
:help="valueHelp(code, index)"
|
|
261
|
+
:error="issueText(code, 'error') || null"
|
|
262
|
+
>
|
|
263
|
+
<template #label-extra>
|
|
264
|
+
<span class="text-dimmed font-mono text-xs">{{ code }}</span>
|
|
265
|
+
<DmsStatusPill
|
|
266
|
+
v-if="code === props.baseLocale"
|
|
267
|
+
dot="none"
|
|
268
|
+
tone="neutral"
|
|
269
|
+
size="sm"
|
|
270
|
+
:label="$t('dms_lang.common.base')"
|
|
271
|
+
/>
|
|
272
|
+
</template>
|
|
273
|
+
<template #default="{ id }">
|
|
274
|
+
<DmsTextarea
|
|
275
|
+
:id="id"
|
|
276
|
+
:model-value="valueOf(code)"
|
|
277
|
+
:rows="code === props.baseLocale ? 2 : 1"
|
|
278
|
+
autoresize
|
|
279
|
+
class="w-full"
|
|
280
|
+
@update:model-value="(value: string) => setValue(code, value)"
|
|
281
|
+
@keydown.meta.enter.prevent="submit"
|
|
282
|
+
@keydown.ctrl.enter.prevent="submit"
|
|
283
|
+
/>
|
|
284
|
+
<UButton
|
|
285
|
+
v-if="hasBlockingIssue(issuesOf(code))"
|
|
286
|
+
class="mt-1"
|
|
287
|
+
size="xs"
|
|
288
|
+
color="error"
|
|
289
|
+
variant="soft"
|
|
290
|
+
icon="i-ph-magic-wand"
|
|
291
|
+
:label="$t('dms_lang.message_issue.escape')"
|
|
292
|
+
@click="setValue(code, escapeMessage(valueOf(code)))"
|
|
293
|
+
/>
|
|
294
|
+
</template>
|
|
295
|
+
</FormFieldRow>
|
|
296
|
+
</FormRows>
|
|
297
|
+
<UButton
|
|
298
|
+
v-if="orderedLocales.length > VISIBLE_LOCALES"
|
|
299
|
+
class="mt-2"
|
|
300
|
+
color="neutral"
|
|
301
|
+
variant="link"
|
|
302
|
+
size="sm"
|
|
303
|
+
:icon="showAll ? 'i-ph-caret-up' : 'i-ph-caret-down'"
|
|
304
|
+
:label="
|
|
305
|
+
showAll
|
|
306
|
+
? $t('dms_lang.key_add.fewer_languages')
|
|
307
|
+
: $t('dms_lang.key_add.more_languages', hiddenCount)
|
|
308
|
+
"
|
|
309
|
+
@click="showAll = !showAll"
|
|
310
|
+
/>
|
|
311
|
+
</form>
|
|
312
|
+
</template>
|
|
313
|
+
<template #footer>
|
|
314
|
+
<div class="flex w-full items-center gap-2">
|
|
315
|
+
<DmsCheckbox
|
|
316
|
+
v-model="addAnother"
|
|
317
|
+
:label="$t('dms_lang.key_add.add_another')"
|
|
318
|
+
/>
|
|
319
|
+
<div class="flex-1" />
|
|
320
|
+
<UButton
|
|
321
|
+
color="neutral"
|
|
322
|
+
variant="outline"
|
|
323
|
+
:label="$t('dms_lang.actions.cancel')"
|
|
324
|
+
@click="close()"
|
|
325
|
+
/>
|
|
326
|
+
<UButton
|
|
327
|
+
:icon="isOverride ? 'i-ph-git-fork' : 'i-ph-plus'"
|
|
328
|
+
:loading="isSubmitting"
|
|
329
|
+
:disabled="!isValid"
|
|
330
|
+
:label="
|
|
331
|
+
isOverride
|
|
332
|
+
? $t('dms_lang.key_add.submit_override')
|
|
333
|
+
: $t('dms_lang.key_add.submit')
|
|
334
|
+
"
|
|
335
|
+
@click="submit"
|
|
336
|
+
/>
|
|
337
|
+
</div>
|
|
338
|
+
</template>
|
|
339
|
+
</UModal>
|
|
340
|
+
</template>
|