-
Notifications
You must be signed in to change notification settings - Fork 953
Expand file tree
/
Copy pathSidebarFill.js
More file actions
151 lines (145 loc) · 6.05 KB
/
SidebarFill.js
File metadata and controls
151 lines (145 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* External dependencies */
import { Fill } from "@wordpress/components";
import { Fragment, lazy, Suspense } from "@wordpress/element";
import PropTypes from "prop-types";
import { __ } from "@wordpress/i18n";
import { get } from "lodash";
import { useSelect } from "@wordpress/data";
/* Internal dependencies */
import CollapsibleCornerstone from "../../containers/CollapsibleCornerstone";
import Warning from "../../containers/Warning";
import { KeywordInput, ReadabilityAnalysis, SeoAnalysis, InclusiveLanguageAnalysis, ContentBlocks } from "@yoast/externals/components";
import { useFirstEligibleNotification } from "../../hooks/use-first-eligible-notification";
import InsightsModal from "../../insights/components/insights-modal";
import { InternalLinkingSuggestionsUpsell } from "../modals/InternalLinkingSuggestionsUpsell";
import SidebarItem from "../SidebarItem";
import SearchAppearanceModal from "../modals/editorModals/SearchAppearanceModal";
import SocialAppearanceModal from "../modals/editorModals/SocialAppearanceModal";
import SchemaTabContainer from "../../containers/SchemaTab";
import SidebarCollapsible from "../SidebarCollapsible";
import AdvancedSettings from "../../containers/AdvancedSettings";
import WincherSEOPerformanceModal from "../../containers/WincherSEOPerformanceModal";
import KeywordUpsell from "../modals/KeywordUpsell";
import isBlockEditor from "../../helpers/isBlockEditor";
import useToggleMarkerStatus from "./hooks/useToggleMarkerStatus";
import { EditorIntro } from "../EditorIntro";
// Lazy-loaded so the planner module is not bundled into block-editor.js.
const ContentPlannerEditorItem = lazy( () => import(
/* webpackChunkName: "ai-content-planner-editor" */
"../../ai-content-planner/containers/content-planner-editor-item"
) );
/* eslint-disable complexity */
/**
* Creates the SidebarFill component.
*
* @param {Object} settings The feature toggles.
* @param {Object} store The Redux store.
* @param {Object} theme The theme to use.
*
* @returns {wp.Element} The Sidebar component.
*
* @constructor
*/
export default function SidebarFill( { settings } ) {
const webinarIntroUrl = get( window, "wpseoScriptData.webinarIntroBlockEditorUrl", "https://yoa.st/webinar-intro-block-editor" );
const FirstEligibleNotification = useFirstEligibleNotification( { webinarIntroUrl } );
const { isAiFeatureActive, isPost } = useSelect( ( select ) => ( {
isAiFeatureActive: select( "yoast-seo/editor" ).getPreference( "isAiFeatureActive" ),
isPost: select( "yoast-seo/editor" ).getPostType() === "post",
} ), [] );
const isBlockEditorActive = isBlockEditor();
if ( isBlockEditorActive ) {
useToggleMarkerStatus();
}
return (
<Fragment>
<Fill name="YoastSidebar">
<SidebarItem key="warning" renderPriority={ 0 }>
<Warning />
</SidebarItem>
<SidebarItem
key="editor-intro"
renderPriority={ 1 }
>
<EditorIntro withPromptForContentSuggestions={ isAiFeatureActive && isBlockEditorActive && isPost }>
{ FirstEligibleNotification && <FirstEligibleNotification inEditorIntro={ true } /> }
</EditorIntro>
</SidebarItem>
{ isPost && isBlockEditorActive && isAiFeatureActive && <SidebarItem key="content-planner" renderPriority={ 2 }>
<Suspense fallback={ null }>
<ContentPlannerEditorItem location="sidebar" />
</Suspense>
</SidebarItem> }
{ settings.isKeywordAnalysisActive && <SidebarItem key="keyword-input" renderPriority={ 8 }>
<KeywordInput
isSEMrushIntegrationActive={ settings.isSEMrushIntegrationActive }
/>
</SidebarItem> }
{ settings.isKeywordAnalysisActive && <SidebarItem key="seo" renderPriority={ 10 }>
<Fragment>
<SeoAnalysis
shouldUpsell={ settings.shouldUpsell }
/>
</Fragment>
</SidebarItem> }
{ settings.isContentAnalysisActive && <SidebarItem key="readability" renderPriority={ 20 }>
<ReadabilityAnalysis
shouldUpsell={ settings.shouldUpsell }
/>
</SidebarItem> }
{ settings.isInclusiveLanguageAnalysisActive && <SidebarItem key="inclusive-language-analysis" renderPriority={ 21 }>
<InclusiveLanguageAnalysis />
</SidebarItem> }
{ settings.isKeywordAnalysisActive && <SidebarItem key="additional-keywords-upsell" renderPriority={ 22 }>
{ settings.shouldUpsell && <KeywordUpsell /> }
</SidebarItem> }
{ settings.isKeywordAnalysisActive && settings.isWincherIntegrationActive && <SidebarItem renderPriority={ 23 }>
<WincherSEOPerformanceModal
location="sidebar"
/>
</SidebarItem> }
{ settings.shouldUpsell && <SidebarItem key="internal-linking-suggestions-upsell" renderPriority={ 25 }>
<InternalLinkingSuggestionsUpsell />
</SidebarItem> }
<SidebarItem key="search-appearance" renderPriority={ 26 }>
<SearchAppearanceModal />
</SidebarItem>
{ ( settings.useOpenGraphData || settings.useTwitterData ) && <SidebarItem key="social-appearance" renderPriority={ 27 }>
<SocialAppearanceModal
useOpenGraphData={ settings.useOpenGraphData }
useTwitterData={ settings.useTwitterData }
/>
</SidebarItem> }
{ settings.displaySchemaSettings && <SidebarItem key="schema" renderPriority={ 28 }>
<SidebarCollapsible
title={ __( "Schema", "wordpress-seo" ) }
>
<SchemaTabContainer />
</SidebarCollapsible>
</SidebarItem> }
{ isBlockEditorActive &&
<SidebarItem key="content-blocks" renderPriority={ 29 }>
<ContentBlocks />
</SidebarItem>
}
{ settings.displayAdvancedTab && <SidebarItem key="advanced" renderPriority={ 30 }>
<SidebarCollapsible
title={ __( "Advanced", "wordpress-seo" ) }
>
<AdvancedSettings />
</SidebarCollapsible>
</SidebarItem> }
{ settings.isCornerstoneActive && <SidebarItem key="cornerstone" renderPriority={ 31 }>
<CollapsibleCornerstone />
</SidebarItem> }
{ settings.isInsightsEnabled && <SidebarItem renderPriority={ 32 }>
<InsightsModal location="sidebar" />
</SidebarItem> }
</Fill>
</Fragment>
);
}
SidebarFill.propTypes = {
settings: PropTypes.object.isRequired,
};
/* eslint-enable complexity */