Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] feat: Ease opening photos picker in album content view #2791

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cypress/e2e/albums.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
addFilesToAlbumFromAlbum,
addFilesToAlbumFromAlbumFromHeader,
createAnAlbumFromAlbums,
deleteAnAlbumFromAlbumContent,
goToAlbum,
removeSelectionFromAlbum,
} from './albumsUtils'
Expand All @@ -45,7 +44,7 @@ Cypress.on('uncaught:exception', (err) => {
}
})

describe('Manage albums', { testIsolation: true }, () => {
describe('Manage albums', () => {
let user = null

beforeEach(function () {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/albumsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export function addFilesToAlbumFromAlbum(albumName: string, itemsIndex: number[]
}

export function addFilesToAlbumFromAlbumFromHeader(albumName: string, itemsIndex: number[]) {
cy.contains('New').click()
cy.contains('Add photos to this album').click()
cy.get('.photos-picker__file-list').within(() => {
selectMedia(itemsIndex)
Expand Down
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

100 changes: 9 additions & 91 deletions src/views/AlbumContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
<HeaderNavigation key="navigation"
slot="header"
slot-scope="{selectedFileIds, resetSelection}"
:class="{'photos-navigation--uploading': uploader.queue?.length > 0}"
:loading="loadingCollectionFiles"
:params="{ albumName }"
:path="'/' + albumName"
:title="albumName"
@refresh="fetchAlbumContent">
<div v-if="album !== undefined && album.location !== ''" slot="subtitle" class="album__location">
<div v-if="album !== undefined && album.location !== ''"
slot="subtitle"
class="album__location">
<MapMarker />{{ album.location }}
</div>

Expand All @@ -52,12 +53,12 @@
</template>

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

<NcButton v-if="sharingEnabled"
type="tertiary"
Expand Down Expand Up @@ -164,12 +165,8 @@
<script>
import { mapActions } from 'vuex'

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

import Close from 'vue-material-design-icons/Close.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
Expand All @@ -179,7 +176,6 @@ import ImagePlus from 'vue-material-design-icons/ImagePlus.vue'
import MapMarker from 'vue-material-design-icons/MapMarker.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import PlusSvg from '@mdi/svg/svg/plus.svg'
import ShareVariant from 'vue-material-design-icons/ShareVariant.vue'

import FetchFilesMixin from '../mixins/FetchFilesMixin.js'
Expand All @@ -193,7 +189,6 @@ import CollectionContent from '../components/Collection/CollectionContent.vue'
import PhotosPicker from '../components/PhotosPicker.vue'
import HeaderNavigation from '../components/HeaderNavigation.vue'

import allowedMimes from '../services/AllowedMimes.js'
import logger from '../services/logger.js'

export default {
Expand Down Expand Up @@ -223,7 +218,6 @@ export default {
Pencil,
Plus,
ShareVariant,
UploadPicker,
},

mixins: [
Expand All @@ -241,26 +235,11 @@ export default {

data() {
return {
allowedMimes,

showAddPhotosModal: false,
showManageCollaboratorView: false,
showEditAlbumForm: false,

loadingAddCollaborators: false,

uploader: getUploader(),

/** @type {import('@nextcloud/files').Entry} */
newFileMenuEntry: {
id: 'album-add',
displayName: t('photos', 'Add photos to this album'),
enabled: (destination) => destination.basename === this.$route.params.albumName,
/** Existing icon css class */
iconSvgInline: PlusSvg,
/** Function to be run after creation */
handler: () => { this.showAddPhotosModal = true },
},
}
},

Expand All @@ -286,47 +265,17 @@ export default {
return OC.Share !== undefined
},

/**
* The upload picker context
* We're uploading to the album folder, and the backend handle
* the writing to the default location as well as the album update.
* The context is also used for the NewFileMenu.
*
* @return {Album&{route: string, root: string}}
*/
uploadContext() {
return {
...this.album,
route: this.$route.name,
root: `dav/photos/${getCurrentUser()?.uid}/albums`,
}
},

/**
* @return {string} The album's filename based on its name. Useful to fetch the location information and content.
*/
albumFileName() {
return this.$store.getters.getAlbumName(this.albumName)
},

albumAsFolder() {
return new Folder({
...this.album,
owner: getCurrentUser()?.uid ?? '',
source: this.album?.source ?? '',
permissions: davParsePermissions(this.album.permissions),
})
},
},

async mounted() {
this.fetchAlbum()
this.fetchAlbumContent()
addNewFileMenuEntry(this.newFileMenuEntry)
},

destroyed() {
removeNewFileMenuEntry(this.newFileMenuEntry)
},

methods: {
Expand Down Expand Up @@ -385,15 +334,6 @@ export default {
}
},

/**
* A new File has been uploaded, let's add it
*
* @param {Upload[]} uploads
*/
onUpload: debounce(function() {
this.fetchAlbumContent()
}, 500),

t: translate,
},
}
Expand Down Expand Up @@ -424,26 +364,4 @@ export default {
color: var(--color-text-lighter);
}
}

.photos-navigation {
position: relative;
// Add space at the bottom for the progress bar.
&--uploading {
margin-bottom: 30px;
}

:deep(.upload-picker) {
.upload-picker__progress {
position: absolute;
bottom: -30px;
left: 64px;
margin: 0;
}
.upload-picker__cancel {
position: absolute;
bottom: -24px;
right: 50px;
}
}
}
</style>
Loading