Skip to content

Commit edd4650

Browse files
r0b1nIllia Obukhau
authored andcommitted
feat(html-element-web): make data source required
As suggested by PAG team, instead of using custom require-ness check on data source, make data source required, when data source is hidden in props, this effectively works as it is not required, no checks run on it.
1 parent e60e5ce commit edd4650

File tree

3 files changed

+34
-43
lines changed

3 files changed

+34
-43
lines changed

packages/pluggableWidgets/html-element-web/src/HTMLElement.editorConfig.ts

Lines changed: 32 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -141,47 +141,38 @@ export function check(values: HTMLElementPreviewProps): Problem[] {
141141
}
142142
}
143143

144-
if (values.tagUseRepeat && values.tagContentRepeatDataSource === null) {
145-
// make date source required if set to repeat
146-
errors.push({
147-
severity: "error",
148-
property: "tagContentRepeatDataSource",
149-
message: "Property 'Data source' is required."
150-
});
151-
} else {
152-
const existingAttributeNames = new Set();
153-
values.attributes.forEach((attr, i) => {
154-
if (existingAttributeNames.has(attr.attributeName)) {
155-
errors.push({
156-
severity: "error",
157-
property: `attributes/${i + 1}/attributeName`,
158-
message: `Attribute with name '${attr.attributeName}' already exists.`
159-
});
160-
}
161-
existingAttributeNames.add(attr.attributeName);
162-
163-
const attributePropName = attributeValuePropNameFor(values, attr.attributeValueType);
164-
if (!attr[attributePropName].length) {
165-
errors.push({
166-
severity: "warning",
167-
property: `attributes/${i + 1}/${attributePropName}`,
168-
message: `Value is not specified for attribute '${attr.attributeName}'.`
169-
});
170-
}
171-
});
172-
173-
const existingEventNames = new Set();
174-
values.events.forEach((attr, i) => {
175-
if (existingEventNames.has(attr.eventName)) {
176-
errors.push({
177-
severity: "error",
178-
property: `attributes/${i + 1}/eventName`,
179-
message: `Event with name '${attr.eventName}' already exists.`
180-
});
181-
}
182-
existingEventNames.add(attr.eventName);
183-
});
184-
}
144+
const existingAttributeNames = new Set();
145+
values.attributes.forEach((attr, i) => {
146+
if (existingAttributeNames.has(attr.attributeName)) {
147+
errors.push({
148+
severity: "error",
149+
property: `attributes/${i + 1}/attributeName`,
150+
message: `Attribute with name '${attr.attributeName}' already exists.`
151+
});
152+
}
153+
existingAttributeNames.add(attr.attributeName);
154+
155+
const attributePropName = attributeValuePropNameFor(values, attr.attributeValueType);
156+
if (!attr[attributePropName].length) {
157+
errors.push({
158+
severity: "warning",
159+
property: `attributes/${i + 1}/${attributePropName}`,
160+
message: `Value is not specified for attribute '${attr.attributeName}'.`
161+
});
162+
}
163+
});
164+
165+
const existingEventNames = new Set();
166+
values.events.forEach((attr, i) => {
167+
if (existingEventNames.has(attr.eventName)) {
168+
errors.push({
169+
severity: "error",
170+
property: `attributes/${i + 1}/eventName`,
171+
message: `Event with name '${attr.eventName}' already exists.`
172+
});
173+
}
174+
existingEventNames.add(attr.eventName);
175+
});
185176

186177
return errors;
187178
}

packages/pluggableWidgets/html-element-web/src/HTMLElement.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</property>
8383

8484
<!-- Data source for repeating content -->
85-
<property key="tagContentRepeatDataSource" type="datasource" required="false" isList="true">
85+
<property key="tagContentRepeatDataSource" type="datasource" required="true" isList="true">
8686
<caption>Data source</caption>
8787
<description />
8888
</property>

packages/pluggableWidgets/html-element-web/typings/HTMLElementProps.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface HTMLElementContainerProps {
5757
tagNameCustom: string;
5858
attributes: AttributesType[];
5959
tagUseRepeat: boolean;
60-
tagContentRepeatDataSource?: ListValue;
60+
tagContentRepeatDataSource: ListValue;
6161
tagContentMode: TagContentModeEnum;
6262
tagContentHTML?: DynamicValue<string>;
6363
tagContentContainer?: ReactNode;

0 commit comments

Comments
 (0)