Fix content type validation in create page view (#1205)

* Fix content type validation in create page view

* Update changelog

* Change disabled to valid
This commit is contained in:
Dawid Tarasiuk 2021-07-12 10:34:13 +02:00 committed by GitHub
parent 51dba9f43b
commit ab54fc6d68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -64,6 +64,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Disable next step when no value selected in variant selector - #1218 by @orzechdev - Disable next step when no value selected in variant selector - #1218 by @orzechdev
- Fix order links on home page - #1219 by @jwm0 - Fix order links on home page - #1219 by @jwm0
- Fix huge payload issue for plugins view - #1203 by @kamilpastuszka - Fix huge payload issue for plugins view - #1203 by @kamilpastuszka
- Fix content type validation in create page view - #1205 by @orzechdev
# 2.11.1 # 2.11.1

View file

@ -132,7 +132,7 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
assignReferencesAttributeId={assignReferencesAttributeId} assignReferencesAttributeId={assignReferencesAttributeId}
onSubmit={onSubmit} onSubmit={onSubmit}
> >
{({ change, data, handlers, hasChanged, submit }) => ( {({ change, data, valid, handlers, hasChanged, submit }) => (
<Container> <Container>
<AppHeader onBack={onBack}> <AppHeader onBack={onBack}>
{intl.formatMessage(sectionNames.pages)} {intl.formatMessage(sectionNames.pages)}
@ -237,7 +237,7 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
</div> </div>
</Grid> </Grid>
<SaveButtonBar <SaveButtonBar
disabled={loading || !hasChanged} disabled={loading || !hasChanged || !valid}
state={saveButtonBarState} state={saveButtonBarState}
onCancel={onBack} onCancel={onBack}
onDelete={page === null ? undefined : onRemove} onDelete={page === null ? undefined : onRemove}

View file

@ -74,6 +74,7 @@ export interface PageUpdateHandlers {
export interface UsePageUpdateFormResult { export interface UsePageUpdateFormResult {
change: FormChange; change: FormChange;
data: PageData; data: PageData;
valid: boolean;
handlers: PageUpdateHandlers; handlers: PageUpdateHandlers;
hasChanged: boolean; hasChanged: boolean;
submit: () => void; submit: () => void;
@ -223,9 +224,12 @@ function usePageForm(
? handleFormSubmit(getSubmitData(), handleSubmit, setChanged) ? handleFormSubmit(getSubmitData(), handleSubmit, setChanged)
: onSubmit(getSubmitData()); : onSubmit(getSubmitData());
const valid = !!opts.selectedPageType;
return { return {
change: handleChange, change: handleChange,
data: getData(), data: getData(),
valid,
handlers: { handlers: {
changeContent, changeContent,
changeMetadata, changeMetadata,