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

mendersoftware / mender-server / 10423

11 Nov 2025 04:53PM UTC coverage: 74.435% (-0.1%) from 74.562%
10423

push

gitlab-ci

web-flow
Merge pull request #1071 from mendersoftware/dependabot/npm_and_yarn/frontend/main/development-dependencies-92732187be

3868 of 5393 branches covered (71.72%)

Branch coverage included in aggregate %.

5 of 5 new or added lines in 2 files covered. (100.0%)

176 existing lines in 95 files now uncovered.

64605 of 86597 relevant lines covered (74.6%)

7.74 hits per line

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

88.51
/frontend/src/js/components/devices/group-management/CreateGroup.tsx
1
// Copyright 2016 Northern.tech AS
2✔
2
//
2✔
3
//    Licensed under the Apache License, Version 2.0 (the "License");
2✔
4
//    you may not use this file except in compliance with the License.
2✔
5
//    You may obtain a copy of the License at
2✔
6
//
2✔
7
//        http://www.apache.org/licenses/LICENSE-2.0
2✔
8
//
2✔
9
//    Unless required by applicable law or agreed to in writing, software
2✔
10
//    distributed under the License is distributed on an "AS IS" BASIS,
2✔
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2✔
12
//    See the License for the specific language governing permissions and
2✔
13
//    limitations under the License.
2✔
14
import { useState } from 'react';
2✔
15
import { useSelector } from 'react-redux';
2✔
16

2✔
17
import { Button, DialogActions, DialogContent } from '@mui/material';
2✔
18

2✔
19
import { BaseDialog } from '@northern.tech/common-ui/dialogs/BaseDialog';
2✔
20
import { getGroups, getSelectedGroupInfo } from '@northern.tech/store/selectors';
2✔
21

2✔
22
import GroupDefinition from './GroupDefinition';
2✔
23

2✔
24
export const CreateGroup = ({ addListOfDevices, fromFilters, isCreation, onClose, selectedDevices }) => {
7✔
25
  const isCreationDynamic = isCreation && fromFilters;
3!
26
  const [invalid, setInvalid] = useState(true);
3✔
27
  const [isModification, setIsModification] = useState(!isCreation);
3✔
28
  const [newGroup, setNewGroup] = useState('');
3✔
29
  const [title, setTitle] = useState(isCreationDynamic ? 'Create a new group' : `Add ${selectedDevices.length ? 'selected ' : ''}devices to group`);
3!
30

2✔
31
  const { selectedGroup } = useSelector(getSelectedGroupInfo);
3✔
32
  // ensure that existing dynamic groups are only listed if a dynamic group should be created
2✔
33
  const { dynamic, static: staticGroups } = useSelector(getGroups);
3✔
34
  const groups = fromFilters ? [...staticGroups.map(g => g.groupId), ...dynamic.map(g => g.groupId)] : staticGroups.map(g => g.groupId);
3!
35

2✔
36
  const onNameChange = (isInvalid, newGroupName, isModification) => {
3✔
37
    const title = !isCreationDynamic ? `Add ${selectedDevices.length ? 'selected ' : ''}devices to group` : 'Create a new group';
2!
38
    setTitle(title);
2✔
39
    setInvalid(isInvalid);
2✔
40
    setIsModification(isModification);
2✔
41
    setNewGroup(newGroupName);
2✔
42
  };
2✔
43

2✔
44
  return (
3✔
45
    <BaseDialog open title={title} disableEscapeKeyDown fullWidth maxWidth="sm" onClose={onClose}>
2✔
46
      <DialogContent>
2✔
47
        <GroupDefinition
2✔
48
          groups={groups}
2✔
49
          isCreationDynamic={isCreationDynamic}
2✔
50
          newGroup={newGroup}
2✔
UNCOV
51
          onInputChange={(invalidName, name, isModification) => onNameChange(invalidName, name, isModification)}
2✔
52
          selectedDevices={selectedDevices}
2✔
53
          selectedGroup={selectedGroup}
2✔
54
        />
2✔
55
      </DialogContent>
2✔
56
      <DialogActions style={{ marginTop: 0 }}>
2✔
57
        <Button style={{ marginRight: 10 }} onClick={onClose}>
2✔
58
          Cancel
2✔
59
        </Button>
2✔
UNCOV
60
        <Button variant="contained" onClick={() => addListOfDevices(selectedDevices, newGroup)} disabled={!newGroup.length || invalid}>
2!
61
          {!isModification || isCreationDynamic || groups.length === 0 ? 'Create group' : 'Add to group'}
2!
62
        </Button>
2✔
63
      </DialogActions>
2✔
64
    </BaseDialog>
2✔
65
  );
2✔
66
};
2✔
67

2✔
68
export default CreateGroup;
2✔
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