Skip to content

Commit 4a5e52b

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

File tree

4 files changed

+73
-42
lines changed
  • modules/apps

4 files changed

+73
-42
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-has-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: 54 additions & 32 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,31 @@ 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'] &&
123+
item['_isItemValid'] === false &&
124+
item['_warningTooltipText'] && (
125+
<ClayList.ItemField>
126+
<ClayTooltipProvider>
127+
<span title={item['_warningTooltipText']}>
128+
<ClaySticker displayType="warning">
129+
<ClayIcon symbol="exclamation-circle" />
130+
</ClaySticker>
131+
</span>
132+
</ClayTooltipProvider>
133+
</ClayList.ItemField>
134+
)}
135+
136+
{item['_isItemValid'] && item['_isItemValid'] === true && (
137+
<ClayList.ItemField>
138+
<ClayTooltipProvider>
139+
<ClaySticker displayType="unstyled">
140+
<ClayIcon symbol="catalog" />
141+
</ClaySticker>
142+
</ClayTooltipProvider>
143+
</ClayList.ItemField>
144+
)}
123145

124146
{image && item[image] ? (
125147
<ClayList.ItemField>
@@ -133,25 +155,22 @@ const ListItem = forwardRef<HTMLLIElement, any>(
133155
item[symbol] && (
134156
<ClayList.ItemField>
135157
<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-
)}
158+
<span
159+
className="ml-1 text-secondary"
160+
data-tooltip-align="top"
161+
title={Liferay.Language.get(
162+
'no-visualization-modes-has-been-defined'
163+
)}
164+
>
165+
<ClaySticker
166+
{...(sticker && item[sticker])}
142167
>
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-
168+
{item[symbol] && (
169+
<ClayIcon symbol={item[symbol]} />
170+
)}
171+
</ClaySticker>
172+
</span>
173+
</ClayTooltipProvider>
155174
</ClayList.ItemField>
156175
)
157176
)}
@@ -178,28 +197,30 @@ const ListItem = forwardRef<HTMLLIElement, any>(
178197
)}
179198
</ClayList.ItemField>
180199

181-
<ClayList.ItemField>
182-
{(itemsActions || item.actionDropdownItems) && (
200+
{(itemsActions || item.actionDropdownItems) && (
201+
<ClayList.ItemField>
183202
<Actions
184203
actions={itemsActions || item.actionDropdownItems}
185204
itemData={item}
186205
itemId={itemId}
187206
items={items}
188207
onItemSelectionChange={onItemSelectionChange}
189208
/>
190-
)}
191-
</ClayList.ItemField>
209+
</ClayList.ItemField>
210+
)}
192211
</ClayList.Item>
193212
);
194213
}
195214
);
196215

197216
const ListItemOptionalDropTarget = ({
217+
clayListItemProps,
198218
item,
199219
items,
200220
onItemSelectionChange,
201221
schema,
202222
}: {
223+
clayListItemProps?: object;
203224
item: any;
204225
items: any[];
205226
onItemSelectionChange: Function;
@@ -213,10 +234,11 @@ const ListItemOptionalDropTarget = ({
213234

214235
const props = {
215236
className,
237+
clayListItemProps,
216238
item,
217239
items,
218240
onItemSelectionChange,
219-
ref:dropRef,
241+
ref: dropRef,
220242
schema,
221243
};
222244

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)