• 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

84.62
/src/js/components/releases/artifactPayload.js
1
// Copyright 2019 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 { List, ListItem, ListItemText, Table, TableBody, TableCell, TableHead, TableRow } from '@mui/material';
17
import { makeStyles } from 'tss-react/mui';
18

19
import { FileSize, getFormattedSize } from '../../helpers';
20
import Time from '../common/time';
21

22
const METADATA_SPACING = 2;
7✔
23

24
const useStyles = makeStyles()(theme => ({
7✔
25
  metadataList: {
26
    display: 'flex',
27
    flexDirection: 'row'
28
  },
29
  table: {
30
    background: 'transparent'
31
  },
32
  metadataListItem: {
33
    paddingBottom: 11,
34
    borderBottom: `1px solid ${theme.palette.grey[600]}`,
35
    marginRight: '2vw'
36
  },
37
  payloadHeader: {
38
    background: theme.palette.grey[500],
39
    margin: 0,
40
    padding: 10,
41
    position: 'absolute',
42
    top: -20
43
  }
44
}));
45

46
const attributes = ['Name', 'Checksum', 'Build date', 'Size (uncompressed)'];
7✔
47

48
export const ArtifactPayload = ({ index, payload: { files: payloadFiles, meta_data = {}, type_info } }) => {
7✔
49
  const { classes } = useStyles();
1✔
50
  const files = payloadFiles || [];
1✔
51
  const summedSize = files.reduce((accu, item) => accu + item.size, 0);
1✔
52
  const metaDataObject = meta_data;
1✔
53
  const metaData = [
1✔
54
    { title: 'Type', value: type_info.type },
55
    { title: 'Total Size (uncompressed)', value: getFormattedSize(summedSize) }
56
  ];
57
  return (
1✔
58
    <div className="file-details">
59
      <h4 className={classes.payloadHeader}>Payload {index}</h4>
60
      <List className={classes.metadataList}>
61
        {metaData.map((item, index) => (
62
          <ListItem disabled={true} className={classes.metadataListItem} classes={{ root: 'attributes', disabled: 'opaque' }} key={`metadata-item-${index}`}>
2✔
63
            <ListItemText primary={item.title} secondary={item.value} />
64
          </ListItem>
65
        ))}
66
      </List>
67
      <div className="file-meta">
68
        {Object.keys(metaDataObject).length ? (
1!
69
          <div>
70
            <h4>Update Metadata</h4>
71
            <pre>
72
              <code>{JSON.stringify(metaDataObject, null, METADATA_SPACING)}</code>
73
            </pre>
74
          </div>
75
        ) : null}
76
        <h4>Files</h4>
77
        {files.length ? (
1!
78
          <Table className={classes.table}>
79
            <TableHead>
80
              <TableRow>
81
                {attributes.map((item, index) => (
82
                  <TableCell key={`file-header-${index}`} tooltip={item}>
×
83
                    {item}
84
                  </TableCell>
85
                ))}
86
              </TableRow>
87
            </TableHead>
88
            <TableBody className={classes.table}>
89
              {files.map((file, index) => (
90
                <TableRow key={index}>
×
91
                  <TableCell>{file.name}</TableCell>
92
                  <TableCell style={{ wordBreak: 'break-word' }}>{file.checksum}</TableCell>
93
                  <TableCell>
94
                    <Time value={file.date} />
95
                  </TableCell>
96
                  <TableCell>
97
                    <FileSize fileSize={file.size} />
98
                  </TableCell>
99
                </TableRow>
100
              ))}
101
            </TableBody>
102
          </Table>
103
        ) : (
104
          <p>There are no files in this Artifact</p>
105
        )}
106
      </div>
107
    </div>
108
  );
109
};
110

111
export default ArtifactPayload;
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