• 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

55.26
/src/js/components/devices/group-management/create-group.js
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 React, { useState } from 'react';
15
import { useSelector } from 'react-redux';
16

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

19
import { UNGROUPED_GROUP } from '../../../constants/deviceConstants';
20
import { getDocsVersion, getSelectedGroupInfo } from '../../../selectors';
21
import GroupDefinition from './group-definition';
22

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

30
  const docsVersion = useSelector(getDocsVersion);
1✔
31
  const { selectedGroup } = useSelector(getSelectedGroupInfo);
1✔
32
  // ensure that existing dynamic groups are only listed if a dynamic group should be created
33
  const groups = useSelector(state =>
1✔
34
    Object.keys(state.devices.groups.byId).filter(group => (fromFilters ? group !== UNGROUPED_GROUP.id : !state.devices.groups.byId[group].filters.length))
2!
35
  );
36

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

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

71
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