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

electron / fiddle / 14365309703

09 Apr 2025 07:22PM UTC coverage: 87.224% (-0.2%) from 87.472%
14365309703

Pull #1695

github

web-flow
Merge 15a759738 into 53057ba0f
Pull Request #1695: feat: add run from ASAR button

995 of 1244 branches covered (79.98%)

Branch coverage included in aggregate %.

7 of 11 new or added lines in 2 files covered. (63.64%)

33 existing lines in 2 files now uncovered.

3777 of 4227 relevant lines covered (89.35%)

34.58 hits per line

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

79.69
/src/renderer/components/commands-runner.tsx
1
import * as React from 'react';
1✔
2

3
import {
1✔
4
  Button,
5
  ButtonGroup,
6
  ButtonProps,
7
  Menu,
8
  MenuItem,
9
  Spinner,
10
} from '@blueprintjs/core';
11
import { Popover2 } from '@blueprintjs/popover2';
1✔
12
import { observer } from 'mobx-react';
1✔
13

14
import { InstallState, VersionSource } from '../../interfaces';
1✔
15
import { AppState } from '../state';
16

17
interface RunnerProps {
18
  appState: AppState;
19
}
20

21
/**
22
 * The runner component is responsible for actually launching the fiddle
23
 * with Electron. It also renders the button that does so.
24
 */
25
export const Runner = observer(
1✔
26
  class Runner extends React.Component<RunnerProps> {
27
    public render() {
28
      const { downloaded, downloading, missing, installing, installed } =
29
        InstallState;
7✔
30
      const {
31
        isRunning,
32
        isInstallingModules,
33
        currentElectronVersion,
34
        isOnline,
35
      } = this.props.appState;
7✔
36

37
      const { downloadProgress, source, state } = currentElectronVersion;
7✔
38
      const props: ButtonProps = { disabled: true };
7✔
39

40
      if ([downloading, missing].includes(state) && !isOnline) {
7!
41
        props.text = 'Offline';
×
42
        props.icon = 'satellite';
×
43
        return <Button id="button-run" {...props} type={undefined} />;
×
44
      }
45

46
      switch (state) {
7✔
47
        case downloading: {
8!
48
          props.text = 'Downloading';
1✔
49
          props.icon = <Spinner size={16} value={downloadProgress} />;
1✔
50
          break;
1✔
51
        }
52
        case installing: {
53
          props.text = 'Unzipping';
1✔
54
          props.icon = <Spinner size={16} />;
1✔
55
          break;
1✔
56
        }
57
        case downloaded:
58
        case installed: {
59
          props.disabled = false;
4✔
60
          if (isRunning) {
4✔
61
            props.active = true;
1✔
62
            props.text = 'Stop';
1✔
63
            props.onClick = window.app.runner.stop;
1✔
64
            props.icon = 'stop';
1✔
65
          } else if (isInstallingModules) {
3✔
66
            props.text = 'Installing modules';
1✔
67
            props.icon = <Spinner size={16} />;
1✔
68
          } else {
69
            props.text = 'Run';
2✔
70
            props.onClick = () => {
2✔
NEW
71
              window.app.runner.run({ runFromAsar: false });
×
72
            };
73
            props.icon = 'play';
2✔
74
          }
75
          break;
4✔
76
        }
77
        case missing: {
78
          if (source === VersionSource.local) {
1!
79
            props.text = 'Unavailable';
×
80
            props.icon = 'issue';
×
81
            break;
×
82
          }
83
        }
84
        default: {
85
          props.text = 'Checking status';
1✔
86
          props.icon = <Spinner size={16} />;
1✔
87
        }
88
      }
89
      const isAsarDisabled: boolean =
90
        props.disabled || isRunning || isInstallingModules;
7✔
91

92
      return (
7✔
93
        <ButtonGroup>
94
          <Button id="button-run" {...props} type={undefined} />
95
          <AsarButton disabled={isAsarDisabled} />
96
        </ButtonGroup>
97
      );
98
    }
99
  },
100
);
101

102
const AsarButton = ({ disabled }: { disabled: boolean }): JSX.Element => {
1✔
103
  const asarButton = (
NEW
104
    <Menu>
×
105
      <MenuItem
106
        text="Run from ASAR"
107
        icon="play"
108
        active={!disabled}
109
        onClick={() => {
NEW
110
          window.app.runner.run({ runFromAsar: true });
×
111
        }}
112
      />
113
    </Menu>
114
  );
115

NEW
116
  return (
×
117
    <Popover2 fill={true} content={asarButton} placement="bottom">
118
      <Button icon="caret-down" style={{ minWidth: 20 }} disabled={disabled} />
119
    </Popover2>
120
  );
121
};
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