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

mendersoftware / gui / 1113439055

19 Dec 2023 09:01PM UTC coverage: 82.752% (-17.2%) from 99.964%
1113439055

Pull #4258

gitlab-ci

mender-test-bot
chore: Types update

Signed-off-by: Mender Test Bot <mender@northern.tech>
Pull Request #4258: chore: Types update

4326 of 6319 branches covered (0.0%)

8348 of 10088 relevant lines covered (82.75%)

189.39 hits per line

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

95.65
/src/js/components/deployments/deployment-wizard/rolloutsteps.js
1
// Copyright 2021 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React from 'react';
15

16
import { Add as AddIcon, ArrowRight as ArrowRightIcon, PauseCircleOutline as PauseIcon } from '@mui/icons-material';
17
import { Chip } from '@mui/material';
18
import { makeStyles } from 'tss-react/mui';
19

20
import { TIMEOUTS } from '../../../constants/appConstants';
21
import DocsLink from '../../common/docslink';
22
import InfoText from '../../common/infotext';
23
import MenderTooltip from '../../common/mendertooltip';
24
import { HELPTOOLTIPS, MenderHelpTooltip } from '../../helptips/helptooltips';
25

26
const useStyles = makeStyles()(theme => ({
32✔
27
  chip: { marginLeft: theme.spacing(-3), marginRight: theme.spacing(-3) },
28
  connector: {
29
    backgroundColor: theme.palette.text.secondary,
30
    height: 3,
31
    width: '100%',
32
    marginRight: theme.spacing(-1),
33
    '& svg': { color: theme.palette.text.secondary }
34
  },
35
  connectorArrowWrapper: { height: theme.spacing(4), paddingLeft: theme.spacing(), width: '100%' },
36
  connectorWrapper: { minWidth: 120 },
37
  pauseConnector: { borderLeft: `${theme.palette.grey[500]} dashed 1px`, height: theme.spacing(6), margin: 4, marginTop: -10 },
38
  stepChip: { minWidth: theme.spacing(11) }
39
}));
40

41
const stepActions = {
12✔
42
  continue: 'continue',
43
  force_continue: 'force_continue',
44
  pause: 'pause',
45
  fail: 'fail'
46
};
47

48
const defaultStep = { action: stepActions.continue };
12✔
49

50
const defaultSteps = {
12✔
51
  ArtifactDownload: { ...defaultStep, title: 'Download', tooltip: 'The Artifact is downloaded (streamed) to the inactive partition.' },
52
  ArtifactInstall_Enter: {
53
    ...defaultStep,
54
    title: 'Install',
55
    tooltip: (
56
      <>
57
        For <b>operating system updates</b>, this means switching the <i>inactive</i> partition on the device to be <i>active</i> next time the device reboots.
58
        This means that on the next reboot the device will boot the updated software, regardless if it was rebooted by Mender, an external process or due to
59
        power loss.
60
        <br />
61
        For <b>application updates</b>, it depends on the Update Module but in general refers to the <i>system changing</i> effects; e.g. writing a file to its
62
        location, running a script, installing or starting a container.
63
      </>
64
    ),
65
    state: 'ArtifactInstall_Enter'
66
  },
67
  ArtifactReboot_Enter: {
68
    ...defaultStep,
69
    title: 'Reboot',
70
    tooltip:
71
      'The device will reboot and the installed update will be active when the device boots up again. As changes are not yet committed, the update is not persistent and the device will still roll back again on the next reboot.',
72
    state: 'ArtifactReboot_Enter'
73
  },
74
  ArtifactCommit_Enter: {
75
    ...defaultStep,
76
    title: 'Commit',
77
    tooltip:
78
      'If the update passes integrity checks, Mender will mark the update as successful and continue running from this partition. The commit makes the update persistent.',
79
    state: 'ArtifactCommit_Enter'
80
  }
81
};
82

83
const menderDemoArtifactName = 'mender-demo-artifact';
12✔
84

85
export const RolloutStepConnector = ({ disabled, step, onStepChange, release = {} }) => {
12✔
86
  const { classes } = useStyles();
732✔
87
  const onTogglePauseClick = () => {
732✔
88
    onStepChange({ ...step, action: step.action === stepActions.pause ? stepActions.continue : stepActions.pause });
×
89
  };
90

91
  let stepModifier = { props: {}, toggleButton: undefined };
732✔
92
  if (onStepChange) {
732✔
93
    stepModifier.props = { onDelete: onTogglePauseClick };
729✔
94
    stepModifier.toggleButton = <Chip className={classes.chip} icon={<AddIcon />} label="Add a pause" color="primary" onClick={onTogglePauseClick} />;
729✔
95
  }
96

97
  const pauseChip = <Chip className={classes.chip} icon={<PauseIcon />} label="Pause" {...stepModifier.props} />;
732✔
98
  const stepPauseChip =
99
    step.state === defaultSteps.ArtifactReboot_Enter.state && release.name?.includes(menderDemoArtifactName) ? (
732!
100
      <MenderTooltip
101
        arrow
102
        leaveDelay={TIMEOUTS.oneSecond}
103
        placement="top"
104
        title="The demo artifact you selected does not require a reboot and will not pause before starting with the next stage."
105
      >
106
        {pauseChip}
107
      </MenderTooltip>
108
    ) : (
109
      pauseChip
110
    );
111

112
  return (
732✔
113
    <div className={`flexbox column center-aligned ${classes.connectorWrapper}`}>
114
      <div className={`flexbox centered ${classes.connectorArrowWrapper}`}>
115
        <div className={classes.connector} />
116
        <ArrowRightIcon fontSize="small" />
117
      </div>
118
      {!disabled && (
1,170✔
119
        <>
120
          {(onStepChange || step.action === stepActions.pause) && <div className={classes.pauseConnector} />}
876✔
121
          {step.action === stepActions.pause ? stepPauseChip : stepModifier.toggleButton}
438!
122
        </>
123
      )}
124
    </div>
125
  );
126
};
127

128
export const RolloutSteps = ({ disabled, onStepChange, release, steps = {} }) => {
12!
129
  const { classes } = useStyles();
244✔
130
  const mappableSteps = Object.entries(defaultSteps).reduce((accu, [key, step]) => [...accu, { ...step, ...steps[key] }], []);
976✔
131

132
  return (
244✔
133
    <div className={`flexbox margin-top ${onStepChange ? 'margin-left-large margin-right-large' : ''}`}>
244✔
134
      {mappableSteps.map((step, index) => (
135
        <React.Fragment key={step.title}>
976✔
136
          {index !== 0 && <RolloutStepConnector disabled={disabled} step={step} onStepChange={onStepChange} release={release} />}
1,708✔
137
          <MenderTooltip title={step.tooltip} arrow>
138
            <Chip className={classes.stepChip} disabled={disabled} label={step.title} variant="outlined" />
139
          </MenderTooltip>
140
        </React.Fragment>
141
      ))}
142
    </div>
143
  );
144
};
145

146
export const RolloutStepsContainer = ({ className = '', disabled, onStepChange, release, steps }) => (
12✔
147
  <div className={className}>
244✔
148
    <div className={disabled ? 'muted' : ''}>
244✔
149
      <RolloutSteps disabled={disabled} onStepChange={onStepChange} release={release} steps={steps} />
150
      {onStepChange && !disabled && (
632✔
151
        <InfoText>
152
          A &apos;pause&apos; means each device will pause its update after completing the previous step, and wait for approval before continuing.
153
          <br />
154
          You can grant approval by clicking &quot;continue&quot; in the deployment progress UI. <DocsLink path="" title="Learn more" />
155
        </InfoText>
156
      )}
157
    </div>
158
    {disabled && (
342✔
159
      <div className="flexbox margin-left-small" style={{ marginTop: -30 }}>
160
        <MenderHelpTooltip id={HELPTOOLTIPS.phasedPausedDeployments.id} />
161
      </div>
162
    )}
163
  </div>
164
);
165

166
export default RolloutStepsContainer;
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