Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface KeenConfig {

declare const config: {
WATER_BUTLER_ENABLED: boolean;
PREPRINT_ADAPTER_OPTIONS_ENABLED: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate this idea, as it always takes me a few minutes to realize why my preprint detail page is broken 😄

plauditWidgetUrl: string,
environment: any;
cedarConfig: any;
Expand Down
16 changes: 14 additions & 2 deletions app/preprints/-components/preprint-status-banner/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const WITHDRAWN = 'withdrawn';
const PRE_MODERATION = 'pre-moderation';
const POST_MODERATION = 'post-moderation';

const PROVIDER_OSF = 'provider-osf';

const STATUS = Object({});
STATUS[PENDING]= 'preprints.detail.status_banner.pending';
STATUS[ACCEPTED]= 'preprints.detail.status_banner.accepted';
Expand All @@ -30,6 +32,7 @@ STATUS[PENDING_WITHDRAWAL]= 'preprints.detail.status_banner.pending_withdrawal';
STATUS[WITHDRAWAL_REJECTED]= 'preprints.detail.status_banner.withdrawal_rejected';

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

const CLASS_NAMES = Object({});
CLASS_NAMES[PROVIDER_OSF] = 'preprint-status-pending-pre';
CLASS_NAMES[PRE_MODERATION] = 'preprint-status-pending-pre';
CLASS_NAMES[POST_MODERATION] = 'preprint-status-pending-post';
CLASS_NAMES[ACCEPTED] = 'preprint-status-accepted';
Expand All @@ -68,6 +72,7 @@ interface InputArgs {
provider: PreprintProviderModel;
latestWithdrawalRequest: PreprintRequestModel | null;
latestAction: PreprintRequestActionModel | ReviewActionModel | null;
isOSFBanner: boolean | null;
}

export default class PreprintStatusBanner extends Component<InputArgs>{
Expand Down Expand Up @@ -104,7 +109,9 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
}

public get getClassName(): string {
if (this.isPendingWithdrawal) {
if (this.args.isOSFBanner) {
return CLASS_NAMES[PROVIDER_OSF];
} else if (this.isPendingWithdrawal) {
return CLASS_NAMES[PENDING_WITHDRAWAL];
} else if (this.isWithdrawn) {
return CLASS_NAMES[WITHDRAWN];
Expand All @@ -119,7 +126,12 @@ export default class PreprintStatusBanner extends Component<InputArgs>{

public get bannerContent(): string {
const { provider } = this.args;
if (this.isPendingWithdrawal) {
if (this.args.isOSFBanner) {
return this.intl.t(MESSAGE[PROVIDER_OSF], {
name: 'OSF',
documentType: provider.documentType.plural,
});
} else if (this.isPendingWithdrawal) {
return this.intl.t(this.statusExplanation, { documentType: provider.documentType.singular });
} else if (this.isWithdrawn) {
return this.intl.t(MESSAGE[WITHDRAWN], { documentType: provider.documentType.singular });
Expand Down
8 changes: 6 additions & 2 deletions app/preprints/-components/preprint-status-banner/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
{{else}}
<div local-class='preprint-banner-status {{this.getClassName}}'>
<div local-class='display-container'>
{{#if this.isWithdrawn}}
{{#if @isOSFBanner}}
<div>
<strong>{{this.bannerContent}}</strong>
</div>
{{else if this.isWithdrawn}}
<div>
<FaIcon @icon='{{this.icon}}' @prefix='fas' local-class='status-icon' aria-hidden='true'/>
<span local-class='banner-content'>{{this.bannerContent}}</span>
<span>{{this.bannerContent}}</span>
</div>
{{else}}
<div>
Expand Down
4 changes: 4 additions & 0 deletions app/preprints/detail/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ export default class PrePrintsDetailController extends Controller {
return false;
}

get showOSFBanner(): boolean {
return this.model.provider.id === config.defaultProvider;
}

get showStatusBanner(): boolean {
return (
this.model.provider.reviewsWorkflow
Expand Down
15 changes: 9 additions & 6 deletions app/preprints/detail/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ export default class PreprintsDetail extends Route {
'contributors',
'identifiers',
];
const adapterOptions = config.PREPRINT_ADAPTER_OPTIONS_ENABLED ? Object({
query: {
'metrics[views]': 'total',
'metrics[downloads]': 'total',
},
}) : undefined;


const preprint = await this.store.findRecord('preprint', guid, {
reload: true,
include: embeddableFields,
adapterOptions: {
query: {
'metrics[views]': 'total',
'metrics[downloads]': 'total',
},
},
adapterOptions,
});

const provider = await preprint?.get('provider');
Expand Down
7 changes: 7 additions & 0 deletions app/preprints/detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
@latestAction={{this.model.latestAction}}
/>
{{/if}}
{{#if this.showOSFBanner}}
<Preprints::-Components::PreprintStatusBanner
@submission={{this.model.preprint}}
@provider={{this.model.provider}}
@isOSFBanner={{true}}
/>
{{/if}}
<div local-class='data-container'>
{{#if this.model.preprint.isWithdrawn}}
<Preprints::-Components::PreprintTombstone
Expand Down
2 changes: 2 additions & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const {
KEEN_CONFIG: keenConfig,
LINT_ON_BUILD: lintOnBuild = false,
WATER_BUTLER_ENABLED = true,
PREPRINT_ADAPTER_OPTIONS_ENABLED = true,
MIRAGE_ENABLED = false,
MIRAGE_SCENARIOS = [
'cedar',
Expand Down Expand Up @@ -118,6 +119,7 @@ module.exports = function(environment) {
modulePrefix: 'ember-osf-web',
cedarConfig,
WATER_BUTLER_ENABLED,
PREPRINT_ADAPTER_OPTIONS_ENABLED,
plauditWidgetUrl,
environment,
lintOnBuild,
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ preprints:
close: 'Close'
message:
base: '{name} uses {reviewsWorkflow}. This {documentType}'
provider_osf: '{name} {documentType} are not peer-reviewed and acceptance is not an indicator of scholarly merit.'
pending_pre: 'is not publicly available or searchable until approved by a moderator.'
pending_post: 'is publicly available and searchable but is subject to removal by a moderator.'
accepted: 'has been accepted by a moderator and is publicly available and searchable.'
Expand Down