@truedat/dd 5.8.4 → 5.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dd",
3
- "version": "5.8.4",
3
+ "version": "5.8.5",
4
4
  "description": "Truedat Web Data Dictionary",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.5",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "5.8.4",
37
+ "@truedat/test": "5.8.5",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -87,9 +87,9 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@apollo/client": "^3.7.1",
90
- "@truedat/auth": "5.8.4",
91
- "@truedat/core": "5.8.4",
92
- "@truedat/df": "5.8.4",
90
+ "@truedat/auth": "5.8.5",
91
+ "@truedat/core": "5.8.5",
92
+ "@truedat/df": "5.8.5",
93
93
  "lodash": "^4.17.21",
94
94
  "moment": "^2.29.4",
95
95
  "path-to-regexp": "^1.7.0",
@@ -114,5 +114,5 @@
114
114
  "react-dom": ">= 16.8.6 < 17",
115
115
  "semantic-ui-react": ">= 2.0.3 < 2.2"
116
116
  },
117
- "gitHead": "7dfd208b88f5e98b40dde7797a58db8a64fef37d"
117
+ "gitHead": "df5ac2e52199ef8054cad09f1e4142c3d6af9d9f"
118
118
  }
@@ -37,6 +37,10 @@ import StructuresLoader from "./StructuresLoader";
37
37
  import StructureFiltersLoader from "./StructureFiltersLoader";
38
38
  import UserSearchFiltersLoader from "./UserSearchFiltersLoader";
39
39
 
40
+ const RolesLoader = React.lazy(() =>
41
+ import("@truedat/auth/roles/components/RolesLoader")
42
+ );
43
+
40
44
  const TemplatesLoader = React.lazy(() =>
41
45
  import("@truedat/df/templates/components/TemplatesLoader")
42
46
  );
@@ -46,7 +50,12 @@ export const GrantRoutes = ({ grantRequestLoaded }) => {
46
50
  <>
47
51
  <Route
48
52
  path={GRANTS_REQUESTS_CHECKOUT}
49
- render={() => <StructureGrantCartCheckout />}
53
+ render={() => (
54
+ <>
55
+ <RolesLoader />
56
+ <StructureGrantCartCheckout />
57
+ </>
58
+ )}
50
59
  />
51
60
  <Switch>
52
61
  <Route exact path={GRANT} render={() => <GrantView />} />
@@ -32,16 +32,24 @@ export const StructureGrantCartInformation = ({
32
32
 
33
33
  return (
34
34
  <Segment loading={loading}>
35
- <Header
36
- title={`${formatMessage({ id: `structure.grant.cart.template` })}`}
37
- >
38
- {formatMessage({ id: `structure.grant.cart.template` })}
39
- </Header>
40
- <Divider />
41
35
  <Form>
42
36
  {!loading && !_.isEmpty(data?.domains) ? (
43
- <StructureGrantCartUserSelector />
37
+ <>
38
+ <Header>
39
+ <Header.Content>
40
+ {formatMessage({ id: "grants.props.user_name" })}
41
+ </Header.Content>
42
+ </Header>
43
+ <Header title={formatMessage({ id: "grants.props.user_name" })} />
44
+ <StructureGrantCartUserSelector />
45
+ <Divider />
46
+ </>
44
47
  ) : null}
48
+ <Header
49
+ title={`${formatMessage({ id: `structure.grant.cart.template` })}`}
50
+ >
51
+ {formatMessage({ id: `structure.grant.cart.template` })}
52
+ </Header>
45
53
  <SelectableDynamicForm
46
54
  scope="gr"
47
55
  content={templateContent}
@@ -1,10 +1,19 @@
1
1
  import _ from "lodash/fp";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { Form, Checkbox, Header } from "semantic-ui-react";
4
+ import {
5
+ Form,
6
+ Dropdown,
7
+ Checkbox,
8
+ Header,
9
+ Label,
10
+ Popup,
11
+ } from "semantic-ui-react";
5
12
  import { connect } from "react-redux";
6
13
  import { useIntl } from "react-intl";
7
14
  import { lowerDeburrTrim } from "@truedat/core/services/sort";
15
+ import { DomainSelector } from "@truedat/core/components";
16
+ import { RoleSelector } from "@truedat/auth/roles/components";
8
17
  import { updateGrantRequestUser } from "../routines";
9
18
 
10
19
  const UsersSearchLoader = React.lazy(() =>
@@ -15,15 +24,21 @@ export const StructureGrantCartUserSelector = ({
15
24
  grantRequestsCart,
16
25
  updateGrantRequestUser,
17
26
  options,
27
+ rolesRaw,
18
28
  }) => {
19
29
  const { formatMessage } = useIntl();
20
30
  const [usersGroupsQuery, setUsersGroupsQuery] = useState("");
21
31
  const [thirdParty, setThirdParty] = useState(false);
32
+ const [domainIds, setDomainIds] = useState([]);
33
+ const [roles, setRoles] = useState([]);
34
+ const [roleIds, setRoleIds] = useState([]);
35
+
22
36
  const [userId, setUserId] = useState(_.path("user.id")(grantRequestsCart));
23
37
 
24
38
  const { modificationGrant } = grantRequestsCart;
25
39
  const updateGrant = !_.isEmpty(modificationGrant);
26
40
 
41
+ const domainActions = ["publishGrantRequest"];
27
42
  useEffect(() => {
28
43
  updateGrantRequestUser({
29
44
  id: userId,
@@ -32,7 +47,30 @@ export const StructureGrantCartUserSelector = ({
32
47
  });
33
48
  if (updateGrant && modificationGrant.user_id)
34
49
  setUserId(modificationGrant.user_id);
35
- }, [userId, thirdParty]);
50
+ }, [
51
+ modificationGrant,
52
+ thirdParty,
53
+ updateGrant,
54
+ updateGrantRequestUser,
55
+ userId,
56
+ ]);
57
+
58
+ useEffect(() => {
59
+ _.flow(
60
+ _.filter({ value: userId }),
61
+ _.first,
62
+ _.pathOr(null, "value"),
63
+ selectUser
64
+ )(options);
65
+ }, [userId, options]);
66
+
67
+ useEffect(() => {
68
+ _.flow(
69
+ _.filter(({ name }) => _.includes(name)(roles)),
70
+ _.map(({ id }) => id),
71
+ setRoleIds
72
+ )(rolesRaw);
73
+ }, [roles, rolesRaw]);
36
74
 
37
75
  const onSearch = (_currentOptions, { searchQuery }) =>
38
76
  setUsersGroupsQuery(lowerDeburrTrim(searchQuery));
@@ -43,6 +81,58 @@ export const StructureGrantCartUserSelector = ({
43
81
  if (userId === "") setThirdParty(false);
44
82
  };
45
83
 
84
+ const userFilters = () => (
85
+ <>
86
+ {formatMessage({ id: "filters" })}:
87
+ <Label.Group>
88
+ <Popup
89
+ basic
90
+ position="bottom left"
91
+ on="click"
92
+ content={
93
+ <DomainSelector
94
+ action={"DomainSelectorGrantCart"}
95
+ value={domainIds}
96
+ onChange={(_e, { value }) => setDomainIds(value)}
97
+ domainActions={domainActions}
98
+ labels
99
+ multiple
100
+ />
101
+ }
102
+ trigger={
103
+ <Label as="a">
104
+ {formatMessage({ id: "userDomainsFilter.placeholder" })}
105
+ {domainIds.length > 0 ? (
106
+ <Label.Detail>{domainIds.length}</Label.Detail>
107
+ ) : null}
108
+ </Label>
109
+ }
110
+ />
111
+ <Popup
112
+ basic
113
+ position="bottom left"
114
+ on="click"
115
+ content={
116
+ <RoleSelector
117
+ onChange={(_e, { value }) => setRoles(value)}
118
+ value={roles}
119
+ labels
120
+ multiple={true}
121
+ />
122
+ }
123
+ trigger={
124
+ <Label as="a">
125
+ {formatMessage({ id: "roles.header" })}
126
+ {roles.length > 0 ? (
127
+ <Label.Detail>{roles.length}</Label.Detail>
128
+ ) : null}
129
+ </Label>
130
+ }
131
+ />
132
+ </Label.Group>
133
+ </>
134
+ );
135
+
46
136
  return updateGrant ? (
47
137
  <Header as="h4">
48
138
  <Header.Content>
@@ -55,6 +145,8 @@ export const StructureGrantCartUserSelector = ({
55
145
  <>
56
146
  <UsersSearchLoader
57
147
  query={usersGroupsQuery}
148
+ domains={domainIds}
149
+ roles={roleIds}
58
150
  permission="allow_foreign_grant_request"
59
151
  hideLoading
60
152
  />
@@ -82,6 +174,7 @@ export const StructureGrantCartUserSelector = ({
82
174
  options={options}
83
175
  value={userId}
84
176
  />
177
+ {userFilters()}
85
178
  </>
86
179
  );
87
180
  };
@@ -90,15 +183,17 @@ StructureGrantCartUserSelector.propTypes = {
90
183
  grantRequestsCart: PropTypes.object,
91
184
  options: PropTypes.array,
92
185
  updateGrantRequestUser: PropTypes.func,
186
+ rolesRaw: PropTypes.array,
93
187
  };
94
188
 
95
- const mapStateToProps = ({ grantRequestsCart, usersSearch }) => ({
189
+ const mapStateToProps = ({ grantRequestsCart, usersSearch, roles }) => ({
96
190
  grantRequestsCart,
97
191
  options: _.map(({ full_name, id }) => ({
98
192
  text: full_name,
99
193
  value: id,
100
194
  icon: "user",
101
195
  }))(usersSearch),
196
+ rolesRaw: roles,
102
197
  });
103
198
 
104
199
  export default connect(mapStateToProps, { updateGrantRequestUser })(
@@ -6,18 +6,16 @@ exports[`<StructureGrantCartInformation /> matches the latest snapshot 1`] = `
6
6
  class="ui loading segment"
7
7
  style="display: none;"
8
8
  >
9
- <div
10
- class="ui header"
11
- title="template"
12
- >
13
- template
14
- </div>
15
- <div
16
- class="ui divider"
17
- />
18
9
  <form
19
10
  class="ui form"
20
- />
11
+ >
12
+ <div
13
+ class="ui header"
14
+ title="template"
15
+ >
16
+ template
17
+ </div>
18
+ </form>
21
19
  </div>
22
20
  </div>
23
21
  `;
@@ -36,14 +36,14 @@ exports[`<StructureGrantCartUserSelector /> matches the latest snapshot 1`] = `
36
36
  <div
37
37
  aria-atomic="true"
38
38
  aria-live="polite"
39
- class="divider text"
39
+ class="divider default text"
40
40
  role="alert"
41
41
  >
42
42
  Select user
43
43
  </div>
44
44
  <i
45
45
  aria-hidden="true"
46
- class="dropdown icon clear"
46
+ class="dropdown icon"
47
47
  />
48
48
  <div
49
49
  class="menu transition"
@@ -69,6 +69,23 @@ exports[`<StructureGrantCartUserSelector /> matches the latest snapshot 1`] = `
69
69
  </div>
70
70
  </div>
71
71
  </div>
72
+
73
+
74
+ <div
75
+ class="ui labels"
76
+ style="display: none;"
77
+ >
78
+ <a
79
+ class="ui label"
80
+ >
81
+ Domains
82
+ </a>
83
+ <a
84
+ class="ui label"
85
+ >
86
+ Roles
87
+ </a>
88
+ </div>
72
89
  lazy
73
90
  </div>
74
91
  `;