Skip to content
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
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.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

47 changes: 43 additions & 4 deletions src/components/Albums/AlbumForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
:value.sync="albumName"
type="text"
name="name"
:helper-text="albumNameValidationError"
:error="albumNameValidationError !== undefined"
:required="true"
:label="t('photos', 'Name of the album')" />
<NcTextField :value.sync="albumLocation"
Expand All @@ -48,15 +50,15 @@
<span class="right-buttons">
<NcButton v-if="sharingEnabled && !editMode"
type="secondary"
:disabled="albumName.trim() === '' || loading"
:disabled="!canSubmit"
@click="showCollaboratorView = true">
<template #icon>
<AccountMultiplePlus :size="20" />
</template>
{{ t('photos', 'Add collaborators') }}
</NcButton>
<NcButton type="primary"
:disabled="albumName === '' || loading"
:disabled="!canSubmit"
@click="submit()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
Expand Down Expand Up @@ -99,6 +101,7 @@
import Send from 'vue-material-design-icons/Send.vue'

import { NcButton, NcLoadingIcon, NcTextField } from '@nextcloud/vue'
import { InvalidFilenameError, InvalidFilenameErrorReason, validateFilename } from '@nextcloud/files'
import moment from '@nextcloud/moment'
import { translate } from '@nextcloud/l10n'

Expand Down Expand Up @@ -159,6 +162,41 @@
albumFileName() {
return this.$store.getters.getAlbumName(this.albumName)
},

albumNameValidationError() {
// If loading is true, it means that the album is being created
// so this condition will eventually become true
// but we don't want to show the error message while loading
const existingAlbum = this.$store.getters.albums[this.albumFileName]
if (existingAlbum !== undefined && this.album !== existingAlbum && !this.loading) {
return t('files', 'This name is already in use.')
}

try {
validateFilename(this.albumName)
} catch (error) {
if (!(error instanceof InvalidFilenameError)) {
throw error
}

switch (error.reason) {
case InvalidFilenameErrorReason.Character:
return t('files', '"{char}" is not allowed inside a filename.', { char: error.segment })
case InvalidFilenameErrorReason.ReservedName:
return undefined // We don't need to enforce that for albums.
case InvalidFilenameErrorReason.Extension:
return undefined // We don't need to enforce that for albums.
default:
return t('files', 'Invalid filename.')
}
}

return undefined
},

canSubmit() {
return this.albumName !== '' && this.albumNameValidationError === undefined && !this.loading
},
},

mounted() {
Expand All @@ -175,9 +213,9 @@
methods: {
...mapActions(['createCollection', 'renameCollection', 'updateCollection']),

/** @param {import('../../store/albums.js').Collaborator[]} collaborators */

Check warning on line 216 in src/components/Albums/AlbumForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "collaborators" description
submit(collaborators = []) {
if (this.albumName === '' || this.loading) {
if (!this.canSubmit) {
return
}

Expand All @@ -188,7 +226,7 @@
}
},

/** @param {import('../../store/albums.js').Collaborator[]} collaborators */

Check warning on line 229 in src/components/Albums/AlbumForm.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "collaborators" description
async handleCreateAlbum(collaborators = []) {
try {
this.loading = true
Expand Down Expand Up @@ -276,7 +314,8 @@
justify-content: space-between;
flex-direction: column;

.left-buttons, .right-buttons {
.left-buttons,
.right-buttons {
display: flex;
gap: calc(var(--default-grid-baseline) * 4);
}
Expand Down
38 changes: 10 additions & 28 deletions src/components/Collection/CollectionCover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,19 @@
</router-link>
</li>
</template>
<script>
<script setup>
import { computed, ref } from 'vue'
import ImageMultiple from 'vue-material-design-icons/ImageMultiple.vue'

export default {
name: 'CollectionCover',
const props = defineProps({
coverUrl: String,

Check warning on line 50 in src/components/Collection/CollectionCover.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'coverUrl' requires default value to be set
altImg: String,

Check warning on line 51 in src/components/Collection/CollectionCover.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'altImg' requires default value to be set
parentRoute: String,

Check warning on line 52 in src/components/Collection/CollectionCover.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'parentRoute' requires default value to be set
collectionName: String

Check warning on line 53 in src/components/Collection/CollectionCover.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma

Check warning on line 53 in src/components/Collection/CollectionCover.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Prop 'collectionName' requires default value to be set
})

components: {
ImageMultiple,
},

props: {
coverUrl: {
type: String,
required: true,
},
altImg: {
type: String,
required: true,
},
link: {
type: String,
required: true,
},
},

data() {
return {
coverLoadingError: false,
}
},
}
const coverLoadingError = ref(false)
const link = computed(() => `${props.parentRoute}/${encodeURIComponent(props.collectionName)}`)
</script>
<style lang="scss" scoped>
.collection-cover {
Expand Down
3 changes: 2 additions & 1 deletion src/views/Albums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@

<CollectionCover :key="collection.basename"
slot-scope="{collection}"
:link="`/albums/${collection.basename}`"
parent-route="/albums"
:collection-name="collection.basename"
:alt-img="t('photos', 'Cover photo for album {albumName}', { albumName: collection.basename })"
:cover-url="collection.lastPhoto | coverUrl">
<span class="album__name">
Expand Down
3 changes: 2 additions & 1 deletion src/views/Places.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

<CollectionCover :key="collection.basename"
slot-scope="{collection}"
:link="`/places/${collection.basename}`"
parent-route="/places"
:collection-name="collection.basename"
:alt-img="t('photos', 'Cover photo for place {placeName}', { placeName: collection.basename })"
:cover-url="collection.lastPhoto | coverUrl">
<span class="place__name">
Expand Down
3 changes: 2 additions & 1 deletion src/views/SharedAlbums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

<CollectionCover :key="collection.basename"
slot-scope="{collection}"
:link="`/sharedalbums/${collection.basename}`"
parent-route="/sharedalbums"
:collection-name="collection.basename"
:alt-img="t('photos', 'Cover photo for shared album {albumName}', { albumName: collection.basename })"
:data-test="collection.basename"
:cover-url="collection.lastPhoto | coverUrl">
Expand Down
Loading