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

mendersoftware / gui / 901187442

pending completion
901187442

Pull #3795

gitlab-ci

mzedel
feat: increased chances of adopting our intended navigation patterns instead of unsupported browser navigation

Ticket: None
Changelog: None
Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3795: feat: increased chances of adopting our intended navigation patterns instead of unsupported browser navigation

4389 of 6365 branches covered (68.96%)

5 of 5 new or added lines in 1 file covered. (100.0%)

1729 existing lines in 165 files now uncovered.

8274 of 10019 relevant lines covered (82.58%)

144.86 hits per line

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

82.89
/src/js/components/common/dialogs/deviceconnectiondialog.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, { useEffect, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16
import { useNavigate } from 'react-router-dom';
17

18
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';
19
import { makeStyles } from 'tss-react/mui';
20

21
import docker from '../../../../assets/img/docker.png';
22
import raspberryPi4 from '../../../../assets/img/raspberrypi4.png';
23
import raspberryPi from '../../../../assets/img/raspberrypi.png';
24
import { setDeviceListState } from '../../../actions/deviceActions';
25
import { advanceOnboarding } from '../../../actions/onboardingActions';
26
import { TIMEOUTS } from '../../../constants/appConstants';
27
import { DEVICE_STATES } from '../../../constants/deviceConstants';
28
import { onboardingSteps } from '../../../constants/onboardingConstants';
29
import { getDeviceCountsByStatus, getDocsVersion, getOnboardingState, getTenantCapabilities } from '../../../selectors';
30
import InfoText from '../../common/infotext';
31
import { DeviceSupportTip } from '../../helptips/helptooltips';
32
import PhysicalDeviceOnboarding from './physicaldeviceonboarding';
33
import VirtualDeviceOnboarding from './virtualdeviceonboarding';
34

35
const useStyles = makeStyles()(theme => ({
3✔
36
  rpiQuickstart: {
37
    backgroundColor: theme.palette.background.lightgrey
38
  },
39
  virtualLogo: { height: 40, marginLeft: theme.spacing(2) }
40
}));
41

42
const DeviceConnectionExplainer = ({ docsVersion, hasMonitor, setOnDevice, setVirtualDevice }) => {
3✔
43
  const { classes } = useStyles();
3✔
44
  return (
3✔
45
    <>
46
      <p>
47
        You can connect almost any device and Linux OS with Mender, but to make things simple during evaluation we recommend you use a Raspberry Pi as a test
48
        device.
49
      </p>
50
      <div className={`padding-small padding-top-none rpi-quickstart ${classes.rpiQuickstart}`}>
51
        <h3>Raspberry Pi quick start</h3>
52
        <p>We&apos;ll walk you through the steps to connect a Raspberry Pi and deploy your first update with Mender.</p>
53
        <div className="flexbox column centered">
54
          <div className="flexbox centered os-list">
55
            {[raspberryPi, raspberryPi4].map((tile, index) => (
56
              <img key={`tile-${index}`} src={tile} />
6✔
57
            ))}
58
          </div>
59
          <Button variant="contained" color="secondary" onClick={() => setOnDevice(true)}>
1✔
60
            Get Started
61
          </Button>
62
        </div>
63
      </div>
64
      <div className="two-columns margin-top">
65
        <div className="padding-small padding-top-none">
66
          <div className="flexbox center-aligned">
67
            <h3>Use a virtual device</h3>
68
            <img src={docker} className={classes.virtualLogo} />
69
          </div>
70
          <p className="margin-top-none">Don&apos;t have a Raspberry Pi?</p>
71
          <p>You can use our Docker-run virtual device to go through the same tutorial.</p>
72
          {hasMonitor && (
3!
73
            <InfoText className="slightly-smaller">
74
              If you want to evaluate our commercial components such as mender-monitor, please use a physical device instead as the virtual client does not
75
              support these components at this time.
76
            </InfoText>
77
          )}
78
          <a onClick={() => setVirtualDevice(true)}>Try a virtual device</a>
1✔
79
        </div>
80
        <div className="padding-small padding-top-none">
81
          <h3>Other devices</h3>
82
          <div>See the documentation to integrate the following with Mender:</div>
83
          <ul>
84
            {[
85
              { key: 'debian', target: `https://docs.mender.io/${docsVersion}operating-system-updates-debian-family`, title: 'Debian family' },
86
              { key: 'yocto', target: `https://docs.mender.io/${docsVersion}operating-system-updates-yocto-project`, title: 'Yocto OSes' }
87
            ].map(item => (
88
              <li key={item.key}>
6✔
89
                <a href={item.target} target="_blank" rel="noopener noreferrer">
90
                  {item.title}
91
                </a>
92
              </li>
93
            ))}
94
          </ul>
95
          Or visit{' '}
96
          <a href="https://hub.mender.io/c/board-integrations" target="_blank" rel="noopener noreferrer">
97
            Mender Hub
98
          </a>{' '}
99
          and search integrations for your device and OS.
100
        </div>
101
      </div>
102
      <DeviceSupportTip />
103
    </>
104
  );
105
};
106

107
export const DeviceConnectionDialog = ({ onCancel }) => {
3✔
108
  const [onDevice, setOnDevice] = useState(false);
5✔
109
  const [progress, setProgress] = useState(1);
5✔
110
  const [virtualDevice, setVirtualDevice] = useState(false);
5✔
111
  const { pending: pendingCount } = useSelector(getDeviceCountsByStatus);
5✔
112
  const [pendingDevicesCount] = useState(pendingCount);
5✔
113
  const [hasMoreDevices, setHasMoreDevices] = useState(false);
5✔
114
  const docsVersion = useSelector(getDocsVersion);
5✔
115
  const { hasMonitor } = useSelector(getTenantCapabilities);
5✔
116
  const { complete: onboardingComplete, deviceType: onboardingDeviceType } = useSelector(getOnboardingState);
5✔
117
  const dispatch = useDispatch();
5✔
118
  const navigate = useNavigate();
5✔
119

120
  useEffect(() => {
5✔
121
    setHasMoreDevices(pendingCount > pendingDevicesCount);
2✔
122
  }, [pendingDevicesCount, pendingCount]);
123

124
  useEffect(() => {
5✔
125
    if ((virtualDevice || progress >= 2) && hasMoreDevices && !window.location.hash.includes('pending')) {
3!
UNCOV
126
      dispatch(advanceOnboarding(onboardingSteps.DASHBOARD_ONBOARDING_START));
×
UNCOV
127
      dispatch(setDeviceListState({ state: DEVICE_STATES.pending }));
×
UNCOV
128
      navigate('/devices/pending');
×
129
    }
130
  }, [advanceOnboarding, hasMoreDevices, progress, virtualDevice]);
131

132
  const onBackClick = () => {
5✔
133
    let updatedProgress = progress - 1;
1✔
134
    if (!updatedProgress) {
1!
135
      updatedProgress = 1;
1✔
136
      setOnDevice(false);
1✔
137
      setVirtualDevice(false);
1✔
138
    }
139
    setProgress(updatedProgress);
1✔
140
  };
141

142
  const onAdvance = () => {
5✔
UNCOV
143
    dispatch(advanceOnboarding(onboardingSteps.DASHBOARD_ONBOARDING_START));
×
UNCOV
144
    setProgress(progress + 1);
×
145
  };
146

147
  let content = <DeviceConnectionExplainer docsVersion={docsVersion} hasMonitor={hasMonitor} setOnDevice={setOnDevice} setVirtualDevice={setVirtualDevice} />;
5✔
148
  if (onDevice) {
5✔
149
    content = <PhysicalDeviceOnboarding progress={progress} />;
1✔
150
  } else if (virtualDevice) {
4✔
151
    content = <VirtualDeviceOnboarding />;
1✔
152
  }
153

154
  if (hasMoreDevices && !onboardingComplete) {
5!
UNCOV
155
    setTimeout(onCancel, TIMEOUTS.twoSeconds);
×
156
  }
157

158
  return (
5✔
159
    <Dialog open={true} PaperProps={{ sx: { maxWidth: '720px' } }}>
160
      <DialogTitle>Connecting a device</DialogTitle>
161
      <DialogContent className="onboard-dialog" style={{ margin: '0 30px' }}>
162
        {content}
163
      </DialogContent>
164
      <DialogActions>
165
        <Button onClick={onCancel}>Cancel</Button>
166
        <div style={{ flexGrow: 1 }} />
167
        {(onDevice || virtualDevice) && (
11✔
168
          <div>
169
            <Button onClick={onBackClick}>Back</Button>
170
            {progress < 2 && (!virtualDevice || progress < 1) ? (
7✔
171
              <Button variant="contained" disabled={!(virtualDevice || (onDevice && onboardingDeviceType))} onClick={onAdvance}>
3✔
172
                Next
173
              </Button>
174
            ) : (
175
              <Button variant="contained" disabled={!onboardingComplete} onClick={onCancel}>
176
                {onboardingComplete ? 'Close' : 'Waiting for device'}
1!
177
              </Button>
178
            )}
179
          </div>
180
        )}
181
      </DialogActions>
182
    </Dialog>
183
  );
184
};
185

186
export default DeviceConnectionDialog;
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