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

mendersoftware / gui / 951400782

pending completion
951400782

Pull #3900

gitlab-ci

web-flow
chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3900: chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

4446 of 6414 branches covered (69.32%)

8342 of 10084 relevant lines covered (82.73%)

186.0 hits per line

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

64.95
/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
  getShowHelptips,
44
  getTenantCapabilities,
45
  getUserCapabilities,
46
  getUserSettings
47
} from '../../selectors';
48
import { useDebounce } from '../../utils/debouncehook';
49
import { getOnboardingComponentFor } from '../../utils/onboardingmanager';
50
import useWindowSize from '../../utils/resizehook';
51
import { clearAllRetryTimers, setRetryTimer } from '../../utils/retrytimer';
52
import Loader from '../common/loader';
53
import { ExpandDevice } from '../helptips/helptooltips';
54
import { defaultHeaders, defaultTextRender, getDeviceIdentityText, routes as states } from './base-devices';
55
import DeviceList, { minCellWidth } from './devicelist';
56
import ColumnCustomizationDialog from './dialogs/custom-columns-dialog';
57
import ExpandedDevice from './expanded-device';
58
import DeviceQuickActions from './widgets/devicequickactions';
59
import Filters from './widgets/filters';
60
import DeviceIssuesSelection from './widgets/issueselection';
61
import ListOptions from './widgets/listoptions';
62

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

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

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

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

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

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

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

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

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

230
  // eslint-disable-next-line no-unused-vars
231
  const size = useWindowSize();
27✔
232

233
  const { classes } = useStyles();
27✔
234

235
  useEffect(() => {
27✔
236
    clearAllRetryTimers(dispatchedSetSnackbar);
3✔
237
    if (!filters.length && selectedGroup && groupFilters.length) {
3!
238
      dispatch(setDeviceFilters(groupFilters));
×
239
    }
240
    return () => {
3✔
241
      clearInterval(timer.current);
3✔
242
      clearAllRetryTimers(dispatchedSetSnackbar);
3✔
243
    };
244
  }, []);
245

246
  useEffect(() => {
27✔
247
    const columnHeaders = getHeaders(columnSelection, currentSelectedState.defaultHeaders, idAttribute, openSettingsDialog);
5✔
248
    setColumnHeaders(columnHeaders);
5✔
249
  }, [columnSelection, selectedState, idAttribute.attribute]);
250

251
  useEffect(() => {
27✔
252
    // only set state after all devices id data retrieved
253
    setIsInitialized(isInitialized => isInitialized || (settingsInitialized && devicesInitialized && pageLoading === false));
8✔
254
    setDevicesInitialized(devicesInitialized => devicesInitialized || pageLoading === false);
8✔
255
  }, [settingsInitialized, devicesInitialized, pageLoading]);
256

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

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

284
  useEffect(() => {
27✔
285
    setShowFilters(false);
3✔
286
  }, [selectedGroup]);
287

288
  const refreshDevices = useCallback(() => {
27✔
289
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
×
290
    return dispatch(setDeviceListState({ refreshTrigger: !refreshTrigger })).catch(err =>
×
291
      setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshLength, dispatchedSetSnackbar)
×
292
    );
293
  }, [refreshTrigger, selectedState]);
294

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

304
  useEffect(() => {
27✔
305
    Object.keys(availableIssueOptions).map(key => dispatch(getIssueCountsByType(key, { filters, group: selectedGroup, state: selectedState })));
8✔
306
    availableIssueOptions[DEVICE_ISSUE_OPTIONS.authRequests.key]
6!
307
      ? dispatch(getIssueCountsByType(DEVICE_ISSUE_OPTIONS.authRequests.key, { filters: [] }))
308
      : undefined;
309
  }, [selectedIssues, availableIssueOptions, selectedState, selectedGroup]);
310

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

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

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

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

346
  const handlePageChange = page => dispatch(setDeviceListState({ selectedId: undefined, page, refreshTrigger: !refreshTrigger }));
27✔
347

348
  const onPageLengthChange = perPage => dispatch(setDeviceListState({ perPage, page: 1, refreshTrigger: !refreshTrigger }));
27✔
349

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

364
  const onFilterChange = () => handlePageChange(1);
27✔
365

366
  const onDeviceStateSelectionChange = newState => dispatch(setDeviceListState({ state: newState, page: 1, refreshTrigger: !refreshTrigger }));
27✔
367

368
  const setDetailsTab = detailsTab => dispatch(setDeviceListState({ detailsTab, setOnly: true }));
27✔
369

370
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
27✔
371
    dispatch(setDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger }));
1✔
372

373
  const onSelectionChange = (selection = []) => {
27!
374
    if (!onboardingState.complete && selection.length) {
1!
375
      dispatch(advanceOnboarding(onboardingSteps.DEVICES_PENDING_ACCEPTING_ONBOARDING));
1✔
376
    }
377
    dispatch(setDeviceListState({ selection, setOnly: true }));
1✔
378
  };
379

380
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
27✔
381

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

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

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

405
  const actionCallbacks = {
27✔
406
    onAddDevicesToGroup: addDevicesToGroup,
407
    onAuthorizationChange,
408
    onCreateDeployment: onCreateDeploymentClick,
409
    onDeviceDismiss,
410
    onPromoteGateway: onMakeGatewayClick,
411
    onRemoveDevicesFromGroup
412
  };
413

414
  const listOptionHandlers = [{ key: 'customize', title: 'Customize', onClick: onToggleCustomizationClick }];
27✔
415
  const devicePendingTip = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING_START, onboardingState);
27✔
416

417
  const EmptyState = currentSelectedState.emptyState;
27✔
418

419
  const groupLabel = selectedGroup ? decodeURIComponent(selectedGroup) : ALL_DEVICES;
27✔
420
  const isUngroupedGroup = selectedGroup && selectedGroup === UNGROUPED_GROUP.id;
27✔
421
  const selectedStaticGroup = selectedGroup && !groupFilters.length ? selectedGroup : undefined;
27✔
422

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

539
export default Authorized;
540

541
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
9!
542
  const theme = useTheme();
25✔
543
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
25✔
544

545
  return (
25✔
546
    <div className="flexbox centered">
547
      Status:
548
      <Select
549
        disableUnderline
550
        onChange={e => onStateChange(e.target.value)}
1✔
551
        value={selectedState}
552
        style={{ fontSize: 13, marginLeft: theme.spacing(), marginTop: 2 }}
553
      >
554
        {availableStates.map(state => (
555
          <MenuItem key={state.key} value={state.key}>
127✔
556
            {state.title()}
557
          </MenuItem>
558
        ))}
559
      </Select>
560
    </div>
561
  );
562
};
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