Skip to content

Commit

Permalink
ELEMENTS-1738: Update our elements to show a view instead of a download
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed May 6, 2024
1 parent 31537cf commit 92e36a2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
19 changes: 16 additions & 3 deletions ui/nuxeo-document-thumbnail/nuxeo-document-thumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,20 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior';
}

_thumbnail(doc) {
return doc &&
if (
doc &&
doc.uid &&
doc.contextParameters &&
doc.contextParameters.thumbnail &&
doc.contextParameters.thumbnail.url
? doc.contextParameters.thumbnail.url
: '';
) {
if (!this.isFollowRedirectEnabled()) {
const splitter = doc.contextParameters.thumbnail.url.indexOf('?') > -1 ? '&' : '?';
doc.contextParameters.thumbnail.url = `${doc.contextParameters.thumbnail.url}${splitter}clientReason=view`;
}
return doc.contextParameters.thumbnail.url;
}
return '';
}

_error() {
Expand All @@ -93,6 +100,12 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior';
_title(doc) {
return doc && doc.title ? this.i18n('accessibility.thumbnail', doc.title) : '';
}

isFollowRedirectEnabled() {
const followRedirect =
Nuxeo && Nuxeo.UI && Nuxeo.UI.config && Nuxeo.UI.config.url && Nuxeo.UI.config.url.followRedirect;
return followRedirect ? String(followRedirect).toLowerCase() === 'true' : false;
}
}
customElements.define(DocumentThumbnail.is, DocumentThumbnail);
Nuxeo.DocumentThumbnail = DocumentThumbnail;
Expand Down
23 changes: 20 additions & 3 deletions ui/nuxeo-justified-grid/nuxeo-justified-grid-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,26 @@ import '@polymer/iron-image/iron-image.js';
}

_url(doc) {
return doc && doc.contextParameters && doc.contextParameters.thumbnail && doc.contextParameters.thumbnail.url
? doc.contextParameters.thumbnail.url
: '';
if (
doc &&
doc.uid &&
doc.contextParameters &&
doc.contextParameters.thumbnail &&
doc.contextParameters.thumbnail.url
) {
if (!this.isFollowRedirectEnabled()) {
const splitter = doc.contextParameters.thumbnail.url.indexOf('?') > -1 ? '&' : '?';
doc.contextParameters.thumbnail.url = `${doc.contextParameters.thumbnail.url}${splitter}clientReason=view`;
}
return doc.contextParameters.thumbnail.url;
}
return '';
}

isFollowRedirectEnabled() {
const followRedirect =
Nuxeo && Nuxeo.UI && Nuxeo.UI.config && Nuxeo.UI.config.url && Nuxeo.UI.config.url.followRedirect;
return followRedirect ? String(followRedirect).toLowerCase() === 'true' : false;
}
}

Expand Down

0 comments on commit 92e36a2

Please sign in to comment.