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

mendersoftware / gui / 897326496

pending completion
897326496

Pull #3752

gitlab-ci

mzedel
chore(e2e): made use of shared timeout & login checking values to remove code duplication

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3752: chore(e2e-tests): slightly simplified log in test + separated log out test

4395 of 6392 branches covered (68.76%)

8060 of 9780 relevant lines covered (82.41%)

126.17 hits per line

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

62.96
/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 { connect } 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 = ({ getReportingLimits, config = {}, isHosted = false }) => {
6!
67
  const [open, setOpen] = useState(false);
1✔
68
  const { classes } = useStyles();
1✔
69
  const { attributes = {}, count = 0, limit = 100 } = config;
1!
70

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

75
  const toggleOpen = () => setOpen(toggle);
1✔
76

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

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

127
const actionCreators = { getReportingLimits };
6✔
128

129
const mapStateToProps = state => {
6✔
130
  const { isHosted } = getFeatures(state);
1✔
131
  return {
1✔
132
    config: state.devices.filteringAttributesConfig,
133
    isHosted: isHosted
134
  };
135
};
136

137
export default connect(mapStateToProps, actionCreators)(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