@wordpress/edit-site 6.19.0 → 6.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/build/components/add-new-template/utils.js +1 -1
  2. package/build/components/add-new-template/utils.js.map +1 -1
  3. package/build/components/app/index.js +19 -2
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/editor/use-editor-title.js +3 -2
  6. package/build/components/editor/use-editor-title.js.map +1 -1
  7. package/build/components/layout/index.js +23 -15
  8. package/build/components/layout/index.js.map +1 -1
  9. package/build/components/page-patterns/header.js +1 -1
  10. package/build/components/page-patterns/header.js.map +1 -1
  11. package/build/components/page-patterns/use-patterns.js +3 -2
  12. package/build/components/page-patterns/use-patterns.js.map +1 -1
  13. package/build/components/sidebar/index.js +17 -11
  14. package/build/components/sidebar/index.js.map +1 -1
  15. package/build/components/sidebar-navigation-screen-patterns/index.js +1 -0
  16. package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  17. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  18. package/build/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen-unsupported/index.js +24 -0
  20. package/build/components/sidebar-navigation-screen-unsupported/index.js.map +1 -0
  21. package/build/components/site-editor-routes/home.js +22 -5
  22. package/build/components/site-editor-routes/home.js.map +1 -1
  23. package/build/components/site-editor-routes/navigation-item.js +21 -5
  24. package/build/components/site-editor-routes/navigation-item.js.map +1 -1
  25. package/build/components/site-editor-routes/navigation.js +21 -5
  26. package/build/components/site-editor-routes/navigation.js.map +1 -1
  27. package/build/components/site-editor-routes/page-item.js +25 -9
  28. package/build/components/site-editor-routes/page-item.js.map +1 -1
  29. package/build/components/site-editor-routes/pages.js +32 -11
  30. package/build/components/site-editor-routes/pages.js.map +1 -1
  31. package/build/components/site-editor-routes/pattern-item.js +10 -3
  32. package/build/components/site-editor-routes/pattern-item.js.map +1 -1
  33. package/build/components/site-editor-routes/patterns.js +23 -24
  34. package/build/components/site-editor-routes/patterns.js.map +1 -1
  35. package/build/components/site-editor-routes/stylebook.js +25 -11
  36. package/build/components/site-editor-routes/stylebook.js.map +1 -1
  37. package/build/components/site-editor-routes/template-item.js +21 -5
  38. package/build/components/site-editor-routes/template-item.js.map +1 -1
  39. package/build/components/site-editor-routes/templates.js +27 -6
  40. package/build/components/site-editor-routes/templates.js.map +1 -1
  41. package/build/components/site-editor-routes/utils.js +20 -0
  42. package/build/components/site-editor-routes/utils.js.map +1 -0
  43. package/build/components/site-hub/index.js +37 -15
  44. package/build/components/site-hub/index.js.map +1 -1
  45. package/build-module/components/add-new-template/utils.js +1 -1
  46. package/build-module/components/add-new-template/utils.js.map +1 -1
  47. package/build-module/components/app/index.js +20 -3
  48. package/build-module/components/app/index.js.map +1 -1
  49. package/build-module/components/editor/use-editor-title.js +3 -2
  50. package/build-module/components/editor/use-editor-title.js.map +1 -1
  51. package/build-module/components/layout/index.js +23 -15
  52. package/build-module/components/layout/index.js.map +1 -1
  53. package/build-module/components/page-patterns/header.js +1 -1
  54. package/build-module/components/page-patterns/header.js.map +1 -1
  55. package/build-module/components/page-patterns/use-patterns.js +3 -2
  56. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  57. package/build-module/components/sidebar/index.js +15 -10
  58. package/build-module/components/sidebar/index.js.map +1 -1
  59. package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -0
  60. package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
  61. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  62. package/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js.map +1 -1
  63. package/build-module/components/sidebar-navigation-screen-unsupported/index.js +17 -0
  64. package/build-module/components/sidebar-navigation-screen-unsupported/index.js.map +1 -0
  65. package/build-module/components/site-editor-routes/home.js +22 -5
  66. package/build-module/components/site-editor-routes/home.js.map +1 -1
  67. package/build-module/components/site-editor-routes/navigation-item.js +21 -5
  68. package/build-module/components/site-editor-routes/navigation-item.js.map +1 -1
  69. package/build-module/components/site-editor-routes/navigation.js +21 -5
  70. package/build-module/components/site-editor-routes/navigation.js.map +1 -1
  71. package/build-module/components/site-editor-routes/page-item.js +25 -9
  72. package/build-module/components/site-editor-routes/page-item.js.map +1 -1
  73. package/build-module/components/site-editor-routes/pages.js +32 -11
  74. package/build-module/components/site-editor-routes/pages.js.map +1 -1
  75. package/build-module/components/site-editor-routes/pattern-item.js +10 -3
  76. package/build-module/components/site-editor-routes/pattern-item.js.map +1 -1
  77. package/build-module/components/site-editor-routes/patterns.js +23 -24
  78. package/build-module/components/site-editor-routes/patterns.js.map +1 -1
  79. package/build-module/components/site-editor-routes/stylebook.js +25 -11
  80. package/build-module/components/site-editor-routes/stylebook.js.map +1 -1
  81. package/build-module/components/site-editor-routes/template-item.js +21 -5
  82. package/build-module/components/site-editor-routes/template-item.js.map +1 -1
  83. package/build-module/components/site-editor-routes/templates.js +27 -6
  84. package/build-module/components/site-editor-routes/templates.js.map +1 -1
  85. package/build-module/components/site-editor-routes/utils.js +14 -0
  86. package/build-module/components/site-editor-routes/utils.js.map +1 -0
  87. package/build-module/components/site-hub/index.js +37 -15
  88. package/build-module/components/site-hub/index.js.map +1 -1
  89. package/build-style/posts-rtl.css +7 -10
  90. package/build-style/posts.css +7 -10
  91. package/build-style/style-rtl.css +7 -10
  92. package/build-style/style.css +7 -10
  93. package/package.json +42 -42
  94. package/src/components/add-new-template/utils.js +1 -2
  95. package/src/components/app/index.js +18 -3
  96. package/src/components/editor/use-editor-title.js +6 -6
  97. package/src/components/layout/index.js +34 -22
  98. package/src/components/layout/style.scss +2 -0
  99. package/src/components/page/style.scss +1 -5
  100. package/src/components/page-patterns/header.js +1 -1
  101. package/src/components/page-patterns/use-patterns.js +7 -7
  102. package/src/components/sidebar/index.js +15 -13
  103. package/src/components/sidebar-navigation-screen-patterns/index.js +1 -0
  104. package/src/components/sidebar-navigation-screen-patterns/use-template-part-areas.js +1 -1
  105. package/src/components/sidebar-navigation-screen-unsupported/index.js +17 -0
  106. package/src/components/site-editor-routes/home.js +27 -3
  107. package/src/components/site-editor-routes/navigation-item.js +25 -5
  108. package/src/components/site-editor-routes/navigation.js +21 -3
  109. package/src/components/site-editor-routes/page-item.js +29 -9
  110. package/src/components/site-editor-routes/pages.js +30 -10
  111. package/src/components/site-editor-routes/pattern-item.js +9 -1
  112. package/src/components/site-editor-routes/patterns.js +22 -21
  113. package/src/components/site-editor-routes/stylebook.js +25 -11
  114. package/src/components/site-editor-routes/template-item.js +25 -3
  115. package/src/components/site-editor-routes/templates.js +26 -4
  116. package/src/components/site-editor-routes/utils.js +14 -0
  117. package/src/components/site-hub/index.js +49 -16
  118. package/tsconfig.tsbuildinfo +1 -1
@@ -8,6 +8,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
8
8
  */
9
9
  import Editor from '../editor';
10
10
  import SidebarNavigationScreenNavigationMenu from '../sidebar-navigation-screen-navigation-menu';
11
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
11
12
  import { unlock } from '../../lock-unlock';
12
13
 
13
14
  const { useLocation } = unlock( routerPrivateApis );
@@ -27,10 +28,29 @@ export const navigationItemRoute = {
27
28
  name: 'navigation-item',
28
29
  path: '/wp_navigation/:postId',
29
30
  areas: {
30
- sidebar: (
31
- <SidebarNavigationScreenNavigationMenu backPath="/navigation" />
32
- ),
33
- preview: <Editor />,
34
- mobile: <MobileNavigationItemView />,
31
+ sidebar( { siteData } ) {
32
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
33
+ return isBlockTheme ? (
34
+ <SidebarNavigationScreenNavigationMenu backPath="/navigation" />
35
+ ) : (
36
+ <SidebarNavigationScreenUnsupported />
37
+ );
38
+ },
39
+ preview( { siteData } ) {
40
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
41
+ return isBlockTheme ? (
42
+ <Editor />
43
+ ) : (
44
+ <SidebarNavigationScreenUnsupported />
45
+ );
46
+ },
47
+ mobile( { siteData } ) {
48
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
49
+ return isBlockTheme ? (
50
+ <MobileNavigationItemView />
51
+ ) : (
52
+ <SidebarNavigationScreenUnsupported />
53
+ );
54
+ },
35
55
  },
36
56
  };
@@ -8,6 +8,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
8
8
  */
9
9
  import Editor from '../editor';
10
10
  import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
11
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
11
12
  import { unlock } from '../../lock-unlock';
12
13
 
13
14
  const { useLocation } = unlock( routerPrivateApis );
@@ -27,8 +28,25 @@ export const navigationRoute = {
27
28
  name: 'navigation',
28
29
  path: '/navigation',
29
30
  areas: {
30
- sidebar: <SidebarNavigationScreenNavigationMenus backPath="/" />,
31
- preview: <Editor />,
32
- mobile: <MobileNavigationView />,
31
+ sidebar( { siteData } ) {
32
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
33
+ return isBlockTheme ? (
34
+ <SidebarNavigationScreenNavigationMenus backPath="/" />
35
+ ) : (
36
+ <SidebarNavigationScreenUnsupported />
37
+ );
38
+ },
39
+ preview( { siteData } ) {
40
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
41
+ return isBlockTheme ? <Editor /> : undefined;
42
+ },
43
+ mobile( { siteData } ) {
44
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
45
+ return isBlockTheme ? (
46
+ <MobileNavigationView />
47
+ ) : (
48
+ <SidebarNavigationScreenUnsupported />
49
+ );
50
+ },
33
51
  },
34
52
  };
@@ -9,19 +9,39 @@ import { __ } from '@wordpress/i18n';
9
9
  import Editor from '../editor';
10
10
  import DataViewsSidebarContent from '../sidebar-dataviews';
11
11
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
12
13
 
13
14
  export const pageItemRoute = {
14
15
  name: 'page-item',
15
16
  path: '/page/:postId',
16
17
  areas: {
17
- sidebar: (
18
- <SidebarNavigationScreen
19
- title={ __( 'Pages' ) }
20
- backPath="/"
21
- content={ <DataViewsSidebarContent postType="page" /> }
22
- />
23
- ),
24
- mobile: <Editor />,
25
- preview: <Editor />,
18
+ sidebar( { siteData } ) {
19
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
20
+ return isBlockTheme ? (
21
+ <SidebarNavigationScreen
22
+ title={ __( 'Pages' ) }
23
+ backPath="/"
24
+ content={ <DataViewsSidebarContent postType="page" /> }
25
+ />
26
+ ) : (
27
+ <SidebarNavigationScreenUnsupported />
28
+ );
29
+ },
30
+ mobile( { siteData } ) {
31
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
32
+ return isBlockTheme ? (
33
+ <Editor />
34
+ ) : (
35
+ <SidebarNavigationScreenUnsupported />
36
+ );
37
+ },
38
+ preview( { siteData } ) {
39
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
40
+ return isBlockTheme ? (
41
+ <Editor />
42
+ ) : (
43
+ <SidebarNavigationScreenUnsupported />
44
+ );
45
+ },
26
46
  },
27
47
  };
@@ -9,6 +9,7 @@ import { __ } from '@wordpress/i18n';
9
9
  */
10
10
  import Editor from '../editor';
11
11
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
12
13
  import DataViewsSidebarContent from '../sidebar-dataviews';
13
14
  import PostList from '../post-list';
14
15
  import { unlock } from '../../lock-unlock';
@@ -27,21 +28,40 @@ export const pagesRoute = {
27
28
  name: 'pages',
28
29
  path: '/page',
29
30
  areas: {
30
- sidebar: (
31
- <SidebarNavigationScreen
32
- title={ __( 'Pages' ) }
33
- backPath="/"
34
- content={ <DataViewsSidebarContent postType="page" /> }
35
- />
36
- ),
37
- content: <PostList postType="page" />,
38
- preview( { query } ) {
31
+ sidebar( { siteData } ) {
32
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
33
+ return isBlockTheme ? (
34
+ <SidebarNavigationScreen
35
+ title={ __( 'Pages' ) }
36
+ backPath="/"
37
+ content={ <DataViewsSidebarContent postType="page" /> }
38
+ />
39
+ ) : (
40
+ <SidebarNavigationScreenUnsupported />
41
+ );
42
+ },
43
+ content( { siteData } ) {
44
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
45
+ return isBlockTheme ? <PostList postType="page" /> : undefined;
46
+ },
47
+ preview( { query, siteData } ) {
48
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
49
+ if ( ! isBlockTheme ) {
50
+ return undefined;
51
+ }
39
52
  const isListView =
40
53
  ( query.layout === 'list' || ! query.layout ) &&
41
54
  query.isCustom !== 'true';
42
55
  return isListView ? <Editor /> : undefined;
43
56
  },
44
- mobile: <MobilePagesView />,
57
+ mobile( { siteData } ) {
58
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
59
+ return isBlockTheme ? (
60
+ <MobilePagesView />
61
+ ) : (
62
+ <SidebarNavigationScreenUnsupported />
63
+ );
64
+ },
45
65
  edit( { query } ) {
46
66
  const hasQuickEdit =
47
67
  ( query.layout ?? 'list' ) !== 'list' && !! query.quickEdit;
@@ -3,12 +3,20 @@
3
3
  */
4
4
  import Editor from '../editor';
5
5
  import SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns';
6
+ import { isClassicThemeWithStyleBookSupport } from './utils';
6
7
 
7
8
  export const patternItemRoute = {
8
9
  name: 'pattern-item',
9
10
  path: '/wp_block/:postId',
10
11
  areas: {
11
- sidebar: <SidebarNavigationScreenPatterns backPath="/" />,
12
+ sidebar( { siteData } ) {
13
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
14
+ const backPath =
15
+ isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
16
+ ? '/'
17
+ : undefined;
18
+ return <SidebarNavigationScreenPatterns backPath={ backPath } />;
19
+ },
12
20
  mobile: <Editor />,
13
21
  preview: <Editor />,
14
22
  },
@@ -1,34 +1,35 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { privateApis as routerPrivateApis } from '@wordpress/router';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns';
10
5
  import PagePatterns from '../page-patterns';
11
- import { unlock } from '../../lock-unlock';
12
-
13
- const { useLocation } = unlock( routerPrivateApis );
14
-
15
- function MobilePatternsView() {
16
- const { query = {} } = useLocation();
17
- const { categoryId } = query;
18
-
19
- return !! categoryId ? (
20
- <PagePatterns />
21
- ) : (
22
- <SidebarNavigationScreenPatterns backPath="/" />
23
- );
24
- }
6
+ import { isClassicThemeWithStyleBookSupport } from './utils';
25
7
 
26
8
  export const patternsRoute = {
27
9
  name: 'patterns',
28
10
  path: '/pattern',
29
11
  areas: {
30
- sidebar: <SidebarNavigationScreenPatterns backPath="/" />,
12
+ sidebar( { siteData } ) {
13
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
14
+ const backPath =
15
+ isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
16
+ ? '/'
17
+ : undefined;
18
+ return <SidebarNavigationScreenPatterns backPath={ backPath } />;
19
+ },
31
20
  content: <PagePatterns />,
32
- mobile: <MobilePatternsView />,
21
+ mobile( { siteData, query } ) {
22
+ const { categoryId } = query;
23
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
24
+ const backPath =
25
+ isBlockTheme || isClassicThemeWithStyleBookSupport( siteData )
26
+ ? '/'
27
+ : undefined;
28
+ return !! categoryId ? (
29
+ <PagePatterns />
30
+ ) : (
31
+ <SidebarNavigationScreenPatterns backPath={ backPath } />
32
+ );
33
+ },
33
34
  },
34
35
  };
@@ -7,22 +7,36 @@ import { __ } from '@wordpress/i18n';
7
7
  * Internal dependencies
8
8
  */
9
9
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
10
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
10
11
  import { StyleBookPreview } from '../style-book';
12
+ import { isClassicThemeWithStyleBookSupport } from './utils';
11
13
 
12
14
  export const stylebookRoute = {
13
15
  name: 'stylebook',
14
16
  path: '/stylebook',
15
17
  areas: {
16
- sidebar: (
17
- <SidebarNavigationScreen
18
- title={ __( 'Styles' ) }
19
- backPath="/"
20
- description={ __(
21
- `Preview your website's visual identity: colors, typography, and blocks.`
22
- ) }
23
- />
24
- ),
25
- preview: <StyleBookPreview isStatic />,
26
- mobile: <StyleBookPreview isStatic />,
18
+ sidebar( { siteData } ) {
19
+ return isClassicThemeWithStyleBookSupport( siteData ) ? (
20
+ <SidebarNavigationScreen
21
+ title={ __( 'Styles' ) }
22
+ backPath="/"
23
+ description={ __(
24
+ `Preview your website's visual identity: colors, typography, and blocks.`
25
+ ) }
26
+ />
27
+ ) : (
28
+ <SidebarNavigationScreenUnsupported />
29
+ );
30
+ },
31
+ preview( { siteData } ) {
32
+ return isClassicThemeWithStyleBookSupport( siteData ) ? (
33
+ <StyleBookPreview isStatic />
34
+ ) : undefined;
35
+ },
36
+ mobile( { siteData } ) {
37
+ return isClassicThemeWithStyleBookSupport( siteData ) ? (
38
+ <StyleBookPreview isStatic />
39
+ ) : undefined;
40
+ },
27
41
  },
28
42
  };
@@ -3,13 +3,35 @@
3
3
  */
4
4
  import Editor from '../editor';
5
5
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
6
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
6
7
 
7
8
  export const templateItemRoute = {
8
9
  name: 'template-item',
9
10
  path: '/wp_template/*postId',
10
11
  areas: {
11
- sidebar: <SidebarNavigationScreenTemplatesBrowse backPath="/" />,
12
- mobile: <Editor />,
13
- preview: <Editor />,
12
+ sidebar( { siteData } ) {
13
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
14
+ return isBlockTheme ? (
15
+ <SidebarNavigationScreenTemplatesBrowse backPath="/" />
16
+ ) : (
17
+ <SidebarNavigationScreenUnsupported />
18
+ );
19
+ },
20
+ mobile( { siteData } ) {
21
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
22
+ return isBlockTheme ? (
23
+ <Editor />
24
+ ) : (
25
+ <SidebarNavigationScreenUnsupported />
26
+ );
27
+ },
28
+ preview( { siteData } ) {
29
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
30
+ return isBlockTheme ? (
31
+ <Editor />
32
+ ) : (
33
+ <SidebarNavigationScreenUnsupported />
34
+ );
35
+ },
14
36
  },
15
37
  };
@@ -3,19 +3,41 @@
3
3
  */
4
4
  import Editor from '../editor';
5
5
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
6
+ import SidebarNavigationScreenUnsupported from '../sidebar-navigation-screen-unsupported';
6
7
  import PageTemplates from '../page-templates';
7
8
 
8
9
  export const templatesRoute = {
9
10
  name: 'templates',
10
11
  path: '/template',
11
12
  areas: {
12
- sidebar: <SidebarNavigationScreenTemplatesBrowse backPath="/" />,
13
- content: <PageTemplates />,
14
- preview( { query } ) {
13
+ sidebar( { siteData } ) {
14
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
15
+ return isBlockTheme ? (
16
+ <SidebarNavigationScreenTemplatesBrowse backPath="/" />
17
+ ) : (
18
+ <SidebarNavigationScreenUnsupported />
19
+ );
20
+ },
21
+ content( { siteData } ) {
22
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
23
+ return isBlockTheme ? <PageTemplates /> : undefined;
24
+ },
25
+ preview( { query, siteData } ) {
26
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
27
+ if ( ! isBlockTheme ) {
28
+ return undefined;
29
+ }
15
30
  const isListView = query.layout === 'list';
16
31
  return isListView ? <Editor /> : undefined;
17
32
  },
18
- mobile: <PageTemplates />,
33
+ mobile( { siteData } ) {
34
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
35
+ return isBlockTheme ? (
36
+ <PageTemplates />
37
+ ) : (
38
+ <SidebarNavigationScreenUnsupported />
39
+ );
40
+ },
19
41
  },
20
42
  widths: {
21
43
  content( { query } ) {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Check if the classic theme supports the stylebook.
3
+ *
4
+ * @param {Object} siteData - The site data provided by the site editor route area resolvers.
5
+ * @return {boolean} True if the stylebook is supported, false otherwise.
6
+ */
7
+ export function isClassicThemeWithStyleBookSupport( siteData ) {
8
+ const isBlockTheme = siteData.currentTheme?.is_block_theme;
9
+ const supportsEditorStyles =
10
+ siteData.currentTheme?.theme_supports[ 'editor-styles' ];
11
+ // This is a temp solution until the has_theme_json value is available for the current theme.
12
+ const hasThemeJson = siteData.editorSettings?.supportsLayout;
13
+ return ! isBlockTheme && ( supportsEditorStyles || hasThemeJson );
14
+ }
@@ -121,21 +121,65 @@ export const SiteHubMobile = memo(
121
121
  const history = useHistory();
122
122
  const { navigate } = useContext( SidebarNavigationContext );
123
123
 
124
- const { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {
124
+ const {
125
+ dashboardLink,
126
+ homeUrl,
127
+ siteTitle,
128
+ isBlockTheme,
129
+ isClassicThemeWithStyleBookSupport,
130
+ } = useSelect( ( select ) => {
125
131
  const { getSettings } = unlock( select( editSiteStore ) );
126
- const { getEntityRecord } = select( coreStore );
132
+ const { getEntityRecord, getCurrentTheme } = select( coreStore );
127
133
  const _site = getEntityRecord( 'root', 'site' );
134
+ const currentTheme = getCurrentTheme();
135
+ const settings = getSettings();
136
+ const supportsEditorStyles =
137
+ currentTheme.theme_supports[ 'editor-styles' ];
138
+ // This is a temp solution until the has_theme_json value is available for the current theme.
139
+ const hasThemeJson = settings.supportsLayout;
140
+
128
141
  return {
129
- dashboardLink: getSettings().__experimentalDashboardLink,
142
+ dashboardLink: settings.__experimentalDashboardLink,
130
143
  homeUrl: getEntityRecord( 'root', '__unstableBase' )?.home,
131
144
  siteTitle:
132
145
  ! _site?.title && !! _site?.url
133
146
  ? filterURLForDisplay( _site?.url )
134
147
  : _site?.title,
148
+ isBlockTheme: currentTheme?.is_block_theme,
149
+ isClassicThemeWithStyleBookSupport:
150
+ ! currentTheme?.is_block_theme &&
151
+ ( supportsEditorStyles || hasThemeJson ),
135
152
  };
136
153
  }, [] );
137
154
  const { open: openCommandCenter } = useDispatch( commandsStore );
138
- const isRoot = path === '/';
155
+
156
+ let backPath;
157
+
158
+ // If the current path is not the root page, find a page to back to.
159
+ if ( path !== '/' ) {
160
+ if ( isBlockTheme || isClassicThemeWithStyleBookSupport ) {
161
+ // If the current theme is a block theme or a classic theme that supports StyleBook,
162
+ // back to the Design screen.
163
+ backPath = '/';
164
+ } else if ( path !== '/pattern' ) {
165
+ // If the current theme is a classic theme that does not support StyleBook,
166
+ // back to the Patterns page.
167
+ backPath = '/pattern';
168
+ }
169
+ }
170
+
171
+ const backButtonProps = {
172
+ href: !! backPath ? undefined : dashboardLink,
173
+ label: !! backPath
174
+ ? __( 'Go to Site Editor' )
175
+ : __( 'Go to the Dashboard' ),
176
+ onClick: !! backPath
177
+ ? () => {
178
+ history.navigate( backPath );
179
+ navigate( 'back' );
180
+ }
181
+ : undefined,
182
+ };
139
183
 
140
184
  return (
141
185
  <div className="edit-site-site-hub">
@@ -156,18 +200,7 @@ export const SiteHubMobile = memo(
156
200
  transform: 'scale(0.5)',
157
201
  borderRadius: 4,
158
202
  } }
159
- { ...( isRoot
160
- ? {
161
- href: dashboardLink,
162
- label: __( 'Go to the Dashboard' ),
163
- }
164
- : {
165
- onClick: () => {
166
- history.navigate( '/' );
167
- navigate( 'back' );
168
- },
169
- label: __( 'Go to Site Editor' ),
170
- } ) }
203
+ { ...backButtonProps }
171
204
  >
172
205
  <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
173
206
  </Button>