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

Replace the MainDashboardButton slot with a setting in the site editor #45149

Merged
merged 1 commit into from
Oct 28, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions packages/edit-site/src/components/main-dashboard-button/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
* Internal dependencies
*/
import { useLink } from '../../routes/link';
import MainDashboardButton from '../../main-dashboard-button';
youknowriad marked this conversation as resolved.
Show resolved Hide resolved
import { store as editSiteStore } from '../../../store';

const SITE_EDITOR_KEY = 'site-editor';
Expand All @@ -40,23 +39,32 @@ function NavLink( { params, replace, ...props } ) {
}

const NavigationPanel = ( { activeItem } ) => {
const { homeTemplate, isNavigationOpen, isTemplatePartsMode, siteTitle } =
useSelect( ( select ) => {
const { getEntityRecord } = select( coreDataStore );
const { getSettings, isNavigationOpened } = select( editSiteStore );
const {
homeTemplate,
isNavigationOpen,
isTemplatePartsMode,
siteTitle,
dashboardLink,
} = useSelect( ( select ) => {
const { getEntityRecord } = select( coreDataStore );
const { getSettings, isNavigationOpened } = select( editSiteStore );

const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
const { supportsTemplatePartsMode, __unstableHomeTemplate } =
getSettings();
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};
const {
supportsTemplatePartsMode,
__unstableHomeTemplate,
__experimentalDashboardLink,
} = getSettings();

return {
siteTitle: siteData.name,
homeTemplate: __unstableHomeTemplate,
isNavigationOpen: isNavigationOpened(),
isTemplatePartsMode: !! supportsTemplatePartsMode,
};
}, [] );
return {
siteTitle: siteData.name,
homeTemplate: __unstableHomeTemplate,
dashboardLink: __experimentalDashboardLink,
isNavigationOpen: isNavigationOpened(),
isTemplatePartsMode: !! supportsTemplatePartsMode,
};
}, [] );
const { setIsNavigationPanelOpened } = useDispatch( editSiteStore );

const closeOnEscape = ( event ) => {
Expand All @@ -82,13 +90,11 @@ const NavigationPanel = ( { activeItem } ) => {
</div>
<div className="edit-site-navigation-panel__scroll-container">
<Navigation activeItem={ activeItem }>
<MainDashboardButton.Slot>
<NavigationBackButton
backButtonLabel={ __( 'Dashboard' ) }
className="edit-site-navigation-panel__back-to-dashboard"
href="index.php"
/>
</MainDashboardButton.Slot>
<NavigationBackButton
backButtonLabel={ __( 'Dashboard' ) }
className="edit-site-navigation-panel__back-to-dashboard"
href={ dashboardLink ?? 'index.php' }
/>

<NavigationMenu>
<NavigationGroup title={ __( 'Editor' ) }>
Expand Down
5 changes: 3 additions & 2 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export function reinitializeEditor( target, settings ) {
message={ __(
'The editor is unable to find a block template for the homepage.'
) }
dashboardLink="index.php"
dashboardLink={
settings.__experimentalDashboardLink ?? 'index.php'
}
/>,
target
);
Expand Down Expand Up @@ -165,7 +167,6 @@ export function initializeEditor( id, settings ) {
reinitializeEditor( target, settings );
}

export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';
export { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';
export { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';
Expand Down