move spec generation stuff

This commit is contained in:
Jonathan Summers-Muir
2022-12-20 12:26:32 +08:00
parent 9bad9a7f0e
commit 08da4652ed
5 changed files with 49 additions and 40 deletions

View File

@@ -22,7 +22,7 @@ import { flattenSections } from '~/lib/helpers'
import NavigationMenuHome from './HomeMenu'
// Filter libCommonSections for just the relevant sections in the current library
function generateAllowedClientLibKeys(sections, spec) {
export function generateAllowedClientLibKeys(sections, spec) {
// Filter parent sections first
const specIds = spec.functions.map((func) => {
@@ -198,7 +198,7 @@ const SideNav = () => {
active={isReference_Javascript_V1}
commonSections={libCommonSections}
lib="javascript"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_js_v1)}
spec={spec_js_v1}
/> */}
<NavigationMenuRefList
key={'reference-js-menu'}
@@ -206,7 +206,7 @@ const SideNav = () => {
active={isReference_Javascript_V2}
commonSections={libCommonSections}
lib="javascript"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_js_v2)}
spec={spec_js_v2}
/>
{/* <NavigationMenuRefList
key={'reference-dart-menu'}
@@ -214,15 +214,15 @@ const SideNav = () => {
active={isReference_Dart_V0}
commonSections={libCommonSections}
lib="dart"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_dart_v0)}
/> */}
{/* <NavigationMenuRefList
spec={spec_dart_v0}
/>
<NavigationMenuRefList
key={'reference-dart-menu'}
id={'reference_dart_v1'}
active={isReference_Dart_V1}
commonSections={libCommonSections}
lib="dart"
allowedClientKeys={generateAllowedClientLibKeys(libCommonSections, spec_dart_v1)}
spec={spec_dart_v1}
/> */}
{/* // Tools */}
{/* <NavigationMenuRefList
@@ -231,8 +231,8 @@ const SideNav = () => {
active={isReference_Cli}
commonSections={cliCommonSections}
lib="cli"
/> */}
{/* <NavigationMenuRefList
/>
<NavigationMenuRefList
key={'reference-api-menu'}
id={'reference_api'}
active={isReference_Api}
@@ -246,15 +246,15 @@ const SideNav = () => {
active={isReference_Self_Hosting_Auth}
commonSections={authServerCommonSections}
lib="self-hosting-auth"
/> */}
{/* <NavigationMenuRefList
/>
<NavigationMenuRefList
key={'reference-self-hosting-storage-menu'}
id={'reference_self_hosting_storage'}
active={isReference_Self_Hosting_Storage}
commonSections={storageServerCommonSections}
lib="self-hosting-storage"
/> */}
{/* <NavigationMenuRefList
/>
<NavigationMenuRefList
key={'reference-self-hosting-realtime-menu'}
id={'reference_self_hosting_realtime'}
active={isReference_Self_Hosting_Realtime}

View File

@@ -1,17 +1,5 @@
import * as Accordion from '@radix-ui/react-accordion'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { IconChevronLeft } from 'ui'
import * as NavItems from './NavigationMenu.constants'
import { find } from 'lodash'
import Image from 'next/image'
import { useTheme } from 'common/Providers'
// import apiCommonSections from '~/../../spec/common-client-libs-sections.json'
import RevVersionDropdown from '~/components/RefVersionDropdown'
import { useMenuActiveRefId, useMenuLevelId } from '~/hooks/useMenuState'
import { RefIdOptions, RefKeyOptions } from './NavigationMenu'
import NavigationMenuRefListItems from './NavigationMenuRefListItems'
@@ -26,14 +14,16 @@ interface INavigationMenuRefList {
// if undefined, we show all the menu items
allowedClientKeys?: string[]
active: boolean
spec?: any
}
const NavigationMenuRefList: React.FC<INavigationMenuRefList> = ({
id,
lib,
commonSections,
allowedClientKeys,
active,
spec,
}) => {
// console.log(filterIds)
// console.log(modifierIds)
@@ -53,12 +43,7 @@ const NavigationMenuRefList: React.FC<INavigationMenuRefList> = ({
!active ? 'opacity-0 invisible absolute h-0 overflow-hidden' : '',
].join(' ')}
>
<NavigationMenuRefListItems
id={id}
lib={lib}
commonSections={commonSections}
allowedClientKeys={allowedClientKeys}
/>
<NavigationMenuRefListItems id={id} lib={lib} commonSections={commonSections} spec={spec} />
</div>
)
}

View File

@@ -13,6 +13,7 @@ import RevVersionDropdown from '~/components/RefVersionDropdown'
import { RefIdOptions, RefKeyOptions } from './NavigationMenu'
import React from 'react'
import { generateAllowedClientLibKeys } from '~/lib/refGenerator/helpers'
const FunctionLink = ({
title,
@@ -80,17 +81,15 @@ interface INavigationMenuRefList {
// the keys of menu items that are allowed to be shown on the side menu
// if undefined, we show all the menu items
allowedClientKeys?: string[]
spec?: any
}
const Content: React.FC<INavigationMenuRefList> = ({
id,
lib,
commonSections,
allowedClientKeys,
}) => {
const Content: React.FC<INavigationMenuRefList> = ({ id, lib, commonSections, spec }) => {
const router = useRouter()
const { isDarkMode } = useTheme()
const allowedClientKeys = spec ? generateAllowedClientLibKeys(commonSections, spec) : undefined
console.log(
id && 'id changed',
lib && 'lib changed',