• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CenterForOpenScience / ember-osf-web / 16684725173

01 Aug 2025 08:39PM UTC coverage: 67.218% (+0.009%) from 67.209%
16684725173

Pull #2607

github

web-flow
Merge 113b60ca0 into 233ec4fa0
Pull Request #2607: Feature/pbs 25 12

3279 of 5350 branches covered (61.29%)

Branch coverage included in aggregate %.

19 of 26 new or added lines in 7 files covered. (73.08%)

3 existing lines in 2 files now uncovered.

8552 of 12251 relevant lines covered (69.81%)

184.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.08
/app/preprints/-components/preprint-status-banner/component.ts
1
import Component from '@glimmer/component';
2
import { inject as service } from '@ember/service';
3
import Theme from 'ember-osf-web/services/theme';
4
import Intl from 'ember-intl/services/intl';
5
import PreprintModel from 'ember-osf-web/models/preprint';
6
import PreprintRequestActionModel from 'ember-osf-web/models/preprint-request-action';
7
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
8
import { tracked } from '@glimmer/tracking';
9
import { ReviewsState } from 'ember-osf-web/models/provider';
10
import ReviewActionModel from 'ember-osf-web/models/review-action';
11
import Media from 'ember-responsive';
12
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
13

14
const UNKNOWN = 'unknown';
1✔
15
const PENDING = 'pending';
1✔
16
const ACCEPTED = 'accepted';
1✔
17
const REJECTED = 'rejected';
1✔
18
const PENDING_WITHDRAWAL = 'pendingWithdrawal';
1✔
19
const WITHDRAWAL_REJECTED = 'withdrawalRejected';
1✔
20
const WITHDRAWN = 'withdrawn';
1✔
21

22
const PRE_MODERATION = 'pre-moderation';
1✔
23
const POST_MODERATION = 'post-moderation';
1✔
24

25
const PROVIDER_OSF = 'provider-osf';
1✔
26

27
const STATUS = Object({});
1✔
28
STATUS[PENDING]= 'preprints.detail.status_banner.pending';
1✔
29
STATUS[ACCEPTED]= 'preprints.detail.status_banner.accepted';
1✔
30
STATUS[REJECTED]= 'preprints.detail.status_banner.rejected';
1✔
31
STATUS[PENDING_WITHDRAWAL]= 'preprints.detail.status_banner.pending_withdrawal';
1✔
32
STATUS[WITHDRAWAL_REJECTED]= 'preprints.detail.status_banner.withdrawal_rejected';
1✔
33

34
const MESSAGE = Object({});
1✔
35
MESSAGE[PROVIDER_OSF] =  'preprints.detail.status_banner.message.provider_osf';
1✔
36
MESSAGE[PRE_MODERATION] =  'preprints.detail.status_banner.message.pending_pre';
1✔
37
MESSAGE[POST_MODERATION] =  'preprints.detail.status_banner.message.pending_post';
1✔
38
MESSAGE[ACCEPTED] =  'preprints.detail.status_banner.message.accepted';
1✔
39
MESSAGE[REJECTED] =  'preprints.detail.status_banner.message.rejected';
1✔
40
MESSAGE[PENDING_WITHDRAWAL] =  'preprints.detail.status_banner.message.pending_withdrawal';
1✔
41
MESSAGE[WITHDRAWAL_REJECTED] =  'preprints.detail.status_banner.message.withdrawal_rejected';
1✔
42
MESSAGE[WITHDRAWN] =  'preprints.detail.status_banner.message.withdrawn';
1✔
43
MESSAGE[UNKNOWN] =  'preprints.detail.status_banner.message.withdrawn';
1✔
44

45
const WORKFLOW = Object({});
1✔
46
WORKFLOW[PRE_MODERATION] = 'preprints.detail.status_banner.pre_moderation';
1✔
47
WORKFLOW[POST_MODERATION] = 'preprints.detail.status_banner.post_moderation';
1✔
48
WORKFLOW[UNKNOWN] = 'preprints.detail.status_banner.post_moderation';
1✔
49

50
const CLASS_NAMES = Object({});
1✔
51
CLASS_NAMES[PROVIDER_OSF] = 'preprint-status-pending-pre';
1✔
52
CLASS_NAMES[PRE_MODERATION] = 'preprint-status-pending-pre';
1✔
53
CLASS_NAMES[POST_MODERATION] =  'preprint-status-pending-post';
1✔
54
CLASS_NAMES[ACCEPTED] =  'preprint-status-accepted';
1✔
55
CLASS_NAMES[REJECTED] =  'preprint-status-rejected';
1✔
56
CLASS_NAMES[PENDING_WITHDRAWAL] =  'preprint-status-rejected';
1✔
57
CLASS_NAMES[WITHDRAWAL_REJECTED] =  'preprint-status-rejected';
1✔
58
CLASS_NAMES[WITHDRAWN] =  'preprint-status-withdrawn';
1✔
59
CLASS_NAMES[UNKNOWN] =  'preprint-status-withdrawn';
1✔
60

61
const ICONS = Object({});
1✔
62
ICONS[PENDING] = 'hourglass';
1✔
63
ICONS[ACCEPTED] = 'check-circle';
1✔
64
ICONS[REJECTED] = 'times-circle';
1✔
65
ICONS[PENDING_WITHDRAWAL] = 'hourglass';
1✔
66
ICONS[WITHDRAWAL_REJECTED] = 'times-circle';
1✔
67
ICONS[WITHDRAWN] = 'exclamation-triangle';
1✔
68
ICONS[UNKNOWN] = 'exclamation-triangle';
1✔
69

70
interface InputArgs {
71
    submission: PreprintModel;
72
    provider: PreprintProviderModel;
73
    latestWithdrawalRequest: PreprintRequestModel | null;
74
    latestAction: PreprintRequestActionModel | ReviewActionModel | null;
75
    isOSFBanner: boolean | null;
76
}
77

78
export default class PreprintStatusBanner extends Component<InputArgs>{
79
    @service intl!: Intl;
80
    @service theme!: Theme;
81
    @service media!: Media;
82

83
    @tracked displayComment = false;
×
84

85
    // translations
86
    labelModeratorFeedback = 'preprints.detail.status_banner.feedback.moderator_feedback';
12✔
87
    moderator = 'preprints.detail.status_banner.feedback.moderator';
12✔
88
    baseMessage = 'preprints.detail.status_banner.message.base';
12✔
89

90
    get isPendingWithdrawal(): boolean {
91
        return Boolean(this.args.latestWithdrawalRequest) && !this.isWithdrawalRejected;
43!
92
    }
93

94
    get isWithdrawalRejected(): boolean {
95
        const isPreprintRequestActionModel = this.args.latestAction instanceof PreprintRequestActionModel;
37✔
96
        return isPreprintRequestActionModel && this.args.latestAction?.actionTrigger === 'reject';
37!
97
    }
98

99
    get reviewerComment(): string | undefined {
100
        return this.args.latestAction?.comment;
4✔
101
    }
102

103
    get reviewerName(): string | undefined {
104
        return this.args.latestAction?.creator.get('fullName');
×
105
    }
106

107
    get isWithdrawn() {
108
        return this.args.submission.isWithdrawn;
38✔
109
    }
110

111
    public get getClassName(): string {
112
        if (this.args.isOSFBanner) {
16✔
113
            return CLASS_NAMES[PROVIDER_OSF];
6✔
114
        } else if (this.isPendingWithdrawal) {
10!
UNCOV
115
            return CLASS_NAMES[PENDING_WITHDRAWAL];
×
116
        } else if (this.isWithdrawn) {
10✔
117
            return CLASS_NAMES[WITHDRAWN];
3✔
118
        } else if (this.isWithdrawalRejected) {
7!
119
            return CLASS_NAMES[WITHDRAWAL_REJECTED];
×
120
        } else {
121
            return this.args.submission.reviewsState === PENDING ?
7✔
122
                CLASS_NAMES[this.args.provider.reviewsWorkflow || UNKNOWN] :
2!
123
                CLASS_NAMES[this.args.submission.reviewsState];
124
        }
125
    }
126

127
    public get bannerContent(): string {
128
        const { provider } = this.args;
16✔
129
        if (this.args.isOSFBanner) {
16✔
130
            return this.intl.t(MESSAGE[PROVIDER_OSF], {
6✔
131
                name: 'OSF',
132
                documentType: provider.documentType.plural,
133
            });
134
        } else if (this.isPendingWithdrawal) {
10!
UNCOV
135
            return this.intl.t(this.statusExplanation, { documentType: provider.documentType.singular });
×
136
        } else if (this.isWithdrawn) {
10✔
137
            return this.intl.t(MESSAGE[WITHDRAWN], { documentType: provider.documentType.singular });
3✔
138
        } else if (this.isWithdrawalRejected) {
7!
139
            return this.intl.t(MESSAGE[WITHDRAWAL_REJECTED], { documentType: provider.documentType.singular });
×
140
        } else {
141
            const tName = this.theme.isProvider ?
7!
142
                this.theme.provider?.name :
143
                this.intl.t('preprints.detail.status_banner.brand_name');
144
            const tWorkflow = this.intl.t(this.workflow);
7✔
145
            const tStatusExplanation = this.intl.t(this.statusExplanation);
7✔
146
            const base = (this.intl.t(this.baseMessage, {
7✔
147
                name: tName,
148
                reviewsWorkflow:
149
                tWorkflow,
150
                documentType: this.args.provider.documentType.singular,
151
            }));
152
            return `${base} ${tStatusExplanation}`;
7✔
153
        }
154
    }
155

156
    private get statusExplanation(): string {
157
        if (this.isPendingWithdrawal) {
7!
158
            return MESSAGE[PENDING_WITHDRAWAL];
×
159
        } else if (this.isWithdrawalRejected) {
7!
160
            return MESSAGE[WITHDRAWAL_REJECTED];
×
161
        } else {
162
            return this.args.submission.reviewsState === PENDING ?
7✔
163
                MESSAGE[this.args.provider.reviewsWorkflow || UNKNOWN ] :
2!
164
                MESSAGE[this.args.submission.reviewsState];
165
        }
166
    }
167

168
    public get status(): string {
169
        let currentState = this.args.submission.reviewsState;
6✔
170
        if (this.isPendingWithdrawal) {
6!
171
            currentState = ReviewsState.PENDING_WITHDRAWAL;
×
172
        } else if (this.isWithdrawalRejected) {
6!
173
            currentState = ReviewsState.WITHDRAWAL_REJECTED;
×
174
        }
175
        return STATUS[currentState];
6✔
176
    }
177

178
    public get icon(): string {
179
        let currentState = this.args.submission.reviewsState;
10✔
180
        if (this.isPendingWithdrawal) {
10!
181
            currentState = ReviewsState.PENDING_WITHDRAWAL;
×
182
        } else if (this.isWithdrawalRejected) {
10!
183
            currentState = ReviewsState.WITHDRAWAL_REJECTED;
×
184
        } else if (this.isWithdrawn) {
10✔
185
            currentState = ReviewsState.WITHDRAWN;
3✔
186
        }
187
        return ICONS[currentState];
10✔
188
    }
189

190
    private get workflow(): string {
191
        return WORKFLOW[this.args.provider.reviewsWorkflow || UNKNOWN];
7!
192
    }
193

194
    get isMobile() {
195
        return this.media.isMobile;
12✔
196
    }
197
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc