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

mendersoftware / mender-server / 10489

17 Nov 2025 09:07AM UTC coverage: 78.221% (+3.8%) from 74.444%
10489

push

gitlab-ci

web-flow
Merge pull request #1084 from joelguittet/jguittet/main/docker-compose-healthy

Introduce docker compose healthcheck

3865 of 5388 branches covered (71.73%)

Branch coverage included in aggregate %.

6845 of 8304 relevant lines covered (82.43%)

68.08 hits per line

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

54.05
/frontend/src/js/components/devices/group-management/CreateGroup.tsx
1
// Copyright 2016 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 { useState } from 'react';
15
import { useSelector } from 'react-redux';
16

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

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

22
import GroupDefinition from './GroupDefinition';
23

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

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

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

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

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