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

caleb531 / flip-book / 10499286139

21 Aug 2024 11:59PM UTC coverage: 25.53% (-2.0%) from 27.541%
10499286139

push

github

caleb531
Convert components to JSX

72 of 100 branches covered (72.0%)

Branch coverage included in aggregate %.

0 of 743 new or added lines in 22 files covered. (0.0%)

54 existing lines in 21 files now uncovered.

386 of 1694 relevant lines covered (22.79%)

6.85 hits per line

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

0.0
/scripts/components/story-header.jsx
NEW
1
import m from "mithril";
×
NEW
2
import ControlComponent from "./control.jsx";
×
NEW
3
import PanelComponent from "./panel.jsx";
×
NEW
4
import StoryListComponent from "./story-list.jsx";
×
NEW
5
import ImportComponent from "./import.jsx";
×
6

7
class StoryHeaderComponent {
×
NEW
8
  oninit({ attrs: { app } }) {
×
9
    this.app = app;
×
10
  }
×
11

12
  createNewStoryWithName() {
×
13
    // Prevent the synchronous prompt() call from blocking the main thread; this
14
    // will allow Mithril to redraw and close all panels before showing the
15
    // modal
16
    setTimeout(async () => {
×
NEW
17
      let storyName = prompt("Please enter a name for your new story:") || "";
×
18
      if (storyName.trim()) {
×
19
        await this.app.createNewStoryWithName(storyName.trim());
×
20
        PanelComponent.closeAllPanels();
×
21
        m.redraw();
×
22
      }
×
23
    });
×
24
  }
×
25

26
  renameSelectedStory() {
×
27
    // Prevent the synchronous confirm() call from blocking the main thread;
28
    // this will allow Mithril to redraw and close all panels before showing the
29
    // modal
30
    setTimeout(async () => {
×
NEW
31
      let newStoryName =
×
NEW
32
        prompt(
×
NEW
33
          "Enter the new name for your story:",
×
NEW
34
          await this.app.getSelectedStoryName(),
×
NEW
35
        ) || "";
×
36
      if (newStoryName.trim()) {
×
37
        await this.app.renameSelectedStory(newStoryName.trim());
×
38
        m.redraw();
×
39
      }
×
40
    });
×
41
  }
×
42

43
  deleteSelectedStory() {
×
44
    // Prevent the synchronous confirm() call from blocking the main thread;
45
    // this will allow Mithril to redraw and close all panels before showing the
46
    // modal
47
    setTimeout(() => {
×
NEW
48
      if (
×
NEW
49
        confirm(
×
NEW
50
          "Are you sure you want to delete this story? This cannot be undone.",
×
NEW
51
        )
×
NEW
52
      ) {
×
53
        this.app.deleteSelectedStory();
×
54
        m.redraw();
×
55
      }
×
56
    });
×
57
  }
×
58

NEW
59
  view({ attrs: { story } }) {
×
NEW
60
    return (
×
NEW
61
      <div className="story-header">
×
NEW
62
        <div className="control-group">
×
NEW
63
          <ControlComponent
×
NEW
64
            id="create-new-story"
×
NEW
65
            title="Create New Story"
×
NEW
66
            icon="add"
×
NEW
67
            action={() => this.createNewStoryWithName()}
×
NEW
68
          />
×
NEW
69
          <ControlComponent
×
NEW
70
            id="open-story"
×
NEW
71
            title="Open Story"
×
NEW
72
            icon="folder"
×
NEW
73
            panel={<StoryListComponent app={this.app} />}
×
NEW
74
            panelPosition="bottom"
×
NEW
75
          />
×
NEW
76
          <ControlComponent
×
NEW
77
            id="import-story"
×
NEW
78
            title="Import Story"
×
NEW
79
            icon="upload"
×
NEW
80
            panel={<ImportComponent app={this.app} />}
×
NEW
81
            panelPosition="bottom"
×
NEW
82
          />
×
NEW
83
        </div>
×
NEW
84
        <span className="selected-story-name">{story.metadata.name}</span>
×
NEW
85
        <ControlComponent
×
NEW
86
          id="rename-story"
×
NEW
87
          title="Rename Story"
×
NEW
88
          icon="edit"
×
NEW
89
          action={() => this.renameSelectedStory()}
×
NEW
90
        />
×
NEW
91
        <div className="control-group">
×
NEW
92
          <ControlComponent
×
NEW
93
            id="delete-story"
×
NEW
94
            title="Delete Story"
×
NEW
95
            icon="delete"
×
NEW
96
            action={() => this.deleteSelectedStory()}
×
NEW
97
          />
×
NEW
98
          <ControlComponent
×
NEW
99
            id="help"
×
NEW
100
            title="Help"
×
NEW
101
            icon="help"
×
NEW
102
            action={() => {
×
NEW
103
              window.open("https://github.com/caleb531/flip-book#how-to-use");
×
NEW
104
            }}
×
NEW
105
          />
×
NEW
106
        </div>
×
NEW
107
      </div>
×
108
    );
UNCOV
109
  }
×
UNCOV
110
}
×
111

112
export default StoryHeaderComponent;
×
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