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

mendersoftware / gui / 917894278

pending completion
917894278

Pull #3837

gitlab-ci

web-flow
chore: bump @playwright/test from 1.35.0 to 1.35.1 in /tests/e2e_tests

Bumps [@playwright/test](https://github.com/Microsoft/playwright) from 1.35.0 to 1.35.1.
- [Release notes](https://github.com/Microsoft/playwright/releases)
- [Commits](https://github.com/Microsoft/playwright/compare/v1.35.0...v1.35.1)

---
updated-dependencies:
- dependency-name: "@playwright/test"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3837: chore: bump @playwright/test from 1.35.0 to 1.35.1 in /tests/e2e_tests

4399 of 6397 branches covered (68.77%)

8302 of 10074 relevant lines covered (82.41%)

167.35 hits per line

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

75.63
/src/js/components/header/header.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, { useEffect, useRef, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16
import { Link } from 'react-router-dom';
17

18
import {
19
  AccountCircle as AccountCircleIcon,
20
  ArrowDropDown as ArrowDropDownIcon,
21
  ArrowDropUp as ArrowDropUpIcon,
22
  ExitToApp as ExitIcon
23
} from '@mui/icons-material';
24
import { Button, IconButton, ListItemSecondaryAction, ListItemText, Menu, MenuItem, Toolbar } from '@mui/material';
25
import { makeStyles } from 'tss-react/mui';
26

27
import moment from 'moment';
28
import Cookies from 'universal-cookie';
29

30
import enterpriseLogo from '../../../assets/img/headerlogo-enterprise.png';
31
import logo from '../../../assets/img/headerlogo.png';
32
import whiteEnterpriseLogo from '../../../assets/img/whiteheaderlogo-enterprise.png';
33
import whiteLogo from '../../../assets/img/whiteheaderlogo.png';
34
import { setFirstLoginAfterSignup, setSearchState } from '../../actions/appActions';
35
import { getAllDeviceCounts } from '../../actions/deviceActions';
36
import { initializeSelf, logoutUser, setHideAnnouncement, toggleHelptips } from '../../actions/userActions';
37
import { getToken } from '../../auth';
38
import { TIMEOUTS } from '../../constants/appConstants';
39
import { decodeSessionToken, isDarkMode } from '../../helpers';
40
import {
41
  getAcceptedDevices,
42
  getCurrentUser,
43
  getDeviceCountsByStatus,
44
  getDeviceLimit,
45
  getDocsVersion,
46
  getFeatures,
47
  getIsEnterprise,
48
  getOrganization,
49
  getShowHelptips,
50
  getUserCapabilities,
51
  getUserSettings
52
} from '../../selectors';
53
import Tracking from '../../tracking';
54
import { useDebounce } from '../../utils/debouncehook';
55
import Search from '../common/search';
56
import Announcement from './announcement';
57
import DemoNotification from './demonotification';
58
import DeploymentNotifications from './deploymentnotifications';
59
import DeviceNotifications from './devicenotifications';
60
import OfferHeader from './offerheader';
61
import TrialNotification from './trialnotification';
62

63
// Change this when a new feature/offer is introduced
64
const currentOffer = {
3✔
65
  name: 'add-ons',
66
  expires: '2021-12-30',
67
  trial: true,
68
  os: true,
69
  professional: true,
70
  enterprise: true
71
};
72

73
const cookies = new Cookies();
3✔
74

75
const useStyles = makeStyles()(theme => ({
53✔
76
  header: {
77
    minHeight: 'unset',
78
    paddingLeft: theme.spacing(4),
79
    paddingRight: theme.spacing(5),
80
    width: '100%',
81
    borderBottom: `1px solid ${theme.palette.grey[100]}`,
82
    display: 'grid'
83
  },
84
  banner: { gridTemplateRows: `1fr ${theme.mixins.toolbar.minHeight}px` },
85
  buttonColor: { color: theme.palette.grey[600] },
86
  dropDown: { height: '100%', marginLeft: theme.spacing(0.5), textTransform: 'none' },
87
  exitIcon: { color: theme.palette.grey[600], fill: theme.palette.grey[600] },
88
  demoTrialAnnouncement: {
89
    fontSize: 14,
90
    height: 'auto'
91
  },
92
  demoAnnouncementIcon: {
93
    height: 16,
94
    color: theme.palette.primary.main,
95
    '&.MuiButton-textPrimary': {
96
      color: theme.palette.primary.main,
97
      height: 'inherit'
98
    }
99
  },
100
  redAnnouncementIcon: {
101
    color: theme.palette.error.dark
102
  }
103
}));
104

105
export const Header = ({ mode }) => {
3✔
106
  const { classes } = useStyles();
570✔
107
  const [anchorEl, setAnchorEl] = useState(null);
570✔
108
  const [loggingOut, setLoggingOut] = useState(false);
570✔
109
  const [gettingUser, setGettingUser] = useState(false);
570✔
110
  const [hasOfferCookie, setHasOfferCookie] = useState(false);
570✔
111
  const sessionId = useDebounce(getToken(), TIMEOUTS.debounceDefault);
570✔
112

113
  const organization = useSelector(getOrganization);
570✔
114
  const { canManageUsers: allowUserManagement } = useSelector(getUserCapabilities);
570✔
115
  const { total: acceptedDevices = 0 } = useSelector(getAcceptedDevices);
570!
116
  const announcement = useSelector(state => state.app.hostedAnnouncement);
1,162✔
117
  const deviceLimit = useSelector(getDeviceLimit);
570✔
118
  const docsVersion = useSelector(getDocsVersion);
570✔
119
  const firstLoginAfterSignup = useSelector(state => state.app.firstLoginAfterSignup);
1,162✔
120
  const { trackingConsentGiven: hasTrackingEnabled } = useSelector(getUserSettings);
570✔
121
  const inProgress = useSelector(state => state.deployments.byStatus.inprogress.total);
1,162✔
122
  const isEnterprise = useSelector(getIsEnterprise);
570✔
123
  const { isDemoMode: demo, hasMultitenancy, isHosted } = useSelector(getFeatures);
570✔
124
  const { isSearching, searchTerm, refreshTrigger } = useSelector(state => state.app.searchState);
1,162✔
125
  const multitenancy = hasMultitenancy || isEnterprise || isHosted;
570✔
126
  const showHelptips = useSelector(getShowHelptips);
570✔
127
  const { pending: pendingDevices } = useSelector(getDeviceCountsByStatus);
570✔
128
  const user = useSelector(getCurrentUser);
570✔
129
  const dispatch = useDispatch();
570✔
130
  const deviceTimer = useRef();
570✔
131

132
  useEffect(() => {
570✔
133
    if ((!sessionId || !user?.id || !user.email.length) && !gettingUser && !loggingOut) {
9✔
134
      updateUsername();
2✔
135
      return;
2✔
136
    }
137
    Tracking.setTrackingEnabled(hasTrackingEnabled);
7✔
138
    if (hasTrackingEnabled && user.id && organization.id) {
7!
139
      Tracking.setOrganizationUser(organization, user);
×
140
      if (firstLoginAfterSignup) {
×
141
        Tracking.pageview('/signup/complete');
×
142
        dispatch(setFirstLoginAfterSignup(false));
×
143
      }
144
    }
145
  }, [sessionId, user.id, user.email, gettingUser, loggingOut]);
146

147
  useEffect(() => {
570✔
148
    const showOfferCookie = cookies.get('offer') === currentOffer.name;
6✔
149
    setHasOfferCookie(showOfferCookie);
6✔
150
    clearInterval(deviceTimer.current);
6✔
151
    deviceTimer.current = setInterval(() => dispatch(getAllDeviceCounts()), TIMEOUTS.refreshDefault);
180✔
152
    return () => {
6✔
153
      clearInterval(deviceTimer.current);
6✔
154
    };
155
  }, []);
156

157
  const updateUsername = () => {
570✔
158
    const userId = decodeSessionToken(getToken());
2✔
159
    if (gettingUser || !userId) {
2✔
160
      return;
1✔
161
    }
162
    setGettingUser(true);
1✔
163
    // get current user
164
    return dispatch(initializeSelf()).finally(() => setGettingUser(false));
1✔
165
  };
166

167
  const onLogoutClick = () => {
570✔
168
    setGettingUser(false);
1✔
169
    setLoggingOut(true);
1✔
170
    setAnchorEl(null);
1✔
171
    dispatch(logoutUser());
1✔
172
  };
173

174
  const onSearch = searchTerm => dispatch(setSearchState({ refreshTrigger: !refreshTrigger, searchTerm, page: 1 }));
570✔
175

176
  const setHideOffer = () => {
570✔
177
    cookies.set('offer', currentOffer.name, { path: '/', maxAge: 2629746 });
×
178
    setHasOfferCookie(true);
×
179
  };
180

181
  const showOffer =
182
    isHosted && moment().isBefore(currentOffer.expires) && (organization.trial ? currentOffer.trial : currentOffer[organization.plan]) && !hasOfferCookie;
570!
183

184
  const headerLogo = isDarkMode(mode) ? (isEnterprise ? whiteEnterpriseLogo : whiteLogo) : isEnterprise ? enterpriseLogo : logo;
570!
185

186
  return (
570✔
187
    <Toolbar id="fixedHeader" className={showOffer ? `${classes.header} ${classes.banner}` : classes.header}>
570!
188
      {!!announcement && (
614✔
189
        <Announcement
190
          announcement={announcement}
191
          errorIconClassName={classes.redAnnouncementIcon}
192
          iconClassName={classes.demoAnnouncementIcon}
193
          sectionClassName={classes.demoTrialAnnouncement}
194
          onHide={() => dispatch(setHideAnnouncement(true))}
×
195
        />
196
      )}
197
      {showOffer && <OfferHeader docsVersion={docsVersion} onHide={setHideOffer} />}
570!
198
      <div className="flexbox space-between">
199
        <div className="flexbox center-aligned">
200
          <Link to="/">
201
            <img id="logo" src={headerLogo} />
202
          </Link>
203
          {demo && <DemoNotification iconClassName={classes.demoAnnouncementIcon} sectionClassName={classes.demoTrialAnnouncement} docsVersion={docsVersion} />}
570!
204
          {organization.trial && (
570!
205
            <TrialNotification
206
              expiration={organization.trial_expiration}
207
              iconClassName={classes.demoAnnouncementIcon}
208
              sectionClassName={classes.demoTrialAnnouncement}
209
            />
210
          )}
211
        </div>
212
        <Search isSearching={isSearching} searchTerm={searchTerm} onSearch={onSearch} />
213
        <div className="flexbox center-aligned">
214
          <DeviceNotifications pending={pendingDevices} total={acceptedDevices} limit={deviceLimit} />
215
          <DeploymentNotifications inprogress={inProgress} />
216
          <Button
217
            className={`header-dropdown ${classes.dropDown}`}
218
            onClick={e => setAnchorEl(e.currentTarget)}
1✔
219
            startIcon={<AccountCircleIcon className={classes.buttonColor} />}
220
            endIcon={anchorEl ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
570✔
221
          >
222
            {user.email}
223
          </Button>
224
          <Menu
225
            anchorEl={anchorEl}
226
            onClose={() => setAnchorEl(null)}
×
227
            open={Boolean(anchorEl)}
228
            anchorOrigin={{
229
              vertical: 'center',
230
              horizontal: 'center'
231
            }}
232
            transformOrigin={{
233
              vertical: 'bottom',
234
              horizontal: 'center'
235
            }}
236
          >
237
            <MenuItem component={Link} to="/settings">
238
              Settings
239
            </MenuItem>
240
            <MenuItem component={Link} to="/settings/my-profile">
241
              My profile
242
            </MenuItem>
243
            {multitenancy && (
1,131✔
244
              <MenuItem component={Link} to="/settings/organization-and-billing">
245
                My organization
246
              </MenuItem>
247
            )}
248
            {allowUserManagement && (
649✔
249
              <MenuItem component={Link} to="/settings/user-management">
250
                User management
251
              </MenuItem>
252
            )}
253
            <MenuItem onClick={() => dispatch(toggleHelptips())}>{showHelptips ? 'Hide help tooltips' : 'Show help tooltips'}</MenuItem>
×
254
            <MenuItem component={Link} to="/help/get-started">
255
              Help & support
256
            </MenuItem>
257
            <MenuItem onClick={onLogoutClick}>
258
              <ListItemText primary="Log out" />
259
              <ListItemSecondaryAction>
260
                <IconButton>
261
                  <ExitIcon className={classes.exitIcon} />
262
                </IconButton>
263
              </ListItemSecondaryAction>
264
            </MenuItem>
265
          </Menu>
266
        </div>
267
      </div>
268
    </Toolbar>
269
  );
270
};
271

272
export default Header;
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