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

mendersoftware / gui / 1057181131

01 Nov 2023 04:10AM UTC coverage: 82.824% (-17.1%) from 99.964%
1057181131

Pull #4125

gitlab-ci

web-flow
chore: Bump axios from 1.5.1 to 1.6.0 in /tests/e2e_tests

Bumps [axios](https://github.com/axios/axios) from 1.5.1 to 1.6.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4125: chore: Bump axios from 1.5.1 to 1.6.0 in /tests/e2e_tests

4349 of 6284 branches covered (0.0%)

8313 of 10037 relevant lines covered (82.82%)

202.07 hits per line

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

95.45
/src/js/components/deployments/inprogressdeployments.js
1
// Copyright 2015 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, { useCallback, useEffect, useRef, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16

17
import { Refresh as RefreshIcon } from '@mui/icons-material';
18
import { makeStyles } from 'tss-react/mui';
19

20
import { setSnackbar } from '../../actions/appActions';
21
import { getDeploymentsByStatus, setDeploymentsState } from '../../actions/deploymentActions';
22
import { DEPLOYMENT_STATES } from '../../constants/deploymentConstants';
23
import { onboardingSteps } from '../../constants/onboardingConstants';
24
import {
25
  getDeploymentsByStatus as getDeploymentsByStatusSelector,
26
  getDeploymentsSelectionState,
27
  getDevicesById,
28
  getIdAttribute,
29
  getIsEnterprise,
30
  getMappedDeploymentSelection,
31
  getOnboardingState,
32
  getUserCapabilities
33
} from '../../selectors';
34
import { getOnboardingComponentFor } from '../../utils/onboardingmanager';
35
import useWindowSize from '../../utils/resizehook';
36
import { clearAllRetryTimers, clearRetryTimer, setRetryTimer } from '../../utils/retrytimer';
37
import LinedHeader from '../common/lined-header';
38
import Loader from '../common/loader';
39
import { defaultRefreshDeploymentsLength as refreshDeploymentsLength } from './deployments';
40
import DeploymentsList from './deploymentslist';
41

42
export const minimalRefreshDeploymentsLength = 2000;
7✔
43

44
const useStyles = makeStyles()(theme => ({
8✔
45
  deploymentsPending: {
46
    borderColor: 'rgba(0, 0, 0, 0.06)',
47
    backgroundColor: theme.palette.background.light,
48
    color: theme.palette.text.primary,
49
    ['.dashboard-header span']: {
50
      backgroundColor: theme.palette.background.light,
51
      color: theme.palette.text.primary
52
    },
53
    ['.MuiButtonBase-root']: {
54
      color: theme.palette.text.primary
55
    }
56
  }
57
}));
58

59
export const Progress = ({ abort, createClick, ...remainder }) => {
7✔
60
  const { canConfigure, canDeploy } = useSelector(getUserCapabilities);
325✔
61
  const { attribute: idAttribute } = useSelector(getIdAttribute);
325✔
62
  const onboardingState = useSelector(getOnboardingState);
325✔
63
  const isEnterprise = useSelector(getIsEnterprise);
325✔
64
  const {
65
    finished: { total: pastDeploymentsCount },
66
    pending: { total: pendingCount },
67
    inprogress: { total: progressCount }
68
  } = useSelector(getDeploymentsByStatusSelector);
325✔
69
  const progress = useSelector(state => getMappedDeploymentSelection(state, DEPLOYMENT_STATES.inprogress));
561✔
70
  const pending = useSelector(state => getMappedDeploymentSelection(state, DEPLOYMENT_STATES.pending));
561✔
71
  const selectionState = useSelector(getDeploymentsSelectionState);
325✔
72
  const devices = useSelector(getDevicesById);
325✔
73
  const dispatch = useDispatch();
325✔
74
  const dispatchedSetSnackbar = useCallback((...args) => dispatch(setSnackbar(...args)), [dispatch]);
325✔
75

76
  const { page: progressPage, perPage: progressPerPage } = selectionState.inprogress;
325✔
77
  const { page: pendingPage, perPage: pendingPerPage } = selectionState.pending;
325✔
78

79
  const [doneLoading, setDoneLoading] = useState(!!(progressCount || pendingCount));
325✔
80
  // eslint-disable-next-line no-unused-vars
81
  const size = useWindowSize();
325✔
82

83
  const currentRefreshDeploymentLength = useRef(refreshDeploymentsLength);
325✔
84
  const inprogressRef = useRef();
325✔
85
  const dynamicTimer = useRef();
325✔
86

87
  const { classes } = useStyles();
325✔
88

89
  // deploymentStatus = <inprogress|pending>
90
  const refreshDeployments = useCallback(
325✔
91
    deploymentStatus => {
92
      const { page, perPage } = selectionState[deploymentStatus];
60✔
93
      return dispatch(getDeploymentsByStatus(deploymentStatus, page, perPage))
60✔
94
        .then(deploymentsAction => {
95
          clearRetryTimer(deploymentStatus, dispatchedSetSnackbar);
56✔
96
          const { total, deploymentIds } = deploymentsAction[deploymentsAction.length - 1];
56✔
97
          if (total && !deploymentIds.length) {
56!
98
            return refreshDeployments(deploymentStatus);
×
99
          }
100
        })
101
        .catch(err => setRetryTimer(err, 'deployments', `Couldn't load deployments.`, refreshDeploymentsLength, dispatchedSetSnackbar))
×
102
        .finally(() => setDoneLoading(true));
56✔
103
    },
104
    // eslint-disable-next-line react-hooks/exhaustive-deps
105
    [dispatch, dispatchedSetSnackbar, pendingPage, pendingPerPage, progressPage, progressPerPage]
106
  );
107

108
  const setupDeploymentsRefresh = useCallback(
325✔
109
    (refreshLength = currentRefreshDeploymentLength.current) => {
12✔
110
      let tasks = [refreshDeployments(DEPLOYMENT_STATES.inprogress), refreshDeployments(DEPLOYMENT_STATES.pending)];
30✔
111
      if (!onboardingState.complete && !pastDeploymentsCount) {
30✔
112
        // retrieve past deployments outside of the regular refresh cycle to not change the selection state for past deployments
113
        dispatch(getDeploymentsByStatus(DEPLOYMENT_STATES.finished, 1, 1, undefined, undefined, undefined, undefined, false));
10✔
114
      }
115
      return Promise.all(tasks)
30✔
116
        .then(() => {
117
          currentRefreshDeploymentLength.current = Math.min(refreshDeploymentsLength, refreshLength * 2);
28✔
118
          clearTimeout(dynamicTimer.current);
28✔
119
          dynamicTimer.current = setTimeout(setupDeploymentsRefresh, currentRefreshDeploymentLength.current);
28✔
120
        })
121
        .finally(() => setDoneLoading(true));
28✔
122
    },
123
    [dispatch, onboardingState.complete, pastDeploymentsCount, refreshDeployments]
124
  );
125

126
  useEffect(() => {
325✔
127
    return () => {
8✔
128
      clearTimeout(dynamicTimer.current);
8✔
129
    };
130
  }, []);
131

132
  useEffect(() => {
325✔
133
    return () => {
8✔
134
      clearAllRetryTimers(dispatchedSetSnackbar);
8✔
135
    };
136
  }, [dispatchedSetSnackbar]);
137

138
  useEffect(() => {
325✔
139
    clearTimeout(dynamicTimer.current);
18✔
140
    setupDeploymentsRefresh(minimalRefreshDeploymentsLength);
18✔
141
    return () => {
18✔
142
      clearTimeout(dynamicTimer.current);
18✔
143
    };
144
  }, [pendingCount, setupDeploymentsRefresh]);
145

146
  useEffect(() => {
325✔
147
    clearTimeout(dynamicTimer.current);
11✔
148
    setupDeploymentsRefresh();
11✔
149
    return () => {
11✔
150
      clearTimeout(dynamicTimer.current);
11✔
151
    };
152
  }, [progressPage, progressPerPage, pendingPage, pendingPerPage, setupDeploymentsRefresh]);
153

154
  const abortDeployment = id =>
325✔
155
    abort(id).then(() => Promise.all([refreshDeployments(DEPLOYMENT_STATES.inprogress), refreshDeployments(DEPLOYMENT_STATES.pending)]));
×
156

157
  const onChangePage = state => page => dispatch(setDeploymentsState({ [state]: { page } }));
615✔
158
  const onChangeRowsPerPage = state => perPage => dispatch(setDeploymentsState({ [state]: { page: 1, perPage } }));
615✔
159

160
  let onboardingComponent = null;
325✔
161
  if (!onboardingState.complete && inprogressRef.current) {
325✔
162
    const anchor = {
201✔
163
      left: inprogressRef.current.offsetLeft + (inprogressRef.current.offsetWidth / 100) * 90,
164
      top: inprogressRef.current.offsetTop + inprogressRef.current.offsetHeight
165
    };
166
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEPLOYMENTS_INPROGRESS, onboardingState, { anchor });
201✔
167
  }
168
  const props = { ...remainder, canDeploy, canConfigure, devices, idAttribute, isEnterprise };
325✔
169
  return doneLoading ? (
325✔
170
    <div className="fadeIn">
171
      {!!progress.length && (
618✔
172
        <div className="margin-left">
173
          <LinedHeader className="margin-top-large  margin-right" heading="In progress now" />
174
          <DeploymentsList
175
            {...props}
176
            abort={abortDeployment}
177
            count={progressCount}
178
            items={progress}
179
            listClass="margin-right-small"
180
            page={progressPage}
181
            pageSize={progressPerPage}
182
            rootRef={inprogressRef}
183
            onChangeRowsPerPage={onChangeRowsPerPage(DEPLOYMENT_STATES.inprogress)}
184
            onChangePage={onChangePage(DEPLOYMENT_STATES.inprogress)}
185
            type={DEPLOYMENT_STATES.inprogress}
186
          />
187
        </div>
188
      )}
189
      {!!onboardingComponent && onboardingComponent}
309!
190
      {!!pending.length && (
615✔
191
        <div className={`deployments-pending margin-top margin-bottom-large ${classes.deploymentsPending}`}>
192
          <LinedHeader className="margin-small margin-top" heading="Pending" />
193
          <DeploymentsList
194
            {...props}
195
            abort={abortDeployment}
196
            componentClass="margin-left-small"
197
            count={pendingCount}
198
            items={pending}
199
            page={pendingPage}
200
            pageSize={pendingPerPage}
201
            onChangeRowsPerPage={onChangeRowsPerPage(DEPLOYMENT_STATES)}
202
            onChangePage={onChangePage(DEPLOYMENT_STATES.pending)}
203
            type={DEPLOYMENT_STATES.pending}
204
          />
205
        </div>
206
      )}
207
      {!(progressCount || pendingCount) && (
618!
208
        <div className="dashboard-placeholder">
209
          <p>Pending and ongoing deployments will appear here. </p>
210
          {canDeploy && (
×
211
            <p>
212
              <a onClick={createClick}>Create a deployment</a> to get started
213
            </p>
214
          )}
215
          <RefreshIcon className="flip-horizontal" style={{ fill: '#e3e3e3', width: 111, height: 111 }} />
216
        </div>
217
      )}
218
    </div>
219
  ) : (
220
    <Loader show={doneLoading} />
221
  );
222
};
223

224
export default Progress;
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