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

mendersoftware / gui / 1315496247

03 Jun 2024 07:49AM UTC coverage: 83.437% (-16.5%) from 99.964%
1315496247

Pull #4434

gitlab-ci

mzedel
chore: aligned snapshots with updated mui version

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #4434: chore: Bump the mui group with 3 updates

4476 of 6391 branches covered (70.04%)

8488 of 10173 relevant lines covered (83.44%)

140.36 hits per line

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

78.61
/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)) {
40✔
75
    accu.header = { ...accu.header, ...header };
6✔
76
  }
77
  return accu;
40✔
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
36✔
121
    ? columnSelection.map(column => {
122
        let header = { ...column, attribute: { ...column }, textRender: defaultTextRender, sortable: true };
4✔
123
        header = Object.values(defaultHeaders).reduce(headersReducer, { column, header }).header;
4✔
124
        header = currentStateHeaders.reduce(headersReducer, { column, header }).header;
4✔
125
        return header;
4✔
126
      })
127
    : currentStateHeaders;
128
  return [
36✔
129
    {
130
      title: idAttributeTitleMap[idAttribute.attribute] ?? idAttribute.attribute,
44✔
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;
21✔
154
  const element = deviceListRef.current?.querySelector('body .deviceListItem > div');
21✔
155
  if (element) {
21✔
156
    const anchor = { left: 200, top: element.offsetTop + element.offsetHeight };
15✔
157
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
15✔
158
  } else if (deviceListRef.current) {
6✔
159
    const anchor = { top: deviceListRef.current.offsetTop + deviceListRef.current.offsetHeight / 3, left: deviceListRef.current.offsetWidth / 2 + 30 };
3✔
160
    onboardingComponent = getOnboardingComponentFor(
3✔
161
      onboardingSteps.DEVICES_PENDING_ONBOARDING_START,
162
      onboardingState,
163
      { anchor, place: 'top' },
164
      onboardingComponent
165
    );
166
  }
167
  return onboardingComponent;
21✔
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);
23✔
181
  const devices = useSelector(state => getMappedDevicesList(state, 'deviceList'));
64✔
182
  const { selectedGroup, groupFilters = [] } = useSelector(getSelectedGroupInfo);
23!
183
  const { columnSelection = [] } = useSelector(getUserSettings);
23!
184
  const attributes = useSelector(getFilterAttributes);
23✔
185
  const { accepted: acceptedCount, pending: pendingCount, rejected: rejectedCount } = useSelector(getDeviceCountsByStatus);
23✔
186
  const allCount = acceptedCount + rejectedCount;
23✔
187
  const availableIssueOptions = useSelector(getAvailableIssueOptionsByType);
23✔
188
  const customColumnSizes = useSelector(state => state.users.customColumns);
64✔
189
  const deviceListState = useSelector(state => state.devices.deviceList);
64✔
190
  const { total: deviceCount } = deviceListState;
23✔
191
  const filters = useSelector(getDeviceFilters);
23✔
192
  const idAttribute = useSelector(getIdAttribute);
23✔
193
  const onboardingState = useSelector(getOnboardingState);
23✔
194
  const settingsInitialized = useSelector(state => state.users.settingsInitialized);
64✔
195
  const tenantCapabilities = useSelector(getTenantCapabilities);
23✔
196
  const userCapabilities = useSelector(getUserCapabilities);
23✔
197
  const dispatch = useDispatch();
23✔
198
  const dispatchedSetSnackbar = useCallback((...args) => dispatch(setSnackbar(...args)), [dispatch]);
23✔
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;
23✔
210
  const { direction: sortDown = SORTING_OPTIONS.desc, key: sortCol } = sort;
23!
211
  const { canManageDevices } = userCapabilities;
23✔
212
  const { hasMonitor } = tenantCapabilities;
23✔
213
  const currentSelectedState = states[selectedState] ?? states.devices;
23!
214
  const [columnHeaders, setColumnHeaders] = useState([]);
23✔
215
  const [isInitialized, setIsInitialized] = useState(false);
23✔
216
  const [devicesInitialized, setDevicesInitialized] = useState(!!devices.length);
23✔
217
  const [showFilters, setShowFilters] = useState(false);
23✔
218
  const [showCustomization, setShowCustomization] = useState(false);
23✔
219
  const deviceListRef = useRef();
23✔
220
  const timer = useRef();
23✔
221
  const navigate = useNavigate();
23✔
222

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

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

228
  useEffect(() => {
23✔
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(() => {
23✔
241
    const columnHeaders = getHeaders(columnSelection, currentSelectedState.defaultHeaders, idAttribute, openSettingsDialog);
7✔
242
    setColumnHeaders(columnHeaders);
7✔
243
    // eslint-disable-next-line react-hooks/exhaustive-deps
244
  }, [columnSelection, idAttribute.attribute, currentSelectedState.defaultHeaders, openSettingsDialog]);
245

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

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

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

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

276
  useEffect(() => {
23✔
277
    setShowFilters(false);
3✔
278
  }, [selectedGroup]);
279
  const dispatchDeviceListState = useCallback(
23✔
280
    (options, shouldSelectDevices = true, forceRefresh = false, fetchAuth = false) => {
9✔
281
      return dispatch(setDeviceListState(options, shouldSelectDevices, forceRefresh, fetchAuth));
3✔
282
    },
283
    [dispatch]
284
  );
285

286
  const refreshDevices = useCallback(() => {
23✔
287
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
×
288
    return dispatchDeviceListState({}, true, true).catch(err =>
×
289
      setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshLength, dispatchedSetSnackbar)
×
290
    );
291
  }, [dispatchedSetSnackbar, selectedState, dispatchDeviceListState]);
292

293
  useEffect(() => {
23✔
294
    if (!devicesInitialized) {
4✔
295
      return;
1✔
296
    }
297
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
3!
298
    clearInterval(timer.current);
3✔
299
    timer.current = setInterval(() => refreshDevices(), refreshLength);
3✔
300
  }, [devicesInitialized, refreshDevices, selectedState]);
301

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

310
  /*
311
   * Devices
312
   */
313
  const devicesToIds = devices => devices.map(device => device.id);
23✔
314

315
  const onRemoveDevicesFromGroup = devices => {
23✔
316
    const deviceIds = devicesToIds(devices);
×
317
    removeDevicesFromGroup(deviceIds);
×
318
    // if devices.length = number on page but < deviceCount
319
    // move page back to pageNO 1
320
    if (devices.length === deviceIds.length) {
×
321
      handlePageChange(1);
×
322
    }
323
  };
324

325
  const onAuthorizationChange = (devices, changedState) => {
23✔
326
    const deviceIds = devicesToIds(devices);
×
327
    return dispatchDeviceListState({ isLoading: true })
×
328
      .then(() => dispatch(updateDevicesAuth(deviceIds, changedState)))
×
329
      .then(() => onSelectionChange([]));
×
330
  };
331

332
  const onDeviceDismiss = devices =>
23✔
333
    dispatchDeviceListState({ isLoading: true })
×
334
      .then(() => {
335
        const deleteRequests = devices.reduce((accu, device) => {
×
336
          if (device.auth_sets?.length) {
×
337
            accu.push(dispatch(deleteAuthset(device.id, device.auth_sets[0].id)));
×
338
          }
339
          return accu;
×
340
        }, []);
341
        return Promise.all(deleteRequests);
×
342
      })
343
      .then(() => onSelectionChange([]));
×
344

345
  const handlePageChange = useCallback(page => dispatchDeviceListState({ selectedId: undefined, page }), [dispatchDeviceListState]);
23✔
346

347
  const onPageLengthChange = perPage => dispatchDeviceListState({ perPage, page: 1, refreshTrigger: !refreshTrigger });
23✔
348

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

361
  const setDetailsTab = detailsTab => dispatchDeviceListState({ detailsTab, setOnly: true });
23✔
362

363
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
23✔
364
    dispatchDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger });
1✔
365

366
  const onSelectionChange = (selection = []) => {
23!
367
    if (!onboardingState.complete && selection.length) {
1!
368
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING));
1✔
369
    }
370
    dispatchDeviceListState({ selection, setOnly: true });
1✔
371
  };
372

373
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
23✔
374

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

387
  const onExpandClick = (device = {}) => {
23!
388
    dispatchedSetSnackbar('');
×
389
    const { id } = device;
×
390
    dispatchDeviceListState({ selectedId: deviceListState.selectedId === id ? undefined : id, detailsTab: deviceListState.detailsTab || 'identity' });
×
391
    if (!onboardingState.complete) {
×
392
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING));
×
393
    }
394
  };
395

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

398
  const onCloseExpandedDevice = useCallback(() => dispatchDeviceListState({ selectedId: undefined, detailsTab: '' }), [dispatchDeviceListState]);
23✔
399

400
  const onResizeColumns = useCallback(columns => dispatch(updateUserColumnSettings(columns)), [dispatch]);
23✔
401

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

411
  const listOptionHandlers = [{ key: 'customize', title: 'Customize', onClick: onToggleCustomizationClick }];
23✔
412
  const EmptyState = currentSelectedState.emptyState;
23✔
413

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

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

513
export default Authorized;
514

515
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
8!
516
  const { classes } = useStyles();
23✔
517
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
23✔
518

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