@truedat/dd 4.28.1 → 4.28.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/CHANGELOG.md +6 -0
- package/package.json +6 -6
- package/src/api.js +4 -0
- package/src/components/EditDomainForm.js +1 -0
- package/src/components/GrantDateFilter.js +30 -0
- package/src/components/GrantFilters.js +28 -0
- package/src/components/GrantFiltersLoader.js +24 -0
- package/src/components/GrantSelectedFilters.js +63 -0
- package/src/components/Grants.js +49 -0
- package/src/components/GrantsLabelResults.js +32 -0
- package/src/components/GrantsLoader.js +41 -0
- package/src/components/GrantsPagination.js +14 -0
- package/src/components/GrantsRoutes.js +33 -0
- package/src/components/GrantsSearch.js +51 -0
- package/src/components/GrantsTable.js +112 -0
- package/src/components/StructureGrantCart.js +16 -14
- package/src/components/StructureGrantCartCheckout.js +9 -9
- package/src/components/StructureSummary.js +5 -5
- package/src/components/StructureTabPane.js +3 -3
- package/src/components/StructureView.js +14 -6
- package/src/components/__tests__/GrantDateFilter.spec.js +11 -0
- package/src/components/__tests__/GrantsLabelResults.js +17 -0
- package/src/components/__tests__/GrantsLoader.spec.js +41 -0
- package/src/components/__tests__/GrantsRoutes.spec.js +19 -0
- package/src/components/__tests__/GrantsTable.spec.js +185 -0
- package/src/components/__tests__/StructureGrantRequestButton.spec.js +20 -9
- package/src/components/__tests__/StructureSummary.spec.js +1 -1
- package/src/components/__tests__/__snapshots__/GrantDateFilter.spec.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/GrantsLabelResults.js.snap +16 -0
- package/src/components/__tests__/__snapshots__/GrantsLoader.spec.js.snap +24 -0
- package/src/components/__tests__/__snapshots__/GrantsRoutes.spec.js.snap +8 -0
- package/src/components/__tests__/__snapshots__/GrantsTable.spec.js.snap +231 -0
- package/src/components/index.js +6 -0
- package/src/messages/en.js +9 -1
- package/src/messages/es.js +9 -1
- package/src/reducers/__tests__/grantDateFilter.spec.js +54 -0
- package/src/reducers/__tests__/grantFilters.spec.js +37 -0
- package/src/reducers/__tests__/grantQuery.spec.js +113 -0
- package/src/reducers/__tests__/grants.spec.js +102 -0
- package/src/reducers/grantActiveFilters.js +46 -0
- package/src/reducers/grantCount.js +20 -0
- package/src/reducers/grantDateFilter.js +31 -0
- package/src/reducers/grantFilters.js +19 -0
- package/src/reducers/grantLoading.js +16 -0
- package/src/reducers/grantQuery.js +62 -0
- package/src/reducers/grantSelectedFilter.js +34 -0
- package/src/reducers/grants.js +24 -0
- package/src/reducers/grantsFilters.js +19 -0
- package/src/reducers/grantsPageSize.js +15 -0
- package/src/reducers/index.js +18 -0
- package/src/reducers/structureDateFilter.js +2 -2
- package/src/reducers/structureQuery.js +2 -2
- package/src/routines.js +20 -0
- package/src/sagas/__tests__/fetchGrants.spec.js +74 -0
- package/src/sagas/fetchGrantFilters.js +29 -0
- package/src/sagas/fetchGrants.js +26 -0
- package/src/sagas/index.js +6 -0
- package/src/selectors/__tests__/__snapshots__/getGrantsColumns.spec.js.snap +10 -0
- package/src/selectors/__tests__/getGrantAvailableFilters.spec.js +15 -0
- package/src/selectors/__tests__/getGrantSelectedFilterActiveValues.spec.js +16 -0
- package/src/selectors/__tests__/getGrantSelectedFilterValues.spec.js +15 -0
- package/src/selectors/__tests__/getGrantSelectedFilters.spec.js +15 -0
- package/src/selectors/__tests__/getGrantsColumns.spec.js +40 -0
- package/src/selectors/__tests__/getTabVisibility.spec.js +30 -30
- package/src/selectors/getGrantAvailableFilters.js +17 -0
- package/src/selectors/getGrantSelectedFilterActiveValues.js +8 -0
- package/src/selectors/getGrantSelectedFilterValues.js +13 -0
- package/src/selectors/getGrantSelectedFilters.js +7 -0
- package/src/selectors/getGrantsColumns.js +82 -8
- package/src/selectors/getStructureSelectedFilterValues.js +5 -3
- package/src/selectors/getTabVisibility.js +7 -7
- package/src/selectors/index.js +4 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
3
|
+
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
4
|
+
import { fetchGrantFilters } from "../routines";
|
|
5
|
+
import { API_GRANT_FILTERS_SEARCH } from "../api";
|
|
6
|
+
|
|
7
|
+
export function* fetchGrantFiltersSaga(payload) {
|
|
8
|
+
try {
|
|
9
|
+
yield put(fetchGrantFilters.request());
|
|
10
|
+
const url = API_GRANT_FILTERS_SEARCH;
|
|
11
|
+
const filters = _.propOr({}, "payload.filters")(payload);
|
|
12
|
+
const body = { filters };
|
|
13
|
+
const { data } = yield call(apiJsonPost, url, body, JSON_OPTS);
|
|
14
|
+
yield put(fetchGrantFilters.success({ data }));
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (error.response) {
|
|
17
|
+
const { status, data } = error.response;
|
|
18
|
+
yield put(fetchGrantFilters.failure({ status, data }));
|
|
19
|
+
} else {
|
|
20
|
+
yield put(fetchGrantFilters.failure(error.message));
|
|
21
|
+
}
|
|
22
|
+
} finally {
|
|
23
|
+
yield put(fetchGrantFilters.fulfill());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function* fetchGrantFiltersRequestSaga() {
|
|
28
|
+
yield takeLatest(fetchGrantFilters.TRIGGER, fetchGrantFiltersSaga);
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { call, put, debounce } from "redux-saga/effects";
|
|
2
|
+
import { apiJsonPost, JSON_OPTS } from "@truedat/core/services/api";
|
|
3
|
+
import { fetchGrants } from "../routines";
|
|
4
|
+
import { API_GRANTS_SEARCH } from "../api";
|
|
5
|
+
|
|
6
|
+
export function* fetchGrantsSaga({ payload: body }) {
|
|
7
|
+
try {
|
|
8
|
+
const url = API_GRANTS_SEARCH;
|
|
9
|
+
yield put(fetchGrants.request(body));
|
|
10
|
+
const { data, headers } = yield call(apiJsonPost, url, body, JSON_OPTS);
|
|
11
|
+
yield put(fetchGrants.success({ data, headers }));
|
|
12
|
+
} catch (error) {
|
|
13
|
+
if (error.response) {
|
|
14
|
+
const { status, data } = error.response;
|
|
15
|
+
yield put(fetchGrants.failure({ status, data }));
|
|
16
|
+
} else {
|
|
17
|
+
yield put(fetchGrants.failure(error.message));
|
|
18
|
+
}
|
|
19
|
+
} finally {
|
|
20
|
+
yield put(fetchGrants.fulfill());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function* fetchGrantsRequestSaga() {
|
|
25
|
+
yield debounce(200, fetchGrants.TRIGGER, fetchGrantsSaga);
|
|
26
|
+
}
|
package/src/sagas/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import { deleteStructureUserFilterRequestSaga } from "./deleteStructureUserFilte
|
|
|
11
11
|
import { doStructureNoteActionRequestSaga } from "./doStructureNoteAction";
|
|
12
12
|
import { downloadCsvGraphRequestSaga } from "./downloadCsvGraph";
|
|
13
13
|
import { downloadStructuresRequestSaga } from "./downloadStructures";
|
|
14
|
+
import { fetchGrantFiltersRequestSaga } from "./fetchGrantFilters";
|
|
15
|
+
import { fetchGrantsRequestSaga } from "./fetchGrants";
|
|
14
16
|
import { fetchGraphRequestSaga } from "./fetchGraph";
|
|
15
17
|
import { fetchLinksStructureTagsRequestSaga } from "./fetchLinksStructureTags";
|
|
16
18
|
import { fetchNodesRequestSaga } from "./fetchNodes";
|
|
@@ -53,6 +55,8 @@ export {
|
|
|
53
55
|
doStructureNoteActionRequestSaga,
|
|
54
56
|
downloadCsvGraphRequestSaga,
|
|
55
57
|
downloadStructuresRequestSaga,
|
|
58
|
+
fetchGrantFiltersRequestSaga,
|
|
59
|
+
fetchGrantsRequestSaga,
|
|
56
60
|
fetchGraphRequestSaga,
|
|
57
61
|
fetchLinksStructureTagsRequestSaga,
|
|
58
62
|
fetchNodesRequestSaga,
|
|
@@ -96,6 +100,8 @@ export default [
|
|
|
96
100
|
doStructureNoteActionRequestSaga(),
|
|
97
101
|
downloadCsvGraphRequestSaga(),
|
|
98
102
|
downloadStructuresRequestSaga(),
|
|
103
|
+
fetchGrantFiltersRequestSaga(),
|
|
104
|
+
fetchGrantsRequestSaga(),
|
|
99
105
|
fetchGraphRequestSaga(),
|
|
100
106
|
fetchLinksStructureTagsRequestSaga(),
|
|
101
107
|
fetchNodesRequestSaga(),
|
|
@@ -42,6 +42,16 @@ exports[`GrantStructureDecorator matches the latest snapshot when structure is n
|
|
|
42
42
|
</div>
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
|
+
exports[`GrantTableStructureDecorator matches the latest snapshot when structure is direct 1`] = `
|
|
46
|
+
<div>
|
|
47
|
+
<a
|
|
48
|
+
href="/structures/1"
|
|
49
|
+
>
|
|
50
|
+
foo
|
|
51
|
+
</a>
|
|
52
|
+
</div>
|
|
53
|
+
`;
|
|
54
|
+
|
|
45
55
|
exports[`GrantUserDecorator matches the latest snapshot 1`] = `
|
|
46
56
|
<div>
|
|
47
57
|
<h4
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getGrantAvailableFilters } from "..";
|
|
2
|
+
|
|
3
|
+
const foo = ["foo1", "foo2"];
|
|
4
|
+
const bar = ["bar1", "bar2"];
|
|
5
|
+
const baz = ["baz1", "baz2"];
|
|
6
|
+
|
|
7
|
+
describe("selectors: getGrantAvailableFilters", () => {
|
|
8
|
+
const grantFilters = { foo, bar, baz };
|
|
9
|
+
const grantActiveFilters = { baz: [] };
|
|
10
|
+
const state = { grantFilters, grantActiveFilters };
|
|
11
|
+
|
|
12
|
+
it("should return the keys of the grant filters which are not currently active", () => {
|
|
13
|
+
expect(getGrantAvailableFilters(state)).toEqual(["foo", "bar"]);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getGrantSelectedFilterActiveValues } from "..";
|
|
2
|
+
|
|
3
|
+
const foo = ["foo1", "foo2"];
|
|
4
|
+
const bar = ["bar1", "bar2"];
|
|
5
|
+
const baz = ["baz1", "baz2"];
|
|
6
|
+
|
|
7
|
+
describe("selectors: getGrantSelectedFilterActiveValues", () => {
|
|
8
|
+
const grantFilters = { foo, bar, baz };
|
|
9
|
+
const grantActiveFilters = { foo: ["foo1"] };
|
|
10
|
+
const grantSelectedFilter = "foo";
|
|
11
|
+
const state = { grantFilters, grantActiveFilters, grantSelectedFilter };
|
|
12
|
+
|
|
13
|
+
it("should return the active values of the currently selected grant filters", () => {
|
|
14
|
+
expect(getGrantSelectedFilterActiveValues(state)).toEqual(["foo1"]);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getGrantSelectedFilterValues } from "..";
|
|
2
|
+
|
|
3
|
+
const foo = ["foo1", "foo2"];
|
|
4
|
+
const bar = ["bar1", "bar2"];
|
|
5
|
+
const baz = ["baz1", "baz2"];
|
|
6
|
+
|
|
7
|
+
describe("selectors: getGrantSelectedFilterValues", () => {
|
|
8
|
+
const grantFilters = { foo, bar, baz };
|
|
9
|
+
const grantSelectedFilter = "foo";
|
|
10
|
+
const state = { grantFilters, grantSelectedFilter };
|
|
11
|
+
|
|
12
|
+
it("should return the values of the currently selected grant filters", () => {
|
|
13
|
+
expect(getGrantSelectedFilterValues(state)).toEqual(foo);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getGrantSelectedFilters } from "..";
|
|
2
|
+
|
|
3
|
+
const foo = ["foo1", "foo2"];
|
|
4
|
+
const bar = ["bar1", "bar2"];
|
|
5
|
+
const baz = ["baz1", "baz2"];
|
|
6
|
+
|
|
7
|
+
describe("selectors: getStructureAvailableFilters", () => {
|
|
8
|
+
const grantFilters = { foo, bar, baz };
|
|
9
|
+
const grantActiveFilters = { baz: [] };
|
|
10
|
+
const state = { grantFilters, grantActiveFilters };
|
|
11
|
+
|
|
12
|
+
it("should return the keys of the grant filters which are currently active", () => {
|
|
13
|
+
expect(getGrantSelectedFilters(state)).toEqual(["baz"]);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -3,9 +3,12 @@ import React from "react";
|
|
|
3
3
|
import { render } from "@truedat/test/render";
|
|
4
4
|
import {
|
|
5
5
|
defaultGrantsColumns,
|
|
6
|
+
defaultGrantsTableColumns,
|
|
6
7
|
getGrantsColumns,
|
|
8
|
+
getGrantsTableColumns,
|
|
7
9
|
GrantUserDecorator,
|
|
8
10
|
GrantStructureDecorator,
|
|
11
|
+
GrantTableStructureDecorator,
|
|
9
12
|
StartDateDecorator,
|
|
10
13
|
EndDateDecorator,
|
|
11
14
|
} from "..";
|
|
@@ -49,6 +52,30 @@ describe("selectors: getGrantsColumns", () => {
|
|
|
49
52
|
});
|
|
50
53
|
});
|
|
51
54
|
|
|
55
|
+
describe("selectors: getGrantsTableColumns", () => {
|
|
56
|
+
const state = {
|
|
57
|
+
authentication,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
it("get default grant columns", () => {
|
|
61
|
+
const columns = getGrantsTableColumns(state);
|
|
62
|
+
expect(_.map("name")(columns)).toEqual(
|
|
63
|
+
_.map("name")(defaultGrantsTableColumns)
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("get specified columns in reducer", () => {
|
|
68
|
+
const grantsColumns = [
|
|
69
|
+
{
|
|
70
|
+
name: "foo",
|
|
71
|
+
fieldDecorator: _.identity,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
const columns = getGrantsTableColumns({ ...state, grantsColumns });
|
|
75
|
+
expect(columns).toStrictEqual(grantsColumns);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
52
79
|
describe("GrantUserDecorator", () => {
|
|
53
80
|
it("matches the latest snapshot", () => {
|
|
54
81
|
const props = {
|
|
@@ -91,6 +118,19 @@ describe("GrantStructureDecorator", () => {
|
|
|
91
118
|
});
|
|
92
119
|
});
|
|
93
120
|
|
|
121
|
+
describe("GrantTableStructureDecorator", () => {
|
|
122
|
+
it("matches the latest snapshot when structure is direct", () => {
|
|
123
|
+
const props = {
|
|
124
|
+
data_structure_version: { data_structure_id: 1, name: "foo" },
|
|
125
|
+
};
|
|
126
|
+
const { container } = render(
|
|
127
|
+
<GrantTableStructureDecorator {...props} />,
|
|
128
|
+
renderOpts
|
|
129
|
+
);
|
|
130
|
+
expect(container).toMatchSnapshot();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
94
134
|
describe("StartDateDecorator", () => {
|
|
95
135
|
it("matches the latest snapshot", () => {
|
|
96
136
|
const props = {
|
|
@@ -3,10 +3,10 @@ import { getTabVisibility } from "../getTabVisibility";
|
|
|
3
3
|
describe("selectors: getTabVisibility", () => {
|
|
4
4
|
it("should include fields iff structureFields is not empty", () => {
|
|
5
5
|
expect(getTabVisibility({ structureFields: [1] })).toMatchObject({
|
|
6
|
-
fields: true
|
|
6
|
+
fields: true,
|
|
7
7
|
});
|
|
8
8
|
expect(getTabVisibility({ structureFields: [] })).toMatchObject({
|
|
9
|
-
fields: false
|
|
9
|
+
fields: false,
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -32,7 +32,7 @@ describe("selectors: getTabVisibility", () => {
|
|
|
32
32
|
const structureFields = [{ profile: { foo: "foo" } }];
|
|
33
33
|
const userPermissions = { view_profiling_permission: true };
|
|
34
34
|
expect(getTabVisibility({ structureFields })).toMatchObject({
|
|
35
|
-
profile: false
|
|
35
|
+
profile: false,
|
|
36
36
|
});
|
|
37
37
|
expect(
|
|
38
38
|
getTabVisibility({ structureFields, userPermissions })
|
|
@@ -42,44 +42,44 @@ describe("selectors: getTabVisibility", () => {
|
|
|
42
42
|
it("should include profile if permission is present and a structure has a profile", () => {
|
|
43
43
|
const userPermissions = { view_profiling_permission: true };
|
|
44
44
|
expect(getTabVisibility({ structure: {} })).toMatchObject({
|
|
45
|
-
profile: false
|
|
45
|
+
profile: false,
|
|
46
46
|
});
|
|
47
47
|
expect(
|
|
48
48
|
getTabVisibility({
|
|
49
49
|
structure: { profile: { foo: "foo" } },
|
|
50
|
-
userPermissions
|
|
50
|
+
userPermissions,
|
|
51
51
|
})
|
|
52
52
|
).toMatchObject({ profile: false });
|
|
53
53
|
expect(
|
|
54
54
|
getTabVisibility({
|
|
55
55
|
structureProfile: { patterns: "foo" },
|
|
56
|
-
userPermissions
|
|
56
|
+
userPermissions,
|
|
57
57
|
})
|
|
58
58
|
).toMatchObject({ profile: true });
|
|
59
59
|
expect(
|
|
60
60
|
getTabVisibility({
|
|
61
61
|
structureProfile: { most_frequent: "foo" },
|
|
62
|
-
userPermissions
|
|
62
|
+
userPermissions,
|
|
63
63
|
})
|
|
64
64
|
).toMatchObject({ profile: true });
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it("should include links iff conceptCount is non-zero or structure has links", () => {
|
|
68
68
|
expect(getTabVisibility({ conceptCount: 1 })).toMatchObject({
|
|
69
|
-
links: true
|
|
69
|
+
links: true,
|
|
70
70
|
});
|
|
71
71
|
expect(getTabVisibility({ conceptCount: 0 })).toMatchObject({
|
|
72
|
-
links: false
|
|
72
|
+
links: false,
|
|
73
73
|
});
|
|
74
74
|
expect(
|
|
75
75
|
getTabVisibility({ structureLinks: [{ resource_type: "concept" }] })
|
|
76
76
|
).toMatchObject({
|
|
77
|
-
links: true
|
|
77
|
+
links: true,
|
|
78
78
|
});
|
|
79
79
|
expect(
|
|
80
80
|
getTabVisibility({ structureLinks: [{ resource_type: "foo" }] })
|
|
81
81
|
).toMatchObject({
|
|
82
|
-
links: false
|
|
82
|
+
links: false,
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -88,17 +88,17 @@ describe("selectors: getTabVisibility", () => {
|
|
|
88
88
|
const templates = [{ name: "foo" }];
|
|
89
89
|
const structureTypes = [{ name: "foo", template: { id: 1, name: "n" } }];
|
|
90
90
|
expect(getTabVisibility({ templatesLoading: true })).toMatchObject({
|
|
91
|
-
notes: false
|
|
91
|
+
notes: false,
|
|
92
92
|
});
|
|
93
93
|
expect(
|
|
94
94
|
getTabVisibility({
|
|
95
95
|
structure,
|
|
96
96
|
templates,
|
|
97
97
|
structureTypes,
|
|
98
|
-
structureTypesLoading: false
|
|
98
|
+
structureTypesLoading: false,
|
|
99
99
|
})
|
|
100
100
|
).toMatchObject({
|
|
101
|
-
notes: true
|
|
101
|
+
notes: true,
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -107,80 +107,80 @@ describe("selectors: getTabVisibility", () => {
|
|
|
107
107
|
const templates = [{ name: "foo" }];
|
|
108
108
|
const structureTypes = [{ name: "foo" }];
|
|
109
109
|
expect(getTabVisibility({ templatesLoading: true })).toMatchObject({
|
|
110
|
-
notes: false
|
|
110
|
+
notes: false,
|
|
111
111
|
});
|
|
112
112
|
expect(
|
|
113
113
|
getTabVisibility({
|
|
114
114
|
structure,
|
|
115
115
|
templates,
|
|
116
116
|
structureTypes,
|
|
117
|
-
structureTypesLoading: false
|
|
117
|
+
structureTypesLoading: false,
|
|
118
118
|
})
|
|
119
119
|
).toMatchObject({
|
|
120
|
-
notes: false
|
|
120
|
+
notes: false,
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
it("should include versions iff structureVersions is not empty", () => {
|
|
125
125
|
expect(getTabVisibility({})).toMatchObject({ versions: false });
|
|
126
126
|
expect(getTabVisibility({ structureVersions: [] })).toMatchObject({
|
|
127
|
-
versions: false
|
|
127
|
+
versions: false,
|
|
128
128
|
});
|
|
129
129
|
expect(getTabVisibility({ structureVersions: [{}] })).toMatchObject({
|
|
130
|
-
versions: true
|
|
130
|
+
versions: true,
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
it("should include events iff structureVersion is empty", () => {
|
|
135
135
|
expect(getTabVisibility({})).toMatchObject({ events: true });
|
|
136
136
|
expect(getTabVisibility({ structureVersion: {} })).toMatchObject({
|
|
137
|
-
events: true
|
|
137
|
+
events: true,
|
|
138
138
|
});
|
|
139
139
|
expect(getTabVisibility({ structureVersion: "whatever" })).toMatchObject({
|
|
140
|
-
events: false
|
|
140
|
+
events: false,
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
it("should include rules iff ruleImplementations is not empty", () => {
|
|
145
145
|
expect(getTabVisibility({})).toMatchObject({ rules: false });
|
|
146
146
|
expect(getTabVisibility({ ruleImplementations: [] })).toMatchObject({
|
|
147
|
-
rules: false
|
|
147
|
+
rules: false,
|
|
148
148
|
});
|
|
149
149
|
expect(getTabVisibility({ ruleImplementations: [{}] })).toMatchObject({
|
|
150
|
-
rules: true
|
|
150
|
+
rules: true,
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
it("should include parents iff parentRelations is not empty", () => {
|
|
155
155
|
expect(getTabVisibility({})).toMatchObject({ parents: false });
|
|
156
156
|
expect(getTabVisibility({ parentRelations: [] })).toMatchObject({
|
|
157
|
-
parents: false
|
|
157
|
+
parents: false,
|
|
158
158
|
});
|
|
159
159
|
expect(getTabVisibility({ parentRelations: [{}] })).toMatchObject({
|
|
160
|
-
parents: true
|
|
160
|
+
parents: true,
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
it("should include children iff childrenRelations is not empty", () => {
|
|
165
165
|
expect(getTabVisibility({})).toMatchObject({ children: false });
|
|
166
166
|
expect(getTabVisibility({ childrenRelations: [] })).toMatchObject({
|
|
167
|
-
children: false
|
|
167
|
+
children: false,
|
|
168
168
|
});
|
|
169
169
|
expect(getTabVisibility({ childrenRelations: [{}] })).toMatchObject({
|
|
170
|
-
children: true
|
|
170
|
+
children: true,
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
it("should include grants if grants is not empty or nil", () => {
|
|
175
175
|
expect(getTabVisibility({})).toMatchObject({ grants: false });
|
|
176
176
|
expect(getTabVisibility({ structure: {} })).toMatchObject({
|
|
177
|
-
grants: false
|
|
177
|
+
grants: false,
|
|
178
178
|
});
|
|
179
179
|
expect(getTabVisibility({ structure: { grants: [] } })).toMatchObject({
|
|
180
|
-
grants: false
|
|
180
|
+
grants: false,
|
|
181
181
|
});
|
|
182
182
|
expect(getTabVisibility({ structure: { grants: [{}] } })).toMatchObject({
|
|
183
|
-
grants: true
|
|
183
|
+
grants: true,
|
|
184
184
|
});
|
|
185
185
|
});
|
|
186
186
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { createSelector } from "reselect";
|
|
3
|
+
import { getGrantSelectedFilters } from "./getGrantSelectedFilters";
|
|
4
|
+
|
|
5
|
+
const getGrantFilters = _.propOr({}, "grantFilters");
|
|
6
|
+
|
|
7
|
+
export const getGrantAvailableFilters = createSelector(
|
|
8
|
+
getGrantFilters,
|
|
9
|
+
getGrantSelectedFilters,
|
|
10
|
+
(grantFilters, grantSelectedFilters) => {
|
|
11
|
+
return _.flow(
|
|
12
|
+
_.omitBy((values) => _.size(values) < 2),
|
|
13
|
+
_.keys,
|
|
14
|
+
_.without(grantSelectedFilters)
|
|
15
|
+
)(grantFilters);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { createSelector } from "reselect";
|
|
3
|
+
|
|
4
|
+
export const getGrantSelectedFilterActiveValues = createSelector(
|
|
5
|
+
[_.prop("grantSelectedFilter"), _.prop("grantActiveFilters")],
|
|
6
|
+
(grantSelectedFilter, grantActiveFilters) =>
|
|
7
|
+
_.propOr([], grantSelectedFilter)(grantActiveFilters)
|
|
8
|
+
);
|