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

mendersoftware / gui / 1113439055

19 Dec 2023 09:01PM UTC coverage: 82.752% (-17.2%) from 99.964%
1113439055

Pull #4258

gitlab-ci

mender-test-bot
chore: Types update

Signed-off-by: Mender Test Bot <mender@northern.tech>
Pull Request #4258: chore: Types update

4326 of 6319 branches covered (0.0%)

8348 of 10088 relevant lines covered (82.75%)

189.39 hits per line

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

73.84
/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, { useCallback, 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 { makeStyles } from 'tss-react/mui';
22

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

60
const deviceRefreshTimes = {
8✔
61
  [DEVICE_STATES.accepted]: TIMEOUTS.refreshLong,
62
  [DEVICE_STATES.pending]: TIMEOUTS.refreshDefault,
63
  [DEVICE_STATES.preauth]: TIMEOUTS.refreshLong,
64
  [DEVICE_STATES.rejected]: TIMEOUTS.refreshLong,
65
  default: TIMEOUTS.refreshDefault
66
};
67

68
const idAttributeTitleMap = {
8✔
69
  id: 'Device ID',
70
  name: 'Name'
71
};
72

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

80
const useStyles = makeStyles()(theme => ({
8✔
81
  filterCommon: {
82
    borderStyle: 'solid',
83
    borderWidth: 1,
84
    borderRadius: 5,
85
    borderColor: theme.palette.grey[100],
86
    background: theme.palette.background.default,
87
    [`.filter-list > .MuiChip-root`]: {
88
      marginBottom: theme.spacing()
89
    },
90
    [`.filter-list > .MuiChip-root > .MuiChip-label`]: {
91
      whiteSpace: 'normal'
92
    },
93
    ['&.filter-header']: {
94
      overflow: 'hidden',
95
      zIndex: 2
96
    },
97
    ['&.filter-toggle']: {
98
      background: 'transparent',
99
      borderBottomRightRadius: 0,
100
      borderBottomLeftRadius: 0,
101
      borderBottomColor: theme.palette.background.default,
102
      marginBottom: -1
103
    },
104
    ['&.filter-wrapper']: {
105
      padding: 20,
106
      borderTopLeftRadius: 0
107
    }
108
  },
109
  selection: {
110
    fontSize: 13,
111
    marginLeft: theme.spacing(0.5),
112
    marginTop: 2,
113
    '>div': {
114
      paddingLeft: theme.spacing(0.5)
115
    }
116
  }
117
}));
118

119
export const getHeaders = (columnSelection = [], currentStateHeaders, idAttribute, openSettingsDialog) => {
8!
120
  const headers = columnSelection.length
960!
121
    ? columnSelection.map(column => {
122
        let header = { ...column, attribute: { ...column }, textRender: defaultTextRender, sortable: true };
×
123
        header = Object.values(defaultHeaders).reduce(headersReducer, { column, header }).header;
×
124
        header = currentStateHeaders.reduce(headersReducer, { column, header }).header;
×
125
        return header;
×
126
      })
127
    : currentStateHeaders;
128
  return [
960✔
129
    {
130
      title: idAttributeTitleMap[idAttribute.attribute] ?? idAttribute.attribute,
961✔
131
      customize: openSettingsDialog,
132
      attribute: { name: idAttribute.attribute, scope: idAttribute.scope },
133
      sortable: true,
134
      textRender: getDeviceIdentityText
135
    },
136
    ...headers,
137
    defaultHeaders.deviceStatus
138
  ];
139
};
140

141
const calculateColumnSelectionSize = (changedColumns, customColumnSizes) =>
8✔
142
  changedColumns.reduce(
1✔
143
    (accu, column) => {
144
      const size = customColumnSizes.find(({ attribute }) => attribute.name === column.key && attribute.scope === column.scope)?.size || minCellWidth;
4✔
145
      accu.columnSizes.push({ attribute: { name: column.key, scope: column.scope }, size });
4✔
146
      accu.selectedAttributes.push({ attribute: column.key, scope: column.scope });
4✔
147
      return accu;
4✔
148
    },
149
    { columnSizes: [], selectedAttributes: [] }
150
  );
151

152
const OnboardingComponent = ({ deviceListRef, onboardingState }) => {
8✔
153
  let onboardingComponent = null;
23✔
154
  const element = deviceListRef.current?.querySelector('body .deviceListItem > div');
23✔
155
  if (element) {
23✔
156
    const anchor = { left: 200, top: element.offsetTop + element.offsetHeight };
18✔
157
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
18✔
158
  } else if (deviceListRef.current) {
5✔
159
    const anchor = { top: deviceListRef.current.offsetTop + deviceListRef.current.offsetHeight / 3, left: deviceListRef.current.offsetWidth / 2 + 30 };
2✔
160
    onboardingComponent = getOnboardingComponentFor(
2✔
161
      onboardingSteps.DEVICES_PENDING_ONBOARDING_START,
162
      onboardingState,
163
      { anchor, place: 'top' },
164
      onboardingComponent
165
    );
166
  }
167
  return onboardingComponent;
23✔
168
};
169

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

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

223
  // eslint-disable-next-line no-unused-vars
224
  const size = useWindowSize();
26✔
225

226
  const { classes } = useStyles();
26✔
227

228
  useEffect(() => {
26✔
229
    clearAllRetryTimers(dispatchedSetSnackbar);
3✔
230
    if (!filters.length && selectedGroup && groupFilters.length) {
3!
231
      dispatch(setDeviceFilters(groupFilters));
×
232
    }
233
    return () => {
3✔
234
      clearInterval(timer.current);
3✔
235
      clearAllRetryTimers(dispatchedSetSnackbar);
3✔
236
    };
237
    // eslint-disable-next-line react-hooks/exhaustive-deps
238
  }, [dispatch, dispatchedSetSnackbar]);
239

240
  useEffect(() => {
26✔
241
    const columnHeaders = getHeaders(columnSelection, currentSelectedState.defaultHeaders, idAttribute, openSettingsDialog);
6✔
242
    setColumnHeaders(columnHeaders);
6✔
243
    // eslint-disable-next-line react-hooks/exhaustive-deps
244
  }, [columnSelection, idAttribute.attribute, currentSelectedState.defaultHeaders, openSettingsDialog]);
245

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

252
  const onDeviceStateSelectionChange = useCallback(
26✔
253
    newState => dispatch(setDeviceListState({ state: newState, page: 1, refreshTrigger: !refreshTrigger })),
×
254
    [dispatch, refreshTrigger]
255
  );
256

257
  useEffect(() => {
26✔
258
    if (onboardingState.complete) {
6!
259
      return;
×
260
    }
261
    if (pendingCount) {
6!
262
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING_START));
6✔
263
      return;
6✔
264
    }
265
    if (!acceptedCount) {
×
266
      return;
×
267
    }
268
    dispatch(advanceOnboarding(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING));
×
269

270
    if (acceptedCount < 2 && !window.sessionStorage.getItem('pendings-redirect')) {
×
271
      window.sessionStorage.setItem('pendings-redirect', true);
×
272
      onDeviceStateSelectionChange(DEVICE_STATES.accepted);
×
273
    }
274
    // eslint-disable-next-line react-hooks/exhaustive-deps
275
  }, [acceptedCount, allCount, pendingCount, onboardingState.complete, dispatch, onDeviceStateSelectionChange, dispatchedSetSnackbar]);
276

277
  useEffect(() => {
26✔
278
    setShowFilters(false);
3✔
279
  }, [selectedGroup]);
280

281
  const refreshDevices = useCallback(() => {
26✔
282
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
×
283
    return dispatch(setDeviceListState({}, true, true)).catch(err =>
×
284
      setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshLength, dispatchedSetSnackbar)
×
285
    );
286
  }, [dispatch, dispatchedSetSnackbar, selectedState]);
287

288
  useEffect(() => {
26✔
289
    if (!devicesInitialized) {
4✔
290
      return;
1✔
291
    }
292
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
3!
293
    clearInterval(timer.current);
3✔
294
    timer.current = setInterval(() => refreshDevices(), refreshLength);
3✔
295
  }, [devicesInitialized, refreshDevices, selectedState]);
296

297
  useEffect(() => {
26✔
298
    Object.keys(availableIssueOptions).map(key => dispatch(getIssueCountsByType(key, { filters, group: selectedGroup, state: selectedState })));
6✔
299
    availableIssueOptions[DEVICE_ISSUE_OPTIONS.authRequests.key]
5!
300
      ? dispatch(getIssueCountsByType(DEVICE_ISSUE_OPTIONS.authRequests.key, { filters: [] }))
301
      : undefined;
302
    // eslint-disable-next-line react-hooks/exhaustive-deps
303
  }, [selectedIssues.join(''), JSON.stringify(availableIssueOptions), selectedState, selectedGroup, dispatch, JSON.stringify(filters)]);
304

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

310
  const onRemoveDevicesFromGroup = devices => {
26✔
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) => {
26✔
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 =>
26✔
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 = useCallback(page => dispatch(setDeviceListState({ selectedId: undefined, page })), [dispatch]);
26✔
341

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

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

358
  const setDetailsTab = detailsTab => dispatch(setDeviceListState({ detailsTab, setOnly: true }));
26✔
359

360
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
26✔
361
    dispatch(setDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger }));
1✔
362

363
  const onSelectionChange = (selection = []) => {
26!
364
    if (!onboardingState.complete && selection.length) {
1!
365
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING));
1✔
366
    }
367
    dispatch(setDeviceListState({ selection, setOnly: true }));
1✔
368
  };
369

370
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
26✔
371

372
  const onChangeColumns = useCallback(
26✔
373
    (changedColumns, customColumnSizes) => {
374
      const { columnSizes, selectedAttributes } = calculateColumnSelectionSize(changedColumns, customColumnSizes);
1✔
375
      dispatch(updateUserColumnSettings(columnSizes));
1✔
376
      dispatch(saveUserSettings({ columnSelection: changedColumns }));
1✔
377
      // we don't need an explicit refresh trigger here, since the selectedAttributes will be different anyway & otherwise the shown list should still be valid
378
      dispatch(setDeviceListState({ selectedAttributes }));
1✔
379
      setShowCustomization(false);
1✔
380
    },
381
    [dispatch]
382
  );
383

384
  const onExpandClick = (device = {}) => {
26!
385
    dispatchedSetSnackbar('');
×
386
    const { id } = device;
×
387
    dispatch(setDeviceListState({ selectedId: deviceListState.selectedId === id ? undefined : id, detailsTab: deviceListState.detailsTab || 'identity' }));
×
388
    if (!onboardingState.complete) {
×
389
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING));
×
390
    }
391
  };
392

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

395
  const onCloseExpandedDevice = useCallback(() => dispatch(setDeviceListState({ selectedId: undefined, detailsTab: '' })), [dispatch]);
26✔
396

397
  const onResizeColumns = useCallback(columns => dispatch(updateUserColumnSettings(columns)), [dispatch]);
26✔
398

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

408
  const listOptionHandlers = [{ key: 'customize', title: 'Customize', onClick: onToggleCustomizationClick }];
26✔
409
  const EmptyState = currentSelectedState.emptyState;
26✔
410

411
  const groupLabel = selectedGroup ? decodeURIComponent(selectedGroup) : ALL_DEVICES;
26✔
412
  const isUngroupedGroup = selectedGroup && selectedGroup === UNGROUPED_GROUP.id;
26✔
413
  const selectedStaticGroup = selectedGroup && !groupFilters.length ? selectedGroup : undefined;
26✔
414

415
  const openedDevice = useDebounce(selectedId, TIMEOUTS.debounceShort);
26✔
416
  return (
26✔
417
    <>
418
      <div className="margin-left-small">
419
        <div className="flexbox">
420
          <h3 className="margin-right">{isUngroupedGroup ? UNGROUPED_GROUP.name : groupLabel}</h3>
26!
421
          <div className="flexbox space-between center-aligned" style={{ flexGrow: 1 }}>
422
            <div className="flexbox">
423
              <DeviceStateSelection onStateChange={onDeviceStateSelectionChange} selectedState={selectedState} states={states} />
424
              {hasMonitor && (
46✔
425
                <DeviceIssuesSelection
426
                  classes={classes}
427
                  onChange={onDeviceIssuesSelectionChange}
428
                  options={Object.values(availableIssueOptions)}
429
                  selection={selectedIssues}
430
                />
431
              )}
432
              {selectedGroup && !isUngroupedGroup && (
32✔
433
                <div className="margin-left muted flexbox centered">
434
                  {!groupFilters.length ? <LockOutlined fontSize="small" /> : <AutorenewIcon fontSize="small" />}
3!
435
                  <span>{!groupFilters.length ? 'Static' : 'Dynamic'}</span>
3!
436
                </div>
437
              )}
438
            </div>
439
            {canManageDevices && selectedGroup && !isUngroupedGroup && (
58✔
440
              <Button onClick={onGroupRemoval} startIcon={<DeleteIcon />}>
441
                Remove group
442
              </Button>
443
            )}
444
          </div>
445
        </div>
446
        <div className="flexbox space-between">
447
          {!isUngroupedGroup && (
52✔
448
            <div className={`flexbox centered filter-header ${showFilters ? `${classes.filterCommon} filter-toggle` : ''}`}>
26!
449
              <Button
450
                color="secondary"
451
                disableRipple
452
                onClick={() => setShowFilters(toggle)}
×
453
                startIcon={<FilterListIcon />}
454
                style={{ backgroundColor: 'transparent' }}
455
              >
456
                {filters.length > 0 ? `Filters (${filters.length})` : 'Filters'}
26!
457
              </Button>
458
            </div>
459
          )}
460
          <ListOptions options={listOptionHandlers} title="Table options" />
461
        </div>
462
        <Filters className={classes.filterCommon} onGroupClick={onGroupClick} open={showFilters} />
463
      </div>
464
      <Loader show={!isInitialized} />
465
      <div className="padding-bottom" ref={deviceListRef}>
466
        {devices.length > 0 ? (
26✔
467
          <DeviceList
468
            columnHeaders={columnHeaders}
469
            customColumnSizes={customColumnSizes}
470
            devices={devices}
471
            deviceListState={deviceListState}
472
            idAttribute={idAttribute}
473
            onChangeRowsPerPage={onPageLengthChange}
474
            onExpandClick={onExpandClick}
475
            onPageChange={handlePageChange}
476
            onResizeColumns={onResizeColumns}
477
            onSelect={onSelectionChange}
478
            onSort={onSortChange}
479
            pageLoading={pageLoading}
480
            pageTotal={deviceCount}
481
          />
482
        ) : (
483
          <EmptyState allCount={allCount} canManageDevices={canManageDevices} filters={filters} limitMaxed={limitMaxed} onClick={onPreauthClick} />
484
        )}
485
      </div>
486
      <ExpandedDevice
487
        actionCallbacks={actionCallbacks}
488
        deviceId={openedDevice}
489
        onClose={onCloseExpandedDevice}
490
        setDetailsTab={setDetailsTab}
491
        tabSelection={tabSelection}
492
      />
493
      {!selectedId && !showsDialog && <OnboardingComponent deviceListRef={deviceListRef} onboardingState={onboardingState} />}
78✔
494
      {canManageDevices && !!selectedRows.length && (
70✔
495
        <DeviceQuickActions actionCallbacks={actionCallbacks} deviceId={openedDevice} selectedGroup={selectedStaticGroup} />
496
      )}
497
      <ColumnCustomizationDialog
498
        attributes={attributes}
499
        columnHeaders={columnHeaders}
500
        customColumnSizes={customColumnSizes}
501
        idAttribute={idAttribute}
502
        open={showCustomization}
503
        onCancel={onToggleCustomizationClick}
504
        onSubmit={onChangeColumns}
505
      />
506
    </>
507
  );
508
};
509

510
export default Authorized;
511

512
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
8!
513
  const { classes } = useStyles();
25✔
514
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
25✔
515

516
  return (
25✔
517
    <div className="flexbox centered">
518
      Status:
519
      <Select className={classes.selection} disableUnderline onChange={e => onStateChange(e.target.value)} value={selectedState}>
1✔
520
        {availableStates.map(state => (
521
          <MenuItem key={state.key} value={state.key}>
127✔
522
            {state.title()}
523
          </MenuItem>
524
        ))}
525
      </Select>
526
    </div>
527
  );
528
};
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