@truedat/dd 5.5.2 → 5.6.1
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 +6 -6
- package/src/components/GrantRemoval.js +6 -3
- package/src/components/GrantRequestCancel.js +4 -2
- package/src/components/GrantRoutes.js +27 -0
- package/src/components/StructureGrantCart.js +19 -12
- package/src/components/StructureGrantDropdown.js +25 -35
- package/src/components/StructureGrantListButton.js +85 -0
- package/src/components/StructureGrantRequestButton.js +1 -21
- package/src/components/StructureGrantSummaryButton.js +87 -0
- package/src/components/StructureRow.js +10 -6
- package/src/components/StructureSummary.js +4 -2
- package/src/components/StructuresGrantRequest.js +0 -0
- package/src/components/StructuresGrantRequestView.js +68 -0
- package/src/components/StructuresLoader.js +4 -2
- package/src/components/StructuresSearch.js +1 -0
- package/src/components/StructuresSearchResults.js +3 -0
- package/src/components/StructuresTable.js +37 -24
- package/src/components/StructuresView.js +9 -10
- package/src/components/__tests__/StructureGrantDropdown.spec.js +66 -29
- package/src/components/__tests__/StructureGrantListButton.spec.js +77 -0
- package/src/components/__tests__/{StructureGrantButton.spec.js → StructureGrantSummaryButton.spec.js} +9 -9
- package/src/components/__tests__/StructureRow.spec.js +10 -10
- package/src/components/__tests__/StructuresGrantRequestView.spec.js +83 -0
- package/src/components/__tests__/StructuresLoader.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +4 -0
- package/src/components/__tests__/__snapshots__/StructureGrantListButton.spec.js.snap +159 -0
- package/src/components/__tests__/__snapshots__/{StructureGrantButton.spec.js.snap → StructureGrantSummaryButton.spec.js.snap} +5 -5
- package/src/components/__tests__/__snapshots__/StructureRow.spec.js.snap +4 -1
- package/src/components/__tests__/__snapshots__/StructuresGrantRequestView.spec.js.snap +310 -0
- package/src/components/__tests__/__snapshots__/StructuresLoader.spec.js.snap +3 -1
- package/src/components/__tests__/__snapshots__/StructuresTable.spec.js.snap +21 -12
- package/src/messages/en.js +4 -0
- package/src/messages/es.js +5 -0
- package/src/reducers/structureActiveFilters.js +10 -9
- package/src/reducers/structureSelectedFilter.js +1 -1
- package/src/reducers/structures.js +5 -0
- package/src/sagas/createGrantRequestStatus.js +12 -3
- package/src/sagas/requestGrantRemoval.js +13 -3
- package/src/selectors/structureColumnsSelector.js +16 -6
- package/src/components/StructureGrantButton.js +0 -43
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
1
2
|
import {
|
|
2
3
|
includes,
|
|
3
4
|
isArray,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
propOr,
|
|
8
9
|
union,
|
|
9
10
|
without,
|
|
11
|
+
tap,
|
|
10
12
|
} from "lodash/fp";
|
|
11
13
|
import {
|
|
12
14
|
addStructureFilter,
|
|
@@ -24,6 +26,13 @@ export const structureActiveFilters = (
|
|
|
24
26
|
state = initialState,
|
|
25
27
|
{ type, payload }
|
|
26
28
|
) => {
|
|
29
|
+
const toggle = (state, filter, value) =>
|
|
30
|
+
_.flow(
|
|
31
|
+
() => state[filter] || [],
|
|
32
|
+
(currentValues) => _.xor(isArray(value) ? value : [value], currentValues),
|
|
33
|
+
(newValues) => ({ ...state, [filter]: newValues })
|
|
34
|
+
);
|
|
35
|
+
|
|
27
36
|
switch (type) {
|
|
28
37
|
case clearStructureFilters.TRIGGER:
|
|
29
38
|
return initialState;
|
|
@@ -50,15 +59,7 @@ export const structureActiveFilters = (
|
|
|
50
59
|
return initialState;
|
|
51
60
|
}
|
|
52
61
|
case toggleStructureFilterValue.TRIGGER: {
|
|
53
|
-
|
|
54
|
-
if (isArray(value)) {
|
|
55
|
-
return { ...state, [filter]: value };
|
|
56
|
-
}
|
|
57
|
-
const values = propOr([], filter)(state);
|
|
58
|
-
const nextValues = includes(value)(values)
|
|
59
|
-
? without([value])(values)
|
|
60
|
-
: union([value])(values);
|
|
61
|
-
return { ...state, [filter]: nextValues };
|
|
62
|
+
return toggle(state, payload.filter, payload.value)();
|
|
62
63
|
}
|
|
63
64
|
default:
|
|
64
65
|
return state;
|
|
@@ -7,6 +7,7 @@ const pickFields = _.pick([
|
|
|
7
7
|
"id",
|
|
8
8
|
"domain_id",
|
|
9
9
|
"name",
|
|
10
|
+
"grants",
|
|
10
11
|
"group",
|
|
11
12
|
"description",
|
|
12
13
|
"path",
|
|
@@ -21,6 +22,10 @@ const pickFields = _.pick([
|
|
|
21
22
|
"mutable_metadata",
|
|
22
23
|
"note",
|
|
23
24
|
"original_name",
|
|
25
|
+
"my_grants",
|
|
26
|
+
"my_grant_request",
|
|
27
|
+
"data_fields",
|
|
28
|
+
"user_permissions",
|
|
24
29
|
]);
|
|
25
30
|
|
|
26
31
|
const structures = (state = initialState, { type, payload }) => {
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { compile } from "path-to-regexp";
|
|
2
2
|
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
3
|
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
createGrantRequestStatus,
|
|
6
|
+
fetchStructure,
|
|
7
|
+
fetchStructures,
|
|
8
|
+
} from "../routines";
|
|
5
9
|
import { API_GRANT_REQUEST_STATUS } from "../api";
|
|
6
10
|
|
|
7
11
|
export function* createGrantRequestStatusSaga({ payload }) {
|
|
8
12
|
try {
|
|
9
|
-
const { grantRequestId, status, structureId } =
|
|
13
|
+
const { grantRequestId, status, structureId, previousStructureQuery } =
|
|
14
|
+
payload;
|
|
10
15
|
const url = compile(API_GRANT_REQUEST_STATUS)({ id: grantRequestId });
|
|
11
16
|
yield put(createGrantRequestStatus.request({ status }));
|
|
12
17
|
const { data } = yield call(apiJsonPost, url, { status }, JSON_OPTS);
|
|
13
18
|
yield put(createGrantRequestStatus.success(data));
|
|
14
|
-
yield put(
|
|
19
|
+
yield put(
|
|
20
|
+
previousStructureQuery
|
|
21
|
+
? fetchStructures.trigger(previousStructureQuery)
|
|
22
|
+
: fetchStructure.trigger({ id: structureId })
|
|
23
|
+
);
|
|
15
24
|
} catch (error) {
|
|
16
25
|
if (error.response) {
|
|
17
26
|
const { status, data } = error.response;
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { compile } from "path-to-regexp";
|
|
2
2
|
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
3
|
import { apiJsonPatch, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
requestGrantRemoval,
|
|
6
|
+
fetchStructure,
|
|
7
|
+
fetchStructures,
|
|
8
|
+
} from "../routines";
|
|
5
9
|
import { API_GRANT } from "../api";
|
|
6
10
|
|
|
7
11
|
export function* requestGrantRemovalSaga({ payload }) {
|
|
8
12
|
try {
|
|
9
|
-
const { id, action, data_structure_id, version } =
|
|
13
|
+
const { id, action, data_structure_id, version, previousStructureQuery } =
|
|
14
|
+
payload;
|
|
10
15
|
const url = compile(API_GRANT)({ id });
|
|
11
16
|
const requestData = { action };
|
|
12
17
|
yield put(requestGrantRemoval.request());
|
|
13
18
|
const { data } = yield call(apiJsonPatch, url, requestData, JSON_OPTS);
|
|
14
19
|
yield put(requestGrantRemoval.success(data));
|
|
15
|
-
|
|
20
|
+
|
|
21
|
+
yield put(
|
|
22
|
+
previousStructureQuery
|
|
23
|
+
? fetchStructures.trigger(previousStructureQuery)
|
|
24
|
+
: fetchStructure.trigger({ id: data_structure_id, version })
|
|
25
|
+
);
|
|
16
26
|
} catch (error) {
|
|
17
27
|
if (error.response) {
|
|
18
28
|
const { status, data } = error.response;
|
|
@@ -80,9 +80,19 @@ const getStructureColumnNames = createSelector(
|
|
|
80
80
|
(columns) => _.concat("structure_type")(_.map("name")(columns))
|
|
81
81
|
);
|
|
82
82
|
|
|
83
|
-
export const structureRowsSelector =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
export const structureRowsSelector = (state, props, extraColumns = []) =>
|
|
84
|
+
createSelector(
|
|
85
|
+
getStructures,
|
|
86
|
+
getStructureColumnNames,
|
|
87
|
+
(structures, columnNames) =>
|
|
88
|
+
_.map(
|
|
89
|
+
_.pick([
|
|
90
|
+
...columnNames,
|
|
91
|
+
"id",
|
|
92
|
+
"domain_id",
|
|
93
|
+
"note",
|
|
94
|
+
"grants",
|
|
95
|
+
...extraColumns,
|
|
96
|
+
])
|
|
97
|
+
)(structures)
|
|
98
|
+
)(state, props);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { useQuery } from "@apollo/client";
|
|
5
|
-
import { connect } from "react-redux";
|
|
6
|
-
import { Loading } from "@truedat/core/components";
|
|
7
|
-
import { LATEST_GRANT_REQUEST_QUERY } from "../api/queries";
|
|
8
|
-
import StructureGrantRequestButton from "./StructureGrantRequestButton";
|
|
9
|
-
import StructureGrantDropdown from "./StructureGrantDropdown";
|
|
10
|
-
|
|
11
|
-
export const StructureGrantButton = ({ structure }) => {
|
|
12
|
-
const { grant, id } = structure;
|
|
13
|
-
|
|
14
|
-
const { loading, error, data } = useQuery(LATEST_GRANT_REQUEST_QUERY, {
|
|
15
|
-
fetchPolicy: "cache-and-network",
|
|
16
|
-
variables: { id },
|
|
17
|
-
});
|
|
18
|
-
if (error) return null;
|
|
19
|
-
if (loading) return <Loading />;
|
|
20
|
-
|
|
21
|
-
const grantRequest = _.prop("latestGrantRequest")(data);
|
|
22
|
-
const isActiveRequest = _.includes(_.prop("status.status")(grantRequest))([
|
|
23
|
-
"pending",
|
|
24
|
-
"approved",
|
|
25
|
-
"processing",
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
return grant || isActiveRequest ? (
|
|
29
|
-
<StructureGrantDropdown
|
|
30
|
-
grantRequest={isActiveRequest ? grantRequest : null}
|
|
31
|
-
/>
|
|
32
|
-
) : (
|
|
33
|
-
<StructureGrantRequestButton />
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
StructureGrantButton.propTypes = {
|
|
38
|
-
structure: PropTypes.object,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const mapStateToProps = ({ structure }) => ({ structure });
|
|
42
|
-
|
|
43
|
-
export default connect(mapStateToProps)(StructureGrantButton);
|