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

mendersoftware / gui / 913068021

pending completion
913068021

Pull #3802

gitlab-ci

mzedel
chore: made tags retrieval optional to ease image startup without connectivity or in non-hosted environments

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3802: Offline container startup support

4408 of 6421 branches covered (68.65%)

8338 of 10131 relevant lines covered (82.3%)

145.0 hits per line

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

64.38
/src/js/components/devices/authorized-devices.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, useMemo, useRef, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16
import { useNavigate } from 'react-router-dom';
17

18
// material ui
19
import { Autorenew as AutorenewIcon, Delete as DeleteIcon, FilterList as FilterListIcon, LockOutlined } from '@mui/icons-material';
20
import { Button, MenuItem, Select } from '@mui/material';
21
import { useTheme } from '@mui/material/styles';
22
import { makeStyles } from 'tss-react/mui';
23

24
import { setSnackbar } from '../../actions/appActions';
25
import { deleteAuthset, setDeviceFilters, setDeviceListState, updateDevicesAuth } from '../../actions/deviceActions';
26
import { getIssueCountsByType } from '../../actions/monitorActions';
27
import { advanceOnboarding } from '../../actions/onboardingActions';
28
import { saveUserSettings, updateUserColumnSettings } from '../../actions/userActions';
29
import { SORTING_OPTIONS, TIMEOUTS } from '../../constants/appConstants';
30
import { ALL_DEVICES, DEVICE_ISSUE_OPTIONS, DEVICE_STATES, UNGROUPED_GROUP } from '../../constants/deviceConstants';
31
import { onboardingSteps } from '../../constants/onboardingConstants';
32
import { duplicateFilter, toggle } from '../../helpers';
33
import {
34
  getAvailableIssueOptionsByType,
35
  getDeviceCountsByStatus,
36
  getDeviceFilters,
37
  getFeatures,
38
  getFilterAttributes,
39
  getIdAttribute,
40
  getLimitMaxed,
41
  getMappedDevicesList,
42
  getOnboardingState,
43
  getSelectedGroupInfo,
44
  getShowHelptips,
45
  getTenantCapabilities,
46
  getUserCapabilities,
47
  getUserSettings
48
} from '../../selectors';
49
import { useDebounce } from '../../utils/debouncehook';
50
import { getOnboardingComponentFor } from '../../utils/onboardingmanager';
51
import useWindowSize from '../../utils/resizehook';
52
import { clearAllRetryTimers, setRetryTimer } from '../../utils/retrytimer';
53
import Loader from '../common/loader';
54
import { ExpandDevice } from '../helptips/helptooltips';
55
import { defaultHeaders, defaultTextRender, getDeviceIdentityText, routes as states } from './base-devices';
56
import DeviceList, { minCellWidth } from './devicelist';
57
import ColumnCustomizationDialog from './dialogs/custom-columns-dialog';
58
import ExpandedDevice from './expanded-device';
59
import DeviceQuickActions from './widgets/devicequickactions';
60
import Filters from './widgets/filters';
61
import DeviceIssuesSelection from './widgets/issueselection';
62
import ListOptions from './widgets/listoptions';
63

64
const refreshDeviceLength = TIMEOUTS.refreshDefault;
9✔
65

66
const idAttributeTitleMap = {
9✔
67
  id: 'Device ID',
68
  name: 'Name'
69
};
70

71
const headersReducer = (accu, header) => {
9✔
72
  if (header.attribute.scope === accu.column.scope && (header.attribute.name === accu.column.name || header.attribute.alternative === accu.column.name)) {
×
73
    accu.header = { ...accu.header, ...header };
×
74
  }
75
  return accu;
×
76
};
77

78
const useStyles = makeStyles()(theme => ({
9✔
79
  filterCommon: {
80
    borderStyle: 'solid',
81
    borderWidth: 1,
82
    borderRadius: 5,
83
    borderColor: theme.palette.grey[100],
84
    background: theme.palette.background.default,
85
    [`.filter-list > .MuiChip-root`]: {
86
      marginBottom: theme.spacing()
87
    },
88
    [`.filter-list > .MuiChip-root > .MuiChip-label`]: {
89
      whiteSpace: 'normal'
90
    },
91
    ['&.filter-header']: {
92
      overflow: 'hidden',
93
      zIndex: 2
94
    },
95
    ['&.filter-toggle']: {
96
      background: 'transparent',
97
      borderBottomRightRadius: 0,
98
      borderBottomLeftRadius: 0,
99
      borderBottomColor: theme.palette.background.default,
100
      marginBottom: -1
101
    },
102
    ['&.filter-wrapper']: {
103
      padding: 20,
104
      borderTopLeftRadius: 0
105
    }
106
  }
107
}));
108

109
export const getHeaders = (columnSelection = [], currentStateHeaders, idAttribute, openSettingsDialog) => {
9!
110
  const headers = columnSelection.length
542!
111
    ? columnSelection.map(column => {
112
        let header = { ...column, attribute: { ...column }, textRender: defaultTextRender, sortable: true };
×
113
        header = Object.values(defaultHeaders).reduce(headersReducer, { column, header }).header;
×
114
        header = currentStateHeaders.reduce(headersReducer, { column, header }).header;
×
115
        return header;
×
116
      })
117
    : currentStateHeaders;
118
  return [
542✔
119
    {
120
      title: idAttributeTitleMap[idAttribute.attribute] ?? idAttribute.attribute,
625✔
121
      customize: openSettingsDialog,
122
      attribute: { name: idAttribute.attribute, scope: idAttribute.scope },
123
      sortable: true,
124
      textRender: getDeviceIdentityText
125
    },
126
    ...headers,
127
    defaultHeaders.deviceStatus
128
  ];
129
};
130

131
const calculateColumnSelectionSize = (changedColumns, customColumnSizes) =>
9✔
132
  changedColumns.reduce(
1✔
133
    (accu, column) => {
134
      const size = customColumnSizes.find(({ attribute }) => attribute.name === column.key && attribute.scope === column.scope)?.size || minCellWidth;
4✔
135
      accu.columnSizes.push({ attribute: { name: column.key, scope: column.scope }, size });
4✔
136
      accu.selectedAttributes.push({ attribute: column.key, scope: column.scope });
4✔
137
      return accu;
4✔
138
    },
139
    { columnSizes: [], selectedAttributes: [] }
140
  );
141

142
const OnboardingComponent = ({ authorizeRef, deviceListRef, onboardingState, selectedRows }) => {
9✔
143
  let onboardingComponent = null;
10✔
144
  if (deviceListRef.current) {
10✔
145
    const element = deviceListRef.current.querySelector('body .deviceListItem > div');
3✔
146
    const anchor = { left: 200, top: element ? element.offsetTop + element.offsetHeight : 170 };
3!
147
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
3✔
148
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED, onboardingState, { anchor }, onboardingComponent);
3✔
149
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
3✔
150
  }
151
  if (selectedRows && authorizeRef.current) {
10!
152
    const anchor = {
×
153
      left: authorizeRef.current.offsetLeft - authorizeRef.current.offsetWidth,
154
      top:
155
        authorizeRef.current.offsetTop +
156
        authorizeRef.current.offsetHeight -
157
        authorizeRef.current.lastElementChild.offsetHeight +
158
        authorizeRef.current.lastElementChild.firstElementChild.offsetHeight * 1.5
159
    };
160
    onboardingComponent = getOnboardingComponentFor(
×
161
      onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING,
162
      onboardingState,
163
      { place: 'left', anchor },
164
      onboardingComponent
165
    );
166
  }
167
  return onboardingComponent;
10✔
168
};
169

170
export const Authorized = ({
9✔
171
  addDevicesToGroup,
172
  onGroupClick,
173
  onGroupRemoval,
174
  onMakeGatewayClick,
175
  onPreauthClick,
176
  openSettingsDialog,
177
  removeDevicesFromGroup,
178
  showsDialog
179
}) => {
180
  const limitMaxed = useSelector(getLimitMaxed);
10✔
181
  const devices = useSelector(state => getMappedDevicesList(state, 'deviceList'));
10✔
182
  const { selectedGroup, groupFilters = [] } = useSelector(getSelectedGroupInfo);
10!
183
  const { columnSelection = [] } = useSelector(getUserSettings);
10!
184
  const attributes = useSelector(getFilterAttributes);
10✔
185
  const { accepted: acceptedCount, pending: pendingCount, rejected: rejectedCount } = useSelector(getDeviceCountsByStatus);
10✔
186
  const allCount = acceptedCount + rejectedCount;
10✔
187
  const availableIssueOptions = useSelector(getAvailableIssueOptionsByType);
10✔
188
  const customColumnSizes = useSelector(state => state.users.customColumns);
10✔
189
  const deviceListState = useSelector(state => state.devices.deviceList);
10✔
190
  const { total: deviceCount } = deviceListState;
10✔
191
  const features = useSelector(getFeatures);
10✔
192
  const filters = useSelector(getDeviceFilters);
10✔
193
  const idAttribute = useSelector(getIdAttribute);
10✔
194
  const onboardingState = useSelector(getOnboardingState);
10✔
195
  const settingsInitialized = useSelector(state => state.users.settingsInitialized);
10✔
196
  const showHelptips = useSelector(getShowHelptips);
10✔
197
  const tenantCapabilities = useSelector(getTenantCapabilities);
10✔
198
  const userCapabilities = useSelector(getUserCapabilities);
10✔
199
  const dispatch = useDispatch();
10✔
200
  const dispatchedSetSnackbar = (...args) => dispatch(setSnackbar(...args));
10✔
201

202
  const {
203
    refreshTrigger,
204
    selectedId,
205
    selectedIssues = [],
×
206
    isLoading: pageLoading,
207
    selection: selectedRows,
208
    sort = {},
×
209
    state: selectedState,
210
    detailsTab: tabSelection
211
  } = deviceListState;
10✔
212
  const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol } = sort;
10!
213
  const { canManageDevices } = userCapabilities;
10✔
214
  const { hasMonitor } = tenantCapabilities;
10✔
215
  const currentSelectedState = states[selectedState] ?? states.devices;
10!
216
  const [columnHeaders, setColumnHeaders] = useState([]);
10✔
217
  const [isInitialized, setIsInitialized] = useState(false);
10✔
218
  const [devicesInitialized, setDevicesInitialized] = useState(!!devices.length);
10✔
219
  const [showFilters, setShowFilters] = useState(false);
10✔
220
  const [showCustomization, setShowCustomization] = useState(false);
10✔
221
  const deviceListRef = useRef();
10✔
222
  const authorizeRef = useRef();
10✔
223
  const timer = useRef();
10✔
224
  const navigate = useNavigate();
10✔
225

226
  // eslint-disable-next-line no-unused-vars
227
  const size = useWindowSize();
10✔
228

229
  const { classes } = useStyles();
10✔
230

231
  useEffect(() => {
10✔
232
    clearAllRetryTimers(dispatchedSetSnackbar);
3✔
233
    if (!filters.length && selectedGroup && groupFilters.length) {
3!
234
      dispatch(setDeviceFilters(groupFilters));
×
235
    }
236
    return () => {
3✔
237
      clearInterval(timer.current);
3✔
238
      clearAllRetryTimers(dispatchedSetSnackbar);
3✔
239
    };
240
  }, []);
241

242
  useEffect(() => {
10✔
243
    const columnHeaders = getHeaders(columnSelection, currentSelectedState.defaultHeaders, idAttribute, openSettingsDialog);
3✔
244
    setColumnHeaders(columnHeaders);
3✔
245
  }, [columnSelection, selectedState, idAttribute.attribute]);
246

247
  useEffect(() => {
10✔
248
    // only set state after all devices id data retrieved
249
    setIsInitialized(isInitialized => isInitialized || (settingsInitialized && devicesInitialized && pageLoading === false));
4✔
250
    setDevicesInitialized(devicesInitialized => devicesInitialized || pageLoading === false);
4✔
251
  }, [settingsInitialized, devicesInitialized, pageLoading]);
252

253
  useEffect(() => {
10✔
254
    if (onboardingState.complete) {
3!
255
      return;
×
256
    }
257
    if (pendingCount) {
3!
258
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING_START));
3✔
259
      return;
3✔
260
    }
261
    if (!acceptedCount) {
×
262
      return;
×
263
    }
264
    dispatch(advanceOnboarding(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING));
×
265

266
    if (acceptedCount < 2) {
×
267
      if (!window.sessionStorage.getItem('pendings-redirect')) {
×
268
        window.sessionStorage.setItem('pendings-redirect', true);
×
269
        onDeviceStateSelectionChange(DEVICE_STATES.accepted);
×
270
      }
271
      setTimeout(() => {
×
272
        const notification = getOnboardingComponentFor(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING_NOTIFICATION, onboardingState, {
×
273
          setSnackbar: dispatchedSetSnackbar
274
        });
275
        !!notification && dispatchedSetSnackbar('open', TIMEOUTS.refreshDefault, '', notification, () => {}, true);
×
276
      }, 400);
277
    }
278
  }, [acceptedCount, allCount, pendingCount, onboardingState.complete]);
279

280
  useEffect(() => {
10✔
281
    setShowFilters(false);
3✔
282
  }, [selectedGroup]);
283

284
  useEffect(() => {
10✔
285
    if (!devicesInitialized) {
4✔
286
      return;
1✔
287
    }
288
    clearInterval(timer.current);
3✔
289
    timer.current = setInterval(
3✔
290
      () =>
291
        dispatch(setDeviceListState({ refreshTrigger: !refreshTrigger })).catch(err =>
×
292
          setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshDeviceLength, dispatchedSetSnackbar)
×
293
        ),
294
      refreshDeviceLength
295
    );
296
  }, [devicesInitialized, refreshTrigger]);
297

298
  useEffect(() => {
10✔
299
    Object.keys(availableIssueOptions).map(key => dispatch(getIssueCountsByType(key, { filters, group: selectedGroup, state: selectedState })));
3✔
300
    availableIssueOptions[DEVICE_ISSUE_OPTIONS.authRequests.key]
3!
301
      ? dispatch(getIssueCountsByType(DEVICE_ISSUE_OPTIONS.authRequests.key, { filters: [] }))
302
      : undefined;
303
  }, [selectedIssues, availableIssueOptions, selectedState, selectedGroup]);
304

305
  /*
306
   * Devices
307
   */
308
  const devicesToIds = devices => devices.map(device => device.id);
10✔
309

310
  const onRemoveDevicesFromGroup = devices => {
10✔
311
    const deviceIds = devicesToIds(devices);
×
312
    removeDevicesFromGroup(deviceIds);
×
313
    // if devices.length = number on page but < deviceCount
314
    // move page back to pageNO 1
315
    if (devices.length === deviceIds.length) {
×
316
      handlePageChange(1);
×
317
    }
318
  };
319

320
  const onAuthorizationChange = (devices, changedState) => {
10✔
321
    const deviceIds = devicesToIds(devices);
×
322
    return dispatch(setDeviceListState({ isLoading: true }))
×
323
      .then(() => dispatch(updateDevicesAuth(deviceIds, changedState)))
×
324
      .then(() => onSelectionChange([]));
×
325
  };
326

327
  const onDeviceDismiss = devices =>
10✔
328
    dispatch(setDeviceListState({ isLoading: true }))
×
329
      .then(() => {
330
        const deleteRequests = devices.reduce((accu, device) => {
×
331
          if (device.auth_sets?.length) {
×
332
            accu.push(dispatch(deleteAuthset(device.id, device.auth_sets[0].id)));
×
333
          }
334
          return accu;
×
335
        }, []);
336
        return Promise.all(deleteRequests);
×
337
      })
338
      .then(() => onSelectionChange([]));
×
339

340
  const handlePageChange = page => dispatch(setDeviceListState({ selectedId: undefined, page, refreshTrigger: !refreshTrigger }));
10✔
341

342
  const onPageLengthChange = perPage => dispatch(setDeviceListState({ perPage, page: 1, refreshTrigger: !refreshTrigger }));
10✔
343

344
  const refreshDevices = () => dispatch(setDeviceListState({ refreshTrigger: !refreshTrigger }));
10✔
345

346
  const onSortChange = attribute => {
10✔
347
    let changedSortCol = attribute.name;
×
348
    let changedSortDown = sortDown === SORTING_OPTIONS.desc ? SORTING_OPTIONS.asc : SORTING_OPTIONS.desc;
×
349
    if (changedSortCol !== sortCol) {
×
350
      changedSortDown = SORTING_OPTIONS.desc;
×
351
    }
352
    dispatch(
×
353
      setDeviceListState({
354
        sort: { direction: changedSortDown, key: changedSortCol, scope: attribute.scope },
355
        refreshTrigger: !refreshTrigger
356
      })
357
    );
358
  };
359

360
  const onFilterChange = () => handlePageChange(1);
10✔
361

362
  const onDeviceStateSelectionChange = newState => dispatch(setDeviceListState({ state: newState, page: 1, refreshTrigger: !refreshTrigger }));
10✔
363

364
  const setDetailsTab = detailsTab => dispatch(setDeviceListState({ detailsTab, setOnly: true }));
10✔
365

366
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
10✔
367
    dispatch(setDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger }));
1✔
368

369
  const onSelectionChange = (selection = []) => {
10!
370
    if (!onboardingState.complete && selection.length) {
1!
371
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING));
1✔
372
    }
373
    dispatch(setDeviceListState({ selection, setOnly: true }));
1✔
374
  };
375

376
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
10✔
377

378
  const onChangeColumns = (changedColumns, customColumnSizes) => {
10✔
379
    const { columnSizes, selectedAttributes } = calculateColumnSelectionSize(changedColumns, customColumnSizes);
1✔
380
    dispatch(updateUserColumnSettings(columnSizes));
1✔
381
    dispatch(saveUserSettings({ columnSelection: changedColumns }));
1✔
382
    // we don't need an explicit refresh trigger here, since the selectedAttributes will be different anyway & otherwise the shown list should still be valid
383
    dispatch(setDeviceListState({ selectedAttributes }));
1✔
384
    setShowCustomization(false);
1✔
385
  };
386

387
  const onExpandClick = (device = {}) => {
10!
388
    dispatchedSetSnackbar('');
×
389
    const { attributes = {}, id, status } = device;
×
390
    dispatch(setDeviceListState({ selectedId: deviceListState.selectedId === id ? undefined : id }));
×
391
    if (!onboardingState.complete) {
×
392
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING));
×
393
      if (status === DEVICE_STATES.accepted && Object.values(attributes).some(value => value)) {
×
394
        dispatch(advanceOnboarding(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING_NOTIFICATION));
×
395
      }
396
    }
397
  };
398

399
  const onCreateDeploymentClick = devices => navigate(`/deployments?open=true&${devices.map(({ id }) => `deviceId=${id}`).join('&')}`);
10✔
400

401
  const actionCallbacks = {
10✔
402
    onAddDevicesToGroup: addDevicesToGroup,
403
    onAuthorizationChange,
404
    onCreateDeployment: onCreateDeploymentClick,
405
    onDeviceDismiss,
406
    onPromoteGateway: onMakeGatewayClick,
407
    onRemoveDevicesFromGroup
408
  };
409

410
  const listOptionHandlers = [{ key: 'customize', title: 'Customize', onClick: onToggleCustomizationClick }];
10✔
411
  const devicePendingTip = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING_START, onboardingState);
10✔
412

413
  const EmptyState = currentSelectedState.emptyState;
10✔
414

415
  const groupLabel = selectedGroup ? decodeURIComponent(selectedGroup) : ALL_DEVICES;
10✔
416
  const isUngroupedGroup = selectedGroup && selectedGroup === UNGROUPED_GROUP.id;
10✔
417
  const selectedStaticGroup = selectedGroup && !groupFilters.length ? selectedGroup : undefined;
10✔
418

419
  const openedDevice = useDebounce(selectedId, TIMEOUTS.debounceShort);
10✔
420
  return (
10✔
421
    <>
422
      <div className="margin-left-small">
423
        <div className="flexbox">
424
          <h3 className="margin-right">{isUngroupedGroup ? UNGROUPED_GROUP.name : groupLabel}</h3>
10!
425
          <div className="flexbox space-between center-aligned" style={{ flexGrow: 1 }}>
426
            <div className="flexbox">
427
              <DeviceStateSelection onStateChange={onDeviceStateSelectionChange} selectedState={selectedState} states={states} />
428
              {hasMonitor && (
15✔
429
                <DeviceIssuesSelection onChange={onDeviceIssuesSelectionChange} options={Object.values(availableIssueOptions)} selection={selectedIssues} />
430
              )}
431
              {selectedGroup && !isUngroupedGroup && (
14✔
432
                <div className="margin-left muted flexbox centered">
433
                  {!groupFilters.length ? <LockOutlined fontSize="small" /> : <AutorenewIcon fontSize="small" />}
2!
434
                  <span>{!groupFilters.length ? 'Static' : 'Dynamic'}</span>
2!
435
                </div>
436
              )}
437
            </div>
438
            {canManageDevices && selectedGroup && !isUngroupedGroup && (
24✔
439
              <Button onClick={onGroupRemoval} startIcon={<DeleteIcon />}>
440
                Remove group
441
              </Button>
442
            )}
443
          </div>
444
        </div>
445
        <div className="flexbox space-between">
446
          {!isUngroupedGroup && (
20✔
447
            <div className={`flexbox centered filter-header ${showFilters ? `${classes.filterCommon} filter-toggle` : ''}`}>
10!
448
              <Button
449
                color="secondary"
450
                disableRipple
451
                onClick={() => setShowFilters(toggle)}
×
452
                startIcon={<FilterListIcon />}
453
                style={{ backgroundColor: 'transparent' }}
454
              >
455
                {filters.length > 0 ? `Filters (${filters.length})` : 'Filters'}
10!
456
              </Button>
457
            </div>
458
          )}
459
          <ListOptions options={listOptionHandlers} title="Table options" />
460
        </div>
461
        <Filters
462
          className={classes.filterCommon}
463
          onFilterChange={onFilterChange}
464
          onGroupClick={onGroupClick}
465
          isModification={!!groupFilters.length}
466
          open={showFilters}
467
        />
468
      </div>
469
      <Loader show={!isInitialized} />
470
      {isInitialized ? (
10✔
471
        devices.length > 0 ? (
6✔
472
          <div className="padding-bottom" ref={deviceListRef}>
473
            <DeviceList
474
              columnHeaders={columnHeaders}
475
              customColumnSizes={customColumnSizes}
476
              devices={devices}
477
              deviceListState={deviceListState}
478
              idAttribute={idAttribute}
479
              onChangeRowsPerPage={onPageLengthChange}
480
              onExpandClick={onExpandClick}
481
              onPageChange={handlePageChange}
482
              onResizeColumns={columns => dispatch(updateUserColumnSettings(columns))}
×
483
              onSelect={onSelectionChange}
484
              onSort={onSortChange}
485
              pageLoading={pageLoading}
486
              pageTotal={deviceCount}
487
            />
488
            {showHelptips && <ExpandDevice />}
10✔
489
          </div>
490
        ) : (
491
          <>
492
            {devicePendingTip && !showsDialog ? (
2!
493
              devicePendingTip
494
            ) : (
495
              <EmptyState
496
                allCount={allCount}
497
                canManageDevices={canManageDevices}
498
                filters={filters}
499
                highlightHelp={showHelptips}
500
                limitMaxed={limitMaxed}
501
                onClick={onPreauthClick}
502
              />
503
            )}
504
          </>
505
        )
506
      ) : (
507
        <div />
508
      )}
509
      <ExpandedDevice
510
        actionCallbacks={actionCallbacks}
511
        deviceId={openedDevice}
512
        onClose={() => dispatch(setDeviceListState({ selectedId: undefined }))}
×
513
        refreshDevices={refreshDevices}
514
        setDetailsTab={setDetailsTab}
515
        tabSelection={tabSelection}
516
      />
517
      {!selectedId && (
20✔
518
        <OnboardingComponent authorizeRef={authorizeRef} deviceListRef={deviceListRef} onboardingState={onboardingState} selectedRows={selectedRows} />
519
      )}
520
      {canManageDevices && !!selectedRows.length && (
20!
521
        <DeviceQuickActions
522
          actionCallbacks={actionCallbacks}
523
          devices={devices}
524
          features={features}
525
          selectedGroup={selectedStaticGroup}
526
          selectedRows={selectedRows}
527
          ref={authorizeRef}
528
          tenantCapabilities={tenantCapabilities}
529
          userCapabilities={userCapabilities}
530
        />
531
      )}
532
      <ColumnCustomizationDialog
533
        attributes={attributes}
534
        columnHeaders={columnHeaders}
535
        customColumnSizes={customColumnSizes}
536
        idAttribute={idAttribute}
537
        open={showCustomization}
538
        onCancel={onToggleCustomizationClick}
539
        onSubmit={onChangeColumns}
540
      />
541
    </>
542
  );
543
};
544

545
export default Authorized;
546

547
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
9!
548
  const theme = useTheme();
12✔
549
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
12✔
550

551
  return (
12✔
552
    <div className="flexbox centered">
553
      Status:
554
      <Select
555
        disableUnderline
556
        onChange={e => onStateChange(e.target.value)}
1✔
557
        value={selectedState}
558
        style={{ fontSize: 13, marginLeft: theme.spacing(), marginTop: 2 }}
559
      >
560
        {availableStates.map(state => (
561
          <MenuItem key={state.key} value={state.key}>
62✔
562
            {state.title()}
563
          </MenuItem>
564
        ))}
565
      </Select>
566
    </div>
567
  );
568
};
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