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

caleb531 / flip-book / 10498848679

21 Aug 2024 11:10PM UTC coverage: 26.831% (+2.8%) from 24.055%
10498848679

push

github

caleb531
Rename components to have *.jsx extension

This is a preliminary step to the actual conversion to JSX.

72 of 102 branches covered (70.59%)

Branch coverage included in aggregate %.

0 of 65 new or added lines in 17 files covered. (0.0%)

386 of 1605 relevant lines covered (24.05%)

7.23 hits per line

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

0.0
/scripts/components/import.jsx
1
import m from 'mithril';
×
2
import Story from '../models/story.js';
×
NEW
3
import ControlComponent from './control.jsx';
×
NEW
4
import PanelComponent from './panel.jsx';
×
NEW
5
import ProgressBarComponent from './progress-bar.jsx';
×
6

7
class ImportComponent {
×
8

9
  oninit({attrs: {app}}) {
×
10
    this.app = app;
×
11
    this.chosenFile = null;
×
12
    this.uploadProgress = null;
×
13
  }
×
14

15
  // Clear details of last upload when panel is closed
16
  onremove() {
×
17
    this.chosenFile = null;
×
18
    this.uploadProgress = null;
×
19
  }
×
20

21
  setChosenFile(chosenFile) {
×
22
    this.chosenFile = chosenFile;
×
23
    this.storyAdded = null;
×
24
    this.uploadProgress = null;
×
25
  }
×
26

27
  uploadChosenFile() {
×
28
    let reader = new FileReader();
×
29
    reader.onprogress = (event) => {
×
30
      this.uploadProgress = event.loaded / event.total;
×
31
      m.redraw();
×
32
    };
×
33
    reader.onload = (event) => {
×
34
      setTimeout(async () => {
×
35
        let story = new Story(JSON.parse(event.target.result));
×
36
        await this.app.addExistingStory(story);
×
37
        this.storyAdded = story;
×
38
        m.redraw();
×
39
        // Show success message for a brief moment, then close panel to take
40
        // user back to editor
41
        setTimeout(() => {
×
42
          PanelComponent.closeAllPanels();
×
43
          m.redraw();
×
44
        }, ProgressBarComponent.delay * 2);
×
45
      }, ProgressBarComponent.delay);
×
46
    };
×
47
    this.uploadProgress = 0;
×
48
    reader.readAsText(this.chosenFile);
×
49
  }
×
50

51
  view() {
×
52
    return m('div.import-options', [
×
53
      m('h2', 'Import Story'),
×
54
      m('div.import-control-wrapper', [
×
55
        m('input[type=file][accept=.flipbook].import-file-input', {
×
56
          onchange: ({target}) => this.setChosenFile(target.files[0])
×
57
        }),
×
58
        m(ControlComponent, {
×
59
          id: 'choose-file',
×
60
          title: 'Choose File',
×
61
          label: 'Choose File...'
×
62
        }),
×
63
        m('div.import-chosen-file-name', this.chosenFile ? this.chosenFile.name : 'No file chosen')
×
64
      ]),
×
65
      m('div.import-footer', [
×
66
        this.storyAdded ? m('div.import-success-message', `"${this.storyAdded.metadata.name}" successfully added!`) :
×
67
        [
×
68
          this.uploadProgress === null ? this.chosenFile ? m(ControlComponent, {
×
69
            id: 'upload-file',
×
70
            title: 'Upload Now',
×
71
            label: 'Upload Now',
×
72
            action: () => this.uploadChosenFile()
×
73
          }) : null : m(ProgressBarComponent, {progress: this.uploadProgress})
×
74
        ]
×
75
      ])
×
76
    ]);
×
77
  }
×
78

79
}
×
80

81
export default ImportComponent;
×
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