Skip to content

Commit 95d4cef

Browse files
artongebackportbot[bot]
authored andcommitted
feat: Ease opening photos picker in album content view
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 1c39d42 commit 95d4cef

File tree

3 files changed

+10
-94
lines changed

3 files changed

+10
-94
lines changed

cypress/e2e/albums.cy.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
addFilesToAlbumFromAlbum,
2424
addFilesToAlbumFromAlbumFromHeader,
2525
createAnAlbumFromAlbums,
26-
deleteAnAlbumFromAlbumContent,
2726
goToAlbum,
2827
removeSelectionFromAlbum,
2928
} from './albumsUtils'
@@ -44,7 +43,7 @@ Cypress.on('uncaught:exception', (err) => {
4443
}
4544
})
4645

47-
describe('Manage albums', { testIsolation: true }, () => {
46+
describe('Manage albums', () => {
4847
let user = null
4948

5049
beforeEach(function() {

cypress/e2e/albumsUtils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export function addFilesToAlbumFromAlbum(albumName: string, itemsIndex: number[]
6868
}
6969

7070
export function addFilesToAlbumFromAlbumFromHeader(albumName: string, itemsIndex: number[]) {
71-
cy.contains('New').click()
7271
cy.contains('Add photos to this album').click()
7372
cy.get('.photos-picker__file-list').within(() => {
7473
selectMedia(itemsIndex)

src/views/AlbumContent.vue

+9-91
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
<HeaderNavigation key="navigation"
3131
slot="header"
3232
slot-scope="{selectedFileIds, resetSelection}"
33-
:class="{'photos-navigation--uploading': uploader.queue?.length > 0}"
3433
:loading="loadingCollectionFiles"
3534
:params="{ albumName }"
3635
:path="'/' + albumName"
3736
:title="albumName"
3837
@refresh="fetchAlbumContent">
39-
<div v-if="album !== undefined && album.location !== ''" slot="subtitle" class="album__location">
38+
<div v-if="album !== undefined && album.location !== ''"
39+
slot="subtitle"
40+
class="album__location">
4041
<MapMarker />{{ album.location }}
4142
</div>
4243

@@ -52,12 +53,12 @@
5253
</template>
5354

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

6263
<NcButton v-if="sharingEnabled"
6364
type="tertiary"
@@ -164,12 +165,8 @@
164165
<script>
165166
import { mapActions } from 'vuex'
166167

167-
import { Folder, addNewFileMenuEntry, removeNewFileMenuEntry, davParsePermissions } from '@nextcloud/files'
168-
import { getCurrentUser } from '@nextcloud/auth'
169168
import { NcActions, NcActionButton, NcButton, NcDialog, NcModal, NcEmptyContent, NcActionSeparator, NcLoadingIcon, isMobile } from '@nextcloud/vue'
170-
import { UploadPicker, getUploader } from '@nextcloud/upload'
171169
import { translate } from '@nextcloud/l10n'
172-
import debounce from 'debounce'
173170

174171
import Close from 'vue-material-design-icons/Close.vue'
175172
import Delete from 'vue-material-design-icons/Delete.vue'
@@ -179,7 +176,6 @@ import ImagePlus from 'vue-material-design-icons/ImagePlus.vue'
179176
import MapMarker from 'vue-material-design-icons/MapMarker.vue'
180177
import Pencil from 'vue-material-design-icons/Pencil.vue'
181178
import Plus from 'vue-material-design-icons/Plus.vue'
182-
import PlusSvg from '@mdi/svg/svg/plus.svg'
183179
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'
184180

185181
import FetchFilesMixin from '../mixins/FetchFilesMixin.js'
@@ -194,7 +190,6 @@ import CollectionContent from '../components/Collection/CollectionContent.vue'
194190
import PhotosPicker from '../components/PhotosPicker.vue'
195191
import HeaderNavigation from '../components/HeaderNavigation.vue'
196192

197-
import allowedMimes from '../services/AllowedMimes.js'
198193
import logger from '../services/logger.js'
199194

200195
export default {
@@ -224,7 +219,6 @@ export default {
224219
Pencil,
225220
Plus,
226221
ShareVariant,
227-
UploadPicker,
228222
},
229223

230224
mixins: [
@@ -243,26 +237,11 @@ export default {
243237

244238
data() {
245239
return {
246-
allowedMimes,
247-
248240
showAddPhotosModal: false,
249241
showManageCollaboratorView: false,
250242
showEditAlbumForm: false,
251243

252244
loadingAddCollaborators: false,
253-
254-
uploader: getUploader(),
255-
256-
/** @type {import('@nextcloud/files').Entry} */
257-
newFileMenuEntry: {
258-
id: 'album-add',
259-
displayName: t('photos', 'Add photos to this album'),
260-
enabled: (destination) => destination.basename === this.$route.params.albumName,
261-
/** Existing icon css class */
262-
iconSvgInline: PlusSvg,
263-
/** Function to be run after creation */
264-
handler: () => { this.showAddPhotosModal = true },
265-
},
266245
}
267246
},
268247

@@ -288,47 +267,17 @@ export default {
288267
return OC.Share !== undefined
289268
},
290269

291-
/**
292-
* The upload picker context
293-
* We're uploading to the album folder, and the backend handle
294-
* the writing to the default location as well as the album update.
295-
* The context is also used for the NewFileMenu.
296-
*
297-
* @return {Album&{route: string, root: string}}
298-
*/
299-
uploadContext() {
300-
return {
301-
...this.album,
302-
route: this.$route.name,
303-
root: `dav/photos/${getCurrentUser()?.uid}/albums`,
304-
}
305-
},
306-
307270
/**
308271
* @return {string} The album's filename based on its name. Useful to fetch the location information and content.
309272
*/
310273
albumFileName() {
311274
return this.$store.getters.getAlbumName(this.albumName)
312275
},
313-
314-
albumAsFolder() {
315-
return new Folder({
316-
...this.album,
317-
owner: getCurrentUser()?.uid ?? '',
318-
source: this.album?.source ?? '',
319-
permissions: davParsePermissions(this.album.permissions),
320-
})
321-
},
322276
},
323277

324278
async mounted() {
325279
this.fetchAlbum()
326280
this.fetchAlbumContent()
327-
addNewFileMenuEntry(this.newFileMenuEntry)
328-
},
329-
330-
destroyed() {
331-
removeNewFileMenuEntry(this.newFileMenuEntry)
332281
},
333282

334283
methods: {
@@ -387,15 +336,6 @@ export default {
387336
}
388337
},
389338

390-
/**
391-
* A new File has been uploaded, let's add it
392-
*
393-
* @param {Upload[]} uploads
394-
*/
395-
onUpload: debounce(function() {
396-
this.fetchAlbumContent()
397-
}, 500),
398-
399339
t: translate,
400340
},
401341
}
@@ -426,26 +366,4 @@ export default {
426366
color: var(--color-text-lighter);
427367
}
428368
}
429-
430-
.photos-navigation {
431-
position: relative;
432-
// Add space at the bottom for the progress bar.
433-
&--uploading {
434-
margin-bottom: 30px;
435-
}
436-
437-
:deep(.upload-picker) {
438-
.upload-picker__progress {
439-
position: absolute;
440-
bottom: -30px;
441-
left: 64px;
442-
margin: 0;
443-
}
444-
.upload-picker__cancel {
445-
position: absolute;
446-
bottom: -24px;
447-
right: 50px;
448-
}
449-
}
450-
}
451369
</style>

0 commit comments

Comments
 (0)