-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add template actions in site editor navigation sidebar #51054
Changes from 3 commits
23392f4
2c78a51
9fed86f
f6e284e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,17 @@ import { store as noticesStore } from '@wordpress/notices'; | |
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../../store'; | ||
import isTemplateRemovable from '../../../utils/is-template-removable'; | ||
import isTemplateRevertable from '../../../utils/is-template-revertable'; | ||
import { store as editSiteStore } from '../../store'; | ||
import isTemplateRemovable from '../../utils/is-template-removable'; | ||
import isTemplateRevertable from '../../utils/is-template-revertable'; | ||
import RenameMenuItem from './rename-menu-item'; | ||
|
||
export default function Actions( { template } ) { | ||
export default function TemplateActions( { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is great that you were able to reuse this. Personally I always prefer reusable components that receive "ids" instead of objects like this as it's more reusable and also more performant in general (can add extra selectors but this won't force the parent to re-render if it's only this component that cares about the object) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated to fetch the data in this component. Also used |
||
template, | ||
className, | ||
toggleProps, | ||
onRemove, | ||
} ) { | ||
const { removeTemplate, revertTemplate } = useDispatch( editSiteStore ); | ||
const { saveEditedEntityRecord } = useDispatch( coreStore ); | ||
const { createSuccessNotice, createErrorNotice } = | ||
|
@@ -41,7 +46,7 @@ export default function Actions( { template } ) { | |
sprintf( | ||
/* translators: The template/part's name. */ | ||
__( '"%s" reverted.' ), | ||
template.title.rendered | ||
template.title.rendered || template.title | ||
), | ||
{ | ||
type: 'snackbar', | ||
|
@@ -62,7 +67,8 @@ export default function Actions( { template } ) { | |
<DropdownMenu | ||
icon={ moreVertical } | ||
label={ __( 'Actions' ) } | ||
className="edit-site-list-table__actions" | ||
className={ className } | ||
toggleProps={ toggleProps } | ||
> | ||
{ ( { onClose } ) => ( | ||
<MenuGroup> | ||
|
@@ -77,6 +83,7 @@ export default function Actions( { template } ) { | |
isTertiary | ||
onClick={ () => { | ||
removeTemplate( template ); | ||
onRemove?.(); | ||
onClose(); | ||
} } | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ export const removeTemplate = | |
sprintf( | ||
/* translators: The template/part's name. */ | ||
__( '"%s" deleted.' ), | ||
template.title.rendered | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not related to this PR, but I believe we'll land it soon and it's a small change. |
||
template.title?.rendered || template.title | ||
), | ||
{ type: 'snackbar', id: 'site-editor-template-deleted-success' } | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there was a recent PR that did that but was reverted due to some side effects. We might want to check whether this change doesn't introduce these side effects back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know about the other PR and I think the issues there were due to some
scale
changes. This doesn't seem to affect anything for now.