@orangelogic/orange-dam-content-browser-sdk 2.1.21 → 2.1.23
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/CBSDKdemo.html +2 -2
- package/gab_extension/GAB.html +2 -2
- package/package.json +1 -1
- package/src/components/ControlBar/ControlBar.cy.tsx +55 -27
- package/src/components/ControlBar/ControlBar.tsx +180 -207
- package/src/components/ControlBar/Facet/Facet.cy.tsx +175 -24
- package/src/components/ControlBar/Facet/Facet.tsx +27 -13
- package/src/consts/data.ts +2 -0
- package/src/page/Home/Home.tsx +103 -79
- package/src/store/assets/assets.api.ts +30 -8
- package/src/store/search/search.api.ts +51 -68
- package/src/types/search.ts +14 -5
package/src/page/Home/Home.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _camelCase from 'lodash-es/camelCase';
|
|
2
2
|
import _debounce from 'lodash-es/debounce';
|
|
3
3
|
import _intersection from 'lodash-es/intersection';
|
|
4
|
+
import _isArray from 'lodash-es/isArray';
|
|
5
|
+
import _pickBy from 'lodash-es/pickBy';
|
|
4
6
|
import {
|
|
5
7
|
FC, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState,
|
|
6
8
|
} from 'react';
|
|
@@ -14,30 +16,35 @@ import FormatDialog from '@/components/FormatDialog';
|
|
|
14
16
|
import Header from '@/components/Header/Header';
|
|
15
17
|
import AssetCardWrapper from '@/components/Result/AssetCard';
|
|
16
18
|
import { ASSET_SIZE } from '@/consts/asset';
|
|
19
|
+
import { COMPUTED_FIELDS } from '@/consts/data';
|
|
17
20
|
import { GlobalConfigContext } from '@/GlobalConfigContext';
|
|
18
21
|
import { useAppDispatch, useAppSelector } from '@/store';
|
|
19
22
|
import {
|
|
20
|
-
useGetAvailableExtensionsQuery,
|
|
21
|
-
|
|
23
|
+
useGetAvailableExtensionsQuery, useGetAvailableFacetsQuery, useGetAvailableProxiesQuery,
|
|
24
|
+
useGetParametersQuery, useGetSortOrdersQuery,
|
|
22
25
|
} from '@/store/assets/assets.api';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
import {
|
|
27
|
+
addAssetToFavorite, importAssets, removeAssetFromFavorite, selectedAssetIdSelector,
|
|
28
|
+
setSelectedAssetId,
|
|
29
|
+
} from '@/store/assets/assets.slice';
|
|
30
|
+
import { applySessionSelector, authenticatedSelector, logout } from '@/store/auth/auth.slice';
|
|
31
|
+
import {
|
|
32
|
+
useGetAssetByIdQuery, useGetAssetsQuery, useGetIsFavoriteQuery,
|
|
33
|
+
} from '@/store/search/search.api';
|
|
26
34
|
import { explorePath, RootFolder } from '@/store/search/search.slice';
|
|
27
35
|
import { useGetUserInfoQuery } from '@/store/user/user.api';
|
|
28
36
|
import { FormatLoaderState } from '@/types/assets';
|
|
29
37
|
import {
|
|
30
|
-
Asset,
|
|
38
|
+
Asset, Facet, Folder, GetAssetLinkResponse, GridView, SortDirection,
|
|
31
39
|
} from '@/types/search';
|
|
32
40
|
import { MOBILE_THRESHOLD, PAGE_SIZE, RESIZE_TIMEOUT } from '@/utils/constants';
|
|
41
|
+
import { isPromise } from '@/utils/function';
|
|
33
42
|
import { getData, storeData } from '@/utils/storage';
|
|
34
|
-
import type { CxResizeEvent, CxResizeObserver } from '@orangelogic-private/design-system';
|
|
35
43
|
import { skipToken } from '@reduxjs/toolkit/query';
|
|
36
44
|
|
|
37
45
|
import { Container } from './Home.styled';
|
|
38
|
-
import { COMPUTED_FIELDS } from '@/consts/data';
|
|
39
|
-
import { isPromise } from '@/utils/function';
|
|
40
46
|
|
|
47
|
+
import type { CxResizeEvent, CxResizeObserver } from '@orangelogic-private/design-system';
|
|
41
48
|
type Props = {
|
|
42
49
|
multiSelect?: boolean;
|
|
43
50
|
};
|
|
@@ -50,24 +57,21 @@ type State = {
|
|
|
50
57
|
currentCount: number;
|
|
51
58
|
currentFolder: Folder;
|
|
52
59
|
defaultPageSize: number;
|
|
53
|
-
|
|
54
|
-
facets: Record<string, Record<string, number>>;
|
|
60
|
+
facets: Facet[];
|
|
55
61
|
hasScrolled: boolean;
|
|
56
62
|
isLoading: boolean;
|
|
57
63
|
isSeeThrough: boolean;
|
|
58
|
-
mediaTypes: string[];
|
|
59
64
|
openBrowser: boolean;
|
|
60
65
|
start: number;
|
|
61
66
|
pageSize: number;
|
|
62
67
|
maxPageSize: number;
|
|
63
68
|
searchText: string;
|
|
69
|
+
selectedFacets: Record<string, string[]>;
|
|
64
70
|
shouldResetFilters: boolean;
|
|
65
71
|
sortDirection?: 'ascending' | 'descending';
|
|
66
72
|
sortOrder: string;
|
|
67
|
-
statuses: string[];
|
|
68
73
|
totalCount: number;
|
|
69
74
|
view: GridView;
|
|
70
|
-
visibilityClasses: string[];
|
|
71
75
|
};
|
|
72
76
|
|
|
73
77
|
type Action =
|
|
@@ -78,8 +82,8 @@ type Action =
|
|
|
78
82
|
folder: Folder,
|
|
79
83
|
shouldResetFilters?: boolean;
|
|
80
84
|
} }
|
|
81
|
-
| { type: 'SET_FACETS'; payload:
|
|
82
|
-
| { type: 'SET_FILTERS'; payload:
|
|
85
|
+
| { type: 'SET_FACETS'; payload: Facet[] }
|
|
86
|
+
| { type: 'SET_FILTERS'; payload: Record<string, string[]> }
|
|
83
87
|
| { type: 'SET_HAS_SCROLLED'; payload: boolean }
|
|
84
88
|
| { type: 'SET_IS_LOADING'; payload: boolean }
|
|
85
89
|
| { type: 'SET_IS_SEE_THROUGH'; payload: boolean }
|
|
@@ -103,24 +107,21 @@ const initialState: State = {
|
|
|
103
107
|
currentCount: 0,
|
|
104
108
|
currentFolder: RootFolder,
|
|
105
109
|
defaultPageSize: PAGE_SIZE,
|
|
106
|
-
|
|
107
|
-
facets: {},
|
|
110
|
+
facets: [],
|
|
108
111
|
hasScrolled: false,
|
|
109
112
|
isLoading: false,
|
|
110
113
|
isSeeThrough: true,
|
|
111
|
-
mediaTypes: [],
|
|
112
114
|
openBrowser: false,
|
|
113
115
|
start: 0,
|
|
114
116
|
pageSize: 0,
|
|
115
117
|
maxPageSize: 0,
|
|
116
118
|
searchText: '',
|
|
119
|
+
selectedFacets: {},
|
|
117
120
|
shouldResetFilters: true,
|
|
118
121
|
sortDirection: undefined,
|
|
119
122
|
sortOrder: '',
|
|
120
|
-
statuses: [],
|
|
121
123
|
totalCount: 0,
|
|
122
124
|
view: GridView.Medium,
|
|
123
|
-
visibilityClasses: [],
|
|
124
125
|
};
|
|
125
126
|
|
|
126
127
|
const reducer = (state: State, action: Action): State => {
|
|
@@ -140,11 +141,8 @@ const reducer = (state: State, action: Action): State => {
|
|
|
140
141
|
case 'SET_FILTERS':
|
|
141
142
|
return {
|
|
142
143
|
...state,
|
|
143
|
-
|
|
144
|
-
visibilityClasses: action.payload.visibilityClasses,
|
|
144
|
+
selectedFacets: action.payload,
|
|
145
145
|
shouldResetFilters: false,
|
|
146
|
-
statuses: action.payload.statuses,
|
|
147
|
-
extensions: action.payload.extensions,
|
|
148
146
|
...resetPageState,
|
|
149
147
|
};
|
|
150
148
|
case 'SET_HAS_SCROLLED':
|
|
@@ -156,15 +154,12 @@ const reducer = (state: State, action: Action): State => {
|
|
|
156
154
|
case 'SET_OPEN_BROWSER':
|
|
157
155
|
return { ...state, openBrowser: action.payload };
|
|
158
156
|
case 'SET_START':{
|
|
159
|
-
return { ...state, start:
|
|
157
|
+
return { ...state, start: action.payload, pageSize: state.defaultPageSize };
|
|
160
158
|
}
|
|
161
159
|
case 'SET_PAGE_SIZE': {
|
|
162
160
|
const result = { ...state, pageSize: action.payload.pageSize, maxPageSize: action.payload.pageSize };
|
|
163
161
|
if (action.payload.returnToFirstPage) {
|
|
164
162
|
result.start = 0;
|
|
165
|
-
} else {
|
|
166
|
-
result.start = state.start + state.pageSize;
|
|
167
|
-
result.pageSize = Math.abs(action.payload.pageSize - result.start);
|
|
168
163
|
}
|
|
169
164
|
return result;
|
|
170
165
|
}
|
|
@@ -260,7 +255,7 @@ const HomePage: FC<Props> = () => {
|
|
|
260
255
|
: skipToken,
|
|
261
256
|
);
|
|
262
257
|
|
|
263
|
-
const { data: availableExtensions } = useGetAvailableExtensionsQuery();
|
|
258
|
+
const { data: availableExtensions } = useGetAvailableExtensionsQuery({ useSession });
|
|
264
259
|
|
|
265
260
|
const { data: params } = useGetParametersQuery({
|
|
266
261
|
useSession,
|
|
@@ -278,6 +273,8 @@ const HomePage: FC<Props> = () => {
|
|
|
278
273
|
useSession,
|
|
279
274
|
});
|
|
280
275
|
|
|
276
|
+
const { data: availableFacets } = useGetAvailableFacetsQuery({ useSession });
|
|
277
|
+
|
|
281
278
|
const { data: isFavorite, refetch: refetchIsFavorite } = useGetIsFavoriteQuery(
|
|
282
279
|
selectedAsset && allowFavorites ? {
|
|
283
280
|
recordId: selectedAsset.id,
|
|
@@ -286,13 +283,14 @@ const HomePage: FC<Props> = () => {
|
|
|
286
283
|
const [browserMounted, setBrowserMounted] = useState(false);
|
|
287
284
|
const [isResized, setIsResized] = useState(false);
|
|
288
285
|
const [showFormatLoader, setShowFormatLoader] = useState<FormatLoaderState>(FormatLoaderState.Hide);
|
|
286
|
+
const [itemsCount, setItemsCount] = useState(0);
|
|
289
287
|
|
|
290
288
|
const browserMountedRef = useRef(browserMounted);
|
|
291
289
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
292
290
|
const resultRef = useRef<HTMLDivElement>(null);
|
|
293
291
|
const containerResizeObserverRef = useRef<CxResizeObserver>(null);
|
|
294
292
|
const loadedFromStorage = useRef(false);
|
|
295
|
-
const facetsRef = useRef<
|
|
293
|
+
const facetsRef = useRef<Facet[]>([]);
|
|
296
294
|
const appDispatch = useAppDispatch();
|
|
297
295
|
|
|
298
296
|
const pageSizeRef = useRef(state.pageSize);
|
|
@@ -310,9 +308,9 @@ const HomePage: FC<Props> = () => {
|
|
|
310
308
|
}, [availableDocTypes, supportedDocTypes]);
|
|
311
309
|
|
|
312
310
|
const mappedMediaTypes = useMemo(() => {
|
|
313
|
-
if (state.
|
|
311
|
+
if (state.selectedFacets.Types && state.selectedFacets.Types.length > 0) return state.selectedFacets.Types;
|
|
314
312
|
return ['*'];
|
|
315
|
-
}, [state.
|
|
313
|
+
}, [state.selectedFacets]);
|
|
316
314
|
|
|
317
315
|
const isConfigError = useMemo(() => (!mappedMediaTypes?.length || mappedMediaTypes.length === 0) && !!supportedDocTypes, [mappedMediaTypes, supportedDocTypes]);
|
|
318
316
|
|
|
@@ -361,21 +359,26 @@ const HomePage: FC<Props> = () => {
|
|
|
361
359
|
});
|
|
362
360
|
}, [availableProxies, allowedExtensions]);
|
|
363
361
|
|
|
364
|
-
const
|
|
365
|
-
|
|
362
|
+
const shouldFetch = useMemo(() => {
|
|
363
|
+
return isResized && sortOrders && mappedMediaTypes?.length && browserMounted;
|
|
364
|
+
}, [isResized, sortOrders, mappedMediaTypes, browserMounted]);
|
|
365
|
+
|
|
366
|
+
const { data, isFetching, isError, refetch } = useGetAssetsQuery(shouldFetch ? {
|
|
366
367
|
folderID: state.currentFolder.id,
|
|
367
368
|
isSeeThrough: state.isSeeThrough,
|
|
368
369
|
limitedToDocTypes: mappedAvailableDocTypes,
|
|
369
|
-
mediaTypes: mappedMediaTypes,
|
|
370
370
|
pageSize: state.pageSize,
|
|
371
371
|
searchText: state.searchText,
|
|
372
|
+
selectedFacets: state.selectedFacets,
|
|
372
373
|
sortOrder: selectedSortOrder?.id,
|
|
373
374
|
start: state.start,
|
|
374
|
-
statuses: state.statuses ?? [],
|
|
375
375
|
useSession,
|
|
376
|
-
visibilityClasses: state.visibilityClasses,
|
|
377
376
|
} : skipToken);
|
|
378
377
|
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
setItemsCount(data?.items.length ?? 0);
|
|
380
|
+
}, [data?.items.length]);
|
|
381
|
+
|
|
379
382
|
useEffect(() => {
|
|
380
383
|
if (isErrorSelectedAsset) {
|
|
381
384
|
appDispatch(setSelectedAssetId(null));
|
|
@@ -429,17 +432,33 @@ const HomePage: FC<Props> = () => {
|
|
|
429
432
|
dispatch({ type: 'SET_SORT_DIRECTION', payload: sortDirection });
|
|
430
433
|
}
|
|
431
434
|
if (typeof view === 'string') {
|
|
432
|
-
|
|
435
|
+
if (!Object.values(GridView).includes(view as GridView)) {
|
|
436
|
+
/**
|
|
437
|
+
* Default to Medium if the stored view is invalid.
|
|
438
|
+
*/
|
|
439
|
+
dispatch({ type: 'SET_VIEW', payload: GridView.Medium });
|
|
440
|
+
} else {
|
|
441
|
+
dispatch({ type: 'SET_VIEW', payload: view as GridView });
|
|
442
|
+
}
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
if (lastLocationMode) {
|
|
436
446
|
if (newFacets) {
|
|
437
447
|
const parsedFacets = JSON.parse(newFacets);
|
|
438
|
-
|
|
448
|
+
if (_isArray(parsedFacets)) {
|
|
449
|
+
dispatch({ type: 'SET_FACETS', payload: parsedFacets });
|
|
450
|
+
} else {
|
|
451
|
+
dispatch({ type: 'SET_FACETS', payload: [] });
|
|
452
|
+
}
|
|
439
453
|
}
|
|
440
454
|
if (selectedFilter) {
|
|
441
455
|
const parsedFilter = JSON.parse(selectedFilter);
|
|
442
|
-
|
|
456
|
+
|
|
457
|
+
if (parsedFilter) {
|
|
458
|
+
dispatch({ type: 'SET_FILTERS', payload: _pickBy(parsedFilter, _isArray) });
|
|
459
|
+
} else {
|
|
460
|
+
dispatch({ type: 'SET_FILTERS', payload: {} });
|
|
461
|
+
}
|
|
443
462
|
}
|
|
444
463
|
if (selectedIsSeeThrough) {
|
|
445
464
|
dispatch({ type: 'SET_IS_SEE_THROUGH', payload: selectedIsSeeThrough === 'true' });
|
|
@@ -454,6 +473,32 @@ const HomePage: FC<Props> = () => {
|
|
|
454
473
|
}
|
|
455
474
|
}, [appDispatch, authenticated, lastLocationMode]);
|
|
456
475
|
|
|
476
|
+
useEffect(() => {
|
|
477
|
+
/**
|
|
478
|
+
* Force re-render of the container to ensure that the width is recalculated correctly.
|
|
479
|
+
* The issue is that the container width is not updated correctly when the Content Browser is mounted inside custom windows, e.g. in the File on Demand, Contentful.
|
|
480
|
+
*/
|
|
481
|
+
let timeout = null;
|
|
482
|
+
const container = containerRef.current;
|
|
483
|
+
|
|
484
|
+
if (!container) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const currentWidth = container.offsetWidth;
|
|
489
|
+
container.style.width = (currentWidth - 1) + 'px';
|
|
490
|
+
|
|
491
|
+
timeout = setTimeout(() => {
|
|
492
|
+
container.style.width = '100%';
|
|
493
|
+
}, 50);
|
|
494
|
+
|
|
495
|
+
return () => {
|
|
496
|
+
if (timeout) {
|
|
497
|
+
clearTimeout(timeout);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}, [authenticated]);
|
|
501
|
+
|
|
457
502
|
useEffect(() => {
|
|
458
503
|
const resizeObserver = containerResizeObserverRef.current;
|
|
459
504
|
if (!resizeObserver) {
|
|
@@ -504,29 +549,11 @@ const HomePage: FC<Props> = () => {
|
|
|
504
549
|
storeData('newFacets', JSON.stringify(state.facets));
|
|
505
550
|
storeData(
|
|
506
551
|
'selectedFilter',
|
|
507
|
-
JSON.stringify(
|
|
508
|
-
mediaTypes: state.mediaTypes,
|
|
509
|
-
visibilityClasses: state.visibilityClasses,
|
|
510
|
-
shouldResetFilters: false,
|
|
511
|
-
statuses: state.statuses,
|
|
512
|
-
extensions: state.extensions,
|
|
513
|
-
}),
|
|
552
|
+
JSON.stringify(state.selectedFacets),
|
|
514
553
|
);
|
|
515
554
|
storeData('selectedIsSeeThrough', state.isSeeThrough.toString());
|
|
516
555
|
storeData('searchText', state.searchText);
|
|
517
|
-
}, [
|
|
518
|
-
state.currentFolder,
|
|
519
|
-
state.extensions,
|
|
520
|
-
state.facets,
|
|
521
|
-
state.isSeeThrough,
|
|
522
|
-
state.mediaTypes,
|
|
523
|
-
state.sortDirection,
|
|
524
|
-
state.sortOrder,
|
|
525
|
-
state.searchText,
|
|
526
|
-
state.statuses,
|
|
527
|
-
state.view,
|
|
528
|
-
state.visibilityClasses,
|
|
529
|
-
]);
|
|
556
|
+
}, [state.currentFolder, state.facets, state.isSeeThrough, state.sortDirection, state.sortOrder, state.searchText, state.view, state.selectedFacets]);
|
|
530
557
|
|
|
531
558
|
const isMobile = state.containerSize.width <= MOBILE_THRESHOLD;
|
|
532
559
|
|
|
@@ -565,7 +592,7 @@ const HomePage: FC<Props> = () => {
|
|
|
565
592
|
const rowCount = Math.ceil(containerHeight / (breakpoint + gutter));
|
|
566
593
|
const newPageSize = Math.ceil((rowCount * columnCount) / defaultPageSizeRef.current + 1) * defaultPageSizeRef.current;
|
|
567
594
|
setIsResized(true);
|
|
568
|
-
if (newPageSize !== pageSizeRef.current) {
|
|
595
|
+
if (newPageSize !== pageSizeRef.current && newPageSize !== 0) {
|
|
569
596
|
dispatch({
|
|
570
597
|
type: 'SET_PAGE_SIZE',
|
|
571
598
|
payload: {
|
|
@@ -577,7 +604,7 @@ const HomePage: FC<Props> = () => {
|
|
|
577
604
|
}, []);
|
|
578
605
|
|
|
579
606
|
const debouncedHandleResize = useMemo(() => {
|
|
580
|
-
return _debounce(handleResize,
|
|
607
|
+
return _debounce(handleResize, RESIZE_TIMEOUT, {
|
|
581
608
|
leading: false,
|
|
582
609
|
});
|
|
583
610
|
}, [handleResize]);
|
|
@@ -601,7 +628,7 @@ const HomePage: FC<Props> = () => {
|
|
|
601
628
|
const onSettingChange = useCallback(
|
|
602
629
|
(
|
|
603
630
|
setting: string,
|
|
604
|
-
value: GridView | SortDirection |
|
|
631
|
+
value: GridView | SortDirection | Record<string, string[]> | string | boolean | string[],
|
|
605
632
|
) => {
|
|
606
633
|
switch (setting) {
|
|
607
634
|
case 'view':
|
|
@@ -620,7 +647,7 @@ const HomePage: FC<Props> = () => {
|
|
|
620
647
|
dispatch({ type: 'SET_IS_SEE_THROUGH', payload: Boolean(value) });
|
|
621
648
|
break;
|
|
622
649
|
case 'filter':
|
|
623
|
-
dispatch({ type: 'SET_FILTERS', payload: value as
|
|
650
|
+
dispatch({ type: 'SET_FILTERS', payload: value as Record<string, string[]> });
|
|
624
651
|
break;
|
|
625
652
|
default:
|
|
626
653
|
break;
|
|
@@ -631,7 +658,7 @@ const HomePage: FC<Props> = () => {
|
|
|
631
658
|
|
|
632
659
|
const onDataChange = useCallback(
|
|
633
660
|
(newData: {
|
|
634
|
-
facets:
|
|
661
|
+
facets: Facet[];
|
|
635
662
|
items: Asset[];
|
|
636
663
|
totalCount: number;
|
|
637
664
|
currentCount: number;
|
|
@@ -667,15 +694,17 @@ const HomePage: FC<Props> = () => {
|
|
|
667
694
|
isWindowResizing.current = false;
|
|
668
695
|
return;
|
|
669
696
|
}
|
|
670
|
-
dispatch({ type: 'SET_START', payload:
|
|
671
|
-
}, []);
|
|
697
|
+
dispatch({ type: 'SET_START', payload: itemsCount ?? 0 });
|
|
698
|
+
}, [itemsCount]);
|
|
672
699
|
|
|
673
700
|
const onScroll = useCallback((e: MouseEvent) => {
|
|
674
701
|
if (!e.target) {
|
|
675
702
|
return;
|
|
676
703
|
}
|
|
677
704
|
|
|
678
|
-
|
|
705
|
+
const newScrollTop = (e.target as HTMLElement).scrollTop;
|
|
706
|
+
|
|
707
|
+
if (newScrollTop === 0) {
|
|
679
708
|
dispatch({ type: 'SET_HAS_SCROLLED', payload: false });
|
|
680
709
|
} else {
|
|
681
710
|
dispatch({ type: 'SET_HAS_SCROLLED', payload: true });
|
|
@@ -725,8 +754,8 @@ const HomePage: FC<Props> = () => {
|
|
|
725
754
|
if (onDataChange) {
|
|
726
755
|
onDataChange({
|
|
727
756
|
currentCount: data?.items.length ?? 0,
|
|
728
|
-
items: data?.items
|
|
729
|
-
facets: data?.facets
|
|
757
|
+
items: data?.items ?? [],
|
|
758
|
+
facets: data?.facets ?? [],
|
|
730
759
|
totalCount: data?.totalCount ?? 0,
|
|
731
760
|
});
|
|
732
761
|
}
|
|
@@ -805,21 +834,19 @@ const HomePage: FC<Props> = () => {
|
|
|
805
834
|
>
|
|
806
835
|
<ControlBar
|
|
807
836
|
allowSorting={selectedSortOrder?.sortDirection !== 'Mono' && !!selectedSortOrder}
|
|
837
|
+
availableFacets={availableFacets ?? []}
|
|
808
838
|
currentCount={state.currentCount}
|
|
809
|
-
extensions={state.extensions}
|
|
810
839
|
facets={state.facets}
|
|
811
840
|
isMobile={isMobile}
|
|
812
841
|
isSeeThrough={state.isSeeThrough}
|
|
813
842
|
loading={state.isLoading}
|
|
814
|
-
mediaTypes={state.mediaTypes}
|
|
815
843
|
searchValue={state.searchText}
|
|
844
|
+
selectedFacets={state.selectedFacets}
|
|
816
845
|
sortDirection={state.sortDirection}
|
|
817
846
|
sortOrder={state.sortOrder}
|
|
818
847
|
sortOrders={sortOrders}
|
|
819
|
-
statuses={state.statuses}
|
|
820
848
|
totalCount={state.totalCount}
|
|
821
849
|
view={state.view}
|
|
822
|
-
visibilityClasses={state.visibilityClasses}
|
|
823
850
|
onSearchChange={onSearchChange}
|
|
824
851
|
onSettingChange={onSettingChange}
|
|
825
852
|
/>
|
|
@@ -872,10 +899,7 @@ const HomePage: FC<Props> = () => {
|
|
|
872
899
|
key={
|
|
873
900
|
state.currentFolder.id +
|
|
874
901
|
state.searchText +
|
|
875
|
-
state.
|
|
876
|
-
state.extensions.join('+') +
|
|
877
|
-
state.statuses.join('+') +
|
|
878
|
-
state.visibilityClasses.join('+') +
|
|
902
|
+
Object.values(state.selectedFacets).join('+') +
|
|
879
903
|
state.isSeeThrough +
|
|
880
904
|
state.view
|
|
881
905
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
|
|
3
3
|
import { SortOrder } from '@/types/assets';
|
|
4
|
-
import { Asset, MediaType, Proxy } from '@/types/search';
|
|
4
|
+
import { Asset, Facet, MediaType, Proxy } from '@/types/search';
|
|
5
5
|
import { AppBaseQuery, GetValueByKeyCaseInsensitive } from '@/utils/api';
|
|
6
6
|
import { hasElements, uniqueArray } from '@/utils/array';
|
|
7
7
|
import { createApi, retry } from '@reduxjs/toolkit/query/react';
|
|
@@ -28,6 +28,8 @@ export type GetAvailableProxiesResponse = {
|
|
|
28
28
|
|
|
29
29
|
type GetAvailableExtensionsResponse = Record<MediaType, { displayName: string; value: string }[]>;
|
|
30
30
|
|
|
31
|
+
type GetAvailableFacetsResponse = Facet['facetDetails'][];
|
|
32
|
+
|
|
31
33
|
/**
|
|
32
34
|
* get query parameter for AvailableProxies_4ea_v2 API
|
|
33
35
|
* @param {GetAvailableProxiesRequest}
|
|
@@ -61,11 +63,12 @@ const baseQueryWithRetry = retry(AppBaseQuery, {
|
|
|
61
63
|
export const assetsApi = createApi({
|
|
62
64
|
reducerPath: 'assetsApi',
|
|
63
65
|
baseQuery: baseQueryWithRetry,
|
|
64
|
-
tagTypes: ['AvailableExtensions', 'AvailableProxies', 'Parameters', 'SortOrders', 'VersionHistory'],
|
|
66
|
+
tagTypes: ['AvailableExtensions', 'AvailableFacets', 'AvailableProxies', 'Parameters', 'SortOrders', 'VersionHistory'],
|
|
65
67
|
endpoints: (builder) => ({
|
|
66
|
-
getAvailableExtensions: builder.query<GetAvailableExtensionsResponse,
|
|
67
|
-
query: () => ({
|
|
68
|
+
getAvailableExtensions: builder.query<GetAvailableExtensionsResponse, { useSession: string }>({
|
|
69
|
+
query: ({ useSession }) => ({
|
|
68
70
|
url: '/webapi/extensibility/integrations/gab/assetbrowser/getavailableextensionsfortransformation_419v_v1',
|
|
71
|
+
params: useSession ? [['UseSession', useSession]] : [],
|
|
69
72
|
}),
|
|
70
73
|
transformResponse: (response: { extensions: GetAvailableExtensionsResponse }) => {
|
|
71
74
|
return response.extensions;
|
|
@@ -96,6 +99,15 @@ export const assetsApi = createApi({
|
|
|
96
99
|
serializeQueryArgs: ({ queryArgs }) => getAvailableProxiesAPIParams(queryArgs),
|
|
97
100
|
providesTags: (_result, _error, _args) => ['AvailableProxies'],
|
|
98
101
|
}),
|
|
102
|
+
getAvailableFacets: builder.query<GetAvailableFacetsResponse, { useSession: string }>({
|
|
103
|
+
keepUnusedDataFor: 0,
|
|
104
|
+
query: ({ useSession }) => ({
|
|
105
|
+
url: '/webapi/extensibility/integrations/gab/assetbrowser/getavailablefacets',
|
|
106
|
+
params: useSession ? [['UseSession', useSession]] : [],
|
|
107
|
+
}),
|
|
108
|
+
transformResponse: (response: { facets: Facet['facetDetails'][] }) => response.facets,
|
|
109
|
+
providesTags: ['AvailableFacets'],
|
|
110
|
+
}),
|
|
99
111
|
getParameters: builder.query<{
|
|
100
112
|
ATSEnabled: boolean;
|
|
101
113
|
autoExtension: string;
|
|
@@ -162,12 +174,21 @@ export const assetsApi = createApi({
|
|
|
162
174
|
versions: Record<string, string>[];
|
|
163
175
|
}, {
|
|
164
176
|
assetId: string;
|
|
177
|
+
useSession?: string;
|
|
165
178
|
}>({
|
|
166
179
|
keepUnusedDataFor: 0,
|
|
167
|
-
query: ({ assetId }) =>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
query: ({ assetId, useSession }) => {
|
|
181
|
+
const params = [['RecordID', assetId]];
|
|
182
|
+
|
|
183
|
+
if (useSession) {
|
|
184
|
+
params.push(['UseSession', useSession]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
url: '/webapi/extensibility/integrations/contentBrowserSDK/getassetversion_418f',
|
|
189
|
+
params,
|
|
190
|
+
};
|
|
191
|
+
},
|
|
171
192
|
transformResponse: (response: { count: number, versions: Record<string, string>[] }) => {
|
|
172
193
|
return {
|
|
173
194
|
count: response.count,
|
|
@@ -195,6 +216,7 @@ export const assetsApi = createApi({
|
|
|
195
216
|
// auto-generated based on the defined endpoints
|
|
196
217
|
export const {
|
|
197
218
|
useGetAvailableExtensionsQuery,
|
|
219
|
+
useGetAvailableFacetsQuery,
|
|
198
220
|
useGetAvailableProxiesQuery,
|
|
199
221
|
useGetParametersQuery,
|
|
200
222
|
useGetSortOrdersQuery,
|