• 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

82.61
/src/js/components/deployments/deployment-report/deploymentstatus.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 { Pause as PauseIcon, ArrowDropDownCircleOutlined as ScrollDownIcon } from '@mui/icons-material';
17
import { makeStyles } from 'tss-react/mui';
18

19
import { deploymentDisplayStates, pauseMap } from '../../../constants/deploymentConstants';
20
import { groupDeploymentStats } from '../../../helpers';
21
import { TwoColumnData } from '../../common/configurationobject';
22
import { defaultColumnDataProps } from '../report';
23

24
const useStyles = makeStyles()(theme => ({
10✔
25
  progressStatus: {
26
    backgroundColor: theme.palette.background.light,
27
    padding: `${theme.spacing(2)} ${theme.spacing(8)} ${theme.spacing(2)}`
28
  },
29
  scrollDown: { marginLeft: theme.spacing() }
30
}));
31

32
export const DeploymentPhaseNotification = ({ className = '', deployment = {}, onReviewClick }) => {
10!
33
  const { classes } = useStyles();
5✔
34
  const { paused } = groupDeploymentStats(deployment);
5✔
35
  if (paused === 0) {
5✔
36
    return null;
4✔
37
  }
38
  return (
1✔
39
    <div className={`${classes.progressStatus} flexbox center-aligned margin-bottom clickable ${className}`} onClick={onReviewClick} style={{ padding: 15 }}>
40
      <PauseIcon />
41
      <div className="muted">
42
        Deployment is <span className="uppercased">paused</span>. <a>Review its status</a> to continue, retry or abort the deployment{' '}
43
      </div>
44
      <ScrollDownIcon fontSize="small" className={`link-color ${classes.scrollDown}`} />
45
    </div>
46
  );
47
};
48

49
export const DeploymentStatus = ({ className = '', deployment = {} }) => {
10!
50
  const { classes } = useStyles();
5✔
51
  const { finished, max_devices, retries = 1, status = 'pending', statistics = {} } = deployment;
5!
52
  const { status: stats = {} } = statistics;
5!
53
  const phaseStats = groupDeploymentStats(deployment, true);
5✔
54

55
  let statusDescription = (
56
    <>
5✔
57
      {deploymentDisplayStates[status]}
58
      {status === 'pending' ? ' (awaiting devices)' : ''}
5!
59
    </>
60
  );
61
  if (finished) {
5!
62
    statusDescription = <div>Finished {!!phaseStats.failure && <span className="failures">with failures</span>}</div>;
×
63
  } else if (status === 'paused' && phaseStats.paused > 0) {
5!
64
    // based on the order of the possible pause states we find the furthest possible and use that as the current pause state - if applicable
65
    const currentPauseState = Object.keys(pauseMap)
×
66
      .reverse()
67
      .find(key => stats[key] > 0);
×
68
    statusDescription = (
×
69
      <>
70
        {deploymentDisplayStates[status]} ({pauseMap[currentPauseState].title})
71
      </>
72
    );
73
  }
74

75
  const statsBasedDeviceCount = Object.values(phaseStats).reduce((sum, count) => sum + count, 0);
30✔
76
  // eslint-disable-next-line no-unused-vars
77
  const { failure, finished: finishedDeployment, scheduled, success, ...phasesWithStats } = deploymentDisplayStates;
5✔
78

79
  return (
5✔
80
    <div className={`${classes.progressStatus} flexbox space-between centered margin-bottom ${className}`}>
81
      <div className="flexbox column">
82
        <div className="muted">Status</div>
83
        <h4 className="margin-bottom-none muted">{statusDescription}</h4>
84
      </div>
85
      <div className="flexbox space-between align-right" style={{ minWidth: '40%' }}>
86
        <div className="flexbox column">
87
          <div className="muted margin-bottom-small"># devices</div>
88
          <div>{statsBasedDeviceCount}</div>
89
        </div>
90
        {Object.entries(phasesWithStats).map(([key, phase]) => (
91
          <div key={key} className="flexbox column">
30✔
92
            <div className="muted margin-bottom-small">{phase}</div>
93
            <div className="status">{phaseStats[key].toLocaleString()}</div>
94
          </div>
95
        ))}
96
      </div>
97
      <TwoColumnData
98
        {...defaultColumnDataProps}
99
        config={{ 'Max attempts per device': retries, 'Maximum number of devices': max_devices || 'N/A' }}
10✔
100
        style={{ ...defaultColumnDataProps.style, gridTemplateColumns: 'max-content 1fr' }}
101
      />
102
    </div>
103
  );
104
};
105

106
export default DeploymentStatus;
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