-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 publish flow in site editor #61136
Changes from 6 commits
6cc674b
283d870
b8eddf0
250eadd
afecc9c
5128cda
4347b5d
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ import { __unstableMotion as motion } from '@wordpress/components'; | |
import { store as preferencesStore } from '@wordpress/preferences'; | ||
import { | ||
DocumentBar, | ||
PostSavedState, | ||
store as editorStore, | ||
privateApis as editorPrivateApis, | ||
} from '@wordpress/editor'; | ||
|
@@ -31,23 +32,26 @@ import { | |
} from '../editor-canvas-container'; | ||
import { unlock } from '../../lock-unlock'; | ||
import { FOCUSABLE_ENTITIES } from '../../utils/constants'; | ||
import { isPreviewingTheme } from '../../utils/is-previewing-theme'; | ||
|
||
const { | ||
CollapsableBlockToolbar, | ||
MoreMenu, | ||
PostViewLink, | ||
PreviewDropdown, | ||
PinnedItems, | ||
PostPublishButtonOrToggle, | ||
} = unlock( editorPrivateApis ); | ||
|
||
export default function HeaderEditMode() { | ||
export default function HeaderEditMode( { setEntitiesSavedStatesCallback } ) { | ||
const { | ||
templateType, | ||
isDistractionFree, | ||
blockEditorMode, | ||
showIconLabels, | ||
editorCanvasView, | ||
isFixedToolbar, | ||
isPublishSidebarOpened, | ||
} = useSelect( ( select ) => { | ||
const { getEditedPostType } = select( editSiteStore ); | ||
const { __unstableGetEditorMode } = select( blockEditorStore ); | ||
|
@@ -64,6 +68,8 @@ export default function HeaderEditMode() { | |
).getEditorCanvasContainerView(), | ||
isDistractionFree: getPreference( 'core', 'distractionFree' ), | ||
isFixedToolbar: getPreference( 'core', 'fixedToolbar' ), | ||
isPublishSidebarOpened: | ||
select( editorStore ).isPublishSidebarOpened(), | ||
}; | ||
}, [] ); | ||
|
||
|
@@ -94,6 +100,7 @@ export default function HeaderEditMode() { | |
ease: 'easeOut', | ||
}; | ||
|
||
const _isPreviewingTheme = isPreviewingTheme(); | ||
return ( | ||
<div | ||
className={ classnames( 'edit-site-header-edit-mode', { | ||
|
@@ -158,7 +165,28 @@ export default function HeaderEditMode() { | |
</div> | ||
) } | ||
<PostViewLink /> | ||
<SaveButton size="compact" /> | ||
{ | ||
// TODO: For now we conditionally render the Save/Publish buttons based on | ||
// some specific site editor extra handling. Examples are when we're previewing | ||
// a theme, handling of global styles changes or when we're in 'view' mode, | ||
// which opens the save panel in a Modal. | ||
} | ||
{ ! _isPreviewingTheme && ! isPublishSidebarOpened && ( | ||
// This button isn't completely hidden by the publish sidebar. | ||
// We can't hide the whole toolbar when the publish sidebar is open because | ||
// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node. | ||
// We track that DOM node to return focus to the PostPublishButtonOrToggle | ||
// when the publish sidebar has been closed. | ||
<PostSavedState /> | ||
) } | ||
{ ! _isPreviewingTheme && ( | ||
<PostPublishButtonOrToggle | ||
setEntitiesSavedStatesCallback={ | ||
setEntitiesSavedStatesCallback | ||
} | ||
/> | ||
) } | ||
{ _isPreviewingTheme && <SaveButton size="compact" /> } | ||
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. Would love a review from @scruffian or @draganescu to test the theme activation flows 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. For me it tested all right! Edit: I did find the activate button disappears when browsing a previewing theme. Testing more. 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 found the regression above on trunk as well so not this PR. |
||
{ ! isDistractionFree && <PinnedItems.Slot scope="core" /> } | ||
<MoreMenu /> | ||
<SiteEditorMoreMenuItems /> | ||
|
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 think the
edit-site
package has selectors/actions for this. See #45200. We should probably put this into theeditor
store and reuse it in both editors.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.
Do you think we can do it in a follow up to minimize the risk of introducing any regressions? I'd love to minimize the changes per PR, as there are more needed for every step that gets us closer. 😄