Skip to content

Commit 6f87609

Browse files
committed
feat: Ease opening photos picker in album content view
Signed-off-by: Louis Chemineau <[email protected]>
1 parent b18e168 commit 6f87609

File tree

1 file changed

+10
-78
lines changed

1 file changed

+10
-78
lines changed

src/views/AlbumContent.vue

+10-78
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
:path="'/' + albumName"
3838
:title="albumName"
3939
@refresh="fetchAlbumContent">
40-
<div v-if="album.location !== ''" slot="subtitle" class="album__location">
40+
<div v-if="album.location !== ''"
41+
slot="subtitle"
42+
class="album__location">
4143
<MapMarker />{{ album.location }}
4244
</div>
4345

@@ -53,13 +55,12 @@
5355
</template>
5456

5557
<template v-if="album !== undefined" slot="right">
56-
<UploadPicker v-if="album.nbItems !== 0"
57-
:accept="allowedMimes"
58-
:context="uploadContext"
59-
:destination="album.basename"
60-
:root="uploadContext.root"
61-
:multiple="true"
62-
@uploaded="onUpload" />
58+
<NcButton @click="showAddPhotosModal = true">
59+
<template #icon>
60+
<Plus :size="20" />
61+
</template>
62+
{{ t('photos', 'Add photos to this album' ) }}
63+
</NcButton>
6364

6465
<NcButton v-if="sharingEnabled"
6566
type="tertiary"
@@ -165,11 +166,10 @@
165166
</template>
166167

167168
<script>
168-
import { addNewFileMenuEntry, removeNewFileMenuEntry } from '@nextcloud/files'
169169
import { getCurrentUser } from '@nextcloud/auth'
170170
import { mapActions, mapGetters } from 'vuex'
171171
import { NcActions, NcActionButton, NcButton, NcModal, NcEmptyContent, NcActionSeparator, NcLoadingIcon, isMobile } from '@nextcloud/vue'
172-
import { UploadPicker, getUploader } from '@nextcloud/upload'
172+
import { getUploader } from '@nextcloud/upload'
173173
import debounce from 'debounce'
174174

175175
import Close from 'vue-material-design-icons/Close.vue'
@@ -180,7 +180,6 @@ import ImagePlus from 'vue-material-design-icons/ImagePlus.vue'
180180
import MapMarker from 'vue-material-design-icons/MapMarker.vue'
181181
import Pencil from 'vue-material-design-icons/Pencil.vue'
182182
import Plus from 'vue-material-design-icons/Plus.vue'
183-
import PlusSvg from '@mdi/svg/svg/plus.svg'
184183
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
185184

186185
import AbortControllerMixin from '../mixins/AbortControllerMixin.js'
@@ -197,7 +196,6 @@ import FilesPicker from '../components/FilesPicker.vue'
197196
import HeaderNavigation from '../components/HeaderNavigation.vue'
198197

199198
import { genFileInfo } from '../utils/fileUtils.js'
200-
import allowedMimes from '../services/AllowedMimes.js'
201199
import client from '../services/DavClient.js'
202200
import DavRequest from '../services/DavRequest.js'
203201
import logger from '../services/logger.js'
@@ -228,7 +226,6 @@ export default {
228226
Pencil,
229227
Plus,
230228
ShareVariant,
231-
UploadPicker,
232229
},
233230

234231
mixins: [
@@ -248,26 +245,11 @@ export default {
248245

249246
data() {
250247
return {
251-
allowedMimes,
252-
253248
showAddPhotosModal: false,
254249
showManageCollaboratorView: false,
255250
showEditAlbumForm: false,
256251

257252
loadingAddCollaborators: false,
258-
259-
uploader: getUploader(),
260-
261-
newFileMenuEntry: {
262-
id: 'album-add',
263-
displayName: t('photos', 'Add photos to this album'),
264-
templateName: '',
265-
if: (context) => context.route === this.$route.name,
266-
/** Existing icon css class */
267-
iconSvgInline: PlusSvg,
268-
/** Function to be run after creation */
269-
handler: () => { this.showAddPhotosModal = true },
270-
},
271253
}
272254
},
273255

@@ -296,20 +278,6 @@ export default {
296278
sharingEnabled() {
297279
return OC.Share !== undefined
298280
},
299-
300-
/**
301-
* The upload picker context
302-
* We're uploading to the album folder, and the backend handle
303-
* the writing to the default location as well as the album update.
304-
* The context is also used for the NewFileMenu.
305-
*/
306-
uploadContext() {
307-
return {
308-
...this.album,
309-
route: this.$route.name,
310-
root: `dav/photos/${getCurrentUser()?.uid}/albums`,
311-
}
312-
},
313281
},
314282

315283
watch: {
@@ -322,11 +290,6 @@ export default {
322290

323291
mounted() {
324292
this.fetchAlbumContent()
325-
addNewFileMenuEntry(this.newFileMenuEntry)
326-
},
327-
328-
destroyed() {
329-
removeNewFileMenuEntry(this.newFileMenuEntry)
330293
},
331294

332295
methods: {
@@ -427,15 +390,6 @@ export default {
427390
this.loadingAddCollaborators = false
428391
}
429392
},
430-
431-
/**
432-
* A new File has been uploaded, let's add it
433-
*
434-
* @param {Upload[]} uploads
435-
*/
436-
onUpload: debounce(function() {
437-
this.fetchAlbumContent()
438-
}, 500),
439393
},
440394
}
441395
</script>
@@ -457,26 +411,4 @@ export default {
457411
color: var(--color-text-lighter);
458412
}
459413
}
460-
461-
.photos-navigation {
462-
position: relative;
463-
// Add space at the bottom for the progress bar.
464-
&--uploading {
465-
margin-bottom: 30px;
466-
}
467-
}
468-
469-
:deep(.upload-picker) {
470-
.upload-picker__progress {
471-
position: absolute;
472-
bottom: -30px;
473-
left: 64px;
474-
margin: 0;
475-
}
476-
.upload-picker__cancel {
477-
position: absolute;
478-
bottom: -24px;
479-
right: 50px;
480-
}
481-
}
482414
</style>

0 commit comments

Comments
 (0)