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

mendersoftware / gui / 1032268278

10 Oct 2023 04:28PM UTC coverage: 82.723% (-17.2%) from 99.964%
1032268278

Pull #4096

gitlab-ci

mzedel
chore: made offline settings saving less aggressive

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

4340 of 6277 branches covered (0.0%)

1 of 2 new or added lines in 1 file covered. (50.0%)

1719 existing lines in 164 files now uncovered.

8307 of 10042 relevant lines covered (82.72%)

201.86 hits per line

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

83.33
/src/js/components/settings/reportinglimits.js
1
// Copyright 2023 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, { useEffect, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16

17
import { ArrowDropDown as ArrowDropDownIcon, ArrowDropUp as ArrowDropUpIcon } from '@mui/icons-material';
18
// material ui
19
import {
20
  Accordion,
21
  AccordionDetails,
22
  AccordionSummary,
23
  IconButton,
24
  InputLabel,
25
  LinearProgress,
26
  List,
27
  ListItem,
28
  ListItemText,
29
  ListSubheader,
30
  accordionClasses,
31
  listSubheaderClasses
32
} from '@mui/material';
33
import { makeStyles } from 'tss-react/mui';
34

35
import { getReportingLimits } from '../../actions/deviceActions';
36
import { toggle } from '../../helpers';
37
import { InfoHintContainer } from '../common/info-hint';
38
import { HELPTOOLTIPS, MenderHelpTooltip } from '../helptips/helptooltips';
39

40
const useStyles = makeStyles()(theme => ({
6✔
41
  accordion: {
42
    ul: {
43
      paddingInlineStart: 0
44
    },
45
    [`&.${accordionClasses.disabled}, &.${accordionClasses.expanded}`]: {
46
      backgroundColor: theme.palette.background.paper
47
    }
48
  },
49
  attributesList: {
50
    overflow: 'auto',
51
    maxHeight: 250,
52
    background: 'white',
53
    width: '100%',
54
    position: 'relative',
55
    [`.${listSubheaderClasses.root}`]: {
56
      top: -10
57
    },
58
    'li > ul': {
59
      overflow: 'initial'
60
    }
61
  },
62
  limitBar: { backgroundColor: theme.palette.grey[500], margin: '15px 0' },
63
  summary: { padding: 0, marginBottom: theme.spacing() }
64
}));
65

66
export const ReportingLimits = () => {
6✔
67
  const [open, setOpen] = useState(false);
2✔
68
  const { classes } = useStyles();
2✔
69
  const dispatch = useDispatch();
2✔
70
  const { attributes = {}, count = 0, limit = 100 } = useSelector(state => state.devices.filteringAttributesConfig);
3!
71

72
  useEffect(() => {
2✔
73
    dispatch(getReportingLimits());
1✔
74
  }, [dispatch]);
75

76
  const toggleOpen = () => setOpen(toggle);
2✔
77

78
  return (
2✔
79
    <>
80
      <InputLabel className="margin-top-small padding-top-small flexbox" shrink id="filterable-attributes-usage-and-limit">
81
        Filterable attributes usage & limit ({count}/{limit})
82
        <InfoHintContainer>
83
          <MenderHelpTooltip id={HELPTOOLTIPS.attributeLimit.id} placement="top" />
84
        </InfoHintContainer>
85
      </InputLabel>
86
      <Accordion className={classes.accordion} square expanded={open} onChange={toggleOpen} disabled={!count}>
87
        <AccordionSummary className={classes.summary}>
88
          <LinearProgress className={classes.limitBar} variant="determinate" value={(count * 100) / limit} style={{ width: '100%' }} />
89
          <IconButton className="margin-left-small expandButton" size="large">
90
            {open ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
2!
91
          </IconButton>
92
        </AccordionSummary>
93
        <AccordionDetails>
94
          <List className={classes.attributesList}>
95
            {Object.entries(attributes).map(([scope, values = []]) => (
×
UNCOV
96
              <li key={scope}>
×
97
                <ul>
98
                  <ListSubheader>{scope}</ListSubheader>
99
                  {values.map(item => (
UNCOV
100
                    <ListItem key={`item-${scope}-${item}`}>
×
101
                      <ListItemText primary={item} />
102
                    </ListItem>
103
                  ))}
104
                </ul>
105
              </li>
106
            ))}
107
          </List>
108
        </AccordionDetails>
109
      </Accordion>
110
    </>
111
  );
112
};
113

114
export default ReportingLimits;
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