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

mendersoftware / gui / 1493849842

13 Oct 2024 07:39AM UTC coverage: 83.457% (-16.5%) from 99.965%
1493849842

Pull #4531

gitlab-ci

web-flow
chore: Bump send and express in /tests/e2e_tests

Bumps [send](https://github.com/pillarjs/send) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together.

Updates `send` from 0.18.0 to 0.19.0
- [Release notes](https://github.com/pillarjs/send/releases)
- [Changelog](https://github.com/pillarjs/send/blob/master/HISTORY.md)
- [Commits](https://github.com/pillarjs/send/compare/0.18.0...0.19.0)

Updates `express` from 4.19.2 to 4.21.1
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.1/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.19.2...4.21.1)

---
updated-dependencies:
- dependency-name: send
  dependency-type: indirect
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4531: chore: Bump send and express in /tests/e2e_tests

4486 of 6422 branches covered (69.85%)

8551 of 10246 relevant lines covered (83.46%)

151.3 hits per line

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

84.09
/src/js/components/settings/roles.js
1
// Copyright 2020 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, useMemo, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16

17
// material ui
18
import { Add as AddIcon, ArrowRightAlt as ArrowRightAltIcon } from '@mui/icons-material';
19
import { Chip } from '@mui/material';
20

21
import { getDynamicGroups, getGroups } from '../../actions/deviceActions';
22
import { getExistingReleaseTags } from '../../actions/releaseActions.js';
23
import { createRole, editRole, getRoles, removeRole } from '../../actions/userActions';
24
import { BENEFITS } from '../../constants/appConstants';
25
import { emptyRole, rolesById } from '../../constants/userConstants';
26
import { getGroupsByIdWithoutUngrouped, getIsEnterprise, getReleaseTagsById, getRolesList } from '../../selectors';
27
import DetailsTable from '../common/detailstable';
28
import { DocsTooltip } from '../common/docslink';
29
import EnterpriseNotification from '../common/enterpriseNotification';
30
import { InfoHintContainer } from '../common/info-hint';
31
import RoleDefinition from './roledefinition';
32

33
const columns = [
4✔
34
  { key: 'name', title: 'Role', render: ({ name }) => name },
67✔
35
  { key: 'description', title: 'Description', render: ({ description }) => description || '-' },
67✔
36
  {
37
    key: 'manage',
38
    title: 'Manage',
39
    render: () => (
40
      <div className="bold flexbox center-aligned link-color margin-right-small uppercased" style={{ whiteSpace: 'nowrap' }}>
67✔
41
        view details <ArrowRightAltIcon />
42
      </div>
43
    )
44
  }
45
];
46

47
export const RoleManagement = () => {
4✔
48
  const [adding, setAdding] = useState(false);
8✔
49
  const [editing, setEditing] = useState(false);
8✔
50
  const [role, setRole] = useState({ ...emptyRole });
8✔
51
  const dispatch = useDispatch();
8✔
52
  const groups = useSelector(getGroupsByIdWithoutUngrouped);
8✔
53
  const releaseTags = useSelector(getReleaseTagsById);
8✔
54
  const roles = useSelector(getRolesList);
8✔
55
  const isEnterprise = useSelector(getIsEnterprise);
8✔
56

57
  useEffect(() => {
8✔
58
    dispatch(getExistingReleaseTags());
2✔
59
  }, [dispatch]);
60

61
  useEffect(() => {
8✔
62
    if (Object.keys(groups).length) {
2!
63
      return;
2✔
64
    }
65
    dispatch(getDynamicGroups());
×
66
    dispatch(getGroups());
×
67
    dispatch(getRoles());
×
68
    // eslint-disable-next-line react-hooks/exhaustive-deps
69
  }, [dispatch, JSON.stringify(groups)]);
70

71
  const addRole = () => {
8✔
72
    setAdding(true);
×
73
    setEditing(false);
×
74
    setRole({ ...emptyRole });
×
75
  };
76

77
  const onEditRole = editedRole => {
8✔
78
    setAdding(false);
2✔
79
    setEditing(true);
2✔
80
    setRole(editedRole);
2✔
81
  };
82

83
  const onCancel = () => {
8✔
84
    setAdding(false);
2✔
85
    setEditing(false);
2✔
86
  };
87

88
  const onSubmit = submittedRole => {
8✔
89
    if (adding) {
1!
90
      dispatch(createRole(submittedRole));
×
91
    } else {
92
      dispatch(editRole(submittedRole));
1✔
93
    }
94
    onCancel();
1✔
95
  };
96

97
  const items = useMemo(
8✔
98
    () =>
99
      Object.keys(rolesById)
4✔
100
        .reverse()
101
        .reduce((accu, key) => {
102
          const index = accu.findIndex(({ id }) => id === key);
100✔
103
          accu = [accu[index], ...accu.filter((item, itemIndex) => index !== itemIndex)];
185✔
104
          return accu;
20✔
105
        }, roles),
106
    // eslint-disable-next-line react-hooks/exhaustive-deps
107
    [JSON.stringify(roles)]
108
  );
109

110
  return (
8✔
111
    <div>
112
      <div className="flexbox center-aligned">
113
        <h2 style={{ marginLeft: 20 }}>Roles</h2>
114
        <InfoHintContainer>
115
          <EnterpriseNotification id={BENEFITS.rbac.id} />
116
          <DocsTooltip />
117
        </InfoHintContainer>
118
      </div>
119
      <DetailsTable columns={columns} items={items} onItemClick={onEditRole} />
120
      <Chip color="primary" icon={<AddIcon />} label="Add a role" onClick={addRole} disabled={!isEnterprise} />
121
      <RoleDefinition
122
        adding={adding}
123
        editing={editing}
124
        onCancel={onCancel}
125
        onSubmit={onSubmit}
126
        removeRole={name => dispatch(removeRole(name))}
1✔
127
        selectedRole={role}
128
        stateGroups={groups}
129
        stateReleaseTags={releaseTags}
130
      />
131
    </div>
132
  );
133
};
134

135
export default RoleManagement;
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