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

mendersoftware / gui / 1081664682

22 Nov 2023 02:11PM UTC coverage: 82.798% (-17.2%) from 99.964%
1081664682

Pull #4214

gitlab-ci

tranchitella
fix: Fixed the infinite page redirects when the back button is pressed

Remove the location and navigate from the useLocationParams.setValue callback
dependencies as they change the set function that is presented in other
useEffect dependencies. This happens when the back button is clicked, which
leads to the location changing infinitely.

Changelog: Title
Ticket: MEN-6847
Ticket: MEN-6796

Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Signed-off-by: Fabio Tranchitella <fabio.tranchitella@northern.tech>
Pull Request #4214: fix: Fixed the infinite page redirects when the back button is pressed

4319 of 6292 branches covered (0.0%)

8332 of 10063 relevant lines covered (82.8%)

191.0 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 => ({
12✔
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();
8✔
34
  const { paused } = groupDeploymentStats(deployment);
8✔
35
  if (paused === 0) {
8✔
36
    return null;
7✔
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();
8✔
51
  const { finished, max_devices, retries = 1, status = 'pending', statistics = {} } = deployment;
8!
52
  const { status: stats = {} } = statistics;
8!
53
  const phaseStats = groupDeploymentStats(deployment, true);
8✔
54

55
  let statusDescription = (
56
    <>
8✔
57
      {deploymentDisplayStates[status]}
58
      {status === 'pending' ? ' (awaiting devices)' : ''}
8!
59
    </>
60
  );
61
  if (finished) {
8!
62
    statusDescription = <div>Finished {!!phaseStats.failure && <span className="failures">with failures</span>}</div>;
×
63
  } else if (status === 'paused' && phaseStats.paused > 0) {
8!
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);
48✔
76
  // eslint-disable-next-line no-unused-vars
77
  const { failure, finished: finishedDeployment, scheduled, success, ...phasesWithStats } = deploymentDisplayStates;
8✔
78

79
  return (
8✔
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">
48✔
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' }}
16✔
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