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

mendersoftware / gui / 1091795320

01 Dec 2023 04:32AM UTC coverage: 82.784% (-17.2%) from 99.964%
1091795320

Pull #4229

gitlab-ci

web-flow
chore: Bump node from 21.1.0-alpine to 21.2.0-alpine

Bumps node from 21.1.0-alpine to 21.2.0-alpine.

---
updated-dependencies:
- dependency-name: node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4229: chore: Bump node from 21.1.0-alpine to 21.2.0-alpine

4316 of 6292 branches covered (0.0%)

8333 of 10066 relevant lines covered (82.78%)

188.98 hits per line

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

97.37
/src/js/components/deployments/deploymentitem.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, { useState } from 'react';
15

16
// material ui
17
import { CancelOutlined as CancelOutlinedIcon } from '@mui/icons-material';
18
import { Button, IconButton, Tooltip } from '@mui/material';
19
import { makeStyles } from 'tss-react/mui';
20

21
import { DEPLOYMENT_STATES, DEPLOYMENT_TYPES } from '../../constants/deploymentConstants';
22
import { FileSize, getDeploymentState } from '../../helpers';
23
import { useDeploymentDevice } from '../../utils/deploymentdevicehook';
24
import Confirm from '../common/confirm';
25
import { RelativeTime } from '../common/time';
26
import { PhaseProgressDisplay } from './deployment-report/phaseprogress';
27
import { getDeploymentTargetText } from './deployment-wizard/softwaredevices';
28
import DeploymentStats from './deploymentstatus';
29
import ProgressDisplay, { DeploymentStatusNotification } from './progressChart';
30

31
export const deploymentTypeClasses = {
11✔
32
  [DEPLOYMENT_STATES.finished]: 'past-item',
33
  [DEPLOYMENT_STATES.pending]: 'pending-item',
34
  [DEPLOYMENT_STATES.inprogress]: 'progress-item',
35
  [DEPLOYMENT_STATES.scheduled]: 'scheduled-item'
36
};
37

38
export const DeploymentDeviceCount = ({ className, deployment }) => (
11✔
39
  <div className={className} key="DeploymentDeviceCount">
1,102✔
40
    {Math.max(deployment.device_count || 0, deployment.max_devices || 0)}
3,313✔
41
  </div>
42
);
43
export const DeploymentDeviceGroup = ({ deployment, devicesById, idAttribute, wrappingClass }) => {
11✔
44
  const deploymentName = getDeploymentTargetText({ deployment, devicesById, idAttribute });
3,478✔
45
  return (
3,478✔
46
    <div className={wrappingClass} key="DeploymentDeviceGroup" title={deploymentName}>
47
      {deploymentName}
48
    </div>
49
  );
50
};
51
export const DeploymentEndTime = ({ deployment }) => <RelativeTime key="DeploymentEndTime" updateTime={deployment.finished} shouldCount="none" />;
1,102✔
52
export const DeploymentPhases = ({ deployment }) => <div key="DeploymentPhases">{deployment.phases ? deployment.phases.length : '-'}</div>;
11!
53
export const DeploymentProgress = ({ deployment, minimal = false }) => {
11✔
54
  const { phases = [], update_control_map } = deployment;
1,816✔
55
  const status = getDeploymentState(deployment);
1,816✔
56
  if (status === 'queued') {
1,816✔
57
    return <DeploymentStatusNotification status={status} />;
903✔
58
  } else if (phases.length > 1 || !update_control_map) {
913!
59
    return <ProgressDisplay key="DeploymentProgress" deployment={deployment} status={status} minimal={minimal} />;
913✔
60
  }
61
  return <PhaseProgressDisplay key="DeploymentProgress" deployment={deployment} status={status} minimal={minimal} />;
×
62
};
63
export const DeploymentRelease = ({ deployment: { artifact_name, type = DEPLOYMENT_TYPES.software }, wrappingClass }) => {
11✔
64
  const deploymentRelease = type === DEPLOYMENT_TYPES.configuration ? type : artifact_name;
1,102!
65
  return (
1,102✔
66
    <div className={wrappingClass} key="DeploymentRelease" title={deploymentRelease}>
67
      {deploymentRelease}
68
    </div>
69
  );
70
};
71
export const DeploymentStartTime = ({ direction = 'both', started }) => <RelativeTime key="DeploymentStartTime" updateTime={started} shouldCount={direction} />;
1,102✔
72

73
export const DeploymentStatus = ({ deployment }) => <DeploymentStats key="DeploymentStatus" deployment={deployment} />;
76✔
74

75
export const DeploymentSize = ({ deployment: { total_size } }) => <div className="align-right">{total_size ? <FileSize fileSize={total_size} /> : '-'}</div>;
76!
76

77
const useStyles = makeStyles()(theme => ({
34✔
78
  detailsButton: {
79
    backgroundColor: 'transparent',
80
    color: theme.palette.text.primary,
81
    justifySelf: 'center',
82
    textTransform: 'none',
83
    [`&:hover`]: {
84
      backgroundColor: 'transparent',
85
      color: theme.palette.text.primary
86
    }
87
  },
88
  textWrapping: { whiteSpace: 'initial' }
89
}));
90

91
export const DeploymentItem = ({
11✔
92
  abort: abortDeployment,
93
  canConfigure,
94
  canDeploy,
95
  columnHeaders,
96
  deployment,
97
  devices,
98
  idAttribute,
99
  isEnterprise,
100
  openReport,
101
  type
102
}) => {
103
  const [abort, setAbort] = useState(null);
1,102✔
104
  useDeploymentDevice(deployment.name);
1,102✔
105

106
  const { classes } = useStyles();
1,102✔
107

108
  const toggleConfirm = id => setTimeout(() => setAbort(abort ? null : id), 150);
1,102✔
109

110
  const { created, id, phases } = deployment;
1,102✔
111

112
  let confirmation;
113
  if (abort === id) {
1,102✔
114
    confirmation = <Confirm classes="flexbox centered confirmation-overlay" cancel={() => toggleConfirm(id)} action={() => abortDeployment(id)} type="abort" />;
5✔
115
  }
116
  const started = isEnterprise && phases?.length >= 1 ? phases[0].start_ts || created : created;
1,102✔
117
  const wrappingClass = `text-overflow ${type === DEPLOYMENT_STATES.inprogress ? classes.textWrapping : ''}`;
1,102✔
118
  return (
1,102✔
119
    <div className={`deployment-item ${deploymentTypeClasses[type]}`}>
120
      {!!confirmation && confirmation}
1,107✔
121
      {columnHeaders.map((column, i) => {
122
        const ColumnComponent = column.renderer;
6,688✔
123
        return (
6,688✔
124
          <div className={column.class} key={`deploy-item-${i}`}>
125
            {column.title && <span className="deployment-item-title muted">{column.title}</span>}
13,376✔
126
            <ColumnComponent
127
              className={column.class || ''}
12,274✔
128
              idAttribute={idAttribute}
129
              deployment={deployment}
130
              devicesById={devices}
131
              started={started}
132
              wrappingClass={wrappingClass}
133
              {...column.props}
134
            />
135
          </div>
136
        );
137
      })}
138
      <Button className={classes.detailsButton} variant="contained" onClick={() => openReport(type, deployment.id)}>
1✔
139
        View details
140
      </Button>
141
      {(canDeploy || (canConfigure && deployment.type === DEPLOYMENT_TYPES.configuration)) && type !== DEPLOYMENT_STATES.finished && (
3,227!
142
        <Tooltip className="columnHeader" title="Abort" placement="top-start">
143
          <IconButton onClick={() => toggleConfirm(id)} size="large">
1✔
144
            <CancelOutlinedIcon className="cancelButton muted" />
145
          </IconButton>
146
        </Tooltip>
147
      )}
148
    </div>
149
  );
150
};
151

152
export default DeploymentItem;
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