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

mendersoftware / gui / 901187442

pending completion
901187442

Pull #3795

gitlab-ci

mzedel
feat: increased chances of adopting our intended navigation patterns instead of unsupported browser navigation

Ticket: None
Changelog: None
Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3795: feat: increased chances of adopting our intended navigation patterns instead of unsupported browser navigation

4389 of 6365 branches covered (68.96%)

5 of 5 new or added lines in 1 file covered. (100.0%)

1729 existing lines in 165 files now uncovered.

8274 of 10019 relevant lines covered (82.58%)

144.86 hits per line

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

62.5
/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, Info as InfoIcon } 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 { getFeatures } from '../../selectors';
38
import { MenderTooltipClickable } from '../common/mendertooltip';
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 { isHosted = false } = useSelector(getFeatures);
2!
71
  const { attributes = {}, count = 0, limit = 100 } = useSelector(state => state.devices.filteringAttributesConfig);
2!
72

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

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

79
  const tooltipContent = () => {
2✔
80
    return isHosted ? (
2!
81
      <div style={{ maxWidth: 350 }}>
82
        Expand to see the list of attributes currently in use. Please{' '}
83
        <a href="mailto:contact@mender.io" target="_blank" rel="noopener noreferrer">
84
          contact our team
85
        </a>{' '}
86
        if your use case requires a different set of attributes.
87
      </div>
88
    ) : (
89
      <div style={{ maxWidth: 350 }}>Expand to see the list of attributes currently in use.</div>
90
    );
91
  };
92

93
  return (
2✔
94
    <>
95
      <InputLabel className="margin-top" shrink id="filterable-attributes-usage-and-limit">
96
        Filterable attributes usage & limit ({count}/{limit}){' '}
97
        <MenderTooltipClickable className="inline-block" style={{ verticalAlign: -5 }} disableHoverListener={false} placement="top" title={tooltipContent()}>
98
          <InfoIcon />
99
        </MenderTooltipClickable>
100
      </InputLabel>
101
      <Accordion className={classes.accordion} square expanded={open} onChange={toggleOpen} disabled={!count}>
102
        <AccordionSummary className={classes.summary}>
103
          <LinearProgress className={classes.limitBar} variant="determinate" value={(count * 100) / limit} style={{ width: '100%' }} />
104
          <IconButton className="margin-left-small expandButton" size="large">
105
            {open ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}
2!
106
          </IconButton>
107
        </AccordionSummary>
108
        <AccordionDetails>
109
          <List className={classes.attributesList}>
110
            {Object.entries(attributes).map(([scope, values = []]) => (
×
UNCOV
111
              <li key={scope}>
×
112
                <ul>
113
                  <ListSubheader>{scope}</ListSubheader>
114
                  {values.map(item => (
UNCOV
115
                    <ListItem key={`item-${scope}-${item}`}>
×
116
                      <ListItemText primary={item} />
117
                    </ListItem>
118
                  ))}
119
                </ul>
120
              </li>
121
            ))}
122
          </List>
123
        </AccordionDetails>
124
      </Accordion>
125
    </>
126
  );
127
};
128

129
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