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

mendersoftware / gui / 963002358

pending completion
963002358

Pull #3870

gitlab-ci

mzedel
chore: cleaned up left over onboarding tooltips & aligned with updated design

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3870: MEN-5413

4348 of 6319 branches covered (68.81%)

95 of 122 new or added lines in 24 files covered. (77.87%)

1734 existing lines in 160 files now uncovered.

8174 of 9951 relevant lines covered (82.14%)

178.12 hits per line

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

65.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
  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✔
UNCOV
77
  if (header.attribute.scope === accu.column.scope && (header.attribute.name === accu.column.name || header.attribute.alternative === accu.column.name)) {
×
UNCOV
78
    accu.header = { ...accu.header, ...header };
×
79
  }
UNCOV
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,125!
116
    ? columnSelection.map(column => {
UNCOV
117
        let header = { ...column, attribute: { ...column }, textRender: defaultTextRender, sortable: true };
×
UNCOV
118
        header = Object.values(defaultHeaders).reduce(headersReducer, { column, header }).header;
×
UNCOV
119
        header = currentStateHeaders.reduce(headersReducer, { column, header }).header;
×
UNCOV
120
        return header;
×
121
      })
122
    : currentStateHeaders;
123
  return [
1,125✔
124
    {
125
      title: idAttributeTitleMap[idAttribute.attribute] ?? idAttribute.attribute,
1,146✔
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 = ({ deviceListRef, onboardingState }) => {
9✔
148
  let onboardingComponent = null;
24✔
149
  const element = deviceListRef.current?.querySelector('body .deviceListItem > div');
24✔
150
  if (element) {
24✔
151
    const anchor = { left: 200, top: element ? element.offsetTop + element.offsetHeight : 170 };
19!
152
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEVICES_PENDING_ONBOARDING, onboardingState, { anchor }, onboardingComponent);
19✔
153
  } else if (deviceListRef.current) {
5✔
154
    const anchor = { top: deviceListRef.current.offsetTop + deviceListRef.current.offsetHeight / 3, left: deviceListRef.current.offsetWidth / 2 + 30 };
2✔
155
    onboardingComponent = getOnboardingComponentFor(
2✔
156
      onboardingSteps.DEVICES_PENDING_ONBOARDING_START,
157
      onboardingState,
158
      { anchor, place: 'top' },
159
      onboardingComponent
160
    );
161
  }
162
  return onboardingComponent;
24✔
163
};
164

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

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

219
  // eslint-disable-next-line no-unused-vars
220
  const size = useWindowSize();
27✔
221

222
  const { classes } = useStyles();
27✔
223

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

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

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

248
  const onDeviceStateSelectionChange = useCallback(
27✔
UNCOV
249
    newState => dispatch(setDeviceListState({ state: newState, page: 1, refreshTrigger: !refreshTrigger })),
×
250
    [dispatch, refreshTrigger]
251
  );
252

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

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

273
  useEffect(() => {
27✔
274
    setShowFilters(false);
3✔
275
  }, [selectedGroup]);
276

277
  const refreshDevices = useCallback(() => {
27✔
UNCOV
278
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
×
UNCOV
279
    return dispatch(setDeviceListState({ refreshTrigger: !refreshTrigger })).catch(err =>
×
UNCOV
280
      setRetryTimer(err, 'devices', `Devices couldn't be loaded.`, refreshLength, dispatchedSetSnackbar)
×
281
    );
282
  }, [dispatch, dispatchedSetSnackbar, refreshTrigger, selectedState]);
283

284
  useEffect(() => {
27✔
285
    if (!devicesInitialized) {
5✔
286
      return;
1✔
287
    }
288
    const refreshLength = deviceRefreshTimes[selectedState] ?? deviceRefreshTimes.default;
4!
289
    clearInterval(timer.current);
4✔
290
    timer.current = setInterval(() => refreshDevices(), refreshLength);
4✔
291
  }, [devicesInitialized, refreshDevices, selectedState]);
292

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

301
  /*
302
   * Devices
303
   */
304
  const devicesToIds = devices => devices.map(device => device.id);
27✔
305

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

316
  const onAuthorizationChange = (devices, changedState) => {
27✔
UNCOV
317
    const deviceIds = devicesToIds(devices);
×
UNCOV
318
    return dispatch(setDeviceListState({ isLoading: true }))
×
UNCOV
319
      .then(() => dispatch(updateDevicesAuth(deviceIds, changedState)))
×
UNCOV
320
      .then(() => onSelectionChange([]));
×
321
  };
322

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

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

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

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

354
  const onFilterChange = () => handlePageChange(1);
27✔
355

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

358
  const onDeviceIssuesSelectionChange = ({ target: { value: selectedIssues } }) =>
27✔
359
    dispatch(setDeviceListState({ selectedIssues, page: 1, refreshTrigger: !refreshTrigger }));
1✔
360

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

368
  const onToggleCustomizationClick = () => setShowCustomization(toggle);
27✔
369

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

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

391
  const onCreateDeploymentClick = devices => {
27✔
NEW
392
    const devicesLink = !onboardingState.complete ? '' : `&${devices.map(({ id }) => `deviceId=${id}`).join('&')}`;
×
NEW
393
    return navigate(`/deployments?open=true${devicesLink}`);
×
394
  };
395

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

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

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

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

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

520
export default Authorized;
521

522
export const DeviceStateSelection = ({ onStateChange, selectedState = '', states }) => {
9!
523
  const theme = useTheme();
26✔
524
  const availableStates = useMemo(() => Object.values(states).filter(duplicateFilter), [states]);
26✔
525

526
  return (
26✔
527
    <div className="flexbox centered">
528
      Status:
529
      <Select
530
        disableUnderline
531
        onChange={e => onStateChange(e.target.value)}
1✔
532
        value={selectedState}
533
        style={{ fontSize: 13, marginLeft: theme.spacing(), marginTop: 2 }}
534
      >
535
        {availableStates.map(state => (
536
          <MenuItem key={state.key} value={state.key}>
132✔
537
            {state.title()}
538
          </MenuItem>
539
        ))}
540
      </Select>
541
    </div>
542
  );
543
};
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