Skip to content

Commit 199f2b9

Browse files
committed
Merge branch 'release/25.14.0'
2 parents b21d2b5 + 66dc39e commit 199f2b9

File tree

17 files changed

+123
-31
lines changed

17 files changed

+123
-31
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
8+
## [25.14.0] - 2025-08-01
9+
### Added
10+
- Misc. improvements
11+
712
## [25.13.0] - 2025-07-08
813
### Added
914
- Verified Resource Linking project release - FE

app/decorators/check-auth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ export default function checkAuth<T extends ConcreteSubclass<Route>>(
3737
// Need to handle view-only links before checking auth, and this is the only reasonable place to do it.
3838
// This limitation points toward replacing this decorator with a service method meant to be
3939
// called in Route.beforeModel. Decorator mixins should probably be considered an anti-pattern.
40-
const { viewOnlyToken = '' } = this.paramsFor('application') as Record<string, string>;
40+
let { viewOnlyToken = '' } = this.paramsFor('application') as Record<string, string>;
4141

4242
try {
4343
if (!this.session.isAuthenticated || this.currentUser.viewOnlyToken !== viewOnlyToken) {
44+
// This is for ENG-8174 where occasionally a %2F or / is at the end of the viewOnlyToken
45+
viewOnlyToken = viewOnlyToken.replace(/(%2[fF]|\/)$/g, '');
4446
this.currentUser.setProperties({ viewOnlyToken });
4547

4648
// Check whether user is actually logged in.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Component from '@glimmer/component';
2+
import { inject as service } from '@ember/service';
3+
import { tracked } from '@glimmer/tracking';
4+
import { task } from 'ember-concurrency';
5+
import { waitFor } from '@ember/test-waiters';
6+
import { taskFor } from 'ember-concurrency-ts';
7+
import Store from '@ember-data/store';
8+
import config from 'ember-osf-web/config/environment';
9+
import { BaseMeta } from 'osf-api';
10+
11+
12+
interface InputArgs {
13+
guid: string;
14+
}
15+
16+
export default class PreprintMetrics extends Component<InputArgs> {
17+
@service store!: Store;
18+
@tracked apiMeta!: BaseMeta;
19+
20+
metricsStartDate = config.OSF.metricsStartDate;
21+
22+
constructor(owner: unknown, args: InputArgs) {
23+
super(owner, args);
24+
25+
taskFor(this.loadPreprintMetrics).perform();
26+
}
27+
28+
@task
29+
@waitFor
30+
private async loadPreprintMetrics() {
31+
try {
32+
const adapterOptions = Object({
33+
query: {
34+
'metrics[views]': 'total',
35+
'metrics[downloads]': 'total',
36+
},
37+
});
38+
39+
const preprintMetrics = await this.store.findRecord('preprint', this.args.guid, {
40+
reload: true,
41+
adapterOptions,
42+
});
43+
44+
this.apiMeta = preprintMetrics.apiMeta;
45+
// eslint-disable-next-line
46+
} catch (_){ }
47+
}
48+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div>
2+
{{#if this.loadPreprintMetrics.isRunning}}
3+
<LoadingIndicator data-test-loading-indicator @dark={{true}} />
4+
{{else}}
5+
<span data-test-view-count-label>
6+
{{t 'preprints.detail.share.views'}}:
7+
</span>
8+
<span data-test-view-count> {{this.apiMeta.metrics.views}} </span> |
9+
<span data-test-download-count-label>
10+
{{t 'preprints.detail.share.downloads'}}:
11+
</span>
12+
<span data-test-download-count>{{this.apiMeta.metrics.downloads}}</span>
13+
<EmberTooltip>
14+
{{t 'preprints.detail.share.metrics_disclaimer'}} {{moment-format this.metricsStartDate 'YYYY-MM-DD'}}
15+
</EmberTooltip>
16+
{{/if}}
17+
</div>

app/preprints/-components/preprint-status-banner/component.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const WITHDRAWN = 'withdrawn';
2222
const PRE_MODERATION = 'pre-moderation';
2323
const POST_MODERATION = 'post-moderation';
2424

25+
const PROVIDER_OSF = 'provider-osf';
26+
2527
const STATUS = Object({});
2628
STATUS[PENDING]= 'preprints.detail.status_banner.pending';
2729
STATUS[ACCEPTED]= 'preprints.detail.status_banner.accepted';
@@ -30,6 +32,7 @@ STATUS[PENDING_WITHDRAWAL]= 'preprints.detail.status_banner.pending_withdrawal';
3032
STATUS[WITHDRAWAL_REJECTED]= 'preprints.detail.status_banner.withdrawal_rejected';
3133

3234
const MESSAGE = Object({});
35+
MESSAGE[PROVIDER_OSF] = 'preprints.detail.status_banner.message.provider_osf';
3336
MESSAGE[PRE_MODERATION] = 'preprints.detail.status_banner.message.pending_pre';
3437
MESSAGE[POST_MODERATION] = 'preprints.detail.status_banner.message.pending_post';
3538
MESSAGE[ACCEPTED] = 'preprints.detail.status_banner.message.accepted';
@@ -45,6 +48,7 @@ WORKFLOW[POST_MODERATION] = 'preprints.detail.status_banner.post_moderation';
4548
WORKFLOW[UNKNOWN] = 'preprints.detail.status_banner.post_moderation';
4649

4750
const CLASS_NAMES = Object({});
51+
CLASS_NAMES[PROVIDER_OSF] = 'preprint-status-pending-pre';
4852
CLASS_NAMES[PRE_MODERATION] = 'preprint-status-pending-pre';
4953
CLASS_NAMES[POST_MODERATION] = 'preprint-status-pending-post';
5054
CLASS_NAMES[ACCEPTED] = 'preprint-status-accepted';
@@ -68,6 +72,7 @@ interface InputArgs {
6872
provider: PreprintProviderModel;
6973
latestWithdrawalRequest: PreprintRequestModel | null;
7074
latestAction: PreprintRequestActionModel | ReviewActionModel | null;
75+
isOSFBanner: boolean | null;
7176
}
7277

7378
export default class PreprintStatusBanner extends Component<InputArgs>{
@@ -104,7 +109,9 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
104109
}
105110

106111
public get getClassName(): string {
107-
if (this.isPendingWithdrawal) {
112+
if (this.args.isOSFBanner) {
113+
return CLASS_NAMES[PROVIDER_OSF];
114+
} else if (this.isPendingWithdrawal) {
108115
return CLASS_NAMES[PENDING_WITHDRAWAL];
109116
} else if (this.isWithdrawn) {
110117
return CLASS_NAMES[WITHDRAWN];
@@ -119,7 +126,12 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
119126

120127
public get bannerContent(): string {
121128
const { provider } = this.args;
122-
if (this.isPendingWithdrawal) {
129+
if (this.args.isOSFBanner) {
130+
return this.intl.t(MESSAGE[PROVIDER_OSF], {
131+
name: 'OSF',
132+
documentType: provider.documentType.plural,
133+
});
134+
} else if (this.isPendingWithdrawal) {
123135
return this.intl.t(this.statusExplanation, { documentType: provider.documentType.singular });
124136
} else if (this.isWithdrawn) {
125137
return this.intl.t(MESSAGE[WITHDRAWN], { documentType: provider.documentType.singular });

app/preprints/-components/preprint-status-banner/template.hbs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
{{else}}
55
<div local-class='preprint-banner-status {{this.getClassName}}'>
66
<div local-class='display-container'>
7-
{{#if this.isWithdrawn}}
7+
{{#if @isOSFBanner}}
8+
<div>
9+
<strong>{{this.bannerContent}}</strong>
10+
</div>
11+
{{else if this.isWithdrawn}}
812
<div>
913
<FaIcon @icon='{{this.icon}}' @prefix='fas' local-class='status-icon' aria-hidden='true'/>
10-
<span local-class='banner-content'>{{this.bannerContent}}</span>
14+
<span>{{this.bannerContent}}</span>
1115
</div>
1216
{{else}}
1317
<div>

app/preprints/-components/submit/file/template.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
@manager={{@manager}}
6969
@preprint={{@manager.preprint}}
7070
@clickableElementId={{id}}
71-
@enable={{true}}
7271
@dragEnter={{fn (mut this.dragging) true}}
7372
@dragOver={{fn (mut this.dragging) true}}
7473
@dragLeave={{fn (mut this.dragging) false}}

app/preprints/-components/submit/file/upload-file/component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class PreprintUpload extends Component<PreprintUploadArgs> {
3030
rootFolder?: FileModel;
3131
primaryFile: FileModel | undefined;
3232
@tracked isUploadFileDisplayed = false;
33+
@tracked isEnabled = false;
3334

3435
constructor(owner: unknown, args: any) {
3536
super(owner, args);
@@ -75,6 +76,7 @@ export default class PreprintUpload extends Component<PreprintUploadArgs> {
7576

7677
this.url = new URL( urlString );
7778
this.rootFolder = rootFolder;
79+
this.isEnabled = true;
7880
}
7981

8082
@action

app/preprints/-components/submit/file/upload-file/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@dragleave={{@dragLeave}}
1313
@dragover={{@dragOver}}
1414
@drop={{@drop}}
15-
@enable={{@enable}}
15+
@enable={{this.isEnabled}}
1616
@id={{id}}
1717
@clickable={{this.clickableElementSelectors}}
1818
@preUpload={{perform this.preUpload}}

app/preprints/-components/submit/supplements/component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default class Supplements extends Component<SupplementsArgs>{
6969
@waitFor
7070
public async removeSelectedProject(): Promise<void> {
7171
try {
72+
this.validate(false);
7273
await this.args.manager.preprint.removeM2MRelationship('node'); // Remove relationship
7374
// Remove relationship on the node side, this only clears the cache locally
7475
this.args.manager.preprint.node.get('preprints')
@@ -89,7 +90,7 @@ export default class Supplements extends Component<SupplementsArgs>{
8990
}
9091

9192
@action
92-
public validate(): void {
93-
this.args.manager.validateSupplements(true);
93+
public validate(isValid = true): void {
94+
this.args.manager.validateSupplements(isValid);
9495
}
9596
}

0 commit comments

Comments
 (0)