Skip to content

Commit 1d178a7

Browse files
committed
feat: enhance navigation components with available plans
- Updated LeftNav and CloudVersionSelect components to accept and utilize an `availablePlans` prop for improved version selection based on user plans. - Modified DocTemplate to dynamically generate the `availablePlans` array based on navigation types, enhancing the documentation structure. - Improved filtering logic in the version selection to display only relevant options based on the user's available plans.
1 parent 3fe8e5b commit 1d178a7

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/components/Layout/Navigation/LeftNav.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,19 @@ interface LeftNavProps {
2626
availIn: string[];
2727
buildType?: BuildType;
2828
bannerEnabled?: boolean;
29+
availablePlans: string[];
2930
}
3031

3132
export function LeftNavDesktop(props: LeftNavProps) {
32-
const { data, current, name, pathConfig, availIn, buildType } = props;
33+
const {
34+
data,
35+
current,
36+
name,
37+
pathConfig,
38+
availIn,
39+
buildType,
40+
availablePlans,
41+
} = props;
3342

3443
return (
3544
<Box
@@ -68,6 +77,7 @@ export function LeftNavDesktop(props: LeftNavProps) {
6877
pathConfig={pathConfig}
6978
availIn={availIn}
7079
buildType={buildType}
80+
availablePlans={availablePlans}
7181
/>
7282
)}
7383
<LeftNavTree data={data} current={current} />

src/components/Layout/VersionSelect/CloudVersionSelect.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const VersionItems = (props: {
5151
pathConfig: PathConfig;
5252
name: string;
5353
onClick: () => void;
54+
availablePlans: string[];
5455
}) => {
5556
const { pathConfig } = props;
5657
const { cloudMode } = useCloudMode(pathConfig.repo);
@@ -72,7 +73,9 @@ const VersionItems = (props: {
7273

7374
return (
7475
<>
75-
{CLOUD_VERSIONS.map((version) => (
76+
{CLOUD_VERSIONS.filter((version) =>
77+
props.availablePlans.includes(version.value)
78+
).map((version) => (
7679
<MenuItem
7780
key={`menu-${version.value}`}
7881
value={`menu-${version.value}`}
@@ -113,10 +116,11 @@ interface VersionSelectProps {
113116
pathConfig: PathConfig;
114117
availIn: string[];
115118
buildType?: BuildType;
119+
availablePlans: string[];
116120
}
117121

118122
export default function CloudVersionSelect(props: VersionSelectProps) {
119-
const { name, pathConfig, availIn } = props;
123+
const { name, pathConfig, availIn, availablePlans } = props;
120124
const { cloudMode } = useCloudMode(pathConfig.repo);
121125
const currentCloudVersion =
122126
CLOUD_VERSIONS.find((version) => version.value === cloudMode) ||
@@ -158,6 +162,7 @@ export default function CloudVersionSelect(props: VersionSelectProps) {
158162
pathConfig={pathConfig}
159163
name={name}
160164
onClick={handleClose}
165+
availablePlans={availablePlans}
161166
/>
162167
</VersionSelectMenu>
163168
</>

src/templates/DocTemplate.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ export default function DocTemplate({
101101
? essentialNavigation
102102
: classicNavigation;
103103

104+
const haveStarter = starterNavigation.length > 0;
105+
const haveEssential = essentialNavigation.length > 0;
106+
const availablePlans = ["dedicated"];
107+
if (haveStarter) {
108+
availablePlans.push("starter");
109+
}
110+
if (haveEssential) {
111+
availablePlans.push("essential");
112+
}
113+
104114
const tocData: TableOfContent[] | undefined = React.useMemo(() => {
105115
if (tableOfContents.items?.length === 1) {
106116
return tableOfContents.items![0].items;
@@ -129,6 +139,7 @@ export default function DocTemplate({
129139
name={name}
130140
pathConfig={pathConfig}
131141
availIn={availIn.version}
142+
availablePlans={availablePlans}
132143
/>
133144
)
134145
}
@@ -188,6 +199,7 @@ export default function DocTemplate({
188199
availIn={availIn.version}
189200
buildType={buildType}
190201
bannerEnabled={bannerVisible}
202+
availablePlans={availablePlans}
191203
/>
192204
)}
193205
<Box

0 commit comments

Comments
 (0)