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

CenterForOpenScience / ember-osf-web / 12832262567

17 Jan 2025 03:43PM UTC coverage: 68.238% (+3.3%) from 64.94%
12832262567

Pull #2447

github

web-flow
Merge 08b0aa590 into 8621f29d7
Pull Request #2447: [ENG-6813] FE Reference PR for Preprints DOI Versioning

2960 of 4717 branches covered (62.75%)

Branch coverage included in aggregate %.

202 of 268 new or added lines in 13 files covered. (75.37%)

94 existing lines in 2 files now uncovered.

7417 of 10490 relevant lines covered (70.71%)

203.5 hits per line

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

10.0
/app/preprints/-components/withdrawal-preprint/component.ts
1
import Component from '@glimmer/component';
2
import { ValidationObject } from 'ember-changeset-validations';
3
import { validateLength } from 'ember-changeset-validations/validators';
4
import buildChangeset from 'ember-osf-web/utils/build-changeset';
5
import { inject as service } from '@ember/service';
6
import Intl from 'ember-intl/services/intl';
7
import { waitFor } from '@ember/test-waiters';
8
import { Task, task } from 'ember-concurrency';
9
import { taskFor } from 'ember-concurrency-ts';
10
import { tracked } from '@glimmer/tracking';
11
import { action } from '@ember/object';
12
import config from 'ember-osf-web/config/environment';
13
import { PreprintProviderReviewsWorkFlow, ReviewsState } from 'ember-osf-web/models/provider';
14
import { SafeString } from '@ember/template/-private/handlebars';
15
import PreprintModel from 'ember-osf-web/models/preprint';
16
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
17

18
const { support: { supportEmail } } = config;
1✔
19

20
interface WithdrawalModalArgs {
21
    preprint: PreprintModel;
22
    provider: PreprintProviderModel;
23
    onWithdrawal: Task<void, []>;
24
}
25

26
interface WithdrawalFormFields {
27
    withdrawalJustification: string;
28
}
29

30

31
export default class WithdrawalComponent extends Component<WithdrawalModalArgs> {
32
    @service intl!: Intl;
33
    @tracked isInvalid = true;
×
34

35
    withdrawalFormValidations: ValidationObject<WithdrawalFormFields> = {
2✔
36
        withdrawalJustification: validateLength({
37
            min: 25,
38
            type: 'greaterThanOrEqualTo',
39
            translationArgs: {
40
                description: this.intl.t('preprints.submit.action-flow.withdrawal-placeholder'),
41
                gte: this.intl.t('preprints.submit.action-flow.withdrawal-input-error'),
42
            },
43
        }),
44
    };
45

46
    withdrawalFormChangeset = buildChangeset(this.args.preprint, this.withdrawalFormValidations);
2✔
47

48
    /**
49
     * Calls the state machine delete method
50
     */
51
    @task
52
    @waitFor
53
    public async onWithdrawal(): Promise<void> {
54
        this.validate();
×
55
        if (this.withdrawalFormChangeset.isInvalid) {
×
56
            return Promise.reject();
×
57
        }
58
        this.withdrawalFormChangeset.execute();
×
NEW
59
        return taskFor(this.args.onWithdrawal).perform();
×
60
    }
61

62
    @action
63
    public validate(): void {
64
        this.withdrawalFormChangeset.validate();
×
65
        this.isInvalid = this.withdrawalFormChangeset.isInvalid;
×
66
    }
67

68
    /**
69
     * internationalize the withdrawal label
70
     */
71
    public get commentLabel(): string {
72
        return this.intl.t('preprints.submit.action-flow.withdrawal-label');
×
73
    }
74

75
    /**
76
     * internationalize the modal title
77
     */
78
    public get modalTitle(): string {
79
        return this.intl.t('preprints.submit.action-flow.withdrawal-modal-title',
×
80
            { singularPreprintWord: this.args.provider.documentType.singularCapitalized});
81
    }
82

83
    /**
84
     * internationalize the modal explanation
85
     */
86
    public get modalExplanation(): SafeString {
NEW
87
        if (this.args.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION
×
88
            && this.args.preprint.reviewsState === ReviewsState.PENDING
89
        ) {
90
            return this.intl.t('preprints.submit.action-flow.pre-moderation-notice-pending',
×
91
                {
92
                    singularPreprintWord: this.args.provider.documentType.singular,
93
                    htmlSafe: true,
94
                }) as SafeString;
NEW
95
        } else if (this.args.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.PRE_MODERATION
×
96
        ) {
97
            return this.intl.t('preprints.submit.action-flow.pre-moderation-notice-accepted',
×
98
                {
99
                    singularPreprintWord: this.args.provider.documentType.singular,
100
                    pluralCapitalizedPreprintWord: this.args.provider.documentType.pluralCapitalized,
101
                    htmlSafe: true,
102
                }) as SafeString;
NEW
103
        } else if (this.args.provider.reviewsWorkflow === PreprintProviderReviewsWorkFlow.POST_MODERATION) {
×
104
            return this.intl.t('preprints.submit.action-flow.post-moderation-notice',
×
105
                {
106
                    singularPreprintWord: this.args.provider.documentType.singular,
107
                    pluralCapitalizedPreprintWord: this.args.provider.documentType.pluralCapitalized,
108
                    htmlSafe: true,
109
                }) as SafeString;
110
        } else {
111
            return this.intl.t('preprints.submit.action-flow.no-moderation-notice',
×
112
                {
113
                    singularPreprintWord: this.args.provider.documentType.singular,
114
                    pluralCapitalizedPreprintWord: this.args.provider.documentType.pluralCapitalized,
115
                    supportEmail,
116
                    htmlSafe: true,
117
                }) as SafeString;
118
        }
119
    }
120
}
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