@truedat/core 8.8.8 → 8.9.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "8.8.8",
3
+ "version": "8.9.1",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -54,7 +54,7 @@
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.3.0",
56
56
  "@testing-library/user-event": "^14.6.1",
57
- "@truedat/test": "8.8.8",
57
+ "@truedat/test": "8.9.1",
58
58
  "identity-obj-proxy": "^3.0.0",
59
59
  "jest": "^29.7.0",
60
60
  "redux-saga-test-plan": "^4.0.6"
@@ -95,5 +95,5 @@
95
95
  "swr": "^2.3.3",
96
96
  "turndown": "^7.2.2"
97
97
  },
98
- "gitHead": "850b1a20250c39f4781aea0174aeebd383898eea"
98
+ "gitHead": "778d7597a979b8c64dd2bbd5d512fd7c4a24b453"
99
99
  }
@@ -34,6 +34,10 @@ export const SearchContextProvider = (props) => {
34
34
  const omitFilters = _.propOr([], "omitFilters")(props);
35
35
  const translations = _.propOr(() => ({}), "translations")(props);
36
36
  const filtersGroup = _.propOr([], "filtersGroup")(props);
37
+ const searchFiltersPropsMapping = _.propOr(
38
+ {},
39
+ "searchFiltersPropsMapping",
40
+ )(props);
37
41
  const enrichSearchPayload = useState(_.prop("enrichSearchPayload")(props))[0];
38
42
 
39
43
  const { formatMessage } = useIntl();
@@ -147,7 +151,16 @@ export const SearchContextProvider = (props) => {
147
151
  const filters = _.flow(
148
152
  _.propOr({}, "data"),
149
153
  _.omit(omitFilters),
150
- _.omitBy(_.flow(_.propOr([], "values"), (values) => _.size(values) < 2)),
154
+ _.omitBy(
155
+ _.cond([
156
+ [_.matches({ type: "search" }), _.stubFalse],
157
+ [
158
+ _.flow(_.propOr([], "values"), (values) => _.size(values) < 2),
159
+ _.stubTrue,
160
+ ],
161
+ [_.stubTrue, _.stubFalse],
162
+ ]),
163
+ ),
151
164
  )(filtersPayload);
152
165
 
153
166
  const allFilters = _.flow(
@@ -388,6 +401,7 @@ export const SearchContextProvider = (props) => {
388
401
  userFiltersType,
389
402
  userFilterScope,
390
403
  useDomainSearchFilter,
404
+ searchFiltersPropsMapping,
391
405
 
392
406
  setOnSearchChange,
393
407
  };
@@ -2,7 +2,9 @@ import _ from "lodash/fp";
2
2
  import { useState } from "react";
3
3
  import { FormattedMessage } from "react-intl";
4
4
  import { useLocation } from "react-router";
5
+ import { useDispatch } from "react-redux";
5
6
  import DomainSearchFilter from "../components/DomainSearchFilter";
7
+ import SearchFilterDropdown from "../components/SearchFilterDropdown";
6
8
  import ModalSaveFilter from "./ModalSaveFilter";
7
9
  import UserFilters from "./UserFilters";
8
10
  import FilterDropdown from "./FilterDropdown";
@@ -15,6 +17,7 @@ const MIN_LENGTH_FOR_QUERY_DROPDOWN = 8;
15
17
 
16
18
  export default function SearchSelectedFilters() {
17
19
  const context = useSearchContext();
20
+ const dispatch = useDispatch();
18
21
  const {
19
22
  selectedFilters,
20
23
  resetFilters,
@@ -23,6 +26,7 @@ export default function SearchSelectedFilters() {
23
26
  activeFilterValues,
24
27
  userFiltersType,
25
28
  useDomainSearchFilter,
29
+ searchFiltersPropsMapping,
26
30
  } = context;
27
31
  const [selectedUserFilter, setSelectedUserFilter] = useState();
28
32
  const { pathname } = useLocation();
@@ -75,6 +79,20 @@ export default function SearchSelectedFilters() {
75
79
  )
76
80
  ) : filterType === "hierarchy" ? (
77
81
  <HierarchyFilterDropdown />
82
+ ) : filterType === "search" &&
83
+ _.prop(filter)(searchFiltersPropsMapping) ? (
84
+ <SearchFilterDropdown
85
+ filter={filter}
86
+ loading={context.loadingFilters}
87
+ openFilter={context.openFilter}
88
+ closeFilter={context.closeFilter}
89
+ removeFilter={context.removeFilter}
90
+ toggleFilterValue={context.toggleFilterValue}
91
+ activeValues={context.activeFilterSelectedValues}
92
+ open={_.isEqual(filter, activeFilterName)}
93
+ searchFilterDispacher={(action) => dispatch(action)}
94
+ {..._.prop(filter)(searchFiltersPropsMapping)}
95
+ />
78
96
  ) : _.size(options) >= MIN_LENGTH_FOR_QUERY_DROPDOWN ? (
79
97
  <FilterQueryDropdown />
80
98
  ) : (
@@ -311,6 +311,38 @@ describe("<SearchContextProvider />", () => {
311
311
  jest.useRealTimers();
312
312
  });
313
313
 
314
+ it("keeps search type filters without values in available filters", async () => {
315
+ jest.useFakeTimers();
316
+ const triggerFiltersSpy = jest.fn().mockReturnValue({
317
+ then: (callback) =>
318
+ callback({
319
+ data: {
320
+ data: {
321
+ status: { type: "term", values: ["draft", "published"] },
322
+ linked_structures_ids: { type: "search", index: "structures" },
323
+ },
324
+ },
325
+ }),
326
+ });
327
+ const useFiltersSpy = () => ({ trigger: triggerFiltersSpy });
328
+
329
+ const rendered = render(
330
+ <SearchContextProvider {...searchProps} useFilters={useFiltersSpy}>
331
+ <ContextConsumer onSearchChangeSpy={jest.fn()} />
332
+ </SearchContextProvider>,
333
+ renderOpts,
334
+ );
335
+
336
+ jest.runAllTimers();
337
+
338
+ await waitFor(() =>
339
+ expect(
340
+ rendered.getByText(/available:\["status","linked_structures_ids"\]/i),
341
+ ).toBeInTheDocument(),
342
+ );
343
+ jest.useRealTimers();
344
+ });
345
+
314
346
  it("handles active and hidden filter toggles and removals", async () => {
315
347
  jest.useFakeTimers();
316
348
  const user = userEvent.setup({
@@ -53,6 +53,17 @@ jest.mock("../HierarchyFilterDropdown", () => ({
53
53
  default: () => <div data-testid="hierarchy-filter-dropdown" />,
54
54
  }));
55
55
 
56
+ jest.mock("../../components/SearchFilterDropdown", () => ({
57
+ __esModule: true,
58
+ default: ({ filter, placeholder }) => (
59
+ <div
60
+ data-testid="search-filter-dropdown"
61
+ data-filter={filter}
62
+ data-placeholder={placeholder}
63
+ />
64
+ ),
65
+ }));
66
+
56
67
  jest.mock("../../components/DomainSearchFilter", () => ({
57
68
  __esModule: true,
58
69
  default: ({ filter, options }) => (