Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Editor: Update hrefs to not specifically refer to themes.php?page=gutenberg-edit-site #36705

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export default function NewTemplatePart( { postType } ) {
} );

// Navigate to the created template part editor.
window.location.search = addQueryArgs( '', {
page: 'gutenberg-edit-site',
window.location.href = addQueryArgs( window.location.href, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be easier if we use window.location.pathname?

Suggested change
window.location.href = addQueryArgs( window.location.href, {
window.location.href = addQueryArgs( window.location.pathname, {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most links in WP Admin use absolute, not relative, URLs, so I say let's do that. (Also I don't want to wait for CI again 😂.)

postId: templatePart.id,
postType: 'wp_template_part',
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export default function NewTemplate( { postType } ) {
} );

// Navigate to the created template editor.
window.location.search = addQueryArgs( '', {
page: 'gutenberg-edit-site',
window.location.href = addQueryArgs( window.location.href, {
postId: template.id,
postType: 'wp_template',
} );
Expand Down
3 changes: 1 addition & 2 deletions packages/edit-site/src/components/list/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ export default function Table( { templateType } ) {
<HStack className="edit-site-list-table-row">
<FlexItem className="edit-site-list-table-column">
<a
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
href={ addQueryArgs( window.location.href, {
postId: template.id,
postType: template.type,
} ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,24 @@ const NavigationPanel = ( { isOpen, setIsOpen, activeTemplateType } ) => {
<NavigationGroup title={ __( 'Editor' ) }>
<NavigationItem
title={ __( 'Site' ) }
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
href={ addQueryArgs( window.location.href, {
postId: undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to reset postId and postType has probably the same amount of efforts as having to pass page=gutenberg-edit-site 😅 . In the future, we can hopefully abstract this away in #36488 so I don't think it matters either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah a router would be nice 😀

postType: undefined,
} ) }
/>
<NavigationItem
title={ __( 'Templates' ) }
item="wp_template"
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
href={ addQueryArgs( window.location.href, {
postId: undefined,
postType: 'wp_template',
} ) }
/>
<NavigationItem
title={ __( 'Template Parts' ) }
item="wp_template_part"
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
href={ addQueryArgs( window.location.href, {
postId: undefined,
postType: 'wp_template_part',
} ) }
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/template-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export default function TemplateDetails( { template, onClose } ) {

<Button
className="edit-site-template-details__show-all-button"
href={ addQueryArgs( '', {
page: 'gutenberg-edit-site',
href={ addQueryArgs( window.location.href, {
// TODO: We should update this to filter by template part's areas as well.
postId: undefined,
postType: template.type,
} ) }
>
Expand Down