Skip to content

Commit

Permalink
Replace the MainDashboardButton slot with a setting in the site editor (
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Oct 28, 2022
1 parent 669cbfc commit 05e92d0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 53 deletions.
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';
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

0 comments on commit 05e92d0

Please sign in to comment.