|
5 | 5 | <template> |
6 | 6 | <NcEmptyContent class="file-drop-empty-content" |
7 | 7 | data-cy-files-sharing-file-drop |
8 | | - :name="t('files_sharing', 'File drop')"> |
| 8 | + :name="name"> |
9 | 9 | <template #icon> |
10 | 10 | <NcIconSvgWrapper :svg="svgCloudUpload" /> |
11 | 11 | </template> |
12 | 12 | <template #description> |
13 | | - {{ t('files_sharing', 'Upload files to {foldername}.', { foldername }) }} |
14 | | - {{ disclaimer === '' ? '' : t('files_sharing', 'By uploading files, you agree to the terms of service.') }} |
| 13 | + <p> |
| 14 | + {{ shareNote || t('files_sharing', 'Upload files to {foldername}.', { foldername }) }} |
| 15 | + </p> |
| 16 | + <p v-if="disclaimer"> |
| 17 | + {{ t('files_sharing', 'By uploading files, you agree to the terms of service.') }} |
| 18 | + </p> |
| 19 | + <NcNoteCard v-if="getSortedUploads().length" |
| 20 | + class="file-drop-empty-content__note-card" |
| 21 | + type="success"> |
| 22 | + <h2 id="file-drop-empty-content__heading"> |
| 23 | + {{ t('files_sharing', 'Successfully uploaded files') }} |
| 24 | + </h2> |
| 25 | + <ul aria-labelledby="file-drop-empty-content__heading" class="file-drop-empty-content__list"> |
| 26 | + <li v-for="file in getSortedUploads()" :key="file"> |
| 27 | + {{ file }} |
| 28 | + </li> |
| 29 | + </ul> |
| 30 | + </NcNoteCard> |
15 | 31 | </template> |
16 | 32 | <template #action> |
17 | 33 | <template v-if="disclaimer"> |
|
33 | 49 | </NcEmptyContent> |
34 | 50 | </template> |
35 | 51 |
|
| 52 | +<script lang="ts"> |
| 53 | +/* eslint-disable import/first */ |
| 54 | +
|
| 55 | +// We need this on module level rather than on the instance as view will be refreshed by the files app after uploading |
| 56 | +const uploads = new Set<string>() |
| 57 | +</script> |
| 58 | + |
36 | 59 | <script setup lang="ts"> |
37 | 60 | import { loadState } from '@nextcloud/initial-state' |
38 | 61 | import { translate as t } from '@nextcloud/l10n' |
39 | | -import { getUploader, UploadPicker } from '@nextcloud/upload' |
| 62 | +import { getUploader, UploadPicker, UploadStatus } from '@nextcloud/upload' |
40 | 63 | import { ref } from 'vue' |
41 | 64 |
|
42 | | -import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' |
43 | | -import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' |
44 | | -import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' |
45 | | -import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js' |
| 65 | +import NcButton from '@nextcloud/vue/components/NcButton' |
| 66 | +import NcDialog from '@nextcloud/vue/components/NcDialog' |
| 67 | +import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' |
| 68 | +import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' |
| 69 | +import NcNoteCard from '@nextcloud/vue/components/NcNoteCard' |
46 | 70 | import svgCloudUpload from '@mdi/svg/svg/cloud-upload.svg?raw' |
47 | 71 |
|
48 | 72 | defineProps<{ |
49 | 73 | foldername: string |
50 | 74 | }>() |
51 | 75 |
|
52 | 76 | const disclaimer = loadState<string>('files_sharing', 'disclaimer', '') |
| 77 | +const shareLabel = loadState<string>('files_sharing', 'label', '') |
| 78 | +const shareNote = loadState<string>('files_sharing', 'note', '') |
| 79 | +
|
| 80 | +const name = shareLabel || t('files_sharing', 'File drop') |
| 81 | +
|
53 | 82 | const showDialog = ref(false) |
54 | 83 | const uploadDestination = getUploader().destination |
55 | | -</script> |
56 | 84 |
|
57 | | -<style scoped> |
58 | | -:deep(.terms-of-service-dialog) { |
59 | | - min-height: min(100px, 20vh); |
| 85 | +getUploader() |
| 86 | + .addNotifier((upload) => { |
| 87 | + if (upload.status === UploadStatus.FINISHED && upload.file.name) { |
| 88 | + uploads.add(upload.file.name) |
| 89 | + console.warn('DONE') |
| 90 | + } else { |
| 91 | + console.warn(upload) |
| 92 | + } |
| 93 | + }) |
| 94 | +
|
| 95 | +/** |
| 96 | + * Get the previous uploads as sorted list |
| 97 | + */ |
| 98 | +function getSortedUploads() { |
| 99 | + return [...uploads].sort((a, b) => a.localeCompare(b)) |
60 | 100 | } |
61 | | -/* TODO fix in library */ |
62 | | -.file-drop-empty-content :deep(.empty-content__action) { |
63 | | - display: flex; |
64 | | - gap: var(--default-grid-baseline); |
| 101 | +</script> |
| 102 | + |
| 103 | +<style scoped lang="scss"> |
| 104 | +.file-drop-empty-content { |
| 105 | + margin: auto; |
| 106 | + max-width: max(50vw, 300px); |
| 107 | +
|
| 108 | + .file-drop-empty-content__note-card { |
| 109 | + width: fit-content; |
| 110 | + margin-inline: auto; |
| 111 | + } |
| 112 | +
|
| 113 | + #file-drop-empty-content__heading { |
| 114 | + margin-block: 0 10px; |
| 115 | + font-weight: bold; |
| 116 | + font-size: 20px; |
| 117 | + } |
| 118 | +
|
| 119 | + .file-drop-empty-content__list { |
| 120 | + list-style: inside; |
| 121 | + max-height: min(350px, 33vh); |
| 122 | + overflow-y: scroll; |
| 123 | + padding-inline-end: calc(2 * var(--default-grid-baseline)); |
| 124 | + } |
| 125 | +
|
| 126 | + :deep(.terms-of-service-dialog) { |
| 127 | + min-height: min(100px, 20vh); |
| 128 | + } |
| 129 | +
|
| 130 | + /* TODO fix in library */ |
| 131 | + :deep(.empty-content__action) { |
| 132 | + display: flex; |
| 133 | + gap: var(--default-grid-baseline); |
| 134 | + } |
65 | 135 | } |
66 | 136 | </style> |
0 commit comments