@truedat/dd 4.37.2 → 4.37.3
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 +7 -0
- package/package.json +5 -5
- package/src/api.js +6 -7
- package/src/components/StructureSelectedFilters.js +12 -9
- package/src/components/StructureSelector.js +2 -2
- package/src/components/StructuresRoutes.js +2 -2
- package/src/components/UserSearchFiltersLoader.js +29 -0
- package/src/components/__tests__/UserSearchFiltersLoader.spec.js +27 -0
- package/src/components/__tests__/__snapshots__/StructureSelector.spec.js.snap +3 -1
- package/src/components/__tests__/__snapshots__/UserSearchFiltersLoader.spec.js.snap +3 -0
- package/src/messages/en.js +2 -2
- package/src/messages/es.js +2 -2
- package/src/reducers/__tests__/grantQuery.spec.js +0 -9
- package/src/reducers/__tests__/selectedUserSearchFilter.spec.js +62 -0
- package/src/reducers/__tests__/structureActiveFilters.spec.js +12 -12
- package/src/reducers/__tests__/structureQuery.spec.js +10 -10
- package/src/reducers/__tests__/structureUserFilters.spec.js +26 -26
- package/src/reducers/index.js +4 -4
- package/src/reducers/selectedUserSearchFilter.js +48 -0
- package/src/reducers/structureActiveFilters.js +4 -4
- package/src/reducers/structureQuery.js +2 -2
- package/src/reducers/{structureUserFilters.js → userSearchFilters.js} +11 -14
- package/src/routines.js +8 -12
- package/src/sagas/__tests__/deleteUserSearchFilter.spec.js +72 -0
- package/src/sagas/__tests__/fetchUserSearchFilters.spec.js +69 -0
- package/src/sagas/__tests__/saveUserSearchFilters.spec.js +78 -0
- package/src/sagas/deleteUserSearchFilter.js +31 -0
- package/src/sagas/fetchUserSearchFilters.js +26 -0
- package/src/sagas/index.js +9 -9
- package/src/sagas/saveUserSearchFilters.js +30 -0
- package/src/components/StructureUserFiltersLoader.js +0 -30
- package/src/components/__tests__/StructureUserFiltersLoader.spec.js +0 -27
- package/src/components/__tests__/__snapshots__/StructureUserFiltersLoader.spec.js.snap +0 -3
- package/src/reducers/__tests__/structureSelectedUserFilter.spec.js +0 -64
- package/src/reducers/structureSelectedUserFilter.js +0 -34
- package/src/sagas/__tests__/deleteStructureUserFilter.spec.js +0 -75
- package/src/sagas/__tests__/fetchStructureUserFilters.spec.js +0 -70
- package/src/sagas/__tests__/saveStructureUserFilters.spec.js +0 -73
- package/src/sagas/deleteStructureUserFilter.js +0 -34
- package/src/sagas/fetchStructureUserFilters.js +0 -29
- package/src/sagas/saveStructureUserFilters.js +0 -31
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "4.37.
|
|
3
|
+
"version": "4.37.3",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@truedat/auth": "4.37.
|
|
88
|
-
"@truedat/core": "4.37.
|
|
89
|
-
"@truedat/df": "4.37.
|
|
87
|
+
"@truedat/auth": "4.37.3",
|
|
88
|
+
"@truedat/core": "4.37.3",
|
|
89
|
+
"@truedat/df": "4.37.3",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
91
|
"path-to-regexp": "^1.7.0",
|
|
92
92
|
"prop-types": "^15.7.2",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"react-dom": ">= 16.8.6 < 17",
|
|
108
108
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "1c418784d34e171a6d62dd7fab3dfd05400998ba"
|
|
111
111
|
}
|
package/src/api.js
CHANGED
|
@@ -34,10 +34,9 @@ const API_STRUCTURE_TYPES = "/api/data_structure_types";
|
|
|
34
34
|
const API_STRUCTURE_TYPES_LITE = "/api/data_structure_types/lite";
|
|
35
35
|
const API_STRUCTURES_TAG = "/api/data_structures/:data_structure_id/tags/:id";
|
|
36
36
|
const API_STRUCTURES_TAGS = "/api/data_structures/:data_structure_id/tags";
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
"/api/data_structure_user_filters/user/me";
|
|
37
|
+
const API_USER_SEARCH_FILTERS = "/api/user_search_filters";
|
|
38
|
+
const API_USER_SEARCH_FILTER = "/api/user_search_filters/:id";
|
|
39
|
+
const API_GET_USER_SEARCH_FILTERS = "/api/user_search_filters/me";
|
|
41
40
|
const API_STRUCTURES_UPLOAD =
|
|
42
41
|
"/api/data_structures/bulk_update_template_content";
|
|
43
42
|
const API_STRUCTURE_NOTE = "/api/data_structures/:data_structure_id/notes/:id";
|
|
@@ -79,11 +78,11 @@ export {
|
|
|
79
78
|
API_STRUCTURE_TYPE,
|
|
80
79
|
API_STRUCTURE_TYPES,
|
|
81
80
|
API_STRUCTURE_TYPES_LITE,
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
API_USER_SEARCH_FILTERS,
|
|
82
|
+
API_USER_SEARCH_FILTER,
|
|
83
|
+
API_GET_USER_SEARCH_FILTERS,
|
|
84
84
|
API_STRUCTURES_TAG,
|
|
85
85
|
API_STRUCTURES_TAGS,
|
|
86
|
-
API_GET_STRUCTURE_USER_FILTERS,
|
|
87
86
|
API_STRUCTURES_UPLOAD,
|
|
88
87
|
API_STRUCTURE_NOTE,
|
|
89
88
|
API_STRUCTURE_NOTES,
|
|
@@ -5,13 +5,13 @@ import { injectIntl } from "react-intl";
|
|
|
5
5
|
import { SelectedFilters } from "@truedat/core/components";
|
|
6
6
|
import { makeOption } from "@truedat/core/services/i18n";
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
applyUserSearchFilter,
|
|
9
9
|
closeStructureFilter,
|
|
10
|
-
|
|
10
|
+
deleteUserSearchFilter,
|
|
11
11
|
openStructureFilter,
|
|
12
12
|
removeStructureFilter,
|
|
13
13
|
resetStructureFilters,
|
|
14
|
-
|
|
14
|
+
saveUserSearchFilters,
|
|
15
15
|
toggleStructureFilterValue,
|
|
16
16
|
} from "../routines";
|
|
17
17
|
import {
|
|
@@ -53,9 +53,11 @@ export const mapStateToProps = (state, ownProps) => {
|
|
|
53
53
|
getStructureSelectedFilterActiveValues(state);
|
|
54
54
|
const selectedFilters = getStructureSelectedFilters(state);
|
|
55
55
|
const structureTypes = _.prop("structureTypes")(state);
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const {
|
|
57
|
+
selectedUserSearchFilter: selectedUserFilter,
|
|
58
|
+
structureActiveFilters: activeFilters,
|
|
59
|
+
userSearchFilters: userFilters,
|
|
60
|
+
} = state;
|
|
59
61
|
return {
|
|
60
62
|
loading,
|
|
61
63
|
selectedFilter,
|
|
@@ -67,19 +69,20 @@ export const mapStateToProps = (state, ownProps) => {
|
|
|
67
69
|
selectedUserFilter,
|
|
68
70
|
activeFilters,
|
|
69
71
|
userFilters,
|
|
72
|
+
userFilterScope: "data_structure",
|
|
70
73
|
};
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
const mapDispatchToProps = (dispatch) =>
|
|
74
77
|
bindActionCreators(
|
|
75
78
|
{
|
|
76
|
-
applyUserFilter:
|
|
79
|
+
applyUserFilter: applyUserSearchFilter,
|
|
77
80
|
closeFilter: closeStructureFilter,
|
|
78
|
-
deleteUserFilter:
|
|
81
|
+
deleteUserFilter: deleteUserSearchFilter,
|
|
79
82
|
openFilter: openStructureFilter,
|
|
80
83
|
removeFilter: removeStructureFilter,
|
|
81
84
|
resetFilters: resetStructureFilters,
|
|
82
|
-
saveFilters:
|
|
85
|
+
saveFilters: saveUserSearchFilters,
|
|
83
86
|
toggleFilterValue: toggleStructureFilterValue,
|
|
84
87
|
},
|
|
85
88
|
dispatch
|
|
@@ -8,7 +8,7 @@ import StructureDateFilter from "./StructureDateFilter";
|
|
|
8
8
|
import StructureFiltersLoader from "./StructureFiltersLoader";
|
|
9
9
|
import StructureSelectedFilters from "./StructureSelectedFilters";
|
|
10
10
|
import StructureTypesLoader from "./StructureTypesLoader";
|
|
11
|
-
import
|
|
11
|
+
import UserSearchFiltersLoader from "./UserSearchFiltersLoader";
|
|
12
12
|
import StructuresLoader from "./StructuresLoader";
|
|
13
13
|
import StructuresSearch from "./StructuresSearch";
|
|
14
14
|
import StructuresSearchResults from "./StructuresSearchResults";
|
|
@@ -40,7 +40,7 @@ export const StructureSelector = ({
|
|
|
40
40
|
<StructuresSearch />
|
|
41
41
|
<StructureSelectedFilters />
|
|
42
42
|
<StructureDateFilter />
|
|
43
|
-
<
|
|
43
|
+
<UserSearchFiltersLoader scope="data_structure" />
|
|
44
44
|
<StructuresSearchResults
|
|
45
45
|
columns={!_.isEmpty(overwriteColumns) ? overwriteColumns : columns}
|
|
46
46
|
loading={loading}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import DomainsLoader from "@truedat/bg/taxonomy/components/DomainsLoader";
|
|
15
15
|
import StructureCrumbs from "./StructureCrumbs";
|
|
16
16
|
import StructureLoader from "./StructureLoader";
|
|
17
|
-
import
|
|
17
|
+
import UserSearchFiltersLoader from "./UserSearchFiltersLoader";
|
|
18
18
|
import StructureTagsLoader from "./StructureTagsLoader";
|
|
19
19
|
import StructureView from "./StructureView";
|
|
20
20
|
import StructuresBulkUpdate from "./StructuresBulkUpdate";
|
|
@@ -71,7 +71,7 @@ const AuthorizedRoutes = () => {
|
|
|
71
71
|
path={STRUCTURES}
|
|
72
72
|
render={() => (
|
|
73
73
|
<>
|
|
74
|
-
<
|
|
74
|
+
<UserSearchFiltersLoader scope="data_structure" />
|
|
75
75
|
<UserDomainsLoader
|
|
76
76
|
permissions={[
|
|
77
77
|
"publish_structure_note_from_draft",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { connect } from "react-redux";
|
|
4
|
+
import { clearUserSearchFilters, fetchUserSearchFilters } from "../routines";
|
|
5
|
+
|
|
6
|
+
export const UserSearchFiltersLoader = ({
|
|
7
|
+
clearUserSearchFilters,
|
|
8
|
+
fetchUserSearchFilters,
|
|
9
|
+
scope,
|
|
10
|
+
}) => {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
fetchUserSearchFilters(scope);
|
|
13
|
+
return () => {
|
|
14
|
+
clearUserSearchFilters();
|
|
15
|
+
};
|
|
16
|
+
}, [clearUserSearchFilters, fetchUserSearchFilters]);
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
UserSearchFiltersLoader.propTypes = {
|
|
21
|
+
clearUserSearchFilters: PropTypes.func,
|
|
22
|
+
fetchUserSearchFilters: PropTypes.func,
|
|
23
|
+
scope: PropTypes.string,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default connect(null, {
|
|
27
|
+
clearUserSearchFilters,
|
|
28
|
+
fetchUserSearchFilters,
|
|
29
|
+
})(UserSearchFiltersLoader);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { shallow, mount } from "enzyme";
|
|
3
|
+
import { UserSearchFiltersLoader } from "../UserSearchFiltersLoader";
|
|
4
|
+
|
|
5
|
+
describe("<UserSearchFiltersLoader />", () => {
|
|
6
|
+
const fetchUserSearchFilters = jest.fn();
|
|
7
|
+
const clearUserSearchFilters = jest.fn();
|
|
8
|
+
|
|
9
|
+
it("matches the latest snapshot", () => {
|
|
10
|
+
const props = { clearUserSearchFilters, fetchUserSearchFilters };
|
|
11
|
+
const wrapper = shallow(<UserSearchFiltersLoader {...props} />);
|
|
12
|
+
expect(wrapper).toMatchSnapshot();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("calls fetchUserSearchFilters when component mounts, clearUserSearchFilters when component unmounts", () => {
|
|
16
|
+
const fetchUserSearchFilters = jest.fn();
|
|
17
|
+
const clearUserSearchFilters = jest.fn();
|
|
18
|
+
|
|
19
|
+
const props = { fetchUserSearchFilters, clearUserSearchFilters };
|
|
20
|
+
const wrapper = mount(<UserSearchFiltersLoader {...props} />);
|
|
21
|
+
expect(clearUserSearchFilters.mock.calls.length).toBe(0);
|
|
22
|
+
expect(fetchUserSearchFilters.mock.calls.length).toBe(1);
|
|
23
|
+
wrapper.unmount();
|
|
24
|
+
expect(clearUserSearchFilters.mock.calls.length).toBe(1);
|
|
25
|
+
expect(fetchUserSearchFilters.mock.calls.length).toBe(1);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -12,7 +12,9 @@ exports[`<StructureSelector /> matches the latest snapshot 1`] = `
|
|
|
12
12
|
<Connect(StructuresSearch) />
|
|
13
13
|
<injectIntl(Connect(SelectedFilters)) />
|
|
14
14
|
<Connect(StructureDateFilter) />
|
|
15
|
-
<Connect(
|
|
15
|
+
<Connect(UserSearchFiltersLoader)
|
|
16
|
+
scope="data_structure"
|
|
17
|
+
/>
|
|
16
18
|
<StructuresSearchResults
|
|
17
19
|
columns={
|
|
18
20
|
Array [
|
package/src/messages/en.js
CHANGED
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
"alert.createStructureTag.failed.header": "Error creating structure tag",
|
|
3
3
|
"alert.export.csv": "Export to CSV",
|
|
4
4
|
"alert.linkStructureTag.failed.header": "Error linking tag to structure",
|
|
5
|
-
"alert.
|
|
5
|
+
"alert.saveUserSearchFilters.failed.header": "Error saving filter",
|
|
6
6
|
"alert.show.more": "Show more",
|
|
7
7
|
"alert.updateStructureTag.failed.header": "Error editing structure tag",
|
|
8
8
|
"alert.updateSystem.failed.header": "Error updating system",
|
|
@@ -163,7 +163,7 @@ export default {
|
|
|
163
163
|
"profiling.field.name": "Name",
|
|
164
164
|
"profiling.field.null": "Nulls",
|
|
165
165
|
"profiling.field.unique": "Uniques",
|
|
166
|
-
"
|
|
166
|
+
"saveUserSearchFilters.error.name.duplicated": "Duplicated name",
|
|
167
167
|
"structure._actions": " ",
|
|
168
168
|
"structure.actions.delete.confirmation.content":
|
|
169
169
|
"This structure and all its descendant structures will be deleted. Are you sure?",
|
package/src/messages/es.js
CHANGED
|
@@ -3,7 +3,7 @@ export default {
|
|
|
3
3
|
"alert.export.csv": "Exportar a CSV",
|
|
4
4
|
"alert.linkStructureTag.failed.header":
|
|
5
5
|
"Error asociando etiqueta a estructura",
|
|
6
|
-
"alert.
|
|
6
|
+
"alert.saveUserSearchFilters.failed.header": "Error guardando filtro",
|
|
7
7
|
"alert.show.more": "Mostrar más",
|
|
8
8
|
"alert.updateStructureTag.failed.header": "Error al editar Etiqueta",
|
|
9
9
|
"alert.updateSystem.failed.header": "Error actualizando sistema",
|
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
"profiling.field.name": "Nombre",
|
|
167
167
|
"profiling.field.null": "Nulos",
|
|
168
168
|
"profiling.field.unique": "Únicos",
|
|
169
|
-
"
|
|
169
|
+
"saveUserSearchFilters.error.name.duplicated": "Nombre duplicado",
|
|
170
170
|
"structure._actions": " ",
|
|
171
171
|
"structure.actions.delete.confirmation.content":
|
|
172
172
|
"Se va a borrar esta estructura y todas las estructuras descendientes. ¿Está seguro?",
|
|
@@ -47,15 +47,6 @@ describe("reducers: grantQuery", () => {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
// // it("should return default page when user filter is applied", () => {
|
|
51
|
-
// // expect(
|
|
52
|
-
// // grantQuery(fooState, { type: applyStructureUserFilter.TRIGGER })
|
|
53
|
-
// // ).toEqual({
|
|
54
|
-
// // ...fooState,
|
|
55
|
-
// // page: 1
|
|
56
|
-
// // });
|
|
57
|
-
// // });
|
|
58
|
-
|
|
59
50
|
it("should return default page when filter is toggled", () => {
|
|
60
51
|
expect(
|
|
61
52
|
grantQuery(fooState, { type: toggleGrantFilterValue.TRIGGER })
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { initialState } from "../selectedUserSearchFilter";
|
|
2
|
+
import {
|
|
3
|
+
applyUserSearchFilter,
|
|
4
|
+
clearUserSearchFilters,
|
|
5
|
+
removeStructureFilter,
|
|
6
|
+
resetStructureFilters,
|
|
7
|
+
} from "../../routines";
|
|
8
|
+
import { selectedUserSearchFilter } from "..";
|
|
9
|
+
|
|
10
|
+
const fooState = { foo: "bar" };
|
|
11
|
+
|
|
12
|
+
describe("reducers: structureActiveFilters", () => {
|
|
13
|
+
it("should provide the initial state", () => {
|
|
14
|
+
expect(selectedUserSearchFilter(undefined, {})).toEqual(initialState);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should handle the applyUserSearchFilter.TRIGGER action", () => {
|
|
18
|
+
const name = "by country";
|
|
19
|
+
const payload = { userFilter: { name } };
|
|
20
|
+
expect(
|
|
21
|
+
selectedUserSearchFilter(fooState, {
|
|
22
|
+
type: applyUserSearchFilter.TRIGGER,
|
|
23
|
+
payload,
|
|
24
|
+
})
|
|
25
|
+
).toEqual(name);
|
|
26
|
+
|
|
27
|
+
expect(
|
|
28
|
+
selectedUserSearchFilter(name, {
|
|
29
|
+
type: applyUserSearchFilter.TRIGGER,
|
|
30
|
+
payload,
|
|
31
|
+
})
|
|
32
|
+
).toEqual(null);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should handle the removeStructureFilter.TRIGGER action", () => {
|
|
36
|
+
expect(
|
|
37
|
+
selectedUserSearchFilter(fooState, {
|
|
38
|
+
type: removeStructureFilter.TRIGGER,
|
|
39
|
+
})
|
|
40
|
+
).toEqual(initialState);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should handle the resetStructureFilters.TRIGGER action", () => {
|
|
44
|
+
expect(
|
|
45
|
+
selectedUserSearchFilter(fooState, {
|
|
46
|
+
type: resetStructureFilters.TRIGGER,
|
|
47
|
+
})
|
|
48
|
+
).toEqual(initialState);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should handle the clearUserSearchFilters.TRIGGER action", () => {
|
|
52
|
+
expect(
|
|
53
|
+
selectedUserSearchFilter(fooState, {
|
|
54
|
+
type: clearUserSearchFilters.TRIGGER,
|
|
55
|
+
})
|
|
56
|
+
).toEqual(initialState);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should ignore unknown actions", () => {
|
|
60
|
+
expect(selectedUserSearchFilter(fooState, { type: "FOO" })).toBe(fooState);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { initialState } from "../structureActiveFilters";
|
|
2
2
|
import {
|
|
3
3
|
addStructureFilter,
|
|
4
|
-
|
|
4
|
+
applyUserSearchFilter,
|
|
5
5
|
clearStructureFilters,
|
|
6
6
|
closeStructureFilter,
|
|
7
7
|
removeStructureFilter,
|
|
8
8
|
resetStructureFilters,
|
|
9
|
-
toggleStructureFilterValue
|
|
9
|
+
toggleStructureFilterValue,
|
|
10
10
|
} from "../../routines";
|
|
11
11
|
import { structureActiveFilters } from "..";
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
20
20
|
it("should handle the clearStructureFilters.TRIGGER action", () => {
|
|
21
21
|
expect(
|
|
22
22
|
structureActiveFilters(fooState, {
|
|
23
|
-
type: clearStructureFilters.TRIGGER
|
|
23
|
+
type: clearStructureFilters.TRIGGER,
|
|
24
24
|
})
|
|
25
25
|
).toEqual(initialState);
|
|
26
26
|
});
|
|
@@ -31,18 +31,18 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
31
31
|
expect(
|
|
32
32
|
structureActiveFilters(fooState, {
|
|
33
33
|
type: addStructureFilter.TRIGGER,
|
|
34
|
-
payload
|
|
34
|
+
payload,
|
|
35
35
|
})
|
|
36
36
|
).toEqual({ ...fooState, baz: [] });
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it("should handle the
|
|
39
|
+
it("should handle the applyUserSearchFilter.TRIGGER action", () => {
|
|
40
40
|
const filters = { country: ["Sp"] };
|
|
41
|
-
const payload = { userFilter: { filters } };
|
|
41
|
+
const payload = { userFilter: { filters }, scope: "data_structure" };
|
|
42
42
|
expect(
|
|
43
43
|
structureActiveFilters(fooState, {
|
|
44
|
-
type:
|
|
45
|
-
payload
|
|
44
|
+
type: applyUserSearchFilter.TRIGGER,
|
|
45
|
+
payload,
|
|
46
46
|
})
|
|
47
47
|
).toEqual({ ...filters });
|
|
48
48
|
});
|
|
@@ -55,7 +55,7 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
55
55
|
expect(
|
|
56
56
|
structureActiveFilters(state, {
|
|
57
57
|
type: closeStructureFilter.TRIGGER,
|
|
58
|
-
payload
|
|
58
|
+
payload,
|
|
59
59
|
})
|
|
60
60
|
).toEqual({ foo });
|
|
61
61
|
});
|
|
@@ -68,7 +68,7 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
68
68
|
expect(
|
|
69
69
|
structureActiveFilters(state, {
|
|
70
70
|
type: removeStructureFilter.TRIGGER,
|
|
71
|
-
payload
|
|
71
|
+
payload,
|
|
72
72
|
})
|
|
73
73
|
).toEqual({ bar });
|
|
74
74
|
});
|
|
@@ -76,7 +76,7 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
76
76
|
it("should handle the resetStructureFilters.TRIGGER action", () => {
|
|
77
77
|
expect(
|
|
78
78
|
structureActiveFilters(fooState, {
|
|
79
|
-
type: resetStructureFilters.TRIGGER
|
|
79
|
+
type: resetStructureFilters.TRIGGER,
|
|
80
80
|
})
|
|
81
81
|
).toEqual(initialState);
|
|
82
82
|
});
|
|
@@ -89,7 +89,7 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
89
89
|
expect(
|
|
90
90
|
structureActiveFilters(state, {
|
|
91
91
|
type: toggleStructureFilterValue.TRIGGER,
|
|
92
|
-
payload
|
|
92
|
+
payload,
|
|
93
93
|
})
|
|
94
94
|
).toEqual({ foo: ["foo1", "foo3"], bar });
|
|
95
95
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
applyUserSearchFilter,
|
|
3
3
|
clearStructureFilters,
|
|
4
4
|
removeStructureFilter,
|
|
5
5
|
searchStructures,
|
|
6
6
|
selectStructurePage,
|
|
7
7
|
sortStructures,
|
|
8
8
|
toggleStructureFilterValue,
|
|
9
|
-
clearStructuresSort
|
|
9
|
+
clearStructuresSort,
|
|
10
10
|
} from "../../routines";
|
|
11
11
|
import { initialState } from "../structureQuery";
|
|
12
12
|
import { structureQuery } from "..";
|
|
@@ -32,7 +32,7 @@ describe("reducers: structureQuery", () => {
|
|
|
32
32
|
).toEqual({
|
|
33
33
|
...fooState,
|
|
34
34
|
page: 1,
|
|
35
|
-
query: ""
|
|
35
|
+
query: "",
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -41,7 +41,7 @@ describe("reducers: structureQuery", () => {
|
|
|
41
41
|
structureQuery(fooState, { type: clearStructuresSort.TRIGGER })
|
|
42
42
|
).toEqual({
|
|
43
43
|
...fooState,
|
|
44
|
-
sort: [{ "name.raw": "asc" }]
|
|
44
|
+
sort: [{ "name.raw": "asc" }],
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -50,16 +50,16 @@ describe("reducers: structureQuery", () => {
|
|
|
50
50
|
structureQuery(fooState, { type: removeStructureFilter.TRIGGER })
|
|
51
51
|
).toEqual({
|
|
52
52
|
...fooState,
|
|
53
|
-
page: 1
|
|
53
|
+
page: 1,
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it("should return default page when user filter is applied", () => {
|
|
58
58
|
expect(
|
|
59
|
-
structureQuery(fooState, { type:
|
|
59
|
+
structureQuery(fooState, { type: applyUserSearchFilter.TRIGGER })
|
|
60
60
|
).toEqual({
|
|
61
61
|
...fooState,
|
|
62
|
-
page: 1
|
|
62
|
+
page: 1,
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -68,7 +68,7 @@ describe("reducers: structureQuery", () => {
|
|
|
68
68
|
structureQuery(fooState, { type: toggleStructureFilterValue.TRIGGER })
|
|
69
69
|
).toEqual({
|
|
70
70
|
...fooState,
|
|
71
|
-
page: 1
|
|
71
|
+
page: 1,
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
|
|
@@ -96,7 +96,7 @@ describe("reducers: structureQuery", () => {
|
|
|
96
96
|
structureQuery(fooState, { type: searchStructures.TRIGGER, payload })
|
|
97
97
|
).toMatchObject({
|
|
98
98
|
query,
|
|
99
|
-
sort: [{ _score: "desc" }, { "name.raw": "asc" }]
|
|
99
|
+
sort: [{ _score: "desc" }, { "name.raw": "asc" }],
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -106,7 +106,7 @@ describe("reducers: structureQuery", () => {
|
|
|
106
106
|
structureQuery(fooState, { type: searchStructures.TRIGGER, payload })
|
|
107
107
|
).toMatchObject({
|
|
108
108
|
query: "",
|
|
109
|
-
sort: [{ "name.raw": "asc" }]
|
|
109
|
+
sort: [{ "name.raw": "asc" }],
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
|
|
3
|
-
import { initialState } from "../
|
|
3
|
+
import { initialState } from "../userSearchFilters";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
fetchUserSearchFilters,
|
|
6
|
+
clearUserSearchFilters,
|
|
7
|
+
deleteUserSearchFilter,
|
|
8
|
+
saveUserSearchFilters,
|
|
9
9
|
} from "../../routines";
|
|
10
|
-
import {
|
|
10
|
+
import { userSearchFilters } from "..";
|
|
11
11
|
|
|
12
12
|
const fooState = { foo: "bar" };
|
|
13
13
|
|
|
14
14
|
describe("reducers: structureActiveFilters", () => {
|
|
15
15
|
it("should provide the initial state", () => {
|
|
16
|
-
expect(
|
|
16
|
+
expect(userSearchFilters(undefined, {})).toEqual(initialState);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("should handle the
|
|
19
|
+
it("should handle the fetchUserSearchFilters.SUCCESS action", () => {
|
|
20
20
|
const filters = [
|
|
21
21
|
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
22
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
22
|
+
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
23
23
|
];
|
|
24
24
|
const sortedFilters = _.sortBy(accentInsensitivePathOrder("name"))(filters);
|
|
25
25
|
expect(
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
payload: { data: filters }
|
|
26
|
+
userSearchFilters(fooState, {
|
|
27
|
+
type: fetchUserSearchFilters.SUCCESS,
|
|
28
|
+
payload: { data: filters },
|
|
29
29
|
})
|
|
30
30
|
).toEqual(sortedFilters);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
it("should handle the
|
|
33
|
+
it("should handle the saveUserSearchFilters.SUCCESS action", () => {
|
|
34
34
|
const filters = [
|
|
35
35
|
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
36
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
36
|
+
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
37
37
|
];
|
|
38
38
|
const newFilter = { name: "c", id: 3, filters: { country: ["S3"] } };
|
|
39
39
|
const sortedFilters = _.flow(
|
|
@@ -42,35 +42,35 @@ describe("reducers: structureActiveFilters", () => {
|
|
|
42
42
|
)(filters);
|
|
43
43
|
|
|
44
44
|
expect(
|
|
45
|
-
|
|
46
|
-
type:
|
|
47
|
-
payload: { data: newFilter }
|
|
45
|
+
userSearchFilters(filters, {
|
|
46
|
+
type: saveUserSearchFilters.SUCCESS,
|
|
47
|
+
payload: { data: newFilter },
|
|
48
48
|
})
|
|
49
49
|
).toEqual(sortedFilters);
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it("should handle the
|
|
52
|
+
it("should handle the deleteUserSearchFilter.SUCCESS action", () => {
|
|
53
53
|
const filters = [
|
|
54
54
|
{ name: "b", id: 1, filters: { country: ["S"] } },
|
|
55
|
-
{ name: "a", id: 2, filters: { country: ["S2"] } }
|
|
55
|
+
{ name: "a", id: 2, filters: { country: ["S2"] } },
|
|
56
56
|
];
|
|
57
57
|
expect(
|
|
58
|
-
|
|
59
|
-
type:
|
|
60
|
-
meta: { id: 1 }
|
|
58
|
+
userSearchFilters(filters, {
|
|
59
|
+
type: deleteUserSearchFilter.SUCCESS,
|
|
60
|
+
meta: { id: 1 },
|
|
61
61
|
})
|
|
62
62
|
).toEqual([{ name: "a", id: 2, filters: { country: ["S2"] } }]);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
it("should handle the
|
|
65
|
+
it("should handle the clearUserSearchFilters.TRIGGER action", () => {
|
|
66
66
|
expect(
|
|
67
|
-
|
|
68
|
-
type:
|
|
67
|
+
userSearchFilters(fooState, {
|
|
68
|
+
type: clearUserSearchFilters.TRIGGER,
|
|
69
69
|
})
|
|
70
70
|
).toEqual(initialState);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("should ignore unknown actions", () => {
|
|
74
|
-
expect(
|
|
74
|
+
expect(userSearchFilters(fooState, { type: "FOO" })).toBe(fooState);
|
|
75
75
|
});
|
|
76
76
|
});
|
package/src/reducers/index.js
CHANGED
|
@@ -59,7 +59,7 @@ import { structureProfile } from "./structureProfile";
|
|
|
59
59
|
import { structureQuery } from "./structureQuery";
|
|
60
60
|
import { structureRedirect } from "./structureRedirect";
|
|
61
61
|
import { structureSelectedFilter } from "./structureSelectedFilter";
|
|
62
|
-
import {
|
|
62
|
+
import { selectedUserSearchFilter } from "./selectedUserSearchFilter";
|
|
63
63
|
import { structureSiblings } from "./structureSiblings";
|
|
64
64
|
import { structuresSiblings } from "./structureSiblings";
|
|
65
65
|
import { structureSystem } from "./structureSystem";
|
|
@@ -72,7 +72,7 @@ import { structureTypeLoading } from "./structureTypeLoading";
|
|
|
72
72
|
import { structureTypes } from "./structureTypes";
|
|
73
73
|
import { structureTypesLoading } from "./structureTypesLoading";
|
|
74
74
|
import { structureUpdating } from "./structureUpdating";
|
|
75
|
-
import {
|
|
75
|
+
import { userSearchFilters } from "./userSearchFilters";
|
|
76
76
|
import { structureVersion } from "./structureVersion";
|
|
77
77
|
import { structureVersions } from "./structureVersions";
|
|
78
78
|
import { structures } from "./structures";
|
|
@@ -155,7 +155,7 @@ export {
|
|
|
155
155
|
structureQuery,
|
|
156
156
|
structureRedirect,
|
|
157
157
|
structureSelectedFilter,
|
|
158
|
-
|
|
158
|
+
selectedUserSearchFilter,
|
|
159
159
|
structureSiblings,
|
|
160
160
|
structureSystem,
|
|
161
161
|
structuresSiblings,
|
|
@@ -169,7 +169,7 @@ export {
|
|
|
169
169
|
structureTypes,
|
|
170
170
|
structureTypesLoading,
|
|
171
171
|
structureUpdating,
|
|
172
|
-
|
|
172
|
+
userSearchFilters,
|
|
173
173
|
structureVersion,
|
|
174
174
|
structureVersions,
|
|
175
175
|
structures,
|