Skip to content

Commit

Permalink
Change default value of automatic redirects checkbox based on page vi…
Browse files Browse the repository at this point in the history
…sibility (#2108)

Change the Behaviour of the Automatic Redirect to default to false if
the corresponding Page is unpublished or archived.

Co-authored-by: Markus Fichtner <markus.fichtner@vivid-planet.com>
  • Loading branch information
fichtnerma and Markus Fichtner committed May 27, 2024
1 parent 90f3480 commit fdf9fa7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-roses-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-admin": minor
---

Automatic Redirects are now set to false if the page is unpublished or archived
9 changes: 8 additions & 1 deletion packages/admin/cms-admin/src/pages/createEditPageNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function createEditPageNode({
hideInMenu
parentId
numberOfDescendants
visibility
document {
... on DocumentInterface {
id
Expand Down Expand Up @@ -190,6 +191,8 @@ export function createEditPageNode({
}
};

const isActivePage = data?.page?.visibility === "Published";

// Use `p-debounce` instead of `use-debounce`
// because Final Form expects all validate calls to be resolved.
// `p-debounce` resolves all calls, `use-debounce` doesn't
Expand Down Expand Up @@ -384,7 +387,11 @@ export function createEditPageNode({
</>
}
>
<Field name="createAutomaticRedirectsOnSlugChange" type="checkbox" initialValue={true}>
<Field
name="createAutomaticRedirectsOnSlugChange"
type="checkbox"
initialValue={isActivePage}
>
{(props) => (
<FormControlLabel
label={
Expand Down

0 comments on commit fdf9fa7

Please sign in to comment.