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

CenterForOpenScience / ember-osf-web / 6327670718

27 Sep 2023 03:12PM UTC coverage: 70.897% (+0.08%) from 70.82%
6327670718

push

github

web-flow
Merge pull request #2008 from CenterForOpenScience/basket/barium

Upgrade Ember to 3.28

2619 of 3926 branches covered (0.0%)

Branch coverage included in aggregate %.

75 of 75 new or added lines in 22 files covered. (100.0%)

6039 of 8286 relevant lines covered (72.88%)

235.76 hits per line

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

85.71
/lib/osf-components/addon/components/delete-button/component.ts
1
import { tagName } from '@ember-decorators/component';
2
import Component from '@ember/component';
3
import { action, computed } from '@ember/object';
4
import { inject as service } from '@ember/service';
5
import { waitFor } from '@ember/test-waiters';
6
import { dropTask } from 'ember-concurrency';
7
import { taskFor } from 'ember-concurrency-ts';
8
import Intl from 'ember-intl/services/intl';
9
import Toast from 'ember-toastr/services/toast';
10

11
import { layout, requiredAction } from 'ember-osf-web/decorators/component';
12
import Analytics from 'ember-osf-web/services/analytics';
13
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';
14
import randomScientist from 'ember-osf-web/utils/random-scientist';
15

16
import styles from './styles';
17
import template from './template';
18

19
@layout(template, styles)
20
@tagName('span')
21
export default class DeleteButton extends Component {
22
    @service analytics!: Analytics;
23
    @service intl!: Intl;
24
    @service toast!: Toast;
25

26
    // Required arguments
27
    @requiredAction delete!: () => unknown;
28

29
    // Optional arguments
30
    small = false;
434✔
31
    smallSecondary = false;
434✔
32
    noBackground = false;
434✔
33
    hardConfirm = false;
434✔
34
    disabled = false;
434✔
35
    shouldStopPropagation = false;
434✔
36
    icon = 'times';
434✔
37
    buttonLabel = this.intl.t('osf-components.delete-button.buttonLabel');
434✔
38
    modalTitle = this.intl.t('osf-components.delete-button.modalTitle');
434✔
39
    modalBody = this.intl.t('osf-components.delete-button.modalBody');
434✔
40
    confirmButtonText = this.intl.t('osf-components.delete-button.confirmButtonText');
434✔
41
    cancelButtonText = this.intl.t('osf-components.delete-button.cancelButtonText');
434✔
42
    errorMessage = this.intl.t('osf-components.delete-button.error');
434✔
43

44
    // Private properties
45
    modalShown = false;
434✔
46
    scientistName = '';
434✔
47
    scientistInput = '';
434✔
48

49
    @computed('_deleteTask.isRunning', 'hardConfirm', 'scientistName', 'scientistInput')
50
    get confirmDisabled() {
51
        return taskFor(this._deleteTask).isRunning || (
38!
52
            this.hardConfirm && (this.scientistName !== this.scientistInput)
53
        );
54
    }
55

56
    @dropTask
57
    @waitFor
58
    async _deleteTask() {
59
        try {
24✔
60
            await this.delete();
24✔
61
            this.set('modalShown', false);
15✔
62
        } catch (e) {
63
            captureException(e, { errorMessage: this.errorMessage });
×
64
            this.toast.error(getApiErrorMessage(e), this.errorMessage);
×
65
        }
66
    }
67

68
    @action
69
    _show(event: Event) {
70
        this.set('modalShown', true);
26✔
71
        if (this.shouldStopPropagation) {
26✔
72
            event.stopPropagation();
3✔
73
        }
74
        if (this.hardConfirm) {
26!
75
            this.setProperties({
×
76
                scientistName: randomScientist(),
77
                scientistInput: '',
78
            });
79
        }
80
    }
81

82
    @action
83
    _cancel() {
84
        this.set('modalShown', false);
1✔
85
    }
86
}
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

© 2026 Coveralls, Inc