@truedat/dd 6.6.0 → 6.6.2
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/CatalogCustomViewCards.js +9 -32
- package/src/components/DictionaryRoutes.js +1 -9
- package/src/components/GrantRemovalDirectButton.js +1 -3
- package/src/components/GrantRequestBulkRoleSelector.js +1 -0
- package/src/components/GrantRequestCancel.js +1 -1
- package/src/components/GrantRoutes.js +22 -15
- package/src/components/StructureGrantListButton.js +4 -4
- package/src/components/StructureSelector.js +70 -44
- package/src/components/StructureStructureForm.js +1 -1
- package/src/components/StructuresBulkUpdate.js +10 -14
- package/src/components/StructuresDownloadOption.js +31 -27
- package/src/components/StructuresEditableDownloadOption.js +12 -7
- package/src/components/StructuresGrantRequestView.js +55 -24
- package/src/components/StructuresLabelResults.js +5 -11
- package/src/components/StructuresPagination.js +13 -15
- package/src/components/StructuresRoutes.js +2 -18
- package/src/components/StructuresTable.js +79 -115
- package/src/components/StructuresUpdateOption.js +77 -9
- package/src/components/StructuresView.js +67 -52
- package/src/components/__tests__/CatalogCustomViewCards.spec.js +44 -7
- package/src/components/__tests__/StructureGrantListButton.spec.js +27 -17
- package/src/components/__tests__/StructureSelector.spec.js +70 -25
- package/src/components/__tests__/StructureStructureForm.spec.js +92 -60
- package/src/components/__tests__/StructureStructureLinks.spec.js +1 -1
- package/src/components/__tests__/StructuresBulkUpdate.spec.js +26 -14
- package/src/components/__tests__/StructuresDownloadOption.spec.js +38 -5
- package/src/components/__tests__/StructuresEditableDownloadOption.spec.js +20 -8
- package/src/components/__tests__/StructuresGrantRequestView.spec.js +43 -15
- package/src/components/__tests__/StructuresLabelResults.spec.js +37 -10
- package/src/components/__tests__/StructuresOptions.spec.js +62 -1
- package/src/components/__tests__/StructuresSearchResults.spec.js +67 -12
- package/src/components/__tests__/StructuresTable.spec.js +77 -88
- package/src/components/__tests__/StructuresUpdateOption.spec.js +53 -6
- package/src/components/__tests__/StructuresView.spec.js +126 -31
- package/src/components/__tests__/__snapshots__/GrantRoutes.spec.js.snap +5 -0
- package/src/components/__tests__/__snapshots__/StructureSelector.spec.js.snap +206 -42
- package/src/components/__tests__/__snapshots__/StructuresDownloadOption.spec.js.snap +17 -0
- package/src/components/__tests__/__snapshots__/StructuresGrantRequestView.spec.js.snap +68 -5
- package/src/components/__tests__/__snapshots__/StructuresLabelResults.spec.js.snap +7 -12
- package/src/components/__tests__/__snapshots__/StructuresSearchResults.spec.js.snap +72 -27
- package/src/components/__tests__/__snapshots__/StructuresTable.spec.js.snap +226 -153
- package/src/components/__tests__/__snapshots__/StructuresUpdateOption.spec.js.snap +3 -3
- package/src/components/index.js +0 -8
- package/src/hooks/useStructures.js +6 -6
- package/src/reducers/__tests__/selectedUserSearchFilter.spec.js +2 -23
- package/src/reducers/__tests__/structureQuery.spec.js +1 -63
- package/src/reducers/index.js +0 -18
- package/src/reducers/previousStructureQuery.js +3 -6
- package/src/reducers/selectedUserSearchFilter.js +1 -10
- package/src/reducers/structureQuery.js +1 -33
- package/src/routines.js +1 -15
- package/src/sagas/__tests__/bulkUpdateStructures.spec.js +7 -7
- package/src/sagas/__tests__/downloadEditableStructures.spec.js +1 -6
- package/src/sagas/__tests__/downloadStructures.spec.js +2 -7
- package/src/sagas/__tests__/fetchStructures.spec.js +4 -4
- package/src/sagas/bulkUpdateStructures.js +6 -4
- package/src/sagas/downloadEditableStructures.js +2 -3
- package/src/sagas/downloadStructures.js +2 -3
- package/src/sagas/index.js +0 -3
- package/src/selectors/__tests__/getGrantSelectedFilters.spec.js +1 -1
- package/src/selectors/__tests__/structureColumnsSelector.spec.js +5 -19
- package/src/selectors/__tests__/templateNamesSelector.spec.js +19 -0
- package/src/selectors/getGrantRequestsSelectedFilters.js +3 -1
- package/src/selectors/index.js +1 -8
- package/src/selectors/structureColumnsSelector.js +6 -46
- package/src/selectors/templateNamesSelector.js +7 -0
- package/src/utils/structureCustomTranslations.js +19 -0
- package/src/components/StructureDateFilter.js +0 -32
- package/src/components/StructureFilters.js +0 -19
- package/src/components/StructureFiltersLoader.js +0 -32
- package/src/components/StructureSelectedFilters.js +0 -94
- package/src/components/__tests__/StructureDateFilter.spec.js +0 -11
- package/src/components/__tests__/__snapshots__/StructureDateFilter.spec.js.snap +0 -13
- package/src/reducers/__tests__/structureActiveFilters.spec.js +0 -100
- package/src/reducers/__tests__/structureDateFilter.spec.js +0 -57
- package/src/reducers/__tests__/structureFilters.spec.js +0 -37
- package/src/reducers/__tests__/structureUserFilters.spec.js +0 -76
- package/src/reducers/__tests__/structuresActions.spec.js +0 -38
- package/src/reducers/__tests__/structuresLoading.spec.js +0 -26
- package/src/reducers/structureActiveFilters.js +0 -58
- package/src/reducers/structureCount.js +0 -20
- package/src/reducers/structureDateFilter.js +0 -33
- package/src/reducers/structureFilters.js +0 -21
- package/src/reducers/structureFiltersLoading.js +0 -14
- package/src/reducers/structureSelectedFilter.js +0 -34
- package/src/reducers/structuresActions.js +0 -18
- package/src/reducers/structuresLoading.js +0 -14
- package/src/reducers/structuresPageSize.js +0 -15
- package/src/sagas/fetchStructureFilters.js +0 -29
- package/src/selectors/__tests__/bulkUpdateDisabledSelector.spec.js +0 -72
- package/src/selectors/__tests__/getStructureAvailableFilters.spec.js +0 -15
- package/src/selectors/__tests__/getStructureSelectedFilterActiveValues.spec.js +0 -20
- package/src/selectors/__tests__/getStructureSelectedFilterValues.spec.js +0 -15
- package/src/selectors/__tests__/getStructureSelectedFilters.spec.js +0 -15
- package/src/selectors/bulkUpdateDisabledSelector.js +0 -46
- package/src/selectors/getPreviousStructureQuery.js +0 -2
- package/src/selectors/getStructureAvailableFilters.js +0 -15
- package/src/selectors/getStructureFilterTypes.js +0 -7
- package/src/selectors/getStructureSelectedFilterActiveValues.js +0 -9
- package/src/selectors/getStructureSelectedFilterValues.js +0 -12
- package/src/selectors/getStructureSelectedFilters.js +0 -7
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { bindActionCreators } from "redux";
|
|
2
|
-
import { connect } from "react-redux";
|
|
3
|
-
import { AvailableFilters } from "@truedat/core/components";
|
|
4
|
-
import { addStructureFilter, resetStructureFilters } from "../routines";
|
|
5
|
-
import { getStructureAvailableFilters } from "../selectors";
|
|
6
|
-
|
|
7
|
-
const mapStateToProps = (state) => ({
|
|
8
|
-
filters: getStructureAvailableFilters(state),
|
|
9
|
-
disabled: state.structureFiltersLoading,
|
|
10
|
-
loading: state.structureFiltersLoading,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const mapDispatchToProps = (dispatch) =>
|
|
14
|
-
bindActionCreators(
|
|
15
|
-
{ addFilter: addStructureFilter, resetFilters: resetStructureFilters },
|
|
16
|
-
dispatch
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export default connect(mapStateToProps, mapDispatchToProps)(AvailableFilters);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { connect } from "react-redux";
|
|
2
|
-
import { bindActionCreators } from "redux";
|
|
3
|
-
import { FiltersLoader } from "@truedat/core/components";
|
|
4
|
-
import { makeActiveFiltersSelector } from "@truedat/core/selectors";
|
|
5
|
-
import {
|
|
6
|
-
clearStructureFilters,
|
|
7
|
-
fetchStructureFilters,
|
|
8
|
-
clearStructuresSort,
|
|
9
|
-
} from "../routines";
|
|
10
|
-
|
|
11
|
-
const mapDispatchToProps = (dispatch) =>
|
|
12
|
-
bindActionCreators(
|
|
13
|
-
{
|
|
14
|
-
clearFilters: clearStructureFilters,
|
|
15
|
-
fetchFilters: fetchStructureFilters,
|
|
16
|
-
clearSort: clearStructuresSort,
|
|
17
|
-
},
|
|
18
|
-
dispatch
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const makeMapStateToProps = () => {
|
|
22
|
-
const activeFiltersSelector = makeActiveFiltersSelector(
|
|
23
|
-
"structureActiveFilters"
|
|
24
|
-
);
|
|
25
|
-
const mapStateToProps = (state, props) => ({
|
|
26
|
-
selectedFilter: state.structureSelectedFilter,
|
|
27
|
-
filters: activeFiltersSelector(state, props),
|
|
28
|
-
});
|
|
29
|
-
return mapStateToProps;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default connect(makeMapStateToProps, mapDispatchToProps)(FiltersLoader);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { bindActionCreators, compose } from "redux";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
|
-
import { injectIntl } from "react-intl";
|
|
5
|
-
import { SelectedFilters } from "@truedat/core/components";
|
|
6
|
-
import { makeOption } from "@truedat/core/services/i18n";
|
|
7
|
-
import {
|
|
8
|
-
applyUserSearchFilter,
|
|
9
|
-
closeStructureFilter,
|
|
10
|
-
deleteUserSearchFilter,
|
|
11
|
-
openStructureFilter,
|
|
12
|
-
removeStructureFilter,
|
|
13
|
-
resetStructureFilters,
|
|
14
|
-
saveUserSearchFilters,
|
|
15
|
-
toggleStructureFilterValue,
|
|
16
|
-
} from "../routines";
|
|
17
|
-
import {
|
|
18
|
-
getStructureSelectedFilterActiveValues,
|
|
19
|
-
getStructureSelectedFilters,
|
|
20
|
-
getStructureSelectedFilterValues,
|
|
21
|
-
getStructureFilterTypes,
|
|
22
|
-
} from "../selectors";
|
|
23
|
-
|
|
24
|
-
const translations = (formatMessage, structureTypes) => ({
|
|
25
|
-
"type.raw": (v) =>
|
|
26
|
-
formatMessage({
|
|
27
|
-
id: `structure.type.${v}.text`,
|
|
28
|
-
defaultMessage:
|
|
29
|
-
_.prop("translation")(_.find(_.propEq("name", v))(structureTypes)) || v,
|
|
30
|
-
}),
|
|
31
|
-
"with_content.raw": (v) =>
|
|
32
|
-
formatMessage({
|
|
33
|
-
id: `filters.with_content.raw.${v}`,
|
|
34
|
-
defaultMessage: v,
|
|
35
|
-
}),
|
|
36
|
-
"with_profiling.raw": (v) =>
|
|
37
|
-
formatMessage({
|
|
38
|
-
id: `filters.with_profiling.raw.${v}`,
|
|
39
|
-
defaultMessage: v,
|
|
40
|
-
}),
|
|
41
|
-
linked_concepts: (v) =>
|
|
42
|
-
formatMessage({ id: `filters.linked_concepts.${v}`, defaultMessage: v }),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const mapStateToProps = (state, ownProps) => {
|
|
46
|
-
const formatMessage = _.pathOr(_.prop("id"), "intl.formatMessage")(ownProps);
|
|
47
|
-
const {
|
|
48
|
-
selectedUserSearchFilter: selectedUserFilter,
|
|
49
|
-
structureActiveFilters: activeFilters,
|
|
50
|
-
structureFiltersLoading: loading,
|
|
51
|
-
structureSelectedFilter: selectedFilter,
|
|
52
|
-
structureTypes,
|
|
53
|
-
userSearchFilters: userFilters,
|
|
54
|
-
} = state;
|
|
55
|
-
const selectedFilterValues = getStructureSelectedFilterValues(state);
|
|
56
|
-
const selectedFilterActiveValues =
|
|
57
|
-
getStructureSelectedFilterActiveValues(state);
|
|
58
|
-
const selectedFilters = getStructureSelectedFilters(state);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
loading,
|
|
62
|
-
filterTypes: getStructureFilterTypes(state),
|
|
63
|
-
selectedFilter,
|
|
64
|
-
selectedFilters,
|
|
65
|
-
selectedFilterActiveValues,
|
|
66
|
-
selectedFilterValues: _.map(
|
|
67
|
-
makeOption(translations(formatMessage, structureTypes), selectedFilter)
|
|
68
|
-
)(selectedFilterValues),
|
|
69
|
-
selectedUserFilter,
|
|
70
|
-
activeFilters,
|
|
71
|
-
userFilters,
|
|
72
|
-
userFilterScope: "data_structure",
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const mapDispatchToProps = (dispatch) =>
|
|
77
|
-
bindActionCreators(
|
|
78
|
-
{
|
|
79
|
-
applyUserFilter: applyUserSearchFilter,
|
|
80
|
-
closeFilter: closeStructureFilter,
|
|
81
|
-
deleteUserFilter: deleteUserSearchFilter,
|
|
82
|
-
openFilter: openStructureFilter,
|
|
83
|
-
removeFilter: removeStructureFilter,
|
|
84
|
-
resetFilters: resetStructureFilters,
|
|
85
|
-
saveFilters: saveUserSearchFilters,
|
|
86
|
-
toggleFilterValue: toggleStructureFilterValue,
|
|
87
|
-
},
|
|
88
|
-
dispatch
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
export default compose(
|
|
92
|
-
injectIntl,
|
|
93
|
-
connect(mapStateToProps, mapDispatchToProps)
|
|
94
|
-
)(SelectedFilters);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { shallow } from "enzyme";
|
|
3
|
-
import { StructureDateFilter } from "../StructureDateFilter";
|
|
4
|
-
|
|
5
|
-
describe("<StructureDateFilter/>", () => {
|
|
6
|
-
it("matches the latest snapshot", () => {
|
|
7
|
-
const props = { active: true };
|
|
8
|
-
const wrapper = shallow(<StructureDateFilter {...props} />);
|
|
9
|
-
expect(wrapper).toMatchSnapshot();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<StructureDateFilter/> matches the latest snapshot 1`] = `
|
|
4
|
-
<DateFilter
|
|
5
|
-
defaultValues={{}}
|
|
6
|
-
label={
|
|
7
|
-
<Memo(MemoizedFormattedMessage)
|
|
8
|
-
id="structure.updated_at"
|
|
9
|
-
/>
|
|
10
|
-
}
|
|
11
|
-
name="updated_at"
|
|
12
|
-
/>
|
|
13
|
-
`;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { initialState } from "../structureActiveFilters";
|
|
2
|
-
import {
|
|
3
|
-
addStructureFilter,
|
|
4
|
-
applyUserSearchFilter,
|
|
5
|
-
clearStructureFilters,
|
|
6
|
-
closeStructureFilter,
|
|
7
|
-
removeStructureFilter,
|
|
8
|
-
resetStructureFilters,
|
|
9
|
-
toggleStructureFilterValue,
|
|
10
|
-
} from "../../routines";
|
|
11
|
-
import { structureActiveFilters } from "..";
|
|
12
|
-
|
|
13
|
-
const fooState = { foo: "bar" };
|
|
14
|
-
|
|
15
|
-
describe("reducers: structureActiveFilters", () => {
|
|
16
|
-
it("should provide the initial state", () => {
|
|
17
|
-
expect(structureActiveFilters(undefined, {})).toEqual(initialState);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should handle the clearStructureFilters.TRIGGER action", () => {
|
|
21
|
-
expect(
|
|
22
|
-
structureActiveFilters(fooState, {
|
|
23
|
-
type: clearStructureFilters.TRIGGER,
|
|
24
|
-
})
|
|
25
|
-
).toEqual(initialState);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should handle the addStructureFilter.TRIGGER action", () => {
|
|
29
|
-
const filter = "baz";
|
|
30
|
-
const payload = { filter };
|
|
31
|
-
expect(
|
|
32
|
-
structureActiveFilters(fooState, {
|
|
33
|
-
type: addStructureFilter.TRIGGER,
|
|
34
|
-
payload,
|
|
35
|
-
})
|
|
36
|
-
).toEqual({ ...fooState, baz: [] });
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should handle the applyUserSearchFilter.TRIGGER action", () => {
|
|
40
|
-
const filters = { country: ["Sp"] };
|
|
41
|
-
const payload = { userFilter: { filters }, scope: "data_structure" };
|
|
42
|
-
expect(
|
|
43
|
-
structureActiveFilters(fooState, {
|
|
44
|
-
type: applyUserSearchFilter.TRIGGER,
|
|
45
|
-
payload,
|
|
46
|
-
})
|
|
47
|
-
).toEqual({ ...filters });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should handle the closeStructureFilter.TRIGGER action", () => {
|
|
51
|
-
const foo = ["foo1"];
|
|
52
|
-
const bar = [];
|
|
53
|
-
const state = { foo, bar };
|
|
54
|
-
const payload = { filter: "bar" };
|
|
55
|
-
expect(
|
|
56
|
-
structureActiveFilters(state, {
|
|
57
|
-
type: closeStructureFilter.TRIGGER,
|
|
58
|
-
payload,
|
|
59
|
-
})
|
|
60
|
-
).toEqual({ foo });
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should handle the removeStructureFilter.TRIGGER action", () => {
|
|
64
|
-
const foo = ["foo1"];
|
|
65
|
-
const bar = [];
|
|
66
|
-
const state = { foo, bar };
|
|
67
|
-
const payload = { filter: "foo" };
|
|
68
|
-
expect(
|
|
69
|
-
structureActiveFilters(state, {
|
|
70
|
-
type: removeStructureFilter.TRIGGER,
|
|
71
|
-
payload,
|
|
72
|
-
})
|
|
73
|
-
).toEqual({ bar });
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("should handle the resetStructureFilters.TRIGGER action", () => {
|
|
77
|
-
expect(
|
|
78
|
-
structureActiveFilters(fooState, {
|
|
79
|
-
type: resetStructureFilters.TRIGGER,
|
|
80
|
-
})
|
|
81
|
-
).toEqual(initialState);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should handle the toggleStructureFilterValue.TRIGGER action", () => {
|
|
85
|
-
const foo = ["foo1", "foo2", "foo3"];
|
|
86
|
-
const bar = [];
|
|
87
|
-
const state = { foo, bar };
|
|
88
|
-
const payload = { filter: "foo", value: "foo2" };
|
|
89
|
-
expect(
|
|
90
|
-
structureActiveFilters(state, {
|
|
91
|
-
type: toggleStructureFilterValue.TRIGGER,
|
|
92
|
-
payload,
|
|
93
|
-
})
|
|
94
|
-
).toEqual({ foo: ["foo1", "foo3"], bar });
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should ignore unknown actions", () => {
|
|
98
|
-
expect(structureActiveFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyStructureDateFilter,
|
|
3
|
-
clearStructureFilters,
|
|
4
|
-
toggleStructureDateFilter
|
|
5
|
-
} from "../../routines";
|
|
6
|
-
import { initialState, structureDateFilter } from "../structureDateFilter";
|
|
7
|
-
|
|
8
|
-
const fooState = { foo: "bar" };
|
|
9
|
-
|
|
10
|
-
describe("reducers: structureDateFilter", () => {
|
|
11
|
-
it("should provide the initial state", () => {
|
|
12
|
-
expect(structureDateFilter(undefined, {})).toBe(initialState);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("should handle the clearStructureFilters.TRIGGER action", () => {
|
|
16
|
-
expect(
|
|
17
|
-
structureDateFilter(fooState, { type: clearStructureFilters.TRIGGER })
|
|
18
|
-
).toBe(initialState);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should handle the toggleStructureDateFilter.TRIGGER action", () => {
|
|
22
|
-
expect(
|
|
23
|
-
structureDateFilter(
|
|
24
|
-
{ active: false },
|
|
25
|
-
{ type: toggleStructureDateFilter.TRIGGER }
|
|
26
|
-
)
|
|
27
|
-
).toEqual({ active: true });
|
|
28
|
-
|
|
29
|
-
expect(
|
|
30
|
-
structureDateFilter(
|
|
31
|
-
{ active: true },
|
|
32
|
-
{ type: toggleStructureDateFilter.TRIGGER }
|
|
33
|
-
)
|
|
34
|
-
).toEqual({ active: false });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should handle the applyStructureDateFilter.TRIGGER action", () => {
|
|
38
|
-
const payload = {
|
|
39
|
-
name: "some_date",
|
|
40
|
-
type: "range",
|
|
41
|
-
value: "2020-01-01 - 2020-02-02"
|
|
42
|
-
};
|
|
43
|
-
expect(
|
|
44
|
-
structureDateFilter(
|
|
45
|
-
{ active: true },
|
|
46
|
-
{
|
|
47
|
-
type: applyStructureDateFilter.TRIGGER,
|
|
48
|
-
payload
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
).toEqual({ ...payload, active: true });
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should ignore unknown actions", () => {
|
|
55
|
-
expect(structureDateFilter(fooState, { type: "FOO" })).toBe(fooState);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { clearStructureFilters, fetchStructureFilters } from "../../routines";
|
|
2
|
-
import { structureFilters } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: structureFilters", () => {
|
|
7
|
-
const initialState = {};
|
|
8
|
-
|
|
9
|
-
it("should provide the initial state", () => {
|
|
10
|
-
expect(structureFilters(undefined, {})).toEqual(initialState);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("should handle the clearStructureFilters.TRIGGER action", () => {
|
|
14
|
-
expect(
|
|
15
|
-
structureFilters(fooState, { type: clearStructureFilters.TRIGGER })
|
|
16
|
-
).toEqual(initialState);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchStructureFilters.SUCCESS action", () => {
|
|
20
|
-
const filter1 = { values: ["value1", "value2"] };
|
|
21
|
-
const filter2 = { values: ["value1", "value2"] };
|
|
22
|
-
const data = { filter1, filter2: { values: ["value1"] } };
|
|
23
|
-
const payload = { data: { data } };
|
|
24
|
-
const state = { filter2 };
|
|
25
|
-
|
|
26
|
-
expect(
|
|
27
|
-
structureFilters(state, {
|
|
28
|
-
type: fetchStructureFilters.SUCCESS,
|
|
29
|
-
payload,
|
|
30
|
-
})
|
|
31
|
-
).toEqual(data);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should ignore unknown actions", () => {
|
|
35
|
-
expect(structureFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
3
|
-
import { initialState } from "../userSearchFilters";
|
|
4
|
-
import {
|
|
5
|
-
fetchUserSearchFilters,
|
|
6
|
-
clearUserSearchFilters,
|
|
7
|
-
deleteUserSearchFilter,
|
|
8
|
-
saveUserSearchFilters,
|
|
9
|
-
} from "../../routines";
|
|
10
|
-
import { userSearchFilters } from "..";
|
|
11
|
-
|
|
12
|
-
const fooState = { foo: "bar" };
|
|
13
|
-
|
|
14
|
-
describe("reducers: structureActiveFilters", () => {
|
|
15
|
-
it("should provide the initial state", () => {
|
|
16
|
-
expect(userSearchFilters(undefined, {})).toEqual(initialState);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("should handle the fetchUserSearchFilters.SUCCESS action", () => {
|
|
20
|
-
const filters = [
|
|
21
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
22
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
23
|
-
];
|
|
24
|
-
const sortedFilters = _.sortBy(accentInsensitivePathOrder("name"))(filters);
|
|
25
|
-
expect(
|
|
26
|
-
userSearchFilters(fooState, {
|
|
27
|
-
type: fetchUserSearchFilters.SUCCESS,
|
|
28
|
-
payload: { data: filters },
|
|
29
|
-
})
|
|
30
|
-
).toEqual(sortedFilters);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("should handle the saveUserSearchFilters.SUCCESS action", () => {
|
|
34
|
-
const filters = [
|
|
35
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
36
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
37
|
-
];
|
|
38
|
-
const newFilter = { name: "c", id: 3, filters: { country: ["S3"] } };
|
|
39
|
-
const sortedFilters = _.flow(
|
|
40
|
-
_.concat([newFilter]),
|
|
41
|
-
_.sortBy(accentInsensitivePathOrder("name"))
|
|
42
|
-
)(filters);
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
userSearchFilters(filters, {
|
|
46
|
-
type: saveUserSearchFilters.SUCCESS,
|
|
47
|
-
payload: { data: newFilter },
|
|
48
|
-
})
|
|
49
|
-
).toEqual(sortedFilters);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should handle the deleteUserSearchFilter.SUCCESS action", () => {
|
|
53
|
-
const filters = [
|
|
54
|
-
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
55
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
56
|
-
];
|
|
57
|
-
expect(
|
|
58
|
-
userSearchFilters(filters, {
|
|
59
|
-
type: deleteUserSearchFilter.SUCCESS,
|
|
60
|
-
meta: { id: 1 },
|
|
61
|
-
})
|
|
62
|
-
).toEqual([{ name: "a", id: 2, filters: { country: ["S2"] } }]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should handle the clearUserSearchFilters.TRIGGER action", () => {
|
|
66
|
-
expect(
|
|
67
|
-
userSearchFilters(fooState, {
|
|
68
|
-
type: clearUserSearchFilters.TRIGGER,
|
|
69
|
-
})
|
|
70
|
-
).toEqual(initialState);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should ignore unknown actions", () => {
|
|
74
|
-
expect(userSearchFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { clearStructures, fetchStructures } from "../../routines";
|
|
2
|
-
import { structuresActions, initialState } from "../structuresActions";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: structuresActions", () => {
|
|
7
|
-
it("should provide the initial state", () => {
|
|
8
|
-
expect(structuresActions(undefined, {})).toBe(initialState);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("should handle the clearStructures.TRIGGER action", () => {
|
|
12
|
-
expect(structuresActions(fooState, { type: clearStructures.TRIGGER })).toBe(
|
|
13
|
-
initialState
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should handle the fetchStructures.TRIGGER action", () => {
|
|
18
|
-
expect(structuresActions(fooState, { type: fetchStructures.TRIGGER })).toBe(
|
|
19
|
-
initialState
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should handle the fetchStructures.SUCCESS action", () => {
|
|
24
|
-
const _actions = { bulkUpdate: {} };
|
|
25
|
-
const data = { _actions };
|
|
26
|
-
|
|
27
|
-
expect(
|
|
28
|
-
structuresActions(fooState, {
|
|
29
|
-
type: fetchStructures.SUCCESS,
|
|
30
|
-
payload: { data },
|
|
31
|
-
})
|
|
32
|
-
).toMatchObject(_actions);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should ignore unknown actions", () => {
|
|
36
|
-
expect(structuresActions(fooState, { type: "FOO" })).toBe(fooState);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { fetchStructures } from "../../routines";
|
|
2
|
-
import { structuresLoading } from "..";
|
|
3
|
-
|
|
4
|
-
const fooState = { foo: "bar" };
|
|
5
|
-
|
|
6
|
-
describe("reducers: structuresLoading", () => {
|
|
7
|
-
it("should provide the initial state", () => {
|
|
8
|
-
expect(structuresLoading(undefined, {})).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("should be true after receiving the fetchStructures.TRIGGER action", () => {
|
|
12
|
-
expect(structuresLoading(false, { type: fetchStructures.TRIGGER })).toBe(
|
|
13
|
-
true
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should be false after receiving the fetchStructures.FULFILL action", () => {
|
|
18
|
-
expect(structuresLoading(true, { type: fetchStructures.FULFILL })).toBe(
|
|
19
|
-
false
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should ignore unhandled actions", () => {
|
|
24
|
-
expect(structuresLoading(fooState, { type: "FOO" })).toBe(fooState);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { isEmpty, omit, prop, propOr } from "lodash/fp";
|
|
3
|
-
import {
|
|
4
|
-
addStructureFilter,
|
|
5
|
-
applyUserSearchFilter,
|
|
6
|
-
clearStructureFilters,
|
|
7
|
-
closeStructureFilter,
|
|
8
|
-
removeStructureFilter,
|
|
9
|
-
resetStructureFilters,
|
|
10
|
-
toggleStructureFilterValue,
|
|
11
|
-
} from "../routines";
|
|
12
|
-
|
|
13
|
-
export const initialState = {};
|
|
14
|
-
|
|
15
|
-
export const structureActiveFilters = (
|
|
16
|
-
state = initialState,
|
|
17
|
-
{ type, payload }
|
|
18
|
-
) => {
|
|
19
|
-
switch (type) {
|
|
20
|
-
case clearStructureFilters.TRIGGER:
|
|
21
|
-
return initialState;
|
|
22
|
-
case addStructureFilter.TRIGGER: {
|
|
23
|
-
const { filter } = payload;
|
|
24
|
-
return { ...state, [filter]: [] };
|
|
25
|
-
}
|
|
26
|
-
case applyUserSearchFilter.TRIGGER: {
|
|
27
|
-
const { userFilter, scope } = payload;
|
|
28
|
-
return scope === "data_structure" ? prop("filters")(userFilter) : state;
|
|
29
|
-
}
|
|
30
|
-
case closeStructureFilter.TRIGGER: {
|
|
31
|
-
const { filter } = payload;
|
|
32
|
-
const values = propOr([], filter)(state);
|
|
33
|
-
return isEmpty(values)
|
|
34
|
-
? omit(filter)(state)
|
|
35
|
-
: { ...state, [filter]: values };
|
|
36
|
-
}
|
|
37
|
-
case removeStructureFilter.TRIGGER: {
|
|
38
|
-
const { filter } = payload;
|
|
39
|
-
return omit(filter)(state);
|
|
40
|
-
}
|
|
41
|
-
case resetStructureFilters.TRIGGER: {
|
|
42
|
-
return initialState;
|
|
43
|
-
}
|
|
44
|
-
case toggleStructureFilterValue.TRIGGER: {
|
|
45
|
-
const { filter, value } = payload;
|
|
46
|
-
if (_.isArray(value)) {
|
|
47
|
-
return { ...state, [filter]: value };
|
|
48
|
-
}
|
|
49
|
-
const values = _.propOr([], filter)(state);
|
|
50
|
-
const nextValues = _.includes(value)(values)
|
|
51
|
-
? _.without([value])(values)
|
|
52
|
-
: _.union([value])(values);
|
|
53
|
-
return { ...state, [filter]: nextValues };
|
|
54
|
-
}
|
|
55
|
-
default:
|
|
56
|
-
return state;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { fetchStructures, clearStructures } from "../routines";
|
|
3
|
-
|
|
4
|
-
const initialState = 0;
|
|
5
|
-
|
|
6
|
-
const structureCount = (state = initialState, { type, payload }) => {
|
|
7
|
-
switch (type) {
|
|
8
|
-
case clearStructures.TRIGGER:
|
|
9
|
-
return initialState;
|
|
10
|
-
case fetchStructures.SUCCESS: {
|
|
11
|
-
const headers = _.propOr({}, "headers")(payload);
|
|
12
|
-
const count = _.propOr("0", "x-total-count")(headers);
|
|
13
|
-
return parseInt(count);
|
|
14
|
-
}
|
|
15
|
-
default:
|
|
16
|
-
return state;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { structureCount };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyStructureDateFilter,
|
|
3
|
-
clearStructureFilters,
|
|
4
|
-
toggleStructureDateFilter,
|
|
5
|
-
} from "../routines";
|
|
6
|
-
|
|
7
|
-
export const initialState = {
|
|
8
|
-
active: false,
|
|
9
|
-
name: "updated_at",
|
|
10
|
-
type: "since",
|
|
11
|
-
unit: "d",
|
|
12
|
-
value: "1",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const structureDateFilter = (
|
|
16
|
-
state = initialState,
|
|
17
|
-
{ type, payload }
|
|
18
|
-
) => {
|
|
19
|
-
switch (type) {
|
|
20
|
-
case clearStructureFilters.TRIGGER:
|
|
21
|
-
return initialState;
|
|
22
|
-
case toggleStructureDateFilter.TRIGGER: {
|
|
23
|
-
const { active } = state;
|
|
24
|
-
return { ...state, active: !active };
|
|
25
|
-
}
|
|
26
|
-
case applyStructureDateFilter.TRIGGER: {
|
|
27
|
-
const { active } = state;
|
|
28
|
-
return { ...payload, active };
|
|
29
|
-
}
|
|
30
|
-
default:
|
|
31
|
-
return state;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import { clearStructureFilters, fetchStructureFilters } from "../routines";
|
|
3
|
-
|
|
4
|
-
const initialState = {};
|
|
5
|
-
|
|
6
|
-
const structureFilters = (state = initialState, { type, payload }) => {
|
|
7
|
-
switch (type) {
|
|
8
|
-
case clearStructureFilters.TRIGGER:
|
|
9
|
-
case fetchStructureFilters.TRIGGER:
|
|
10
|
-
return initialState;
|
|
11
|
-
case fetchStructureFilters.SUCCESS:
|
|
12
|
-
return _.flow(
|
|
13
|
-
_.propOr({}, "data.data"),
|
|
14
|
-
_.omitBy(_.flow(_.getOr([], "values"), _.isEmpty))
|
|
15
|
-
)(payload);
|
|
16
|
-
default:
|
|
17
|
-
return state;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { structureFilters };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fetchStructureFilters } from "../routines";
|
|
2
|
-
|
|
3
|
-
const structureFiltersLoading = (state = false, { type }) => {
|
|
4
|
-
switch (type) {
|
|
5
|
-
case fetchStructureFilters.REQUEST:
|
|
6
|
-
return true;
|
|
7
|
-
case fetchStructureFilters.FULFILL:
|
|
8
|
-
return false;
|
|
9
|
-
default:
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { structureFiltersLoading };
|