Skip to content

Commit 0e73d48

Browse files
authored
[Content] Skip url path part validation for datasets (#2945)
Fixes an issue where users will not be able to create dataset items because of the missing url path part even if it is not needed for dataset items.
1 parent 7295c9d commit 0e73d48

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/apps/content-editor/src/app/views/ItemCreate/ItemCreate.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ export const ItemCreate = () => {
164164
setSaving(true);
165165

166166
try {
167-
const res: any = await dispatch(createItem(modelZUID, itemZUID));
167+
const res: any = await dispatch(
168+
createItem({
169+
modelZUID,
170+
itemZUID,
171+
skipPathPartValidation: model?.type === "dataset",
172+
})
173+
);
168174
if (res.err || res.error) {
169175
if (res.missingRequired || res.lackingCharLength) {
170176
const missingRequiredFieldNames: string[] =

src/apps/content-editor/src/app/views/ItemEdit/Meta/index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,18 @@ export const Meta = forwardRef(
138138
};
139139
});
140140

141+
// No need to validate pathPart for datasets
142+
if (model?.type === "dataset") {
143+
delete currentErrors.pathPart;
144+
}
145+
141146
setTimeout(() => {
142147
setErrors(currentErrors);
143148
});
144149
},
145150
};
146151
},
147-
[errors, web]
152+
[errors, web, model]
148153
);
149154

150155
useEffect(() => {

src/shell/store/content.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export function saveItem({
514514
};
515515
}
516516

517-
export function createItem(modelZUID, itemZUID) {
517+
export function createItem({ modelZUID, itemZUID, skipPathPartValidation }) {
518518
return (dispatch, getState) => {
519519
const state = getState();
520520

@@ -553,10 +553,11 @@ export function createItem(modelZUID, itemZUID) {
553553
return false;
554554
});
555555

556-
const hasMissingRequiredSEOFields =
557-
!item?.web?.metaTitle ||
558-
!item?.web?.metaDescription ||
559-
!item?.web?.pathPart;
556+
const hasMissingRequiredSEOFields = skipPathPartValidation
557+
? !item?.web?.metaTitle || !item?.web?.metaDescription
558+
: !item?.web?.metaTitle ||
559+
!item?.web?.metaDescription ||
560+
!item?.web?.pathPart;
560561

561562
// Check minlength is satisfied
562563
const lackingCharLength = fields?.filter(

0 commit comments

Comments
 (0)