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

mendersoftware / gui / 1057188406

01 Nov 2023 04:24AM UTC coverage: 82.824% (-17.1%) from 99.964%
1057188406

Pull #4134

gitlab-ci

web-flow
chore: Bump uuid from 9.0.0 to 9.0.1

Bumps [uuid](https://github.com/uuidjs/uuid) from 9.0.0 to 9.0.1.
- [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uuidjs/uuid/compare/v9.0.0...v9.0.1)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4134: chore: Bump uuid from 9.0.0 to 9.0.1

4349 of 6284 branches covered (0.0%)

8313 of 10037 relevant lines covered (82.82%)

200.97 hits per line

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

72.99
/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 { 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
  getFilterAttributes,
38
  getIdAttribute,
39
  getLimitMaxed,
40
  getMappedDevicesList,
41
  getOnboardingState,
42
  getSelectedGroupInfo,
43
  getTenantCapabilities,
44
  getUserCapabilities,
45
  getUserSettings
46
} from '../../selectors';
47
import { useDebounce } from '../../utils/debouncehook';
48
import { getOnboardingComponentFor } from '../../utils/onboardingmanager';
49
import useWindowSize from '../../utils/resizehook';
50
import { clearAllRetryTimers, setRetryTimer } from '../../utils/retrytimer';
51
import Loader from '../common/loader';
52
import { defaultHeaders, defaultTextRender, getDeviceIdentityText, routes as states } from './base-devices';
53
import DeviceList, { minCellWidth } from './devicelist';
54
import ColumnCustomizationDialog from './dialogs/custom-columns-dialog';
55
import ExpandedDevice from './expanded-device';
56
import DeviceQuickActions from './widgets/devicequickactions';
57
import Filters from './widgets/filters';
58
import DeviceIssuesSelection from './widgets/issueselection';
59
import ListOptions from './widgets/listoptions';
60

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

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

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

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

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

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

145
const OnboardingComponent = ({ deviceListRef, onboardingState }) => {
9✔
146
  let onboardingComponent = null;
23✔
147
  const element = deviceListRef.current?.querySelector('body .deviceListItem > div');
23✔
148
  if (element) {
23✔
149
    const anchor = { left: 200, top: element ? element.offsetTop + element.offsetHeight : 170 };
18!
150
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
18✔
151
  } else if (deviceListRef.current) {
5✔
152
    const anchor = { top: deviceListRef.current.offsetTop + deviceListRef.current.offsetHeight / 3, left: deviceListRef.current.offsetWidth / 2 + 30 };
2✔
153
    onboardingComponent = getOnboardingComponentFor(
2✔
154
      onboardingSteps.DEVICES_PENDING_ONBOARDING_START,
155
      onboardingState,
156
      { anchor, place: 'top' },
157
      onboardingComponent
158
    );
159
  }
160
  return onboardingComponent;
23✔
161
};
162

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

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

216
  // eslint-disable-next-line no-unused-vars
217
  const size = useWindowSize();
26✔
218

219
  const { classes } = useStyles();
26✔
220

221
  useEffect(() => {
26✔
222
    clearAllRetryTimers(dispatchedSetSnackbar);
3✔
223
    if (!filters.length && selectedGroup && groupFilters.length) {
3!
224
      dispatch(setDeviceFilters(groupFilters));
×
225
    }
226
    return () => {
3✔
227
      clearInterval(timer.current);
3✔
228
      clearAllRetryTimers(dispatchedSetSnackbar);
3✔
229
    };
230
    // eslint-disable-next-line react-hooks/exhaustive-deps
231
  }, [dispatch, dispatchedSetSnackbar]);
232

233
  useEffect(() => {
26✔
234
    const columnHeaders = getHeaders(columnSelection, currentSelectedState.defaultHeaders, idAttribute, openSettingsDialog);
6✔
235
    setColumnHeaders(columnHeaders);
6✔
236
    // eslint-disable-next-line react-hooks/exhaustive-deps
237
  }, [columnSelection, idAttribute.attribute, currentSelectedState.defaultHeaders, openSettingsDialog]);
238

239
  useEffect(() => {
26✔
240
    // only set state after all devices id data retrieved
241
    setIsInitialized(isInitialized => isInitialized || (settingsInitialized && devicesInitialized && pageLoading === false));
8✔
242
    setDevicesInitialized(devicesInitialized => devicesInitialized || pageLoading === false);
8✔
243
  }, [settingsInitialized, devicesInitialized, pageLoading]);
244

245
  const onDeviceStateSelectionChange = useCallback(
26✔
246
    newState => dispatch(setDeviceListState({ state: newState, page: 1, refreshTrigger: !refreshTrigger })),
×
247
    [dispatch, refreshTrigger]
248
  );
249

250
  useEffect(() => {
26✔
251
    if (onboardingState.complete) {
6!
252
      return;
×
253
    }
254
    if (pendingCount) {
6!
255
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING_START));
6✔
256
      return;
6✔
257
    }
258
    if (!acceptedCount) {
×
259
      return;
×
260
    }
261
    dispatch(advanceOnboarding(onboardingSteps.DEVICES_ACCEPTED_ONBOARDING));
×
262

263
    if (acceptedCount < 2 && !window.sessionStorage.getItem('pendings-redirect')) {
×
264
      window.sessionStorage.setItem('pendings-redirect', true);
×
265
      onDeviceStateSelectionChange(DEVICE_STATES.accepted);
×
266
    }
267
    // eslint-disable-next-line react-hooks/exhaustive-deps
268
  }, [acceptedCount, allCount, pendingCount, onboardingState.complete, dispatch, onDeviceStateSelectionChange, dispatchedSetSnackbar]);
269

270
  useEffect(() => {
26✔
271
    setShowFilters(false);
3✔
272
  }, [selectedGroup]);
273

274
  const refreshDevices = useCallback(() => {
26✔
275
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
×
276
    return dispatch(setDeviceListState({}, true, true)).catch(err =>
×
277
      setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshLength, dispatchedSetSnackbar)
×
278
    );
279
  }, [dispatch, dispatchedSetSnackbar, selectedState]);
280

281
  useEffect(() => {
26✔
282
    if (!devicesInitialized) {
4✔
283
      return;
1✔
284
    }
285
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
3!
286
    clearInterval(timer.current);
3✔
287
    timer.current = setInterval(() => refreshDevices(), refreshLength);
3✔
288
  }, [devicesInitialized, refreshDevices, selectedState]);
289

290
  useEffect(() => {
26✔
291
    Object.keys(availableIssueOptions).map(key => dispatch(getIssueCountsByType(key, { filters, group: selectedGroup, state: selectedState })));
6✔
292
    availableIssueOptions[DEVICE_ISSUE_OPTIONS.authRequests.key]
5!
293
      ? dispatch(getIssueCountsByType(DEVICE_ISSUE_OPTIONS.authRequests.key, { filters: [] }))
294
      : undefined;
295
    // eslint-disable-next-line react-hooks/exhaustive-deps
296
  }, [selectedIssues.join(''), JSON.stringify(availableIssueOptions), selectedState, selectedGroup, dispatch, JSON.stringify(filters)]);
297

298
  /*
299
   * Devices
300
   */
301
  const devicesToIds = devices => devices.map(device => device.id);
26✔
302

303
  const onRemoveDevicesFromGroup = devices => {
26✔
304
    const deviceIds = devicesToIds(devices);
×
305
    removeDevicesFromGroup(deviceIds);
×
306
    // if devices.length = number on page but < deviceCount
307
    // move page back to pageNO 1
308
    if (devices.length === deviceIds.length) {
×
309
      handlePageChange(1);
×
310
    }
311
  };
312

313
  const onAuthorizationChange = (devices, changedState) => {
26✔
314
    const deviceIds = devicesToIds(devices);
×
315
    return dispatch(setDeviceListState({ isLoading: true }))
×
316
      .then(() => dispatch(updateDevicesAuth(deviceIds, changedState)))
×
317
      .then(() => onSelectionChange([]));
×
318
  };
319

320
  const onDeviceDismiss = devices =>
26✔
321
    dispatch(setDeviceListState({ isLoading: true }))
×
322
      .then(() => {
323
        const deleteRequests = devices.reduce((accu, device) => {
×
324
          if (device.auth_sets?.length) {
×
325
            accu.push(dispatch(deleteAuthset(device.id, device.auth_sets[0].id)));
×
326
          }
327
          return accu;
×
328
        }, []);
329
        return Promise.all(deleteRequests);
×
330
      })
331
      .then(() => onSelectionChange([]));
×
332

333
  const handlePageChange = useCallback(page => dispatch(setDeviceListState({ selectedId: undefined, page })), [dispatch]);
26✔
334

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

337
  const onSortChange = attribute => {
26✔
338
    let changedSortCol = attribute.name;
×
339
    let changedSortDown = sortDown === SORTING_OPTIONS.desc ? SORTING_OPTIONS.asc : SORTING_OPTIONS.desc;
×
340
    if (changedSortCol !== sortCol) {
×
341
      changedSortDown = SORTING_OPTIONS.desc;
×
342
    }
343
    dispatch(
×
344
      setDeviceListState({
345
        sort: { direction: changedSortDown, key: changedSortCol, scope: attribute.scope },
346
        refreshTrigger: !refreshTrigger
347
      })
348
    );
349
  };
350

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

353
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
26✔
354
    dispatch(setDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger }));
1✔
355

356
  const onSelectionChange = (selection = []) => {
26!
357
    if (!onboardingState.complete && selection.length) {
1!
358
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING));
1✔
359
    }
360
    dispatch(setDeviceListState({ selection, setOnly: true }));
1✔
361
  };
362

363
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
26✔
364

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

377
  const onExpandClick = (device = {}) => {
26!
378
    dispatchedSetSnackbar('');
×
379
    const { id } = device;
×
380
    dispatch(setDeviceListState({ selectedId: deviceListState.selectedId === id ? undefined : id, detailsTab: deviceListState.detailsTab || 'identity' }));
×
381
    if (!onboardingState.complete) {
×
382
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ONBOARDING));
×
383
    }
384
  };
385

386
  const onCreateDeploymentClick = devices => {
26✔
387
    const devicesLink = !onboardingState.complete ? '' : `&${devices.map(({ id }) => `deviceId=${id}`).join('&')}`;
×
388
    return navigate(`/deployments?open=true${devicesLink}`);
×
389
  };
390

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

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

395
  const actionCallbacks = {
26✔
396
    onAddDevicesToGroup: addDevicesToGroup,
397
    onAuthorizationChange,
398
    onCreateDeployment: onCreateDeploymentClick,
399
    onDeviceDismiss,
400
    onPromoteGateway: onMakeGatewayClick,
401
    onRemoveDevicesFromGroup
402
  };
403

404
  const listOptionHandlers = [{ key: 'customize', title: 'Customize', onClick: onToggleCustomizationClick }];
26✔
405
  const EmptyState = currentSelectedState.emptyState;
26✔
406

407
  const groupLabel = selectedGroup ? decodeURIComponent(selectedGroup) : ALL_DEVICES;
26✔
408
  const isUngroupedGroup = selectedGroup && selectedGroup === UNGROUPED_GROUP.id;
26✔
409
  const selectedStaticGroup = selectedGroup && !groupFilters.length ? selectedGroup : undefined;
26✔
410

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

501
export default Authorized;
502

503
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
9!
504
  const theme = useTheme();
25✔
505
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
25✔
506

507
  return (
25✔
508
    <div className="flexbox centered">
509
      Status:
510
      <Select
511
        disableUnderline
512
        onChange={e => onStateChange(e.target.value)}
1✔
513
        value={selectedState}
514
        style={{ fontSize: 13, marginLeft: theme.spacing(), marginTop: 2 }}
515
      >
516
        {availableStates.map(state => (
517
          <MenuItem key={state.key} value={state.key}>
127✔
518
            {state.title()}
519
          </MenuItem>
520
        ))}
521
      </Select>
522
    </div>
523
  );
524
};
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