Skip to content

Commit

Permalink
Merge pull request #38510 from nextcloud/artonge/backport/stable27/38467
Browse files Browse the repository at this point in the history
[stable27] Add fallback when a there is no preview for a version
  • Loading branch information
artonge authored Jun 14, 2023
2 parents 6698367 + 7337188 commit dfc2888
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
27 changes: 20 additions & 7 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, NcActionLink, NcListItem, NcModal, NcButton, NcTextField, Tooltip } from '@nextcloud/vue'
import moment from '@nextcloud/moment'
import { translate } from '@nextcloud/l10n'
Expand All @@ -133,6 +137,7 @@ export default {
Pencil,
Check,
Delete,
ImageOffOutline,
},
directives: {
tooltip: Tooltip,
Expand Down Expand Up @@ -177,26 +182,29 @@ export default {
showVersionLabelForm: false,
formVersionLabelValue: this.version.label,
capabilities: loadState('core', 'capabilities', { files: { version_labeling: false, version_deletion: false } }),
previewError: false,
}
},
computed: {
/**
* @return {string}
*/
versionLabel() {
const label = this.version.label ?? ''
if (this.isCurrent) {
if (this.version.label === undefined || this.version.label === '') {
if (label === '') {
return translate('files_versions', 'Current version')
} else {
return `${this.version.label} (${translate('files_versions', 'Current version')})`
return `${label} (${translate('files_versions', 'Current version')})`
}
}
if (this.isFirstVersion && this.version.label === '') {
if (this.isFirstVersion && label === '') {
return translate('files_versions', 'Initial version')
}
return this.version.label
return label
},
/**
Expand Down Expand Up @@ -275,6 +283,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-text-light);
}
}
Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit dfc2888

Please sign in to comment.