• 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

54.05
/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 { connect } 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 } from '../../../selectors';
21
import GroupDefinition from './group-definition';
22

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

29
  const onNameChange = (isInvalid, newGroupName, isModification) => {
1✔
30
    const title = !isCreationDynamic ? `Add ${selectedDevices.length ? 'selected ' : ''}devices to group` : 'Create a new group';
×
31
    setTitle(title);
×
32
    setInvalid(isInvalid);
×
33
    setIsModification(isModification);
×
34
    setNewGroup(newGroupName);
×
35
  };
36

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

63
const mapStateToProps = (state, ownProps) => {
5✔
64
  // ensure that existing dynamic groups are only listed if a dynamic group should be created
65
  const groups = Object.keys(state.devices.groups.byId).filter(group =>
1✔
66
    ownProps.fromFilters ? group !== UNGROUPED_GROUP.id : !state.devices.groups.byId[group].filters.length
2!
67
  );
68
  return {
1✔
69
    docsVersion: getDocsVersion(state),
70
    groups,
71
    isCreationDynamic: ownProps.isCreation && ownProps.fromFilters,
1!
72
    selectedGroup: state.devices.groups.selectedGroup
73
  };
74
};
75

76
export default connect(mapStateToProps)(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