Skip to content

Commit db2d144

Browse files
LPD-24670 Mark invalid items without mutating the original ones
1 parent 1c6bd75 commit db2d144

File tree

4 files changed

+88
-55
lines changed
  • modules/apps

4 files changed

+88
-55
lines changed

modules/apps/frontend-data-set/frontend-data-set-admin-web/src/main/resources/META-INF/resources/item/selector/FDSAdminItemSelector.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,26 @@ const views = [
3434
!item.dataSetToDataSetTableSections.length &&
3535
!item.dataSetToDataSetListSections.length
3636
) {
37-
3837
return {
39-
...props, // we need to avoid item mutation
38+
...props,
4039
item: {
4140
...item,
42-
symbol: 'warning',
43-
tooltip: 'perico'
44-
}
45-
}
46-
41+
_isItemValid: false,
42+
_warningTooltipText: Liferay.Language.get(
43+
'no-visualization-modes-have-been-defined'
44+
),
45+
},
46+
};
47+
}
48+
else {
49+
return {
50+
...props,
51+
item: {
52+
...item,
53+
_isItemValid: true,
54+
},
55+
};
4756
}
48-
49-
return props;
5057
},
5158
},
5259
];

modules/apps/frontend-data-set/frontend-data-set-web/src/main/resources/META-INF/resources/utils/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,12 @@ export interface IListTitleRenderer {
244244
export interface IListSchema {
245245
description: string;
246246
image?: string;
247+
isItemValid?: string;
247248
sticker?: string;
248249
symbol: string;
249250
title: string;
250251
titleRenderer: IListTitleRenderer;
252+
tooltipText?: string;
251253
}
252254

253255
export type ISchema = ITableSchema | ICardSchema | IListSchema;

modules/apps/frontend-data-set/frontend-data-set-web/src/main/resources/META-INF/resources/views/list/List.tsx

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ClayIcon from '@clayui/icon';
88
import ClayLayout from '@clayui/layout';
99
import ClayList from '@clayui/list';
1010
import ClaySticker from '@clayui/sticker';
11+
import {ClayTooltipProvider} from '@clayui/tooltip';
1112
import classNames from 'classnames';
1213
import {getObjectValueFromPath} from 'frontend-js-web';
1314
import React, {forwardRef, useContext} from 'react';
@@ -25,7 +26,6 @@ import {
2526
IView,
2627
} from '../../utils/types';
2728
import ViewsContext from '../ViewsContext';
28-
import Tooltip, { ClayTooltipProvider } from '@clayui/tooltip';
2929

3030
const Title = ({
3131
item,
@@ -57,12 +57,14 @@ const ListItem = forwardRef<HTMLLIElement, any>(
5757
(
5858
{
5959
className,
60+
clayListItemProps,
6061
item,
6162
items,
6263
onItemSelectionChange,
6364
schema,
6465
}: {
6566
className: string;
67+
clayListItemProps: Object;
6668
item: any;
6769
items: any[];
6870
onItemSelectionChange: Function;
@@ -94,14 +96,12 @@ const ListItem = forwardRef<HTMLLIElement, any>(
9496
active: selectedItemsValue?.includes(itemId),
9597
}),
9698
flex: true,
99+
...clayListItemProps,
97100
};
98101

99102
return (
100-
<ClayList.Item
101-
{...props}
102-
ref={ref}
103-
>
104-
{!selectable ? (
103+
<ClayList.Item {...props} ref={ref}>
104+
{selectable && (
105105
<ClayList.ItemField className="justify-content-center selection-control">
106106
<SelectionInput
107107
checked={
@@ -117,9 +117,30 @@ const ListItem = forwardRef<HTMLLIElement, any>(
117117
value={itemId}
118118
/>
119119
</ClayList.ItemField>
120-
):
121-
<ClayList.ItemField className="justify-content-center selection-control"></ClayList.ItemField>
122-
}
120+
)}
121+
122+
{item['_isItemValid'] === false &&
123+
item['_warningTooltipText'] && (
124+
<ClayList.ItemField>
125+
<ClayTooltipProvider>
126+
<span title={item['_warningTooltipText']}>
127+
<ClaySticker displayType="warning">
128+
<ClayIcon symbol="exclamation-circle" />
129+
</ClaySticker>
130+
</span>
131+
</ClayTooltipProvider>
132+
</ClayList.ItemField>
133+
)}
134+
135+
{item['_isItemValid'] === true && (
136+
<ClayList.ItemField>
137+
<ClayTooltipProvider>
138+
<ClaySticker displayType="unstyled">
139+
<ClayIcon symbol="catalog" />
140+
</ClaySticker>
141+
</ClayTooltipProvider>
142+
</ClayList.ItemField>
143+
)}
123144

124145
{image && item[image] ? (
125146
<ClayList.ItemField>
@@ -133,25 +154,22 @@ const ListItem = forwardRef<HTMLLIElement, any>(
133154
item[symbol] && (
134155
<ClayList.ItemField>
135156
<ClayTooltipProvider>
136-
<span
137-
className="ml-1 text-secondary"
138-
data-tooltip-align="top"
139-
title={Liferay.Language.get(
140-
'no-visualization-modes-has-been-defined'
141-
)}
157+
<span
158+
className="ml-1 text-secondary"
159+
data-tooltip-align="top"
160+
title={Liferay.Language.get(
161+
'no-visualization-modes-has-been-defined'
162+
)}
163+
>
164+
<ClaySticker
165+
{...(sticker && item[sticker])}
142166
>
143-
<ClaySticker {...(sticker && item[sticker])}>
144-
{item[symbol] && (
145-
<ClayIcon symbol={item[symbol]} />
146-
)}
147-
148-
</ClaySticker>
149-
</span>
150-
151-
152-
</ClayTooltipProvider>
153-
154-
167+
{item[symbol] && (
168+
<ClayIcon symbol={item[symbol]} />
169+
)}
170+
</ClaySticker>
171+
</span>
172+
</ClayTooltipProvider>
155173
</ClayList.ItemField>
156174
)
157175
)}
@@ -178,54 +196,48 @@ const ListItem = forwardRef<HTMLLIElement, any>(
178196
)}
179197
</ClayList.ItemField>
180198

181-
<ClayList.ItemField>
182-
{(itemsActions || item.actionDropdownItems) && (
199+
{(itemsActions || item.actionDropdownItems) && (
200+
<ClayList.ItemField>
183201
<Actions
184202
actions={itemsActions || item.actionDropdownItems}
185203
itemData={item}
186204
itemId={itemId}
187205
items={items}
188206
onItemSelectionChange={onItemSelectionChange}
189207
/>
190-
)}
191-
</ClayList.ItemField>
208+
</ClayList.ItemField>
209+
)}
192210
</ClayList.Item>
193211
);
194212
}
195213
);
196214

197215
const ListItemOptionalDropTarget = ({
216+
clayListItemProps,
198217
item,
199218
items,
200219
onItemSelectionChange,
201220
schema,
202221
}: {
222+
clayListItemProps?: object;
203223
item: any;
204224
items: any[];
205225
onItemSelectionChange: Function;
206226
schema: IListSchema;
207227
}) => {
208228
const {className, dropRef} = useFDSDrop({item});
209229

210-
const [viewsContext] = useContext(ViewsContext);
211-
212-
const activeView: IView = viewsContext.activeView;
213-
214230
const props = {
215231
className,
232+
clayListItemProps,
216233
item,
217234
items,
218235
onItemSelectionChange,
219-
ref:dropRef,
236+
ref: dropRef,
220237
schema,
221238
};
222239

223-
return (
224-
<ListItem
225-
{...props}
226-
{...(activeView.setItemComponentProps?.({item, props}) ?? {})}
227-
/>
228-
);
240+
return <ListItem {...props} />;
229241
};
230242

231243
const List = ({
@@ -241,10 +253,20 @@ const List = ({
241253
}) => {
242254
const {selectedItemsKey} = useContext(FrontendDataSetContext);
243255

256+
const [viewsContext] = useContext(ViewsContext);
257+
244258
if (!items?.length) {
245259
return null;
246260
}
247261

262+
const activeView: IView = viewsContext.activeView;
263+
264+
const props = {
265+
items,
266+
onItemSelectionChange,
267+
schema,
268+
};
269+
248270
return (
249271
<ClayLayout.Sheet
250272
className={classNames('list-sheet', {
@@ -262,7 +284,6 @@ const List = ({
262284
{items.map((item: any, index: number) => (
263285
<ListItemOptionalDropTarget
264286
item={item}
265-
items={items}
266287
key={
267288
selectedItemsKey
268289
? getObjectValueFromPath({
@@ -271,8 +292,11 @@ const List = ({
271292
})
272293
: index
273294
}
274-
onItemSelectionChange={onItemSelectionChange}
275-
schema={schema}
295+
{...props}
296+
{...(activeView.setItemComponentProps?.({
297+
item,
298+
props,
299+
}) ?? {})}
276300
/>
277301
))}
278302
</ClayList>

modules/apps/portal-language/portal-language-lang/src/main/resources/content/Language.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12832,7 +12832,7 @@ no-variations=No Variations
1283212832
no-version-was-found=No version was found.
1283312833
no-video-preview-available=No video preview available.
1283412834
no-views-created=No Views Created
12835-
no-visualization-modes-has-been-defined=No visualization modes has been defined. The Data Set will not be displayed.
12835+
no-visualization-modes-have-been-defined=No visualization modes have been defined. The Data Set will not be displayed.
1283612836
no-vocabularies=No Vocabularies
1283712837
no-vocabularies-yet=No Vocabularies Yet
1283812838
no-warehouses-were-found=No warehouses were found.

0 commit comments

Comments
 (0)