@truedat/dd 6.12.4 → 6.12.6
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 +5 -5
- package/src/components/StructuresRoutes.js +22 -7
- package/src/components/__tests__/StructureSelector.spec.js +5 -2
- package/src/components/__tests__/StructuresGrantRequestView.spec.js +3 -3
- package/src/selectors/__tests__/getTabVisibility.spec.js +37 -4
- package/src/selectors/getTabVisibility.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.6",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@apollo/client": "^3.7.1",
|
|
91
|
-
"@truedat/auth": "6.12.
|
|
92
|
-
"@truedat/core": "6.12.
|
|
93
|
-
"@truedat/df": "6.12.
|
|
91
|
+
"@truedat/auth": "6.12.6",
|
|
92
|
+
"@truedat/core": "6.12.6",
|
|
93
|
+
"@truedat/df": "6.12.6",
|
|
94
94
|
"lodash": "^4.17.21",
|
|
95
95
|
"moment": "^2.29.4",
|
|
96
96
|
"path-to-regexp": "^1.7.0",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"react-dom": ">= 16.8.6 < 17",
|
|
116
116
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "6ee7f5e8767d2149347997223377f91f0164ee34"
|
|
119
119
|
}
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
STRUCTURE_VERSION,
|
|
15
15
|
STRUCTURE_MEMBERS_NEW,
|
|
16
16
|
} from "@truedat/core/routes";
|
|
17
|
+
import { connect } from "react-redux";
|
|
18
|
+
import PropTypes from "prop-types";
|
|
17
19
|
import AddStructureMember from "./AddStructureMember";
|
|
18
20
|
import StructureCrumbs from "./StructureCrumbs";
|
|
19
21
|
import StructureLoader from "./StructureLoader";
|
|
@@ -50,9 +52,8 @@ const StructureEventsLoader = () => {
|
|
|
50
52
|
return <EventsLoader resource_id={id} resource_type="data_structure" />;
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
const AuthorizedRoutes = () => {
|
|
55
|
+
const AuthorizedRoutes = ({ view_quality }) => {
|
|
54
56
|
const { formatMessage } = useIntl();
|
|
55
|
-
|
|
56
57
|
return (
|
|
57
58
|
<>
|
|
58
59
|
<Switch>
|
|
@@ -85,7 +86,7 @@ const AuthorizedRoutes = () => {
|
|
|
85
86
|
return (
|
|
86
87
|
<>
|
|
87
88
|
<StructureLoader />
|
|
88
|
-
<StructureImplementationsLoader />
|
|
89
|
+
{view_quality ? <StructureImplementationsLoader /> : null}
|
|
89
90
|
</>
|
|
90
91
|
);
|
|
91
92
|
}}
|
|
@@ -107,15 +108,29 @@ const AuthorizedRoutes = () => {
|
|
|
107
108
|
);
|
|
108
109
|
};
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
const authorized = useAuthorized("data_dictionary");
|
|
111
|
+
AuthorizedRoutes.propTypes = { view_quality: PropTypes.bool };
|
|
112
112
|
|
|
113
|
+
export const StructuresRoutes = ({ view_quality }) => {
|
|
114
|
+
const authorized = useAuthorized("data_dictionary");
|
|
113
115
|
return (
|
|
114
116
|
<Route
|
|
115
117
|
path={[STRUCTURES, BUCKET_VIEW, BUCKETS_VIEW]}
|
|
116
|
-
render={() =>
|
|
118
|
+
render={() =>
|
|
119
|
+
authorized ? (
|
|
120
|
+
<AuthorizedRoutes view_quality={view_quality} />
|
|
121
|
+
) : (
|
|
122
|
+
<Unauthorized />
|
|
123
|
+
)
|
|
124
|
+
}
|
|
117
125
|
/>
|
|
118
126
|
);
|
|
119
127
|
};
|
|
120
128
|
|
|
121
|
-
|
|
129
|
+
StructuresRoutes.propTypes = { view_quality: PropTypes.bool };
|
|
130
|
+
|
|
131
|
+
const mapStateToProps = (state) => ({
|
|
132
|
+
view_quality: state.userPermissions.view_quality,
|
|
133
|
+
userPermissions: state.userPermissions,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export default connect(mapStateToProps)(StructuresRoutes);
|
|
@@ -76,12 +76,15 @@ describe("<StructureSelector />", () => {
|
|
|
76
76
|
columns,
|
|
77
77
|
onSelect: jest.fn(),
|
|
78
78
|
};
|
|
79
|
-
const { container } = render(
|
|
79
|
+
const { container, findByText } = render(
|
|
80
|
+
<StructureSelector {...props} />,
|
|
81
|
+
renderOpts
|
|
82
|
+
);
|
|
80
83
|
|
|
81
84
|
await waitFor(() => {
|
|
82
85
|
expect(container.querySelector(".loading")).toBeNull();
|
|
83
86
|
});
|
|
84
|
-
|
|
87
|
+
await findByText(/Results/);
|
|
85
88
|
expect(container).toMatchSnapshot();
|
|
86
89
|
});
|
|
87
90
|
});
|
|
@@ -77,9 +77,9 @@ describe("<StructuresGrantRequestView />", () => {
|
|
|
77
77
|
renderOpts
|
|
78
78
|
);
|
|
79
79
|
await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
|
|
80
|
-
await waitFor(() =>
|
|
81
|
-
expect(
|
|
82
|
-
);
|
|
80
|
+
await waitFor(() => {
|
|
81
|
+
expect(container.querySelector(".loading")).toBeNull();
|
|
82
|
+
});
|
|
83
83
|
await waitFor(() => expect(container).toMatchSnapshot());
|
|
84
84
|
|
|
85
85
|
const structure1Row = await queryByText(/structure_1/).closest("tr");
|
|
@@ -152,20 +152,53 @@ describe("selectors: getTabVisibility", () => {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
it("should include rules iff structure.implementation_count is greater than 0", () => {
|
|
156
|
-
expect(getTabVisibility({})).toMatchObject({ rules: false });
|
|
155
|
+
it("should include rules iff structure.implementation_count is greater than 0 with permissions", () => {
|
|
157
156
|
expect(
|
|
158
|
-
getTabVisibility({
|
|
157
|
+
getTabVisibility({ userPermissions: { view_quality: true } })
|
|
159
158
|
).toMatchObject({
|
|
160
159
|
rules: false,
|
|
161
160
|
});
|
|
162
161
|
expect(
|
|
163
|
-
getTabVisibility({
|
|
162
|
+
getTabVisibility({
|
|
163
|
+
structure: { implementation_count: 0 },
|
|
164
|
+
userPermissions: { view_quality: true },
|
|
165
|
+
})
|
|
166
|
+
).toMatchObject({
|
|
167
|
+
rules: false,
|
|
168
|
+
});
|
|
169
|
+
expect(
|
|
170
|
+
getTabVisibility({
|
|
171
|
+
structure: { implementation_count: 123 },
|
|
172
|
+
userPermissions: { view_quality: true },
|
|
173
|
+
})
|
|
164
174
|
).toMatchObject({
|
|
165
175
|
rules: true,
|
|
166
176
|
});
|
|
167
177
|
});
|
|
168
178
|
|
|
179
|
+
it("should not include rules iff structure.implementation_count is greater than 0 without permissions", () => {
|
|
180
|
+
expect(
|
|
181
|
+
getTabVisibility({ userPermissions: { view_quality: false } })
|
|
182
|
+
).toMatchObject({
|
|
183
|
+
rules: false,
|
|
184
|
+
});
|
|
185
|
+
expect(
|
|
186
|
+
getTabVisibility({
|
|
187
|
+
structure: { implementation_count: 0 },
|
|
188
|
+
userPermissions: { view_quality: false },
|
|
189
|
+
})
|
|
190
|
+
).toMatchObject({
|
|
191
|
+
rules: false,
|
|
192
|
+
});
|
|
193
|
+
expect(
|
|
194
|
+
getTabVisibility({
|
|
195
|
+
structure: { implementation_count: 123 },
|
|
196
|
+
userPermissions: { view_quality: false },
|
|
197
|
+
})
|
|
198
|
+
).toMatchObject({
|
|
199
|
+
rules: false,
|
|
200
|
+
});
|
|
201
|
+
});
|
|
169
202
|
it("should include parents iff parentRelations is not empty", () => {
|
|
170
203
|
expect(getTabVisibility({})).toMatchObject({ parents: false });
|
|
171
204
|
expect(getTabVisibility({ parentRelations: [] })).toMatchObject({
|
|
@@ -45,7 +45,9 @@ const structureLinksTabVisible = (state) =>
|
|
|
45
45
|
const rolesTabVisible = (state) =>
|
|
46
46
|
_.has("manage_structure_acl_entry", state?.structureActions) ||
|
|
47
47
|
!_.isEmpty(state?.structure?.roles);
|
|
48
|
-
const rulesTabVisible = (state) =>
|
|
48
|
+
const rulesTabVisible = (state) =>
|
|
49
|
+
state?.structure?.implementation_count > 0 &&
|
|
50
|
+
state?.userPermissions?.view_quality;
|
|
49
51
|
const lineageTabVisible = _.anyPass([_.path("structure.degree.in")]);
|
|
50
52
|
const impactTabVisible = _.anyPass([_.path("structure.degree.out")]);
|
|
51
53
|
const parentsTabVisible = _.conformsTo({ parentRelations: notEmpty });
|