@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
|
@@ -4,56 +4,170 @@ import Facet from './Facet';
|
|
|
4
4
|
|
|
5
5
|
describe('Facet', () => {
|
|
6
6
|
it('Should render nothing when no facet is provided', () => {
|
|
7
|
-
cy.mount(<Facet
|
|
7
|
+
cy.mount(<Facet values={[]} type="" collections={[]} displayName=''/>);
|
|
8
8
|
cy.get('cx-details').should('not.exist');
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it('Should render the facet with some items', () => {
|
|
12
12
|
const data = {
|
|
13
13
|
type: 'example',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
values: [
|
|
15
|
+
{
|
|
16
|
+
'displayValue': 'images',
|
|
17
|
+
'value': 'images',
|
|
18
|
+
'count': 50,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
'displayValue': 'others',
|
|
22
|
+
'value': 'others',
|
|
23
|
+
'count': 9,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
'displayValue': 'videos',
|
|
27
|
+
'value': 'videos',
|
|
28
|
+
'count': 5,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
'displayValue': '3d assets',
|
|
32
|
+
'value': '3d assets',
|
|
33
|
+
'count': 4,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
'displayValue': 'audio',
|
|
37
|
+
'value': 'audio',
|
|
38
|
+
'count': 3,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
'displayValue': 'image',
|
|
42
|
+
'value': 'image',
|
|
43
|
+
'count': 1,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
'displayValue': 'images>>image 1s',
|
|
47
|
+
'value': 'images>>image 1s',
|
|
48
|
+
'count': 1,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
'displayValue': 'images>>image 2s',
|
|
52
|
+
'value': 'images>>image 2s',
|
|
53
|
+
'count': 1,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
18
56
|
displayName: 'Example Facet',
|
|
19
57
|
};
|
|
20
|
-
cy.mount(<Facet
|
|
58
|
+
cy.mount(<Facet values={data.values} type={data.type} collections={[]} displayName={data.displayName}/>);
|
|
21
59
|
cy.waitForCustomElement('cx-details');
|
|
22
60
|
cy.waitForCustomElement('cx-tree');
|
|
23
61
|
cy.waitForCustomElement('cx-tree-item');
|
|
24
62
|
cy.get('cx-details').should('exist');
|
|
25
63
|
cy.get('cx-tree').should('exist');
|
|
26
|
-
cy.get('cx-tree-item').should('have.length',
|
|
64
|
+
cy.get('cx-tree-item').should('have.length', data.values.length);
|
|
27
65
|
});
|
|
28
66
|
|
|
29
67
|
it('Should render the facet with selected items', () => {
|
|
30
68
|
const data = {
|
|
31
69
|
type: 'example',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
70
|
+
values: [
|
|
71
|
+
{
|
|
72
|
+
'displayValue': 'images',
|
|
73
|
+
'value': 'images',
|
|
74
|
+
'count': 50,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
'displayValue': 'others',
|
|
78
|
+
'value': 'others',
|
|
79
|
+
'count': 9,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
'displayValue': 'videos',
|
|
83
|
+
'value': 'videos',
|
|
84
|
+
'count': 5,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
'displayValue': '3d assets',
|
|
88
|
+
'value': '3d assets',
|
|
89
|
+
'count': 4,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
'displayValue': 'audio',
|
|
93
|
+
'value': 'audio',
|
|
94
|
+
'count': 3,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
'displayValue': 'image',
|
|
98
|
+
'value': 'image',
|
|
99
|
+
'count': 1,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
'displayValue': 'images>>image 1s',
|
|
103
|
+
'value': 'images>>image 1s',
|
|
104
|
+
'count': 1,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
'displayValue': 'images>>image 2s',
|
|
108
|
+
'value': 'images>>image 2s',
|
|
109
|
+
'count': 1,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
36
112
|
displayName: 'Example Facet',
|
|
37
113
|
};
|
|
38
|
-
cy.mount(<Facet
|
|
114
|
+
cy.mount(<Facet values={data.values} type={data.type} collections={['item1']} displayName={data.displayName}/>);
|
|
39
115
|
cy.waitForCustomElement('cx-details');
|
|
40
116
|
cy.waitForCustomElement('cx-tree');
|
|
41
117
|
cy.waitForCustomElement('cx-tree-item');
|
|
42
118
|
cy.get('cx-details').should('exist');
|
|
43
119
|
cy.get('cx-tree').should('exist');
|
|
44
|
-
cy.get('cx-tree-item').should('have.length',
|
|
120
|
+
cy.get('cx-tree-item').should('have.length', data.values.length);
|
|
45
121
|
});
|
|
46
122
|
|
|
47
123
|
it('should render the facet with loading state', () => {
|
|
48
124
|
const data = {
|
|
49
125
|
type: 'example',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
126
|
+
values: [
|
|
127
|
+
{
|
|
128
|
+
'displayValue': 'images',
|
|
129
|
+
'value': 'images',
|
|
130
|
+
'count': 50,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
'displayValue': 'others',
|
|
134
|
+
'value': 'others',
|
|
135
|
+
'count': 9,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
'displayValue': 'videos',
|
|
139
|
+
'value': 'videos',
|
|
140
|
+
'count': 5,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
'displayValue': '3d assets',
|
|
144
|
+
'value': '3d assets',
|
|
145
|
+
'count': 4,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
'displayValue': 'audio',
|
|
149
|
+
'value': 'audio',
|
|
150
|
+
'count': 3,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
'displayValue': 'image',
|
|
154
|
+
'value': 'image',
|
|
155
|
+
'count': 1,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
'displayValue': 'images>>image 1s',
|
|
159
|
+
'value': 'images>>image 1s',
|
|
160
|
+
'count': 1,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
'displayValue': 'images>>image 2s',
|
|
164
|
+
'value': 'images>>image 2s',
|
|
165
|
+
'count': 1,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
54
168
|
displayName: 'Example Facet',
|
|
55
169
|
};
|
|
56
|
-
cy.mount(<Facet
|
|
170
|
+
cy.mount(<Facet values={data.values} type={data.type} collections={[]} loading={true} displayName={data.displayName}/>);
|
|
57
171
|
cy.waitForCustomElement('cx-details');
|
|
58
172
|
cy.waitForCustomElement('cx-spinner');
|
|
59
173
|
cy.get('cx-spinner').should('exist');
|
|
@@ -62,14 +176,51 @@ describe('Facet', () => {
|
|
|
62
176
|
it('should render the facet with subtype', () => {
|
|
63
177
|
const data = {
|
|
64
178
|
type: 'example',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
179
|
+
values: [
|
|
180
|
+
{
|
|
181
|
+
'displayValue': 'images',
|
|
182
|
+
'value': 'images',
|
|
183
|
+
'count': 50,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
'displayValue': 'others',
|
|
187
|
+
'value': 'others',
|
|
188
|
+
'count': 9,
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
'displayValue': 'videos',
|
|
192
|
+
'value': 'videos',
|
|
193
|
+
'count': 5,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
'displayValue': '3d assets',
|
|
197
|
+
'value': '3d assets',
|
|
198
|
+
'count': 4,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
'displayValue': 'audio',
|
|
202
|
+
'value': 'audio',
|
|
203
|
+
'count': 3,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
'displayValue': 'image',
|
|
207
|
+
'value': 'image',
|
|
208
|
+
'count': 1,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
'displayValue': 'images>>image 1s',
|
|
212
|
+
'value': 'images>>image 1s',
|
|
213
|
+
'count': 1,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
'displayValue': 'images>>image 2s',
|
|
217
|
+
'value': 'images>>image 2s',
|
|
218
|
+
'count': 1,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
70
221
|
displayName: 'Example Facet',
|
|
71
222
|
};
|
|
72
|
-
cy.mount(<Facet
|
|
223
|
+
cy.mount(<Facet values={data.values} type={data.type} collections={[]} loading={false} displayName={data.displayName}/>);
|
|
73
224
|
cy.waitForCustomElement('cx-details');
|
|
74
225
|
cy.waitForCustomElement('cx-tree');
|
|
75
226
|
cy.waitForCustomElement('cx-tree-item');
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import LoadMoreButton from '@/components/Browser/LoadMoreButton';
|
|
2
|
-
import _capitalize from 'lodash-es/capitalize';
|
|
3
2
|
import { FC, useMemo, useState } from 'react';
|
|
4
3
|
|
|
5
4
|
const ITEMS_PER_PAGE = 20;
|
|
6
5
|
|
|
7
6
|
type Props = {
|
|
8
|
-
|
|
7
|
+
values: {
|
|
8
|
+
count: number;
|
|
9
|
+
displayValue: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}[];
|
|
9
12
|
type: string;
|
|
10
13
|
displayName: string;
|
|
11
14
|
collections: string[];
|
|
12
|
-
capitalize?: boolean;
|
|
13
15
|
loading?: boolean;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
const Facet: FC<Props> = ({
|
|
17
|
-
|
|
19
|
+
values,
|
|
18
20
|
type,
|
|
19
21
|
displayName,
|
|
20
22
|
collections,
|
|
21
|
-
capitalize = true,
|
|
22
23
|
loading = false,
|
|
23
24
|
}) => {
|
|
24
25
|
const [page, setPage] = useState(1);
|
|
@@ -32,7 +33,7 @@ const Facet: FC<Props> = ({
|
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
const mappedSubtypes = useMemo(() => {
|
|
35
|
-
return
|
|
36
|
+
return values.reduce((acc, { value: key, count: value }) => {
|
|
36
37
|
const [parent, subtype] = key.split('>>');
|
|
37
38
|
|
|
38
39
|
if (!acc[parent] || typeof acc[parent] !== 'object') {
|
|
@@ -51,14 +52,22 @@ const Facet: FC<Props> = ({
|
|
|
51
52
|
|
|
52
53
|
return acc;
|
|
53
54
|
}, {} as Record<string, Record<string, number> | number>);
|
|
54
|
-
}, [
|
|
55
|
+
}, [values]);
|
|
56
|
+
|
|
57
|
+
const mappedDisplayNames = useMemo(() => {
|
|
58
|
+
return values.reduce((acc, { value: key, displayValue: value }) => {
|
|
59
|
+
acc[key] = value;
|
|
60
|
+
|
|
61
|
+
return acc;
|
|
62
|
+
}, {} as Record<string, string>);
|
|
63
|
+
}, [values]);
|
|
55
64
|
|
|
56
65
|
const hasNextPage = useMemo(
|
|
57
66
|
() => Object.keys(mappedSubtypes).length > page * ITEMS_PER_PAGE,
|
|
58
67
|
[mappedSubtypes, page],
|
|
59
68
|
);
|
|
60
69
|
|
|
61
|
-
if (
|
|
70
|
+
if (values.length === 0) {
|
|
62
71
|
return null;
|
|
63
72
|
}
|
|
64
73
|
|
|
@@ -74,7 +83,7 @@ const Facet: FC<Props> = ({
|
|
|
74
83
|
{loading && <cx-spinner></cx-spinner>}
|
|
75
84
|
</cx-space>
|
|
76
85
|
<cx-space direction="vertical">
|
|
77
|
-
<cx-tree selection="multiple" data-facet={type}>
|
|
86
|
+
<cx-tree selection="multiple" label-selects-single data-facet={type}>
|
|
78
87
|
{Object.entries(mappedSubtypes)
|
|
79
88
|
.slice(0, page * ITEMS_PER_PAGE)
|
|
80
89
|
.map(([key, value]) => {
|
|
@@ -83,6 +92,11 @@ const Facet: FC<Props> = ({
|
|
|
83
92
|
|
|
84
93
|
const { all, ...rest } = value;
|
|
85
94
|
|
|
95
|
+
const totalCount = Object.values(rest).reduce(
|
|
96
|
+
(sum, count) => sum + count,
|
|
97
|
+
0,
|
|
98
|
+
);
|
|
99
|
+
|
|
86
100
|
return (
|
|
87
101
|
<cx-tree-item
|
|
88
102
|
key={key}
|
|
@@ -90,9 +104,9 @@ const Facet: FC<Props> = ({
|
|
|
90
104
|
data-type={type}
|
|
91
105
|
readonly={loading}
|
|
92
106
|
selected={selected}
|
|
93
|
-
disabled-sync-checkboxes
|
|
107
|
+
disabled-sync-checkboxes={totalCount !== all ? true : undefined}
|
|
94
108
|
>
|
|
95
|
-
{
|
|
109
|
+
{mappedDisplayNames[key]} {!!all && `(${all})`}
|
|
96
110
|
{Object.entries(rest).map(([subtype, count]) => (
|
|
97
111
|
<cx-tree-item
|
|
98
112
|
key={subtype}
|
|
@@ -101,7 +115,7 @@ const Facet: FC<Props> = ({
|
|
|
101
115
|
readonly={loading}
|
|
102
116
|
selected={collections.includes(`${key}>>${subtype}`)}
|
|
103
117
|
>
|
|
104
|
-
{
|
|
118
|
+
{mappedDisplayNames[`${key}>>${subtype}`]} ({count})
|
|
105
119
|
</cx-tree-item>
|
|
106
120
|
))}
|
|
107
121
|
</cx-tree-item>
|
|
@@ -115,7 +129,7 @@ const Facet: FC<Props> = ({
|
|
|
115
129
|
readonly={loading}
|
|
116
130
|
selected={collections.includes(key)}
|
|
117
131
|
>
|
|
118
|
-
{
|
|
132
|
+
{mappedDisplayNames[key]} ({value})
|
|
119
133
|
</cx-tree-item>
|
|
120
134
|
);
|
|
121
135
|
})}
|
package/src/consts/data.ts
CHANGED
|
@@ -12,6 +12,8 @@ export const FIELD_SCRUB_URL = 'ScrubURL';
|
|
|
12
12
|
export const FIELD_SUBTYPE = 'CoreField.DocSubType';
|
|
13
13
|
export const FIELD_TITLE_WITH_FALLBACK = 'CoreField.TitleWithFallback';
|
|
14
14
|
export const FIELD_HAS_BROWSER_CHILDREN = 'Document.HasBrowserChildren';
|
|
15
|
+
export const FIELD_ORIGINAL_FILE_NAME = 'CoreField.OriginalFileName';
|
|
16
|
+
export const FIELD_UPDATED_FILE_NAME = 'CoreField.UpdatedFileName';
|
|
15
17
|
export const LIBRARY_NAME = 'Library';
|
|
16
18
|
export const MESSAGE_NEW_LINE = '\n';
|
|
17
19
|
export const ORIGINAL_VIEW_SIZE = 'CoreField.OriginalPreview';
|