|
28 | 28 | </span> |
29 | 29 | </component> |
30 | 30 | <SharingEntryQuickShareSelect |
| 31 | + v-if="!config.sharingDialogEnabled" |
31 | 32 | :share="share" |
32 | 33 | :file-info="fileInfo" |
33 | 34 | @open-sharing-details="openShareDetailsForCustomSettings(share)" /> |
34 | 35 | </div> |
35 | 36 | <ShareExpiryTime v-if="share && share.expireDate" :share="share" /> |
36 | 37 | <NcButton |
37 | | - v-if="share.canEdit" |
| 38 | + v-if="share.canEdit && !config.sharingDialogEnabled" |
38 | 39 | class="sharing-entry__action" |
39 | 40 | data-cy-files-sharing-share-actions |
40 | 41 | :aria-label="t('files_sharing', 'Open Sharing Details')" |
|
44 | 45 | <DotsHorizontalIcon :size="20" /> |
45 | 46 | </template> |
46 | 47 | </NcButton> |
| 48 | + <!-- Unified dialog: edit + delete as a simple dual button --> |
| 49 | + <template v-else-if="config.sharingDialogEnabled"> |
| 50 | + <NcButton |
| 51 | + v-if="share.canEdit" |
| 52 | + class="sharing-entry__action" |
| 53 | + :aria-label="t('files_sharing', 'Edit share')" |
| 54 | + variant="tertiary" |
| 55 | + @click="openEditDialog"> |
| 56 | + <template #icon> |
| 57 | + <PencilIcon :size="20" /> |
| 58 | + </template> |
| 59 | + </NcButton> |
| 60 | + <NcButton |
| 61 | + v-if="share.canDelete" |
| 62 | + class="sharing-entry__action" |
| 63 | + :aria-label="t('files_sharing', 'Delete share')" |
| 64 | + variant="tertiary" |
| 65 | + @click="confirmDelete"> |
| 66 | + <template #icon> |
| 67 | + <DeleteIcon :size="20" /> |
| 68 | + </template> |
| 69 | + </NcButton> |
| 70 | + </template> |
47 | 71 | </li> |
48 | 72 | </template> |
49 | 73 |
|
50 | 74 | <script> |
| 75 | +import { DialogBuilder } from '@nextcloud/dialogs' |
51 | 76 | import { ShareType } from '@nextcloud/sharing' |
52 | 77 | import NcAvatar from '@nextcloud/vue/components/NcAvatar' |
53 | 78 | import NcButton from '@nextcloud/vue/components/NcButton' |
54 | 79 | import NcSelect from '@nextcloud/vue/components/NcSelect' |
| 80 | +import DeleteIcon from 'vue-material-design-icons/Delete.vue' |
55 | 81 | import DotsHorizontalIcon from 'vue-material-design-icons/DotsHorizontal.vue' |
| 82 | +import PencilIcon from 'vue-material-design-icons/Pencil.vue' |
56 | 83 | import ShareExpiryTime from './ShareExpiryTime.vue' |
57 | 84 | import SharingEntryQuickShareSelect from './SharingEntryQuickShareSelect.vue' |
58 | 85 | import ShareDetails from '../mixins/ShareDetails.js' |
59 | 86 | import SharesMixin from '../mixins/SharesMixin.js' |
| 87 | +import logger from '../services/logger.ts' |
| 88 | +import { openShareEditDialog } from '../services/SharingDialog.ts' |
60 | 89 |
|
61 | 90 | export default { |
62 | 91 | name: 'SharingEntry', |
63 | 92 |
|
64 | 93 | components: { |
65 | 94 | NcButton, |
66 | 95 | NcAvatar, |
| 96 | + DeleteIcon, |
67 | 97 | DotsHorizontalIcon, |
| 98 | + PencilIcon, |
68 | 99 | NcSelect, |
69 | 100 | ShareExpiryTime, |
70 | 101 | SharingEntryQuickShareSelect, |
@@ -128,6 +159,54 @@ export default { |
128 | 159 | return (typeof this.share.status === 'object' && !Array.isArray(this.share.status)) |
129 | 160 | }, |
130 | 161 | }, |
| 162 | +
|
| 163 | + methods: { |
| 164 | + /** |
| 165 | + * Open the unified sharing dialog to edit this share. |
| 166 | + */ |
| 167 | + async openEditDialog() { |
| 168 | + try { |
| 169 | + await openShareEditDialog(this.share.id, this.fileInfo.node) |
| 170 | + } catch (error) { |
| 171 | + logger.error('Failed to open the sharing dialog', { error }) |
| 172 | + } |
| 173 | + }, |
| 174 | +
|
| 175 | + /** |
| 176 | + * Ask for confirmation before deleting the share. |
| 177 | + */ |
| 178 | + async confirmDelete() { |
| 179 | + let confirmed = false |
| 180 | + const dialog = (new DialogBuilder()) |
| 181 | + .setName(t('files_sharing', 'Delete share')) |
| 182 | + .setText(t('files_sharing', 'Are you sure you want to delete this share? This operation cannot be undone.')) |
| 183 | + .setButtons([ |
| 184 | + { |
| 185 | + label: t('files_sharing', 'Cancel'), |
| 186 | + variant: 'secondary', |
| 187 | + callback: () => {}, |
| 188 | + }, |
| 189 | + { |
| 190 | + label: t('files_sharing', 'Delete'), |
| 191 | + variant: 'error', |
| 192 | + callback: () => { |
| 193 | + confirmed = true |
| 194 | + }, |
| 195 | + }, |
| 196 | + ]) |
| 197 | + .build() |
| 198 | +
|
| 199 | + try { |
| 200 | + await dialog.show() |
| 201 | + } catch (error) { |
| 202 | + logger.debug('Delete confirmation dialog closed', { error }) |
| 203 | + } |
| 204 | +
|
| 205 | + if (confirmed) { |
| 206 | + this.onDelete() |
| 207 | + } |
| 208 | + }, |
| 209 | + }, |
131 | 210 | } |
132 | 211 | </script> |
133 | 212 |
|
|
0 commit comments