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

mendersoftware / mender-server / 10423

11 Nov 2025 04:53PM UTC coverage: 74.435% (-0.1%) from 74.562%
10423

push

gitlab-ci

web-flow
Merge pull request #1071 from mendersoftware/dependabot/npm_and_yarn/frontend/main/development-dependencies-92732187be

3868 of 5393 branches covered (71.72%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

176 existing lines in 95 files now uncovered.

64605 of 86597 relevant lines covered (74.6%)

7.74 hits per line

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

96.46
/frontend/src/js/components/deployments/deployment-wizard/ScheduleRollout.tsx
1
// Copyright 2019 Northern.tech AS
2✔
2
//
2✔
3
//    Licensed under the Apache License, Version 2.0 (the "License");
2✔
4
//    you may not use this file except in compliance with the License.
2✔
5
//    You may obtain a copy of the License at
2✔
6
//
2✔
7
//        http://www.apache.org/licenses/LICENSE-2.0
2✔
8
//
2✔
9
//    Unless required by applicable law or agreed to in writing, software
2✔
10
//    distributed under the License is distributed on an "AS IS" BASIS,
2✔
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2✔
12
//    See the License for the specific language governing permissions and
2✔
13
//    limitations under the License.
2✔
14
import { useState } from 'react';
2✔
15

2✔
16
import { FormControl, MenuItem, Select } from '@mui/material';
2✔
17
import { DateTimePicker } from '@mui/x-date-pickers';
2✔
18
import { makeStyles } from 'tss-react/mui';
2✔
19

2✔
20
import EnterpriseNotification from '@northern.tech/common-ui/EnterpriseNotification';
2✔
21
import { InfoHintContainer } from '@northern.tech/common-ui/InfoHint';
2✔
22
import { BENEFITS } from '@northern.tech/store/constants';
2✔
23
import dayjs from 'dayjs';
2✔
24

2✔
25
import { HELPTOOLTIPS } from '../../helptips/HelpTooltips';
2✔
26
import { MenderHelpTooltip } from '../../helptips/MenderTooltip';
2✔
27

2✔
28
const useStyles = makeStyles()(() => ({
7✔
29
  textField: { minWidth: 400 },
2✔
30
  infoStyle: { minWidth: 400, borderBottom: 'none' },
2✔
31
  pickerStyle: { marginBottom: 15, width: 'min-content' }
2✔
32
}));
2✔
33

2✔
34
export const ScheduleRollout = ({ canSchedule, commonClasses, setDeploymentSettings, deploymentObject, open = false }) => {
7✔
35
  const [isPickerOpen, setIsPickerOpen] = useState(open);
120✔
36
  const { classes } = useStyles();
120✔
37

2✔
38
  const { phases = [] } = deploymentObject;
120✔
39

2✔
40
  const handleStartTimeChange = value => {
120✔
41
    // if there is no existing phase, set phase and start time
2✔
42
    if (!phases.length) {
2!
43
      setDeploymentSettings({ phases: [{ batch_size: 100, start_ts: value, delay: 0 }] });
2✔
44
    } else {
2✔
45
      //if there are existing phases, set the first phases to the new start time and adjust later phases in different function
2✔
46
      const newPhases = phases;
2✔
47
      newPhases[0].start_ts = value;
2✔
48
      setDeploymentSettings({ phases: newPhases });
2✔
49
    }
2✔
50
  };
2✔
51

2✔
52
  const handleStartChange = event => {
120✔
53
    // To be used with updated datetimepicker to open programmatically
2✔
54
    if (event.target.value) {
2!
55
      setIsPickerOpen(true);
2✔
56
    } else {
2✔
57
      handleStartTimeChange();
2✔
58
    }
2✔
59
  };
2✔
60

2✔
61
  const start_time = phases.length ? phases[0].start_ts : undefined;
120✔
62

2✔
63
  const startTime = dayjs(start_time);
120✔
64
  return (
120✔
65
    <>
2✔
66
      <h4 className={`margin-top-none ${canSchedule ? '' : commonClasses.disabled}`}>Select a start time</h4>
2✔
67
      <div className={commonClasses.columns}>
2✔
68
        <FormControl className={classes.pickerStyle} disabled={!canSchedule}>
2✔
69
          <Select className={classes.textField} onChange={handleStartChange} value={start_time ? 'custom' : 0}>
2✔
70
            <MenuItem value={0}>Start immediately</MenuItem>
2✔
71
            <MenuItem value="custom">Schedule the start date &amp; time</MenuItem>
2✔
72
          </Select>
2✔
73
        </FormControl>
2✔
74
        <InfoHintContainer>
2✔
75
          <EnterpriseNotification id={BENEFITS.scheduledDeployments.id} />
2✔
76
          <MenderHelpTooltip id={HELPTOOLTIPS.scheduleDeployment.id} />
2✔
77
        </InfoHintContainer>
2✔
78
      </div>
2✔
79
      {Boolean(isPickerOpen || start_time) && (
2✔
80
        <FormControl className={classes.pickerStyle} disabled={!canSchedule}>
2✔
81
          <DateTimePicker
2✔
82
            ampm={false}
2✔
83
            open={isPickerOpen}
2✔
UNCOV
84
            onOpen={() => setIsPickerOpen(true)}
2✔
UNCOV
85
            onClose={() => setIsPickerOpen(false)}
2✔
86
            label="Starting at"
2✔
87
            minDateTime={dayjs()}
2✔
88
            disabled={!canSchedule}
2✔
UNCOV
89
            onChange={date => handleStartTimeChange(date.toISOString())}
2✔
90
            slotProps={{ textField: { style: { minWidth: 400 } } }}
2✔
91
            value={startTime}
2✔
92
          />
2✔
93
        </FormControl>
2✔
94
      )}
2✔
95
    </>
2✔
96
  );
2✔
97
};
2✔
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