From ed3f790fde28f3dc7a38c5bee94ed257f5c6012d Mon Sep 17 00:00:00 2001
From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com>
Date: Mon, 4 Dec 2023 11:05:50 -0500
Subject: [PATCH 01/13] Wait until after headTags are set to render plaudit
(#2074)
---
app/preprints/detail/controller.ts | 1 +
app/preprints/detail/route.ts | 2 ++
app/preprints/detail/template.hbs | 4 +++-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/preprints/detail/controller.ts b/app/preprints/detail/controller.ts
index 620245f4f34..3b9274c4515 100644
--- a/app/preprints/detail/controller.ts
+++ b/app/preprints/detail/controller.ts
@@ -46,6 +46,7 @@ export default class PrePrintsDetailController extends Controller {
@service media!: Media;
@tracked fullScreenMFR = false;
+ @tracked plauditIsReady = false;
metricsStartDate = config.OSF.metricsStartDate;
diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts
index f46b9e145b3..c2d43906eba 100644
--- a/app/preprints/detail/route.ts
+++ b/app/preprints/detail/route.ts
@@ -17,6 +17,7 @@ import Ready from 'ember-osf-web/services/ready';
import Theme from 'ember-osf-web/services/theme';
import captureException from 'ember-osf-web/utils/capture-exception';
import pathJoin from 'ember-osf-web/utils/path-join';
+import PrePrintsDetailController from './controller';
/**
* @module ember-preprints
@@ -143,6 +144,7 @@ export default class PreprintsDetail extends Route {
}
this.set('headTags', allTags);
this.metaTags.updateHeadTags();
+ (this.controller as PrePrintsDetailController).plauditIsReady = true;
}
blocker.done();
}
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index 8ae3c8dbce9..bbfb7b4e112 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -125,7 +125,9 @@
-
+ {{#if this.plauditIsReady}}
+
+ {{/if}}
Date: Wed, 6 Dec 2023 22:20:14 -0500
Subject: [PATCH 02/13] stop loading node in route model hook (#2077)
---
app/preprints/detail/route.ts | 3 ---
app/preprints/detail/template.hbs | 14 +++++++-------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts
index c2d43906eba..65d3731ea7b 100644
--- a/app/preprints/detail/route.ts
+++ b/app/preprints/detail/route.ts
@@ -67,8 +67,6 @@ export default class PreprintsDetail extends Route {
const license = await preprint?.get('license');
- const node = await preprint?.get('node');
-
const subjects = await preprint?.queryHasMany('subjects');
return {
@@ -79,7 +77,6 @@ export default class PreprintsDetail extends Route {
primaryFile,
license,
subjects,
- node,
};
} catch (error) {
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index bbfb7b4e112..6e72e26ceaa 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -69,7 +69,7 @@
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}}
{{#unless this.isMobile}}
-
|
+
|
{{/unless}}
{{#if this.isWithdrawn}}
{{t 'preprints.detail.header.withdrawn_on'}}: {{moment-format this.model.preprint.dateWithdrawn 'MMMM DD, YYYY'}}
@@ -87,7 +87,7 @@
@type='default'
>
{{if this.fullScreenMFR (t 'preprints.detail.collapse') (t 'preprints.detail.expand')}}
-
+
{{/unless}}
@@ -111,7 +111,7 @@
data-test-download-button
data-analytics-name='downloads'
local-class='btn btn-primary'
- @href={{ this.fileDownloadUrl }}
+ @href={{ this.fileDownloadUrl }}
>
{{t 'preprints.detail.share.download' documentType=this.model.provider.documentType.singular}}
@@ -153,15 +153,15 @@
- {{#if this.model.node}}
+ {{#if this.model.preprint.node}}
{{t 'preprints.detail.supplemental_materials'}}
- {{this.model.node.links.html}}
+ {{this.model.preprint.node.links.html}}
@@ -173,7 +173,7 @@
{{this.model.preprint.articleDoiUrl}}
From 8839c885fa5f0d906f1165510685298082c6fd35 Mon Sep 17 00:00:00 2001
From: Yuhuai Liu
Date: Wed, 6 Dec 2023 23:59:23 -0500
Subject: [PATCH 03/13] not show the links if supplemental node is private
(#2078)
---
app/preprints/detail/template.hbs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index 6e72e26ceaa..9bcaf145737 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -153,7 +153,7 @@
- {{#if this.model.preprint.node}}
+ {{#if this.model.preprint.node.links}}
{{t 'preprints.detail.supplemental_materials'}}
Date: Tue, 5 Dec 2023 17:11:32 -0500
Subject: [PATCH 04/13] Update Preprint label to Paper for yale law school
---
.../addon/components/search-page/component.ts | 9 ++++++++-
.../addon/components/search-page/template.hbs | 2 +-
.../components/search-result-card/component.ts | 15 ++++++++++++---
mirage/factories/institution.ts | 2 ++
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/lib/osf-components/addon/components/search-page/component.ts b/lib/osf-components/addon/components/search-page/component.ts
index 6bf191b82d4..c2a6803ae37 100644
--- a/lib/osf-components/addon/components/search-page/component.ts
+++ b/lib/osf-components/addon/components/search-page/component.ts
@@ -158,6 +158,13 @@ export default class SearchPage extends Component {
return this.sortOptions.find(option => option.value === this.sort);// || this.sortOptions[0];
}
+ get preprintLabel() {
+ if (this.args.institution?.id === 'yls') {
+ return this.intl.t('documentType.paper.pluralCapitalized');
+ }
+ return this.intl.t('search.resource-type.preprints');
+ }
+
// Resource type
defaultResourceTypeOptions: ResourceTypeOption[] = [
{
@@ -173,7 +180,7 @@ export default class SearchPage extends Component {
value: ResourceTypeFilterValue.Registrations,
},
{
- display: this.intl.t('search.resource-type.preprints'),
+ display: this.preprintLabel,
value: ResourceTypeFilterValue.Preprints,
},
{
diff --git a/lib/osf-components/addon/components/search-page/template.hbs b/lib/osf-components/addon/components/search-page/template.hbs
index bd08792e367..047d404ee7b 100644
--- a/lib/osf-components/addon/components/search-page/template.hbs
+++ b/lib/osf-components/addon/components/search-page/template.hbs
@@ -227,7 +227,7 @@ as |layout|>
{{else}}
{{#each this.searchResults as |item|}}
-
+
{{else}}
{{t 'search.no-results'}}
diff --git a/lib/osf-components/addon/components/search-result-card/component.ts b/lib/osf-components/addon/components/search-result-card/component.ts
index dab8376a399..2b9bf7b9d8a 100644
--- a/lib/osf-components/addon/components/search-result-card/component.ts
+++ b/lib/osf-components/addon/components/search-result-card/component.ts
@@ -7,6 +7,7 @@ import Intl from 'ember-intl/services/intl';
import SearchResultModel from 'ember-osf-web/models/search-result';
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
+import InstitutionModel from 'ember-osf-web/models/institution';
const CardLabelTranslationKeys = {
@@ -23,6 +24,7 @@ const CardLabelTranslationKeys = {
interface Args {
result: SearchResultModel;
provider?: PreprintProviderModel;
+ institution?: InstitutionModel;
}
export default class SearchResultCard extends Component
{
@@ -37,10 +39,17 @@ export default class SearchResultCard extends Component {
}
get cardTypeLabel() {
- const provider = this.args.provider;
+ const { provider, institution } = this.args;
const resourceType = this.args.result.resourceType;
- return (provider?.preprintWord && resourceType === 'preprint') ? provider.documentType.singularCapitalized :
- this.intl.t(CardLabelTranslationKeys[resourceType]);
+ if (resourceType === 'preprint') {
+ if (institution?.id === 'yls') {
+ return this.intl.t('documentType.paper.singularCapitalized');
+ }
+ if (provider?.preprintWord) {
+ return provider.documentType.singularCapitalized;
+ }
+ }
+ return this.intl.t(CardLabelTranslationKeys[resourceType]);
}
get secondaryMetadataComponent() {
diff --git a/mirage/factories/institution.ts b/mirage/factories/institution.ts
index d13536b1095..fa2259e8e75 100644
--- a/mirage/factories/institution.ts
+++ b/mirage/factories/institution.ts
@@ -28,6 +28,8 @@ export default Factory.extend({
},
iri: faker.internet.url,
rorIri: faker.internet.url,
+ iris: [faker.internet.url],
+
withMetrics: trait({
afterCreate(institution, server) {
const userMetrics = server.createList('institution-user', 15);
From 02e257ce9fdfe2193e46b89af73f24ab41e54937 Mon Sep 17 00:00:00 2001
From: Lord Business <113387478+bp-cos@users.noreply.github.com>
Date: Fri, 8 Dec 2023 07:00:05 -0700
Subject: [PATCH 05/13] [ENG-5012][ENG-5014] Updates to see the file version
for the latest preprint deploy (#2075)
* Updates to see the file version
* Added mobile formatting, a trait for different images
* Fixed the sorting and versioning on the file versions
* Updates per the PR
* Updated the file-renderer to use "allowCommenting". Updated the tests
* Revert "Updated the file-renderer to use "allowCommenting". Updated the tests"
This reverts commit 3b274d898613b6e28d6fecc30ca22f20df3ccfff.
* Fixed all the issues from the PR
* Fixed the date created issue
* A few minor fixes
---
app/models/file-version.ts | 9 ++
.../preprint-file-render/component.ts | 83 ++++++++++++
.../preprint-file-render/styles.scss | 122 ++++++++++++++++++
.../preprint-file-render/template.hbs | 49 +++++++
app/preprints/detail/route.ts | 2 +
app/preprints/detail/styles.scss | 2 +-
app/preprints/detail/template.hbs | 11 +-
.../addon/application/template.hbs | 1 +
mirage/config.ts | 4 +
mirage/factories/file-version.ts | 32 +++++
mirage/factories/file.ts | 4 +
mirage/factories/preprint.ts | 1 -
mirage/serializers/file-version.ts | 24 ++++
translations/en-us.yml | 3 +
14 files changed, 340 insertions(+), 7 deletions(-)
create mode 100644 app/preprints/-components/preprint-file-render/component.ts
create mode 100644 app/preprints/-components/preprint-file-render/styles.scss
create mode 100644 app/preprints/-components/preprint-file-render/template.hbs
create mode 100644 mirage/factories/file-version.ts
create mode 100644 mirage/serializers/file-version.ts
diff --git a/app/models/file-version.ts b/app/models/file-version.ts
index f598e6e944f..aa2df5a3507 100644
--- a/app/models/file-version.ts
+++ b/app/models/file-version.ts
@@ -1,11 +1,20 @@
import { attr } from '@ember-data/model';
+import { Link } from 'jsonapi-typescript';
+import { NormalLinks } from 'osf-api';
import OsfModel from './osf-model';
+export interface FileVersionLinks extends NormalLinks {
+ download?: Link;
+ render?: Link;
+}
+
export default class FileVersionModel extends OsfModel {
@attr('number') size!: number;
@attr('date') dateCreated!: Date;
@attr('fixstring') contentType!: string;
+ @attr('fixstring') name!: string;
+ @attr() links!: FileVersionLinks;
}
declare module 'ember-data/types/registries/model' {
diff --git a/app/preprints/-components/preprint-file-render/component.ts b/app/preprints/-components/preprint-file-render/component.ts
new file mode 100644
index 00000000000..a7cd225fc2a
--- /dev/null
+++ b/app/preprints/-components/preprint-file-render/component.ts
@@ -0,0 +1,83 @@
+import Component from '@glimmer/component';
+import { inject as service } from '@ember/service';
+import FileModel from 'ember-osf-web/models/file';
+import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
+import PreprintModel from 'ember-osf-web/models/preprint';
+import Theme from 'ember-osf-web/services/theme';
+import { tracked } from '@glimmer/tracking';
+import { task } from 'ember-concurrency';
+import { waitFor } from '@ember/test-waiters';
+import { taskFor } from 'ember-concurrency-ts';
+import FileVersionModel from 'ember-osf-web/models/file-version';
+import Media from 'ember-responsive';
+
+
+interface InputArgs {
+ preprint: PreprintModel;
+ provider: PreprintProviderModel;
+ primaryFile: FileModel;
+}
+
+export interface VersionModel extends FileVersionModel {
+ downloadUrl?: string;
+}
+
+export default class PreprintFileRender extends Component {
+ @service theme!: Theme;
+ @service media!: Media;
+
+ @tracked allowCommenting = false;
+ @tracked primaryFileHasVersions = false;
+ @tracked fileVersions: VersionModel[] = [];
+
+ primaryFile = this.args.primaryFile;
+ provider = this.args.provider;
+ preprint = this.args.preprint;
+
+ constructor(owner: unknown, args: InputArgs) {
+ super(owner, args);
+
+ taskFor(this.loadPrimaryFileVersions).perform();
+
+ this.allowCommenting = this.provider.allowCommenting && this.preprint.isPublished && this.preprint.public;
+ }
+
+ @task
+ @waitFor
+ private async loadPrimaryFileVersions() {
+ const primaryFileVersions = (await this.primaryFile.queryHasMany('versions', {
+ sort: '-id', 'page[size]': 50,
+ })).toArray();
+ this.serializeVersions(primaryFileVersions);
+ this.primaryFileHasVersions = primaryFileVersions.length > 0;
+ }
+
+ private serializeVersions(versions: FileVersionModel[]) {
+ const downloadUrl = this.primaryFile.links.download as string || '';
+ const primaryFileGuid = this.primaryFile.guid;
+
+ const directDownloadUrl = downloadUrl.replace(
+ `download/${primaryFileGuid}`,
+ `${primaryFileGuid}/download`,
+ );
+
+ versions.map((version: VersionModel) => {
+ const dateFormatted = encodeURIComponent(version.dateCreated.toISOString());
+ const displayName = version.name.replace(/(\.\w+)?$/, ext => `-${dateFormatted}${ext}`);
+
+ this.fileVersions.push(
+ {
+ name: version.name,
+ id: version.id,
+ dateCreated: version.dateCreated,
+ downloadUrl: `${directDownloadUrl}?version=${version.id}&displayName=${displayName}`,
+ } as VersionModel,
+ );
+ return version;
+ });
+ }
+
+ get isMobile() {
+ return this.media.isMobile;
+ }
+}
diff --git a/app/preprints/-components/preprint-file-render/styles.scss b/app/preprints/-components/preprint-file-render/styles.scss
new file mode 100644
index 00000000000..7b03c399330
--- /dev/null
+++ b/app/preprints/-components/preprint-file-render/styles.scss
@@ -0,0 +1,122 @@
+// stylelint-disable max-nesting-depth, selector-max-compound-selectors
+
+.file-renderer-container {
+ width: 100%;
+ height: 1150px;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ justify-content: flex-start;
+
+ .file-container {
+ width: 100%;
+ height: 1100px;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ justify-content: flex-start;
+ }
+
+ .details-container {
+ width: 100%;
+ height: 50px;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+
+ .name-container {
+ width: 60%;
+ height: 50px;
+ overflow: hidden;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: space-between;
+
+ .name,
+ .version {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+ height: 25px;
+ }
+ }
+
+ .version-container {
+ width: 40%;
+ height: 50px;
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-end;
+
+ .version-menu {
+ background-color: $color-bg-white;
+ border: 1px solid rgba(0, 0, 0, 0.15);
+ border-radius: 4px;
+ box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
+ padding: 5px;
+ margin: 2px 0 0;
+
+ ul {
+ list-style: none;
+ padding-inline-start: 0;
+ }
+
+ .li-container {
+ margin-top: 10px;
+ margin-bottom: 10px;
+
+ .btn {
+ display: inline-block;
+ margin-bottom: 0;
+ font-weight: 400;
+ text-align: center;
+ white-space: nowrap;
+ touch-action: manipulation;
+ cursor: pointer;
+ background-image: none;
+ border: 1px solid transparent;
+ border-radius: 2px;
+ padding: 6px 12px;
+ font-size: 14px;
+ line-height: 1.42857;
+ user-select: none;
+ vertical-align: middle;
+ color: $color-text-white;
+ }
+
+ .btn-primary {
+ color: $color-text-white;
+ background-color: $color-bg-blue-dark;
+ border-color: #2e6da4;
+ }
+ }
+ }
+ }
+ }
+
+ &.mobile {
+ height: 500px;
+
+ .file-container {
+ height: 400px;
+ }
+
+ .details-container {
+ height: 100px;
+ flex-direction: column;
+
+ .version-container,
+ .name-container {
+ height: 50px;
+ width: 100%;
+ justify-content: center;
+ align-items: flex-start;
+ flex-direction: column;
+ }
+ }
+ }
+}
diff --git a/app/preprints/-components/preprint-file-render/template.hbs b/app/preprints/-components/preprint-file-render/template.hbs
new file mode 100644
index 00000000000..badebe2a5c8
--- /dev/null
+++ b/app/preprints/-components/preprint-file-render/template.hbs
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+ {{this.primaryFile.name}}
+
+
+ {{t 'preprints.detail.file_renderer.version'}}: {{this.primaryFile.currentVersion}}
+
+
+
+ {{#if this.primaryFileHasVersions}}
+
+
+ {{t 'preprints.detail.file_renderer.download_previous_versions'}}
+
+
+
+
+ {{#each this.fileVersions as |version|}}
+ -
+
+ {{t 'preprints.detail.file_renderer.version'}} {{version.id}}, {{moment-format version.dateCreated 'MM/DD/YYYY HH:mm:SS'}}
+
+
+ {{/each}}
+
+
+
+ {{/if}}
+
+
+
\ No newline at end of file
diff --git a/app/preprints/detail/route.ts b/app/preprints/detail/route.ts
index 65d3731ea7b..25b296a55f5 100644
--- a/app/preprints/detail/route.ts
+++ b/app/preprints/detail/route.ts
@@ -60,6 +60,8 @@ export default class PreprintsDetail extends Route {
const primaryFile = await preprint?.get('primaryFile');
+ primaryFile.versions = await primaryFile?.versions;
+
this.theme.set('providerType', 'preprint');
this.theme.set('id', provider.id);
diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss
index cf86e1a40dc..9193fea10e7 100644
--- a/app/preprints/detail/styles.scss
+++ b/app/preprints/detail/styles.scss
@@ -204,7 +204,7 @@
}
.data-container-left {
- height: 481px;
+ height: 500px;
.file-description-container {
flex-direction: column;
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index 9bcaf145737..a74074630fb 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -61,13 +61,14 @@
{{else}}
{{#if this.model.preprint.public}}
-
+
-
{{t this.dateLabel}}: {{moment-format this.model.dateCreated 'MMMM DD, YYYY'}}
+
{{t this.dateLabel}}: {{moment-format this.model.preprint.dateCreated 'MMMM DD, YYYY'}}
{{#unless this.isMobile}}
|
{{/unless}}
diff --git a/lib/analytics-page/addon/application/template.hbs b/lib/analytics-page/addon/application/template.hbs
index 5995ab5cbf1..3c2b9bcb143 100644
--- a/lib/analytics-page/addon/application/template.hbs
+++ b/lib/analytics-page/addon/application/template.hbs
@@ -110,6 +110,7 @@
{{t (get this.timespanIntlKeys this.timespan)}}
+
({
+ id() {
+ return faker.random.number(1000);
+ },
+ size() {
+ return faker.random.number(1000);
+ },
+ contentType: 'application/octet-stream',
+ dateCreated() {
+ return faker.date.past(2, new Date(2018, 0, 0));
+ },
+ name() {
+ return faker.system.commonFileName(faker.system.commonFileExt());
+ },
+});
+
+declare module 'ember-cli-mirage/types/registries/model' {
+ export default interface MirageModelRegistry {
+ 'file-version': FileVersionModel;
+ } // eslint-disable-line semi
+}
+
+declare module 'ember-cli-mirage/types/registries/schema' {
+ export default interface MirageSchemaRegistry {
+ 'file-version': FileVersionModel;
+ } // eslint-disable-line semi
+}
diff --git a/mirage/factories/file.ts b/mirage/factories/file.ts
index 3af6082d4e5..05938d733d0 100644
--- a/mirage/factories/file.ts
+++ b/mirage/factories/file.ts
@@ -27,8 +27,12 @@ export default Factory.extend({
id: newObj.id,
referentType: newObj.modelName,
});
+
+ const versions = server.createList('file-version', 3);
+
newObj.update({
guid: newObj.id,
+ versions,
});
},
diff --git a/mirage/factories/preprint.ts b/mirage/factories/preprint.ts
index 6d2b199a69a..e984d08193d 100644
--- a/mirage/factories/preprint.ts
+++ b/mirage/factories/preprint.ts
@@ -197,7 +197,6 @@ export default Factory.extend({
preprint.update({ reviewActions: [preprintReviewAction]});
},
}),
-
});
declare module 'ember-cli-mirage/types/registries/model' {
diff --git a/mirage/serializers/file-version.ts b/mirage/serializers/file-version.ts
new file mode 100644
index 00000000000..aa4a7dd7a9e
--- /dev/null
+++ b/mirage/serializers/file-version.ts
@@ -0,0 +1,24 @@
+import { ModelInstance } from 'ember-cli-mirage';
+import config from 'ember-osf-web/config/environment';
+import FileVersionModel from 'ember-osf-web/models/file-version';
+
+import ApplicationSerializer, { SerializedRelationships } from './application';
+
+const { OSF: { apiUrl} } = config;
+
+export default class FileVersionSerializer extends ApplicationSerializer {
+ // eslint-disable-next-line
+ buildRelationships(model: ModelInstance) {
+ const relationships: SerializedRelationships = {};
+ return relationships;
+ }
+
+ buildNormalLinks(model: ModelInstance) {
+ return {
+ ...super.buildNormalLinks(model),
+ html: `${apiUrl}/wb/files/${model.id}?version=${model.id}`,
+ download: `${apiUrl}/wb/files/${model.id}/download/?version=${model.id}`,
+ render: `${apiUrl}/wb/files/${model.id}/render/?version=${model.id}`,
+ };
+ }
+}
diff --git a/translations/en-us.yml b/translations/en-us.yml
index e02a124104c..0d08efa3e29 100644
--- a/translations/en-us.yml
+++ b/translations/en-us.yml
@@ -1156,6 +1156,9 @@ preprints:
supplemental_materials: 'Supplemental Materials'
tags: 'Tags'
reason_for_withdrawal: 'Reason for withdrawal'
+ file_renderer:
+ download_previous_versions: 'Download previous versions'
+ version: 'Version'
author-assertions:
header_label: 'Author Assertions'
describe: 'Describe'
From 96ea8ac53c8a70a9ca527b1936902d44cc65b534 Mon Sep 17 00:00:00 2001
From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com>
Date: Fri, 8 Dec 2023 10:28:53 -0500
Subject: [PATCH 06/13] Use links for preprint contributor names (#2080)
---
app/preprints/detail/template.hbs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index a74074630fb..8d96744c7cc 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -31,7 +31,11 @@
{{t 'preprints.detail.header.authors_label'}}
-
+
Date: Fri, 8 Dec 2023 14:16:34 -0700
Subject: [PATCH 07/13] Added the feature to allowCommenting on a preprint
document (#2082)
* Added a min-height to the data-column for the preprint details page
* Fixed a typo in the template file
* Updated the file renderer to send a message to the iframe
---
app/config/environment.d.ts | 1 +
app/preprints/detail/styles.scss | 1 +
app/preprints/detail/template.hbs | 2 +-
config/environment.js | 2 ++
.../components/file-renderer/component.ts | 27 +++++++++++++++++--
.../components/file-renderer/template.hbs | 2 +-
mirage/fixtures/preprint-providers.ts | 1 +
mirage/scenarios/preprints.ts | 2 +-
8 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/app/config/environment.d.ts b/app/config/environment.d.ts
index 7baccd822bf..902f347a48e 100644
--- a/app/config/environment.d.ts
+++ b/app/config/environment.d.ts
@@ -72,6 +72,7 @@ declare const config: {
learnMoreUrl: string;
donateUrl: string;
renderUrl: string;
+ mfrUrl: string;
waterbutlerUrl: string;
helpUrl: string;
shareBaseUrl: string;
diff --git a/app/preprints/detail/styles.scss b/app/preprints/detail/styles.scss
index 9193fea10e7..eb2ac488960 100644
--- a/app/preprints/detail/styles.scss
+++ b/app/preprints/detail/styles.scss
@@ -71,6 +71,7 @@
.data-container {
padding: 30px;
width: 100%;
+ min-height: 1250px;
display: flex;
flex-direction: row;
justify-content: flex-start;
diff --git a/app/preprints/detail/template.hbs b/app/preprints/detail/template.hbs
index 8d96744c7cc..76e7c326f65 100644
--- a/app/preprints/detail/template.hbs
+++ b/app/preprints/detail/template.hbs
@@ -164,7 +164,7 @@
{{this.model.preprint.node.links.html}}
diff --git a/config/environment.js b/config/environment.js
index c2b5c62e970..67312189170 100644
--- a/config/environment.js
+++ b/config/environment.js
@@ -46,6 +46,7 @@ const {
OSF_API_URL: apiUrl = 'http://localhost:8000',
OSF_API_VERSION: apiVersion = '2.20',
OSF_RENDER_URL: renderUrl = 'http://localhost:7778/render',
+ OSF_MFR_URL: mfrUrl = 'http://localhost:4200',
OSF_FILE_URL: waterbutlerUrl = 'http://localhost:7777/',
OSF_HELP_URL: helpUrl = 'http://localhost:4200/help',
OSF_AUTHENTICATOR: osfAuthenticator = 'osf-cookie',
@@ -151,6 +152,7 @@ module.exports = function(environment) {
learnMoreUrl: 'https://cos.io/our-products/osf/',
donateUrl: 'https://cos.io/donate',
renderUrl,
+ mfrUrl,
waterbutlerUrl,
helpUrl,
shareBaseUrl,
diff --git a/lib/osf-components/addon/components/file-renderer/component.ts b/lib/osf-components/addon/components/file-renderer/component.ts
index 178d41d781c..d2b9fcb99ae 100644
--- a/lib/osf-components/addon/components/file-renderer/component.ts
+++ b/lib/osf-components/addon/components/file-renderer/component.ts
@@ -9,7 +9,7 @@ import { tracked } from 'tracked-built-ins';
import template from './template';
-const { OSF: { renderUrl } } = config;
+const { OSF: { renderUrl, mfrUrl } } = config;
interface Params {
direct?: '';
@@ -46,6 +46,7 @@ export default class FileRenderer extends Component {
height = '100%';
allowfullscreen = true;
version?: number;
+ allowCommenting = false;
@tracked isLoading = true;
@computed('download', 'params', 'version')
@@ -64,7 +65,7 @@ export default class FileRenderer extends Component {
}
@computed('downloadUrl', 'isLoading')
- get mfrUrl(): string {
+ get getMfrUrl(): string {
// Waiting until the iframe is loaded then changing the URL avoids a race condition in the MFR iframe
// This is most apparent in 3D files
const urlWithParams = new URL(renderUrl);
@@ -88,4 +89,26 @@ export default class FileRenderer extends Component {
next(this, () => this.set('isLoading', false));
}
}
+
+ private mfrOrigin(): string {
+ const urlParts = mfrUrl.split('/');
+ if (urlParts.length < 3) {
+ // if unable to extract mfr origin, just return config mfrUrl
+ return mfrUrl;
+ }
+
+ return `${urlParts[0]}//${urlParts[2]}`;
+ }
+
+ didRender() {
+ if (this.allowCommenting) {
+ const iframeElement = window.document.getElementsByTagName('iframe')[0];
+ iframeElement.addEventListener('load', () => {
+ iframeElement.contentWindow?.postMessage(
+ {type: 'startHypothesis', parentUrl: window.location.toString()},
+ this.mfrOrigin(),
+ );
+ });
+ }
+ }
}
diff --git a/lib/osf-components/addon/components/file-renderer/template.hbs b/lib/osf-components/addon/components/file-renderer/template.hbs
index 97b04377b88..5a1a4461183 100644
--- a/lib/osf-components/addon/components/file-renderer/template.hbs
+++ b/lib/osf-components/addon/components/file-renderer/template.hbs
@@ -3,7 +3,7 @@
{{/if}}