@antelopejs/dms-media 0.5.1 → 0.6.1
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 +3 -3
- package/dist/db/models/mediaFolders.model.d.ts +0 -3
- package/dist/db/models/mediaFolders.model.js +0 -29
- package/dist/db/models/mediaFolders.model.js.map +1 -1
- package/dist/db/tables/mediaDeclarations.table.d.ts +0 -4
- package/dist/db/tables/mediaDeclarations.table.js +0 -16
- package/dist/db/tables/mediaDeclarations.table.js.map +1 -1
- package/dist/declared/assets.d.ts +0 -2
- package/dist/declared/assets.js +12 -140
- package/dist/declared/assets.js.map +1 -1
- package/dist/declared/folders.d.ts +1 -5
- package/dist/declared/folders.js +14 -80
- package/dist/declared/folders.js.map +1 -1
- package/dist/declared/index.d.ts +0 -2
- package/dist/declared/index.js +0 -2
- package/dist/declared/index.js.map +1 -1
- package/dist/declared/records.d.ts +2 -30
- package/dist/declared/records.js +3 -33
- package/dist/declared/records.js.map +1 -1
- package/dist/derivatives.js +5 -17
- package/dist/derivatives.js.map +1 -1
- package/dist/frontend-module.d.ts +4 -0
- package/dist/frontend-module.js +24 -0
- package/dist/frontend-module.js.map +1 -0
- package/dist/implementations/interface-dms-media/index.d.ts +1 -3
- package/dist/implementations/interface-dms-media/index.js +0 -2
- package/dist/implementations/interface-dms-media/index.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +3 -19
- package/dist/index.js.map +1 -1
- package/dist/library/realtime.js +8 -1
- package/dist/library/realtime.js.map +1 -1
- package/dist/pages/activity.d.ts +1 -0
- package/dist/pages/activity.js +3 -0
- package/dist/pages/activity.js.map +1 -1
- package/dist/pages/overview.d.ts +1 -0
- package/dist/pages/overview.js +3 -2
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/toolbar.d.ts +3 -0
- package/dist/pages/toolbar.js +19 -0
- package/dist/pages/toolbar.js.map +1 -0
- package/dist/pages/uploads.d.ts +1 -0
- package/dist/pages/uploads.js +4 -0
- package/dist/pages/uploads.js.map +1 -1
- package/dist/routes/media/delivery-stream.js +7 -21
- package/dist/routes/media/delivery-stream.js.map +1 -1
- package/dist/routes/media/manage.d.ts +23 -0
- package/dist/routes/media/manage.js +7 -4
- package/dist/routes/media/manage.js.map +1 -1
- package/dist/routes/media/upload.js +2 -5
- package/dist/routes/media/upload.js.map +1 -1
- package/dist/test/antelope.test.js +9 -4
- package/dist/test/antelope.test.js.map +1 -1
- package/dist/test/integration/media-activity-overview.test.js +6 -0
- package/dist/test/integration/media-activity-overview.test.js.map +1 -1
- package/dist/test/integration/media-declared-content.test.js +17 -317
- package/dist/test/integration/media-declared-content.test.js.map +1 -1
- package/dist/test/integration/media-linked-subfolders.test.js +2 -2
- package/dist/test/integration/media-linked-subfolders.test.js.map +1 -1
- package/dist/test/integration/media-storage-origin-unreachable.test.js +79 -0
- package/dist/test/integration/media-storage-origin-unreachable.test.js.map +1 -0
- package/dist/test/unit/declared.test.js +0 -66
- package/dist/test/unit/declared.test.js.map +1 -1
- package/dist/test/unit/library/realtime.test.d.ts +1 -0
- package/dist/test/unit/library/realtime.test.js +44 -0
- package/dist/test/unit/library/realtime.test.js.map +1 -0
- package/dist/test/unit/pages/toolbar.test.d.ts +1 -0
- package/dist/test/unit/pages/toolbar.test.js +64 -0
- package/dist/test/unit/pages/toolbar.test.js.map +1 -0
- package/dist/test/unit/routes/preset-row.test.d.ts +1 -0
- package/dist/test/unit/routes/preset-row.test.js +36 -0
- package/dist/test/unit/routes/preset-row.test.js.map +1 -0
- package/dist/validation/declared.schema.d.ts +7 -36
- package/dist/validation/declared.schema.js +1 -12
- package/dist/validation/declared.schema.js.map +1 -1
- package/frontend-vue/app/components/Explorer.vue +2 -0
- package/frontend-vue/app/components/FirstRun.vue +3 -1
- package/frontend-vue/app/components/PresetCards.vue +28 -5
- package/frontend-vue/app/components/RecentFiles.vue +11 -5
- package/frontend-vue/app/components/UploadQueue.vue +3 -1
- package/frontend-vue/app/components/UploadStrip.vue +3 -1
- package/frontend-vue/app/components/explorer/ExplorerDetailsDrawer.vue +10 -0
- package/frontend-vue/app/components/explorer/ExplorerInspector.vue +19 -14
- package/frontend-vue/app/components/explorer/ExplorerShell.vue +1 -11
- package/frontend-vue/app/composables/library/useExplorerCommands.ts +7 -1
- package/frontend-vue/app/composables/library/useExplorerDetailsDrawer.ts +75 -0
- package/frontend-vue/i18n/locales/media-en-GB.json +9 -2
- package/frontend-vue/i18n/locales/media-fr-FR.json +9 -2
- package/frontend-vue/package.json +1 -1
- package/frontend-vue/tests/detailsDrawer.test.ts +150 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +70 -0
- package/frontend-vue/tests/locales.test.ts +17 -0
- package/frontend-vue/tests/serverRender.test.ts +47 -2
- package/package.json +10 -9
- package/skills/dms-media/SKILL.md +17 -24
- package/src/db/models/mediaFolders.model.ts +0 -44
- package/src/db/tables/mediaDeclarations.table.ts +3 -19
- package/src/declared/assets.ts +19 -210
- package/src/declared/folders.ts +22 -135
- package/src/declared/index.ts +0 -2
- package/src/declared/records.ts +8 -82
- package/src/derivatives.ts +7 -17
- package/src/frontend-module.ts +35 -0
- package/src/implementations/interface-dms-media/index.ts +1 -8
- package/src/index.ts +4 -28
- package/src/library/realtime.ts +12 -3
- package/src/pages/activity.ts +4 -0
- package/src/pages/overview.ts +4 -3
- package/src/pages/toolbar.ts +28 -0
- package/src/pages/uploads.ts +5 -0
- package/src/routes/media/delivery-stream.ts +12 -28
- package/src/routes/media/manage.ts +17 -4
- package/src/routes/media/upload.ts +4 -6
- package/src/test/antelope.test.ts +13 -4
- package/src/test/integration/media-activity-overview.test.ts +5 -0
- package/src/test/integration/media-declared-content.test.ts +17 -360
- package/src/test/integration/media-linked-subfolders.test.ts +2 -2
- package/src/test/integration/media-storage-origin-unreachable.test.ts +110 -0
- package/src/test/unit/declared.test.ts +0 -87
- package/src/test/unit/library/realtime.test.ts +55 -0
- package/src/test/unit/pages/toolbar.test.ts +92 -0
- package/src/test/unit/routes/preset-row.test.ts +39 -0
- package/src/validation/declared.schema.ts +0 -13
- package/dist/declared/readiness.d.ts +0 -2
- package/dist/declared/readiness.js +0 -52
- package/dist/declared/readiness.js.map +0 -1
- package/dist/declared/retire.d.ts +0 -3
- package/dist/declared/retire.js +0 -118
- package/dist/declared/retire.js.map +0 -1
- package/dist/test/integration/media-declared-retire.test.js +0 -186
- package/dist/test/integration/media-declared-retire.test.js.map +0 -1
- package/src/declared/readiness.ts +0 -64
- package/src/declared/retire.ts +0 -206
- package/src/test/integration/media-declared-retire.test.ts +0 -257
- /package/dist/test/integration/{media-declared-retire.test.d.ts → media-storage-origin-unreachable.test.d.ts} +0 -0
|
@@ -9,11 +9,13 @@ const format = useMediaFormat()
|
|
|
9
9
|
const overlay = useOverlay()
|
|
10
10
|
const destinationDialog = overlay.create(DestinationDialog)
|
|
11
11
|
const { prefs, update } = useMediaPrefs()
|
|
12
|
-
const { tree, refresh: reload } = useLibraryTree()
|
|
12
|
+
const { tree, refresh: reload, ready } = useLibraryTree()
|
|
13
13
|
const toasts = useUploadToasts()
|
|
14
14
|
const route = useDmsRoute()
|
|
15
15
|
const router = useDmsRouter()
|
|
16
16
|
const { t } = useI18n()
|
|
17
|
+
// Read with the page: a client navigation waits for the folders, so the drop zone shows with it, saying whether files can go.
|
|
18
|
+
await ready()
|
|
17
19
|
const canUpload = computed(() => Boolean(tree.value?.folders.some((folder) => folder.rights.write)))
|
|
18
20
|
const fileInput = useTemplateRef<HTMLInputElement>('fileInput')
|
|
19
21
|
const destination = ref<MediaFolder | null>(null)
|
|
@@ -6,10 +6,12 @@ const uploads = useUploadQueue()
|
|
|
6
6
|
const overlay = useOverlay()
|
|
7
7
|
const destinationDialog = overlay.create(DestinationDialog)
|
|
8
8
|
const { prefs, update } = useMediaPrefs()
|
|
9
|
-
const { tree, refresh: reload } = useLibraryTree()
|
|
9
|
+
const { tree, refresh: reload, ready } = useLibraryTree()
|
|
10
10
|
const { t } = useI18n()
|
|
11
11
|
const toast = useUploadToasts()
|
|
12
12
|
const fileInput = useTemplateRef<HTMLInputElement>('fileInput')
|
|
13
|
+
// Read with the page: a client navigation waits for the folders, so the strip shows with it rather than after.
|
|
14
|
+
await ready()
|
|
13
15
|
const isDragging = ref(false)
|
|
14
16
|
let dragDepth = 0
|
|
15
17
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ExplorerInspector from './ExplorerInspector.vue'
|
|
3
|
+
|
|
4
|
+
// The DMS drawer's body: it injects what the explorer that opened it
|
|
5
|
+
// provides (its library and commands), as a drawer in its template would.
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<ExplorerInspector class="min-w-0 flex-1" />
|
|
10
|
+
</template>
|
|
@@ -41,6 +41,13 @@ function isCurrent<T>(read: ApiDataResult<T>): boolean {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const previewUrl = computed(() => (isCurrent(previewRead) ? previewRead.data.value?.url : undefined))
|
|
44
|
+
/** "Image · PNG"; once when the extension is the type ("PDF"). */
|
|
45
|
+
const typeLabel = computed(() => {
|
|
46
|
+
if (!asset.value) return ''
|
|
47
|
+
const type = t(`dms_media.type_single.${asset.value.typeGroup}`)
|
|
48
|
+
const extension = extensionOf(asset.value).toUpperCase()
|
|
49
|
+
return !extension || extension === type.toUpperCase() ? type : `${type} · ${extension}`
|
|
50
|
+
})
|
|
44
51
|
const uploadedBy = computed(() => (isCurrent(detailsRead) ? (detailsRead.data.value?.uploadedBy ?? null) : null))
|
|
45
52
|
|
|
46
53
|
function saveAlt(alt: string): Promise<boolean> {
|
|
@@ -101,15 +108,15 @@ function saveAlt(alt: string): Promise<boolean> {
|
|
|
101
108
|
<dl class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 p-3 text-[13px]">
|
|
102
109
|
<DmsEyebrow :label="t('dms_media.explorer.details')" tone="muted" class="col-span-2 mb-1" />
|
|
103
110
|
<dt class="text-muted">{{ t('dms_media.columns.type') }}</dt>
|
|
104
|
-
<dd class="text-highlighted
|
|
111
|
+
<dd class="text-highlighted">{{ typeLabel }}</dd>
|
|
105
112
|
<dt class="text-muted">{{ t('dms_media.columns.size') }}</dt>
|
|
106
|
-
<dd class="text-highlighted
|
|
113
|
+
<dd class="text-highlighted font-mono">{{ format.formatBytes(asset.size) }}</dd>
|
|
107
114
|
<template v-if="asset.width && asset.height">
|
|
108
115
|
<dt class="text-muted">{{ t('dms_media.columns.dimensions') }}</dt>
|
|
109
|
-
<dd class="text-highlighted
|
|
116
|
+
<dd class="text-highlighted font-mono">{{ format.formatDimensions(asset.width, asset.height) }}</dd>
|
|
110
117
|
</template>
|
|
111
118
|
<dt class="text-muted">{{ t('dms_media.columns.visibility') }}</dt>
|
|
112
|
-
<dd
|
|
119
|
+
<dd>
|
|
113
120
|
<UButton
|
|
114
121
|
v-if="commands.canChangeVisibility(asset)"
|
|
115
122
|
variant="link"
|
|
@@ -122,18 +129,16 @@ function saveAlt(alt: string): Promise<boolean> {
|
|
|
122
129
|
<span v-else class="text-highlighted">{{ t(`dms_media.visibility.${asset.effectiveVisibility}`) }}</span>
|
|
123
130
|
</dd>
|
|
124
131
|
<dt class="text-muted">{{ t('dms_media.columns.added') }}</dt>
|
|
125
|
-
<dd class="text-highlighted
|
|
126
|
-
{{ format.formatDateTime(asset.createdAt) }}
|
|
127
|
-
</dd>
|
|
132
|
+
<dd class="text-highlighted">{{ format.formatDateTime(asset.createdAt) }}</dd>
|
|
128
133
|
<template v-if="uploadedBy">
|
|
129
134
|
<dt class="text-muted">{{ t('dms_media.inspector.added_by') }}</dt>
|
|
130
|
-
<dd class="text-highlighted truncate
|
|
135
|
+
<dd class="text-highlighted truncate" :title="uploadedBy">{{ uploadedBy }}</dd>
|
|
131
136
|
</template>
|
|
132
137
|
<dt class="text-muted">{{ t('dms_media.columns.modified') }}</dt>
|
|
133
|
-
<dd class="text-highlighted
|
|
138
|
+
<dd class="text-highlighted">{{ format.formatDateTime(asset.updatedAt) }}</dd>
|
|
134
139
|
<template v-if="asset.hasOriginal">
|
|
135
140
|
<dt class="text-muted">{{ t('dms_media.columns.original') }}</dt>
|
|
136
|
-
<dd
|
|
141
|
+
<dd><UBadge :label="t('dms_media.file.preserved')" color="neutral" variant="subtle" size="sm" /></dd>
|
|
137
142
|
</template>
|
|
138
143
|
</dl>
|
|
139
144
|
</template>
|
|
@@ -153,11 +158,11 @@ function saveAlt(alt: string): Promise<boolean> {
|
|
|
153
158
|
</div>
|
|
154
159
|
<dl class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 text-[13px]">
|
|
155
160
|
<dt class="text-muted">{{ t('dms_media.inspector.files_with_subfolders') }}</dt>
|
|
156
|
-
<dd class="text-highlighted
|
|
161
|
+
<dd class="text-highlighted font-mono">{{ format.formatNumber(folder.fileCount) }}</dd>
|
|
157
162
|
<dt class="text-muted">{{ t('dms_media.columns.size') }}</dt>
|
|
158
|
-
<dd class="text-highlighted
|
|
163
|
+
<dd class="text-highlighted font-mono">{{ format.formatBytes(folder.size) }}</dd>
|
|
159
164
|
<dt class="text-muted">{{ t('dms_media.columns.visibility') }}</dt>
|
|
160
|
-
<dd
|
|
165
|
+
<dd>
|
|
161
166
|
<UButton
|
|
162
167
|
v-if="isBrowse && commands.canChangeFolderVisibility?.(folder)"
|
|
163
168
|
variant="link"
|
|
@@ -170,7 +175,7 @@ function saveAlt(alt: string): Promise<boolean> {
|
|
|
170
175
|
<span v-else class="text-highlighted">{{ t(`dms_media.visibility.${folder.visibility}`) }}</span>
|
|
171
176
|
</dd>
|
|
172
177
|
<dt class="text-muted">{{ t('dms_media.inspector.your_rights') }}</dt>
|
|
173
|
-
<dd class="text-highlighted
|
|
178
|
+
<dd class="text-highlighted">{{ t(`dms_media.rights.${folder.rights.manage ? 'manage' : folder.rights.write ? 'write' : folder.rights.read ? 'read' : 'none'}`) }}</dd>
|
|
174
179
|
</dl>
|
|
175
180
|
<UButton
|
|
176
181
|
v-if="library.selection.focusedFolderId.value"
|
|
@@ -75,6 +75,7 @@ const commands = useExplorerCommands(library, {
|
|
|
75
75
|
},
|
|
76
76
|
})
|
|
77
77
|
provideExplorerCommands(commands)
|
|
78
|
+
useExplorerDetailsDrawer(layout, { library, commands })
|
|
78
79
|
const interactions = createAssetInteractions(library, commands, layout)
|
|
79
80
|
provideAssetNavigation(createAssetNavigation(library, interactions.onCheck))
|
|
80
81
|
const { uploads, enqueue } = useExplorerUploads(library, { accept: props.accept, pick: interactions.onCheck })
|
|
@@ -243,17 +244,6 @@ defineExpose({
|
|
|
243
244
|
<ExplorerSidebar class="min-w-0 flex-1" />
|
|
244
245
|
</template>
|
|
245
246
|
</USlideover>
|
|
246
|
-
<USlideover
|
|
247
|
-
v-if="!layout.hasInlineDetails.value"
|
|
248
|
-
v-model:open="layout.isDetailsDrawerOpen.value"
|
|
249
|
-
side="right"
|
|
250
|
-
:title="t('dms_media.explorer.details')"
|
|
251
|
-
:ui="{ content: 'max-w-sm', body: 'flex p-0 sm:p-0' }"
|
|
252
|
-
>
|
|
253
|
-
<template #body>
|
|
254
|
-
<ExplorerInspector class="min-w-0 flex-1" />
|
|
255
|
-
</template>
|
|
256
|
-
</USlideover>
|
|
257
247
|
<slot name="footer">
|
|
258
248
|
<ExplorerStatusBar />
|
|
259
249
|
</slot>
|
|
@@ -295,7 +295,13 @@ export function provideExplorerCommands(commands: ExplorerCommands): void {
|
|
|
295
295
|
provide(COMMANDS_KEY, commands)
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
/** The library and commands the explorer's panels read. */
|
|
299
|
+
export interface ExplorerContext {
|
|
300
|
+
library: MediaLibrary
|
|
301
|
+
commands: ExplorerCommands
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function useExplorerContext(): ExplorerContext {
|
|
299
305
|
const commands = inject(COMMANDS_KEY)
|
|
300
306
|
if (!commands) throw new Error('useExplorerContext() needs a media explorer above it')
|
|
301
307
|
return { library: useMediaLibrary(), commands }
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { DrawerInstance, DrawerRowHeader } from '#dms-ui/app/composables/containers/types'
|
|
2
|
+
import ExplorerDetailsDrawer from '../../components/explorer/ExplorerDetailsDrawer.vue'
|
|
3
|
+
import type { ExplorerContext } from './useExplorerCommands'
|
|
4
|
+
import type { ExplorerLayout } from './useExplorerLayout'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Below the width that keeps the details beside the files, shows them in the
|
|
8
|
+
* DMS drawer while `layout.isDetailsDrawerOpen` is on. The drawer reads the
|
|
9
|
+
* explorer's own library, so it follows the selection; closing it turns the
|
|
10
|
+
* state off, and a wider explorer puts it away until it narrows again.
|
|
11
|
+
*
|
|
12
|
+
* On a single file, the DMS's row header names it with its place among the
|
|
13
|
+
* files shown: previous / next (and J / K) select the neighbouring file, as
|
|
14
|
+
* the arrows do in the explorer.
|
|
15
|
+
*/
|
|
16
|
+
export function useExplorerDetailsDrawer(layout: ExplorerLayout, context: ExplorerContext): void {
|
|
17
|
+
const { open } = useDrawer()
|
|
18
|
+
const { t } = useI18n()
|
|
19
|
+
const { listing, selection } = context.library
|
|
20
|
+
let drawer: DrawerInstance | null = null
|
|
21
|
+
|
|
22
|
+
function selectAt(index: number): void {
|
|
23
|
+
const target = listing.assets.value[index]
|
|
24
|
+
if (target) selection.select(target.id, { extend: false, toggle: false })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The focused file's header; the drawer's own title on a folder, several files or none. */
|
|
28
|
+
const rowHeader = computed<DrawerRowHeader>(() => {
|
|
29
|
+
const asset = selection.focusedAsset.value
|
|
30
|
+
const assets = listing.assets.value
|
|
31
|
+
const index = asset ? assets.findIndex((entry) => entry.id === asset.id) : -1
|
|
32
|
+
if (!asset || index < 0) return {}
|
|
33
|
+
return {
|
|
34
|
+
title: asset.name,
|
|
35
|
+
navigation: {
|
|
36
|
+
index,
|
|
37
|
+
total: assets.length,
|
|
38
|
+
hasPrev: index > 0,
|
|
39
|
+
hasNext: index < assets.length - 1,
|
|
40
|
+
prev: () => selectAt(index - 1),
|
|
41
|
+
next: () => selectAt(index + 1),
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
function show(): void {
|
|
47
|
+
if (drawer) return
|
|
48
|
+
const instance = open({
|
|
49
|
+
direction: 'right',
|
|
50
|
+
title: t('dms_media.explorer.details'),
|
|
51
|
+
// Its body injects the explorer's library and commands: call this in
|
|
52
|
+
// the setup of the component that provides them.
|
|
53
|
+
component: ExplorerDetailsDrawer,
|
|
54
|
+
rowHeader: rowHeader.value,
|
|
55
|
+
})
|
|
56
|
+
drawer = instance
|
|
57
|
+
void instance.result.finally(() => {
|
|
58
|
+
if (drawer !== instance) return
|
|
59
|
+
drawer = null
|
|
60
|
+
layout.isDetailsDrawerOpen.value = false
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function hide(): void {
|
|
65
|
+
const instance = drawer
|
|
66
|
+
drawer = null
|
|
67
|
+
instance?.close()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const isShown = computed(() => layout.isDetailsDrawerOpen.value && !layout.hasInlineDetails.value)
|
|
71
|
+
watch(isShown, (shown) => (shown ? show() : hide()))
|
|
72
|
+
watch(rowHeader, (header) => drawer?.patch({ rowHeader: header }))
|
|
73
|
+
// The explorer goes (a page left, a picker closed): its drawer with it.
|
|
74
|
+
onScopeDispose(hide)
|
|
75
|
+
}
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
"description": "Files, storage, public files and missing alt text",
|
|
109
109
|
"name": "Library figures"
|
|
110
110
|
},
|
|
111
|
+
"page_toolbar": {
|
|
112
|
+
"description": "When the page last read the library, live mode and pause",
|
|
113
|
+
"name": "Toolbar"
|
|
114
|
+
},
|
|
111
115
|
"preset_cache": {
|
|
112
116
|
"description": "Clean-up schedule and link lifetimes",
|
|
113
117
|
"name": "Cache"
|
|
@@ -661,14 +665,14 @@
|
|
|
661
665
|
"description": "What's new, what needs attention and how much space the library uses.",
|
|
662
666
|
"kpis": {
|
|
663
667
|
"files": "Files",
|
|
664
|
-
"files_detail": "Nothing
|
|
668
|
+
"files_detail": "Nothing new in 30 days | +1 in the last 30 days | +{files} in the last 30 days",
|
|
665
669
|
"label": "Library at a glance",
|
|
666
670
|
"missing_alt": "Missing alt text",
|
|
667
671
|
"public": "Public files",
|
|
668
672
|
"storage": "Storage",
|
|
669
673
|
"storage_detail": "no files yet | used by 1 file | used by {files} files",
|
|
670
674
|
"storage_quota_detail": "{percent}% of the {quota} plan",
|
|
671
|
-
"public_share": "{percent}% of the library
|
|
675
|
+
"public_share": "{percent}% of the library",
|
|
672
676
|
"missing_alt_none": "Every image is described",
|
|
673
677
|
"missing_alt_public": "None of them is public | 1 of them is public | {files} of them are public"
|
|
674
678
|
},
|
|
@@ -1050,6 +1054,9 @@
|
|
|
1050
1054
|
"missing_alt": "Some images have no alt text",
|
|
1051
1055
|
"healthy": "Everything is in order"
|
|
1052
1056
|
},
|
|
1057
|
+
"live": {
|
|
1058
|
+
"missed": "{count} change | {count} changes"
|
|
1059
|
+
},
|
|
1053
1060
|
"activity_page": {
|
|
1054
1061
|
"title": "Activity",
|
|
1055
1062
|
"description": "Everything that happened in the library lately: uploads, edits, moves and deletions.",
|
|
@@ -108,6 +108,10 @@
|
|
|
108
108
|
"description": "Fichiers, stockage, fichiers publics et textes alternatifs manquants",
|
|
109
109
|
"name": "Chiffres de la bibliothèque"
|
|
110
110
|
},
|
|
111
|
+
"page_toolbar": {
|
|
112
|
+
"description": "Dernière lecture de la bibliothèque, mode direct et pause",
|
|
113
|
+
"name": "Barre d'outils"
|
|
114
|
+
},
|
|
111
115
|
"preset_cache": {
|
|
112
116
|
"description": "Nettoyage planifié et durée des liens",
|
|
113
117
|
"name": "Cache"
|
|
@@ -661,14 +665,14 @@
|
|
|
661
665
|
"description": "Les nouveautés, ce qui demande votre attention et la place utilisée par la bibliothèque.",
|
|
662
666
|
"kpis": {
|
|
663
667
|
"files": "Fichiers",
|
|
664
|
-
"files_detail": "
|
|
668
|
+
"files_detail": "Rien de neuf en 30 jours | +1 en 30 jours | +{files} en 30 jours",
|
|
665
669
|
"label": "La bibliothèque en un coup d'œil",
|
|
666
670
|
"missing_alt": "Texte alternatif manquant",
|
|
667
671
|
"public": "Fichiers publics",
|
|
668
672
|
"storage": "Stockage",
|
|
669
673
|
"storage_detail": "aucun fichier pour l'instant | utilisé par 1 fichier | utilisé par {files} fichiers",
|
|
670
674
|
"storage_quota_detail": "{percent} % de l'offre de {quota}",
|
|
671
|
-
"public_share": "{percent} % de la bibliothèque
|
|
675
|
+
"public_share": "{percent} % de la bibliothèque",
|
|
672
676
|
"missing_alt_none": "Toutes les images sont décrites",
|
|
673
677
|
"missing_alt_public": "Aucune n'est publique | 1 est publique | {files} sont publiques"
|
|
674
678
|
},
|
|
@@ -1050,6 +1054,9 @@
|
|
|
1050
1054
|
"missing_alt": "Des images n'ont pas de texte alternatif",
|
|
1051
1055
|
"healthy": "Tout est en ordre"
|
|
1052
1056
|
},
|
|
1057
|
+
"live": {
|
|
1058
|
+
"missed": "{count} modification | {count} modifications"
|
|
1059
|
+
},
|
|
1053
1060
|
"activity_page": {
|
|
1054
1061
|
"title": "Activité",
|
|
1055
1062
|
"description": "Tout ce qui s'est passé récemment dans la bibliothèque : imports, retouches, déplacements et suppressions.",
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { computed, effectScope, nextTick, ref } from 'vue'
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import './fixtures/serverRender'
|
|
4
|
+
import type { ExplorerContext } from '../app/composables/library/useExplorerCommands'
|
|
5
|
+
import { useExplorerDetailsDrawer } from '../app/composables/library/useExplorerDetailsDrawer'
|
|
6
|
+
import type { ExplorerLayout } from '../app/composables/library/useExplorerLayout'
|
|
7
|
+
import type { DrawerRowHeader } from '#dms-ui/app/composables/containers/types'
|
|
8
|
+
|
|
9
|
+
// Narrower than the inline details panel, the explorer shows its details in
|
|
10
|
+
// the DMS drawer: it opens and closes with the layout's state, closing it
|
|
11
|
+
// turns the state off, and it follows the explorer's width and lifetime.
|
|
12
|
+
|
|
13
|
+
interface OpenedDrawer {
|
|
14
|
+
options: { direction: string; componentOptions?: unknown; rowHeader: DrawerRowHeader }
|
|
15
|
+
close: ReturnType<typeof vi.fn>
|
|
16
|
+
patch: ReturnType<typeof vi.fn>
|
|
17
|
+
settle: () => Promise<void>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface TestFile {
|
|
21
|
+
id: string
|
|
22
|
+
name: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let opened: OpenedDrawer[] = []
|
|
26
|
+
|
|
27
|
+
function openDrawer(options: OpenedDrawer['options']) {
|
|
28
|
+
let resolve!: () => void
|
|
29
|
+
const result = new Promise<void>((done) => (resolve = done))
|
|
30
|
+
const drawer: OpenedDrawer = {
|
|
31
|
+
options,
|
|
32
|
+
close: vi.fn(() => resolve()),
|
|
33
|
+
patch: vi.fn(),
|
|
34
|
+
settle: async () => {
|
|
35
|
+
resolve()
|
|
36
|
+
await result
|
|
37
|
+
await nextTick()
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
opened.push(drawer)
|
|
41
|
+
return { result, close: drawer.close, patch: drawer.patch }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const FILES: TestFile[] = [
|
|
45
|
+
{ id: 'a', name: 'a.png' },
|
|
46
|
+
{ id: 'b', name: 'b.pdf' },
|
|
47
|
+
{ id: 'c', name: 'c.jpg' },
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
function setup(isWide = false) {
|
|
51
|
+
const layout = { isDetailsDrawerOpen: ref(false), hasInlineDetails: ref(isWide) } as unknown as ExplorerLayout
|
|
52
|
+
const assets = ref(FILES)
|
|
53
|
+
const selectedIds = ref<string[]>([])
|
|
54
|
+
const select = vi.fn((id: string) => (selectedIds.value = [id]))
|
|
55
|
+
const focusedAsset = computed(() =>
|
|
56
|
+
selectedIds.value.length === 1 ? assets.value.find((file) => file.id === selectedIds.value[0]) : undefined,
|
|
57
|
+
)
|
|
58
|
+
const library = { listing: { assets }, selection: { focusedAsset, select } }
|
|
59
|
+
const context = { library, commands: {} } as unknown as ExplorerContext
|
|
60
|
+
const scope = effectScope()
|
|
61
|
+
scope.run(() => useExplorerDetailsDrawer(layout, context))
|
|
62
|
+
return { layout, scope, selectedIds, select }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function toggle(layout: ExplorerLayout, isOpen: boolean): Promise<void> {
|
|
66
|
+
layout.isDetailsDrawerOpen.value = isOpen
|
|
67
|
+
await nextTick()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
opened = []
|
|
72
|
+
vi.stubGlobal('useDrawer', () => ({ open: openDrawer }))
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe('details drawer', () => {
|
|
76
|
+
it('opens on the right, and closes with the state', async () => {
|
|
77
|
+
const { layout } = setup()
|
|
78
|
+
await toggle(layout, true)
|
|
79
|
+
expect(opened).toHaveLength(1)
|
|
80
|
+
expect(opened[0]!.options.direction).toBe('right')
|
|
81
|
+
// Nothing handed as props: the body injects what the explorer provides.
|
|
82
|
+
expect(opened[0]!.options.componentOptions).toBeUndefined()
|
|
83
|
+
await toggle(layout, false)
|
|
84
|
+
expect(opened[0]!.close).toHaveBeenCalledOnce()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('turns the state off when the drawer is dismissed', async () => {
|
|
88
|
+
const { layout } = setup()
|
|
89
|
+
await toggle(layout, true)
|
|
90
|
+
await opened[0]!.settle()
|
|
91
|
+
expect(layout.isDetailsDrawerOpen.value).toBe(false)
|
|
92
|
+
await toggle(layout, true)
|
|
93
|
+
expect(opened).toHaveLength(2)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('puts the drawer away while the details sit inline, and brings it back', async () => {
|
|
97
|
+
const { layout } = setup()
|
|
98
|
+
await toggle(layout, true)
|
|
99
|
+
layout.hasInlineDetails.value = true
|
|
100
|
+
await nextTick()
|
|
101
|
+
expect(opened[0]!.close).toHaveBeenCalledOnce()
|
|
102
|
+
await nextTick()
|
|
103
|
+
expect(layout.isDetailsDrawerOpen.value).toBe(true)
|
|
104
|
+
layout.hasInlineDetails.value = false
|
|
105
|
+
await nextTick()
|
|
106
|
+
expect(opened).toHaveLength(2)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('never opens while the details sit inline', async () => {
|
|
110
|
+
const { layout } = setup(true)
|
|
111
|
+
await toggle(layout, true)
|
|
112
|
+
expect(opened).toHaveLength(0)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('closes with the explorer', async () => {
|
|
116
|
+
const { layout, scope } = setup()
|
|
117
|
+
await toggle(layout, true)
|
|
118
|
+
scope.stop()
|
|
119
|
+
expect(opened[0]!.close).toHaveBeenCalledOnce()
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('heads a single file with its name and place among the files shown', async () => {
|
|
123
|
+
const { layout, selectedIds } = setup()
|
|
124
|
+
selectedIds.value = ['b']
|
|
125
|
+
await toggle(layout, true)
|
|
126
|
+
const header = opened[0]!.options.rowHeader
|
|
127
|
+
expect(header.title).toBe('b.pdf')
|
|
128
|
+
expect(header.navigation).toMatchObject({ index: 1, total: 3, hasPrev: true, hasNext: true })
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('keeps its own title without a single file', async () => {
|
|
132
|
+
const { layout, selectedIds } = setup()
|
|
133
|
+
selectedIds.value = ['a', 'b']
|
|
134
|
+
await toggle(layout, true)
|
|
135
|
+
expect(opened[0]!.options.rowHeader).toEqual({})
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
it('steps through the files by selecting them, and follows the selection', async () => {
|
|
139
|
+
const { layout, selectedIds, select } = setup()
|
|
140
|
+
selectedIds.value = ['a']
|
|
141
|
+
await toggle(layout, true)
|
|
142
|
+
expect(opened[0]!.options.rowHeader.navigation?.hasPrev).toBe(false)
|
|
143
|
+
opened[0]!.options.rowHeader.navigation?.next()
|
|
144
|
+
expect(select).toHaveBeenCalledWith('b', { extend: false, toggle: false })
|
|
145
|
+
await nextTick()
|
|
146
|
+
const patched = opened[0]!.patch.mock.lastCall?.[0] as { rowHeader: DrawerRowHeader }
|
|
147
|
+
expect(patched.rowHeader.title).toBe('b.pdf')
|
|
148
|
+
expect(patched.rowHeader.navigation?.index).toBe(1)
|
|
149
|
+
})
|
|
150
|
+
})
|
|
@@ -61,6 +61,7 @@ provideGlobal('useRegionalFormat', () => ({ formatNumber: (value: number) => Str
|
|
|
61
61
|
provideGlobal('useToast', () => ({ add: noop }))
|
|
62
62
|
provideGlobal('useConfirm', () => ({ confirm: async () => false }))
|
|
63
63
|
provideGlobal('useOverlay', () => ({ create: () => ({ open: async () => undefined }) }))
|
|
64
|
+
provideGlobal('useDrawer', () => ({ open: noop }))
|
|
64
65
|
provideGlobal('useApiError', noop)
|
|
65
66
|
provideGlobal('useUnsavedChanges', noop)
|
|
66
67
|
provideGlobal('usePageLiveRefresh', noop)
|
|
@@ -198,3 +199,72 @@ export function inBrowserApp<T>(setup: () => T, respond: Backend = () => ({})):
|
|
|
198
199
|
reads: () => reads.map((read) => describeRead(read.method, read.url, read.query)),
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
|
|
203
|
+
/** What `suspendedMount` gives back. */
|
|
204
|
+
export interface SuspendedMount {
|
|
205
|
+
/** Whether the Suspense waited for the component: it was not shown at once. */
|
|
206
|
+
waited: boolean
|
|
207
|
+
/** The backend requests made before the Suspense showed it, as `METHOD url?query`. */
|
|
208
|
+
readsBeforeShown: string[]
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Vue's renderer on bare objects: a browser mount and its Suspense, without a DOM.
|
|
212
|
+
const blankRenderer = vue.createRenderer<object, object>({
|
|
213
|
+
createElement: () => ({}),
|
|
214
|
+
createText: () => ({}),
|
|
215
|
+
createComment: () => ({}),
|
|
216
|
+
setText: noop,
|
|
217
|
+
setElementText: noop,
|
|
218
|
+
insert: noop,
|
|
219
|
+
remove: noop,
|
|
220
|
+
parentNode: () => null,
|
|
221
|
+
nextSibling: () => null,
|
|
222
|
+
patchProp: noop,
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Mounts `component` as a client navigation does, on the renderer's browser
|
|
227
|
+
* data layer with nothing read before, under the page's Suspense: whether the
|
|
228
|
+
* page waits for it, and what it read by the time it is shown. The test build
|
|
229
|
+
* compiles components for the server, so it renders nothing: the markup is
|
|
230
|
+
* `serverRender`'s to check.
|
|
231
|
+
*/
|
|
232
|
+
export async function suspendedMount(component: Component, options: { respond?: Backend } = {}): Promise<SuspendedMount> {
|
|
233
|
+
backend = options.respond ?? (() => ({}))
|
|
234
|
+
reads.length = 0
|
|
235
|
+
const runtime = engine.createDmsFrontendRuntime(undefined, {}, false)
|
|
236
|
+
let waited = false
|
|
237
|
+
let shown: (readsBeforeShown: string[]) => void = noop
|
|
238
|
+
const isShown = new Promise<string[]>((resolve) => {
|
|
239
|
+
shown = resolve
|
|
240
|
+
})
|
|
241
|
+
const app = blankRenderer.createApp({
|
|
242
|
+
render: () =>
|
|
243
|
+
h(
|
|
244
|
+
vue.Suspense,
|
|
245
|
+
{
|
|
246
|
+
onPending: () => {
|
|
247
|
+
waited = true
|
|
248
|
+
},
|
|
249
|
+
onResolve: () => shown(reads.map((read) => describeRead(read.method, read.url, read.query))),
|
|
250
|
+
},
|
|
251
|
+
{ default: () => h(component) },
|
|
252
|
+
),
|
|
253
|
+
})
|
|
254
|
+
engine.provideDmsFrontendRuntime(app, runtime)
|
|
255
|
+
// What the server build of a component records of itself, while it renders nowhere.
|
|
256
|
+
app.provide(vue.ssrContextKey, {})
|
|
257
|
+
for (const name of UI_COMPONENTS) app.component(name, uiStub(name))
|
|
258
|
+
Object.assign(app.config.globalProperties, autoImports)
|
|
259
|
+
app.config.warnHandler = noop
|
|
260
|
+
// The window the blocks listen on once mounted (a drop of files) and the history the library follows, for the time of the mount.
|
|
261
|
+
vi.stubGlobal('window', { addEventListener: noop, removeEventListener: noop, history: { state: null, replaceState: noop } })
|
|
262
|
+
try {
|
|
263
|
+
app.mount({})
|
|
264
|
+
const readsBeforeShown = await isShown
|
|
265
|
+
app.unmount()
|
|
266
|
+
return { waited, readsBeforeShown }
|
|
267
|
+
} finally {
|
|
268
|
+
vi.stubGlobal('window', undefined)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -7,6 +7,13 @@ type Messages = { [key: string]: string | Messages }
|
|
|
7
7
|
const LOCALES_DIR = join(__dirname, '../i18n/locales')
|
|
8
8
|
const APP_DIR = join(__dirname, '../app')
|
|
9
9
|
const KEY_PATTERN = /\bt\(\s*'(dms_media\.[a-z0-9_.-]+)'/g
|
|
10
|
+
// What one line of an overview KPI card holds at four columns (183px of 12px
|
|
11
|
+
// text at 1440px wide): a detail on two lines makes the cards taller than their
|
|
12
|
+
// skeleton, and every block below moves when they land.
|
|
13
|
+
const KPI_DETAIL_MAX_LENGTH = 32
|
|
14
|
+
const KPI_DETAILS = ['files_detail', 'storage_detail', 'storage_quota_detail', 'public_share', 'missing_alt_none', 'missing_alt_public']
|
|
15
|
+
// The widest values a detail is written with.
|
|
16
|
+
const WIDEST_PARAMS: Record<string, string> = { files: '99,999', percent: '100', quota: '100 GB' }
|
|
10
17
|
|
|
11
18
|
function load(file: string): Messages {
|
|
12
19
|
return JSON.parse(readFileSync(join(LOCALES_DIR, file), 'utf8')) as Messages
|
|
@@ -34,6 +41,16 @@ describe('media locales', () => {
|
|
|
34
41
|
expect(leaves(french).sort()).toEqual(leaves(english).sort())
|
|
35
42
|
})
|
|
36
43
|
|
|
44
|
+
it('keeps each overview KPI detail on one line of its card', () => {
|
|
45
|
+
for (const messages of [english, french]) {
|
|
46
|
+
const kpis = ((messages.dms_media as Messages).overview as Messages).kpis as Messages
|
|
47
|
+
const written = KPI_DETAILS.flatMap((key) =>
|
|
48
|
+
(kpis[key] as string).split(' | ').map((form) => form.replace(/\{(\w+)\}/g, (_, name: string) => WIDEST_PARAMS[name] ?? name)),
|
|
49
|
+
)
|
|
50
|
+
expect(written.filter((text) => text.length > KPI_DETAIL_MAX_LENGTH)).toEqual([])
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
37
54
|
it('translates every literal key the layer uses', () => {
|
|
38
55
|
const known = new Set(leaves(english))
|
|
39
56
|
const used = sources(APP_DIR).flatMap((file) =>
|