Skip to content

Commit

Permalink
Add fallback when a there is no preview for a version
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed May 25, 2023
1 parent d1d944c commit f3981d8
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions apps/files_versions/src/components/Version.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
:force-display-actions="true"
data-files-versions-version>
<template #icon>
<img lazy="true"
<img v-if="!previewError"
:src="previewURL"
alt=""
height="256"
width="256"
class="version__image"
@error="previewError = true">
<div v-else
class="version__image">
<ImageOffOutline :size="20" />
</div>
</template>
<template #subtitle>
<div class="version__info">
Expand Down Expand Up @@ -112,6 +115,7 @@ import Download from 'vue-material-design-icons/Download.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import Check from 'vue-material-design-icons/Check.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import ImageOffOutline from 'vue-material-design-icons/ImageOffOutline.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
import NcListItem from '@nextcloud/vue/dist/Components/NcListItem.js'
Expand Down Expand Up @@ -139,6 +143,7 @@ export default {
Pencil,
Check,
Delete,
ImageOffOutline,
},
directives: {
tooltip: Tooltip,
Expand Down Expand Up @@ -183,6 +188,7 @@ export default {
showVersionLabelForm: false,
formVersionLabelValue: this.version.label,
capabilities: loadState('core', 'capabilities', { files: { version_labeling: false, version_deletion: false } }),
previewError: false,
}
},
computed: {
Expand Down Expand Up @@ -283,6 +289,11 @@ export default {
height: 3rem;
border: 1px solid var(--color-border);
border-radius: var(--border-radius-large);

// Useful to display no preview icon.
display: flex;
justify-content: center;
color: var(--color-main-text);
}
}

Expand Down

0 comments on commit f3981d8

Please sign in to comment.