From c6949c3dc8a4907b2907c41057c0aa0cff6079a8 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Mon, 13 May 2024 15:18:24 +0100 Subject: [PATCH 01/14] docs: add prototype partials --- .../getting-started/getting-started.md | 15 ++++++ .../PartialsComponent/PartialsComponent.tsx | 52 +++++++++++++++++++ .../getting-started/_palette-setup.mdx | 2 + src/components/PartialsComponent/index.ts | 3 ++ src/theme/MDXComponents/MDXComponents.ts | 2 + tsconfig.json | 4 +- 6 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/components/PartialsComponent/PartialsComponent.tsx create mode 100644 src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx create mode 100644 src/components/PartialsComponent/index.ts diff --git a/docs/docs-content/getting-started/getting-started.md b/docs/docs-content/getting-started/getting-started.md index f1d604e9c8..b496a012bb 100644 --- a/docs/docs-content/getting-started/getting-started.md +++ b/docs/docs-content/getting-started/getting-started.md @@ -8,6 +8,21 @@ sidebar_custom_props: tags: ["getting-started"] --- +### Partials test + + + This page gives you an overview of how to get started with Spectro Cloud Palette and begin leveraging its Kubernetes full-stack management at scale. Palette's unique capabilities provide end-to-end declarative cluster management, cluster monitoring and reconciliation, as well as enterprise-grade security. diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx new file mode 100644 index 0000000000..58d8902c38 --- /dev/null +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -0,0 +1,52 @@ +import React from "react"; +import PaletteSetup from "./_partials/getting-started/_palette-setup.mdx" + + +type PartialComponentProperty = {[key: string] : string} + +interface InputProperty { + key: string, + value: string, +} + +interface PartialsComponentDetails { + name: string; + props: InputProperty[]; +} + +interface PartialsMap { + [key: string]: React.ReactElement; +} + +export const partials: PartialsMap = { + PaletteSetup: , +}; + +export default function PartialsComponent(details : PartialsComponentDetails) : React.ReactElement { + if (!partials[details.name]) { + throw new Error("No partial found for ". + concat(details.name). + concat(". Check partial names in PartialsComponent.")) + } + // [ + // { + // key: "cloud", + // value : "AWS" + // }, + // { + // key: "version", + // value : "2.0" + // }, + // ] + // console.log(details.props) + var propAttribute: PartialComponentProperty = {} + details.props.map((val) => { + propAttribute[val.key] = val.value + }) + // {cloud:"AWS", version: "2.0"} + // console.log(propAttribute) + + + return React.cloneElement(partials[details.name], propAttribute); +} + diff --git a/src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx b/src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx new file mode 100644 index 0000000000..816f39a03d --- /dev/null +++ b/src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx @@ -0,0 +1,2 @@ +This is how we set up Palette with {props.cloud} {props.version}. + diff --git a/src/components/PartialsComponent/index.ts b/src/components/PartialsComponent/index.ts new file mode 100644 index 0000000000..6bd77efbc4 --- /dev/null +++ b/src/components/PartialsComponent/index.ts @@ -0,0 +1,3 @@ +import PartialsComponent from "./PartialsComponent"; + +export default PartialsComponent; \ No newline at end of file diff --git a/src/theme/MDXComponents/MDXComponents.ts b/src/theme/MDXComponents/MDXComponents.ts index a0b9996943..bc2b1cdd97 100644 --- a/src/theme/MDXComponents/MDXComponents.ts +++ b/src/theme/MDXComponents/MDXComponents.ts @@ -12,6 +12,7 @@ import TOCInline from "@theme/TOCInline"; import { TechnicalPreviewReleaseNote as TpBadge } from "@site/src/components/Badges"; import SimpleCardGrid from "@site/src/components/SimpleCardGrid/index"; import ReleaseNotesVersions from "@site/src/components/ReleaseNotesVersions/index"; +import PartialsComponent from "@site/src/components/PartialsComponent"; export default { ...MDXComponents, @@ -28,4 +29,5 @@ export default { TpBadge, SimpleCardGrid, ReleaseNotesVersions, + PartialsComponent, }; diff --git a/tsconfig.json b/tsconfig.json index 3eb9b67a6f..5d490025fa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,10 @@ { // This file is not used in compilation. It is here just for a nice editor experience. "extends": "@tsconfig/docusaurus/tsconfig.json", - "include": ["src", "declarations.d.ts", "utils"], + "include": ["src", "declarations.d.ts", "utils", "**/*.mdx",], "exclude": ["src/deprecated"], "compilerOptions": { - "types": ["node", "jest", "@testing-library/jest-dom"], + "types": ["node", "jest", "@testing-library/jest-dom", "mdx"], "esModuleInterop": true, "target": "es6", "module": "Node16", From 0a1e633412435152d4fdfed9b79fb9c09a861557 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Mon, 13 May 2024 20:11:11 +0100 Subject: [PATCH 02/14] docs: prototype partials DOC-1159 --- .../getting-started/getting-started.md | 3 ++- .../PartialsComponent/PartialsComponent.tsx | 22 +++---------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/docs/docs-content/getting-started/getting-started.md b/docs/docs-content/getting-started/getting-started.md index b496a012bb..82f0685c29 100644 --- a/docs/docs-content/getting-started/getting-started.md +++ b/docs/docs-content/getting-started/getting-started.md @@ -10,7 +10,8 @@ tags: ["getting-started"] ### Partials test - { propAttribute[val.key] = val.value - }) - // {cloud:"AWS", version: "2.0"} - // console.log(propAttribute) - + }) return React.cloneElement(partials[details.name], propAttribute); } From 8abbaf5d4ac49f2d0bbb915ac53062c6992767d8 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Mon, 13 May 2024 20:40:15 +0100 Subject: [PATCH 03/14] docs: add comments to component --- src/components/PartialsComponent/PartialsComponent.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx index b36bbe1854..7442a5fccf 100644 --- a/src/components/PartialsComponent/PartialsComponent.tsx +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -1,4 +1,5 @@ import React from "react"; +// Import each partial here import PaletteSetup from "./_partials/getting-started/_palette-setup.mdx" interface InputProperty { @@ -8,13 +9,15 @@ interface InputProperty { interface PartialsComponentDetails { name: string; + // Pass the key-value property pairs props: InputProperty[]; } interface PartialsMap { [key: string]: React.ReactElement; } - + +// Maintain a map of existing partials export const partials: PartialsMap = { PaletteSetup: , }; @@ -26,6 +29,7 @@ export default function PartialsComponent(details : PartialsComponentDetails) : concat(". Check partial names in PartialsComponent.")) } + // Map elements to index signatures var propAttribute: {[key: string] : string} = {} details.props.map((val) => { propAttribute[val.key] = val.value From 664e4fa006aeed38b46dee123c9df909aa810a01 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Tue, 14 May 2024 16:21:09 +0100 Subject: [PATCH 04/14] docs: add partial categories --- .../getting-started/_palette-setup.mdx | 0 .../getting-started/getting-started.md | 3 +- .../PartialsComponent/PartialsComponent.tsx | 39 ++++++++++++------- .../PartialsComponent/PartialsMap.tsx | 24 ++++++++++++ .../maps/GettingStartedPartialsMap.tsx | 9 +++++ 5 files changed, 59 insertions(+), 16 deletions(-) rename {src/components/PartialsComponent/_partials => _partials}/getting-started/_palette-setup.mdx (100%) create mode 100644 src/components/PartialsComponent/PartialsMap.tsx create mode 100644 src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx diff --git a/src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx b/_partials/getting-started/_palette-setup.mdx similarity index 100% rename from src/components/PartialsComponent/_partials/getting-started/_palette-setup.mdx rename to _partials/getting-started/_palette-setup.mdx diff --git a/docs/docs-content/getting-started/getting-started.md b/docs/docs-content/getting-started/getting-started.md index 82f0685c29..6895ba84ff 100644 --- a/docs/docs-content/getting-started/getting-started.md +++ b/docs/docs-content/getting-started/getting-started.md @@ -10,7 +10,8 @@ tags: ["getting-started"] ### Partials test -, -}; - export default function PartialsComponent(details : PartialsComponentDetails) : React.ReactElement { - if (!partials[details.name]) { - throw new Error("No partial found for ". + + var foundCategoryMap = null; + AllPartials.maps.forEach((val) => { + if (val.category == details.category) { + foundCategoryMap = val; + return + } + }) + + if (!foundCategoryMap) { + throw new Error("No partial found for category". + concat(details.name). + concat(".")); + } + + const partialsMap = foundCategoryMap as PartialsMapCategory; + if (!partialsMap.map[details.name]) { + throw new Error("No partial found for name ". concat(details.name). - concat(". Check partial names in PartialsComponent.")) + concat("in category "). + concat(details.category). + concat(".=")); } // Map elements to index signatures @@ -35,6 +44,6 @@ export default function PartialsComponent(details : PartialsComponentDetails) : propAttribute[val.key] = val.value }) - return React.cloneElement(partials[details.name], propAttribute); + return React.cloneElement(partialsMap.map[details.name], propAttribute); } diff --git a/src/components/PartialsComponent/PartialsMap.tsx b/src/components/PartialsComponent/PartialsMap.tsx new file mode 100644 index 0000000000..ecd47d4b40 --- /dev/null +++ b/src/components/PartialsComponent/PartialsMap.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import { GettingStartedPartials } from "./maps/GettingStartedPartialsMap" + +export interface PartialsMap { + [key: string]: React.ReactElement; +} + +export interface PartialsMapCategory { + category: string; + map: PartialsMap; +} + +interface PartialsMapCategories { + maps: PartialsMapCategory[] +} + +// Maintain a map of existing partials +export const AllPartials: PartialsMapCategories = { + maps: [ + { + category: "GETTING-STARTED", + map: GettingStartedPartials + } + ]}; diff --git a/src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx b/src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx new file mode 100644 index 0000000000..e96e2ac7f2 --- /dev/null +++ b/src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx @@ -0,0 +1,9 @@ +import React from "react"; +// Import each partial here +import PaletteSetup from "@site/_partials/getting-started/_palette-setup.mdx" +import { PartialsMap } from "@site/src/components/PartialsComponent/PartialsMap.tsx" + +// Maintain a map of existing partials +export const GettingStartedPartials: PartialsMap = { + "PaletteSetup": , +}; \ No newline at end of file From f65a95d03d079e49215e27ed213bf6b734047719 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Tue, 14 May 2024 16:50:29 +0100 Subject: [PATCH 05/14] docs: add partial categories --- .../{PartialsMap.tsx => PartialsCategories.tsx} | 15 ++++++--------- .../PartialsComponent/PartialsComponent.tsx | 4 ++-- ...PartialsMap.tsx => GettingStartedPartials.tsx} | 2 +- .../PartialsComponent/maps/PartialsMap.tsx | 5 +++++ 4 files changed, 14 insertions(+), 12 deletions(-) rename src/components/PartialsComponent/{PartialsMap.tsx => PartialsCategories.tsx} (65%) rename src/components/PartialsComponent/maps/{GettingStartedPartialsMap.tsx => GettingStartedPartials.tsx} (75%) create mode 100644 src/components/PartialsComponent/maps/PartialsMap.tsx diff --git a/src/components/PartialsComponent/PartialsMap.tsx b/src/components/PartialsComponent/PartialsCategories.tsx similarity index 65% rename from src/components/PartialsComponent/PartialsMap.tsx rename to src/components/PartialsComponent/PartialsCategories.tsx index ecd47d4b40..6007508810 100644 --- a/src/components/PartialsComponent/PartialsMap.tsx +++ b/src/components/PartialsComponent/PartialsCategories.tsx @@ -1,17 +1,13 @@ -import React from "react"; -import { GettingStartedPartials } from "./maps/GettingStartedPartialsMap" +import { GettingStartedPartials } from "./maps/GettingStartedPartials" +import { PartialsMap } from "./maps/PartialsMap" -export interface PartialsMap { - [key: string]: React.ReactElement; -} - -export interface PartialsMapCategory { +export interface PartialsCategory { category: string; map: PartialsMap; } interface PartialsMapCategories { - maps: PartialsMapCategory[] + maps: PartialsCategory[] } // Maintain a map of existing partials @@ -21,4 +17,5 @@ export const AllPartials: PartialsMapCategories = { category: "GETTING-STARTED", map: GettingStartedPartials } - ]}; + ] +}; diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx index c8675e5e02..74446f7e12 100644 --- a/src/components/PartialsComponent/PartialsComponent.tsx +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { AllPartials, PartialsMapCategory } from "./PartialsMap" +import { AllPartials, PartialsCategory } from "./PartialsCategories" interface InputProperty { key: string, @@ -29,7 +29,7 @@ export default function PartialsComponent(details : PartialsComponentDetails) : concat(".")); } - const partialsMap = foundCategoryMap as PartialsMapCategory; + const partialsMap = foundCategoryMap as PartialsCategory; if (!partialsMap.map[details.name]) { throw new Error("No partial found for name ". concat(details.name). diff --git a/src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx b/src/components/PartialsComponent/maps/GettingStartedPartials.tsx similarity index 75% rename from src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx rename to src/components/PartialsComponent/maps/GettingStartedPartials.tsx index e96e2ac7f2..097c167b44 100644 --- a/src/components/PartialsComponent/maps/GettingStartedPartialsMap.tsx +++ b/src/components/PartialsComponent/maps/GettingStartedPartials.tsx @@ -1,7 +1,7 @@ import React from "react"; // Import each partial here import PaletteSetup from "@site/_partials/getting-started/_palette-setup.mdx" -import { PartialsMap } from "@site/src/components/PartialsComponent/PartialsMap.tsx" +import { PartialsMap } from "./PartialsMap" // Maintain a map of existing partials export const GettingStartedPartials: PartialsMap = { diff --git a/src/components/PartialsComponent/maps/PartialsMap.tsx b/src/components/PartialsComponent/maps/PartialsMap.tsx new file mode 100644 index 0000000000..545e80140b --- /dev/null +++ b/src/components/PartialsComponent/maps/PartialsMap.tsx @@ -0,0 +1,5 @@ +import React from "react"; + +export interface PartialsMap { + [key: string]: React.ReactElement; +} \ No newline at end of file From 3ba92af986749a05d995c8dc39a9c66fa260a163 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Wed, 15 May 2024 20:24:16 +0100 Subject: [PATCH 06/14] docs: add frontmatter approach --- _partials/clusters/_cluster_profile.mdx | 6 ++ _partials/clusters/index.ts | 5 ++ _partials/getting-started/_palette-setup.mdx | 5 ++ _partials/getting-started/index.ts | 5 ++ _partials/index.ts | 7 ++ .../getting-started/getting-started.md | 15 ++++ .../PartialsComponent/PartialsCategories.tsx | 5 ++ .../PartialsComponent/PartialsComponent.tsx | 6 +- .../maps/ClustersPartials.tsx | 9 +++ .../PartialsComponent/maps/PartialsMap.tsx | 5 +- .../PartialsComponent.tsx | 78 +++++++++++++++++++ .../PartialsComponentFrontMatter/index.ts | 3 + src/theme/MDXComponents/MDXComponents.ts | 2 + 13 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 _partials/clusters/_cluster_profile.mdx create mode 100644 _partials/clusters/index.ts create mode 100644 _partials/getting-started/index.ts create mode 100644 _partials/index.ts create mode 100644 src/components/PartialsComponent/maps/ClustersPartials.tsx create mode 100644 src/components/PartialsComponentFrontMatter/PartialsComponent.tsx create mode 100644 src/components/PartialsComponentFrontMatter/index.ts diff --git a/_partials/clusters/_cluster_profile.mdx b/_partials/clusters/_cluster_profile.mdx new file mode 100644 index 0000000000..f45383e9e9 --- /dev/null +++ b/_partials/clusters/_cluster_profile.mdx @@ -0,0 +1,6 @@ +--- +partial_category: clusters +partial_name: cluster-profile +--- + +This is the second import {props.cloud} {props.version}. diff --git a/_partials/clusters/index.ts b/_partials/clusters/index.ts new file mode 100644 index 0000000000..31e49693c0 --- /dev/null +++ b/_partials/clusters/index.ts @@ -0,0 +1,5 @@ +import * as ClusterProfile from "./_cluster_profile.mdx"; + +export default { + ClusterProfile +} \ No newline at end of file diff --git a/_partials/getting-started/_palette-setup.mdx b/_partials/getting-started/_palette-setup.mdx index 816f39a03d..45d963aec7 100644 --- a/_partials/getting-started/_palette-setup.mdx +++ b/_partials/getting-started/_palette-setup.mdx @@ -1,2 +1,7 @@ +--- +partial_category: getting-started +partial_name: palette-setup +--- + This is how we set up Palette with {props.cloud} {props.version}. diff --git a/_partials/getting-started/index.ts b/_partials/getting-started/index.ts new file mode 100644 index 0000000000..a50c3a4a41 --- /dev/null +++ b/_partials/getting-started/index.ts @@ -0,0 +1,5 @@ +import * as PaletteSetup from "./_palette-setup.mdx"; + +export default { + PaletteSetup +} \ No newline at end of file diff --git a/_partials/index.ts b/_partials/index.ts new file mode 100644 index 0000000000..e776be0e49 --- /dev/null +++ b/_partials/index.ts @@ -0,0 +1,7 @@ +import * as Clusters from "./clusters"; +import * as GettingStarted from "./getting-started"; + +export default { + Clusters, + GettingStarted +} \ No newline at end of file diff --git a/docs/docs-content/getting-started/getting-started.md b/docs/docs-content/getting-started/getting-started.md index 6895ba84ff..e2c422bd16 100644 --- a/docs/docs-content/getting-started/getting-started.md +++ b/docs/docs-content/getting-started/getting-started.md @@ -25,6 +25,21 @@ tags: ["getting-started"] ]} /> + + This page gives you an overview of how to get started with Spectro Cloud Palette and begin leveraging its Kubernetes full-stack management at scale. Palette's unique capabilities provide end-to-end declarative cluster management, cluster monitoring and reconciliation, as well as enterprise-grade security. diff --git a/src/components/PartialsComponent/PartialsCategories.tsx b/src/components/PartialsComponent/PartialsCategories.tsx index 6007508810..730d10cbf8 100644 --- a/src/components/PartialsComponent/PartialsCategories.tsx +++ b/src/components/PartialsComponent/PartialsCategories.tsx @@ -1,3 +1,4 @@ +import { ClusterPartials } from "./maps/ClustersPartials" import { GettingStartedPartials } from "./maps/GettingStartedPartials" import { PartialsMap } from "./maps/PartialsMap" @@ -16,6 +17,10 @@ export const AllPartials: PartialsMapCategories = { { category: "GETTING-STARTED", map: GettingStartedPartials + }, + { + category: "CLUSTERS", + map: ClusterPartials } ] }; diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx index 74446f7e12..6c3e37a17e 100644 --- a/src/components/PartialsComponent/PartialsComponent.tsx +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -44,6 +44,10 @@ export default function PartialsComponent(details : PartialsComponentDetails) : propAttribute[val.key] = val.value }) - return React.cloneElement(partialsMap.map[details.name], propAttribute); + var cloned = React.cloneElement(partialsMap.map[details.name], propAttribute) + + console.log("Found ORIGINAL: ", partialsMap.map[details.name]); + console.log("Cloned ORIGINAL: ", cloned); + return cloned; } diff --git a/src/components/PartialsComponent/maps/ClustersPartials.tsx b/src/components/PartialsComponent/maps/ClustersPartials.tsx new file mode 100644 index 0000000000..c1f97a7342 --- /dev/null +++ b/src/components/PartialsComponent/maps/ClustersPartials.tsx @@ -0,0 +1,9 @@ +import React from "react"; +// Import each partial here +import ClusterProfiles from "@site/_partials/clusters/_cluster_profile.mdx" +import { PartialsMap } from "./PartialsMap" + +// Maintain a map of existing partials +export const ClusterPartials: PartialsMap = { + "ClusterProfile": , +}; \ No newline at end of file diff --git a/src/components/PartialsComponent/maps/PartialsMap.tsx b/src/components/PartialsComponent/maps/PartialsMap.tsx index 545e80140b..5360cc5583 100644 --- a/src/components/PartialsComponent/maps/PartialsMap.tsx +++ b/src/components/PartialsComponent/maps/PartialsMap.tsx @@ -2,4 +2,7 @@ import React from "react"; export interface PartialsMap { [key: string]: React.ReactElement; -} \ No newline at end of file +} + +// {key: x, value: y} +// {x : y} \ No newline at end of file diff --git a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx new file mode 100644 index 0000000000..d9b3b0cf97 --- /dev/null +++ b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx @@ -0,0 +1,78 @@ +import React, { FunctionComponent } from "react"; +// Import all the partials as one module. +import * as PartialModules from "@site/_partials"; + +export interface PartialsMap { + [key: string]: FunctionComponent; +} + +interface InputProperty { + key: string, + value: string, +} + +interface PartialsComponentDetails { + category: string; + name: string; + // Pass the key-value property pairs + props: InputProperty[]; +} + +const AllPartials = importPartials() + + +export default function PartialsComponentFrontMatter(details : PartialsComponentDetails) : React.ReactElement { + var mapKey = getMapKey(details.category, details.name) + + if (!AllPartials[mapKey]) { + throw new Error("No partial found for name ". + concat(details.name). + concat(" in category "). + concat(details.category). + concat(".=")); + } + + // Map elements to index signatures + var propAttribute: {[key: string] : string} = {} + details.props.map((val) => { + propAttribute[val.key] = val.value + }) + + var cloned = React.createElement(AllPartials[mapKey], propAttribute); + console.log("Found NEW: ", AllPartials[mapKey]); + console.log("Cloned NEW: ", cloned); + return cloned; +} + +function importPartials() : PartialsMap { + const pmap : PartialsMap = {} + + // Partials exported as default + const defaultModules = PartialModules.default + // The keys are the names of each imported module in _partials/index.ts + const categoryKeys = Object.keys(defaultModules); + + for (const categoryKey of categoryKeys) { + var currentCategory = defaultModules[categoryKey]; + + // Each category contains its own partials exported as default in its own index.ts + const defaultPartials = currentCategory.default + // The keys are the names of each imported module in _partials/index.ts + const partialKeys = Object.keys(defaultPartials); + for (const partialKey of partialKeys) { + var currentPartial = defaultPartials[partialKey]; + var catFrontMatter = currentPartial["frontMatter"]["partial_category"]; + var nameFrontMatter = currentPartial["frontMatter"]["partial_name"]; + + pmap[getMapKey(catFrontMatter, nameFrontMatter)] = currentPartial.default as FunctionComponent; + } + } + + console.log("Pmap: ", pmap) + + return pmap +} + +function getMapKey(category: string, name: string): string { + return category.concat('#').concat(name) +} \ No newline at end of file diff --git a/src/components/PartialsComponentFrontMatter/index.ts b/src/components/PartialsComponentFrontMatter/index.ts new file mode 100644 index 0000000000..18274c052f --- /dev/null +++ b/src/components/PartialsComponentFrontMatter/index.ts @@ -0,0 +1,3 @@ +import PartialsComponentFrontMatter from "./PartialsComponent"; + +export default PartialsComponentFrontMatter; \ No newline at end of file diff --git a/src/theme/MDXComponents/MDXComponents.ts b/src/theme/MDXComponents/MDXComponents.ts index bc2b1cdd97..e2e4f56d99 100644 --- a/src/theme/MDXComponents/MDXComponents.ts +++ b/src/theme/MDXComponents/MDXComponents.ts @@ -13,6 +13,7 @@ import { TechnicalPreviewReleaseNote as TpBadge } from "@site/src/components/Bad import SimpleCardGrid from "@site/src/components/SimpleCardGrid/index"; import ReleaseNotesVersions from "@site/src/components/ReleaseNotesVersions/index"; import PartialsComponent from "@site/src/components/PartialsComponent"; +import PartialsComponentFrontMatter from "@site/src/components/PartialsComponentFrontMatter"; export default { ...MDXComponents, @@ -30,4 +31,5 @@ export default { SimpleCardGrid, ReleaseNotesVersions, PartialsComponent, + PartialsComponentFrontMatter: PartialsComponentFrontMatter, }; From 9ac3d1449f8eb4b5e93b80c7fdb54de268b1df36 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Wed, 15 May 2024 20:57:50 +0100 Subject: [PATCH 07/14] docs: add duplicate key validation --- .../PartialsComponent/PartialsComponent.tsx | 3 --- .../PartialsComponent.tsx | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx index 6c3e37a17e..62357e9345 100644 --- a/src/components/PartialsComponent/PartialsComponent.tsx +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -45,9 +45,6 @@ export default function PartialsComponent(details : PartialsComponentDetails) : }) var cloned = React.cloneElement(partialsMap.map[details.name], propAttribute) - - console.log("Found ORIGINAL: ", partialsMap.map[details.name]); - console.log("Cloned ORIGINAL: ", cloned); return cloned; } diff --git a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx index d9b3b0cf97..03d80a5e0e 100644 --- a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx +++ b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx @@ -20,16 +20,15 @@ interface PartialsComponentDetails { const AllPartials = importPartials() - export default function PartialsComponentFrontMatter(details : PartialsComponentDetails) : React.ReactElement { var mapKey = getMapKey(details.category, details.name) if (!AllPartials[mapKey]) { - throw new Error("No partial found for name ". - concat(details.name). - concat(" in category "). - concat(details.category). - concat(".=")); + throw new Error("No partial found for name ". + concat(details.name). + concat(" in category "). + concat(details.category). + concat(".=")); } // Map elements to index signatures @@ -39,8 +38,6 @@ export default function PartialsComponentFrontMatter(details : PartialsComponent }) var cloned = React.createElement(AllPartials[mapKey], propAttribute); - console.log("Found NEW: ", AllPartials[mapKey]); - console.log("Cloned NEW: ", cloned); return cloned; } @@ -64,12 +61,18 @@ function importPartials() : PartialsMap { var catFrontMatter = currentPartial["frontMatter"]["partial_category"]; var nameFrontMatter = currentPartial["frontMatter"]["partial_name"]; - pmap[getMapKey(catFrontMatter, nameFrontMatter)] = currentPartial.default as FunctionComponent; + var mapKey = getMapKey(catFrontMatter, nameFrontMatter) + if (pmap[mapKey]) { + throw new Error("Duplicate partial defined for name ". + concat(nameFrontMatter). + concat(" in category "). + concat(catFrontMatter). + concat(".=")); + } + + pmap[mapKey] = currentPartial.default as FunctionComponent; } } - - console.log("Pmap: ", pmap) - return pmap } From 36b775916ee18dd1851bbc82c54d57926be70eb4 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Thu, 16 May 2024 14:18:40 +0100 Subject: [PATCH 08/14] docs: add generate-partials script --- .gitignore | 5 ++- Makefile | 8 ++++ ...uster_profile.mdx => _cluster-profile.mdx} | 0 _partials/clusters/index.ts | 5 --- _partials/getting-started/index.ts | 5 --- _partials/index.ts | 7 ---- scripts/generate-partials.sh | 18 +++++++++ .../maps/ClustersPartials.tsx | 2 +- .../PartialsComponent.tsx | 40 +++++++------------ 9 files changed, 46 insertions(+), 44 deletions(-) rename _partials/clusters/{_cluster_profile.mdx => _cluster-profile.mdx} (100%) delete mode 100644 _partials/clusters/index.ts delete mode 100644 _partials/getting-started/index.ts delete mode 100644 _partials/index.ts create mode 100755 scripts/generate-partials.sh diff --git a/.gitignore b/.gitignore index b53c25652e..80da385917 100644 --- a/.gitignore +++ b/.gitignore @@ -61,4 +61,7 @@ screenshots/ tests/screenshot.spec.ts-snapshots/ test-results/ playwright-report/ -artifact.zip \ No newline at end of file +artifact.zip + +# Ignore _partials/index.ts +_partials/index.ts \ No newline at end of file diff --git a/Makefile b/Makefile index c6f76e8688..afcc8ec269 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ init: ## Initialize npm dependencies npx husky install start: ## Start a local development server + make generate-partials npm run start build: ## Run npm build @@ -203,6 +204,13 @@ format-images: ## Format images @echo "formatting images in /static/assets/docs/images/ folder" ./scripts/compress-convert-images.sh +###@ Generate _partials/index.ts required to automatic partials usage. + +generate-partials: ## Generate + @echo "Starting generation of _partials/index.ts." + ./scripts/generate-partials.sh + @echo "Completed generation of _partials/index.ts." + ###@ Aloglia Indexing update-dev-index: ## Update the Algolia index for the dev environment diff --git a/_partials/clusters/_cluster_profile.mdx b/_partials/clusters/_cluster-profile.mdx similarity index 100% rename from _partials/clusters/_cluster_profile.mdx rename to _partials/clusters/_cluster-profile.mdx diff --git a/_partials/clusters/index.ts b/_partials/clusters/index.ts deleted file mode 100644 index 31e49693c0..0000000000 --- a/_partials/clusters/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as ClusterProfile from "./_cluster_profile.mdx"; - -export default { - ClusterProfile -} \ No newline at end of file diff --git a/_partials/getting-started/index.ts b/_partials/getting-started/index.ts deleted file mode 100644 index a50c3a4a41..0000000000 --- a/_partials/getting-started/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as PaletteSetup from "./_palette-setup.mdx"; - -export default { - PaletteSetup -} \ No newline at end of file diff --git a/_partials/index.ts b/_partials/index.ts deleted file mode 100644 index e776be0e49..0000000000 --- a/_partials/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import * as Clusters from "./clusters"; -import * as GettingStarted from "./getting-started"; - -export default { - Clusters, - GettingStarted -} \ No newline at end of file diff --git a/scripts/generate-partials.sh b/scripts/generate-partials.sh new file mode 100755 index 0000000000..7a03503eb4 --- /dev/null +++ b/scripts/generate-partials.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Enable error handling +set -e + +# # Remove the index.ts file if it exists already. +rm -f _partials/index.ts + +# Create the file and add the generated warning. +echo "// This file is generated. DO NOT EDIT!" >> _partials/index.ts + +# Find all the MDX files recursively in the _partials folder. +# Loop through each file. +find _partials -name "*.mdx" -print0 | while read -d $'\0' path +do + module_name=$(basename ${path} .mdx | tr -d '_' | tr -d '-') + echo "export * as ${module_name}${RANDOM} from '@site/${path}';" >> _partials/index.ts +done \ No newline at end of file diff --git a/src/components/PartialsComponent/maps/ClustersPartials.tsx b/src/components/PartialsComponent/maps/ClustersPartials.tsx index c1f97a7342..0a183f2f19 100644 --- a/src/components/PartialsComponent/maps/ClustersPartials.tsx +++ b/src/components/PartialsComponent/maps/ClustersPartials.tsx @@ -1,6 +1,6 @@ import React from "react"; // Import each partial here -import ClusterProfiles from "@site/_partials/clusters/_cluster_profile.mdx" +import ClusterProfiles from "@site/_partials/clusters/_cluster-profile.mdx" import { PartialsMap } from "./PartialsMap" // Maintain a map of existing partials diff --git a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx index 03d80a5e0e..ffbca77ef5 100644 --- a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx +++ b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx @@ -44,34 +44,24 @@ export default function PartialsComponentFrontMatter(details : PartialsComponent function importPartials() : PartialsMap { const pmap : PartialsMap = {} - // Partials exported as default - const defaultModules = PartialModules.default - // The keys are the names of each imported module in _partials/index.ts - const categoryKeys = Object.keys(defaultModules); + // The keys are the names of each exported module in _partials/index.ts + const partialKeys = Object.keys(PartialModules); - for (const categoryKey of categoryKeys) { - var currentCategory = defaultModules[categoryKey]; + for (const pkey of partialKeys) { + var currentPartial = PartialModules[pkey]; + var catFrontMatter = currentPartial["frontMatter"]["partial_category"]; + var nameFrontMatter = currentPartial["frontMatter"]["partial_name"]; - // Each category contains its own partials exported as default in its own index.ts - const defaultPartials = currentCategory.default - // The keys are the names of each imported module in _partials/index.ts - const partialKeys = Object.keys(defaultPartials); - for (const partialKey of partialKeys) { - var currentPartial = defaultPartials[partialKey]; - var catFrontMatter = currentPartial["frontMatter"]["partial_category"]; - var nameFrontMatter = currentPartial["frontMatter"]["partial_name"]; - - var mapKey = getMapKey(catFrontMatter, nameFrontMatter) - if (pmap[mapKey]) { - throw new Error("Duplicate partial defined for name ". - concat(nameFrontMatter). - concat(" in category "). - concat(catFrontMatter). - concat(".=")); - } - - pmap[mapKey] = currentPartial.default as FunctionComponent; + var mapKey = getMapKey(catFrontMatter, nameFrontMatter) + if (pmap[mapKey]) { + throw new Error("Duplicate partial defined for name ". + concat(nameFrontMatter). + concat(" in category "). + concat(catFrontMatter). + concat(".=")); } + + pmap[mapKey] = currentPartial.default as FunctionComponent; } return pmap } From b0fca9a46ebcc9b058ec935b523963afe479b92d Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Thu, 16 May 2024 15:26:37 +0100 Subject: [PATCH 09/14] docs: add more error handling --- .../PartialsComponent.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx index ffbca77ef5..364fe53943 100644 --- a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx +++ b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx @@ -37,8 +37,7 @@ export default function PartialsComponentFrontMatter(details : PartialsComponent propAttribute[val.key] = val.value }) - var cloned = React.createElement(AllPartials[mapKey], propAttribute); - return cloned; + return React.createElement(AllPartials[mapKey], propAttribute); } function importPartials() : PartialsMap { @@ -52,13 +51,19 @@ function importPartials() : PartialsMap { var catFrontMatter = currentPartial["frontMatter"]["partial_category"]; var nameFrontMatter = currentPartial["frontMatter"]["partial_name"]; + if (!catFrontMatter || !nameFrontMatter) { + throw new Error("Please specify partial_category and partial_name for ". + concat(pkey). + concat(".")); + } + var mapKey = getMapKey(catFrontMatter, nameFrontMatter) if (pmap[mapKey]) { throw new Error("Duplicate partial defined for name ". concat(nameFrontMatter). concat(" in category "). concat(catFrontMatter). - concat(".=")); + concat(".")); } pmap[mapKey] = currentPartial.default as FunctionComponent; From 74c8c5b128bf5cbde6b6de32a1f72676e28c653b Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Thu, 16 May 2024 16:02:20 +0100 Subject: [PATCH 10/14] docs: add generate-partials to build --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index afcc8ec269..cfa77e2813 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ start: ## Start a local development server npm run start build: ## Run npm build + make generate-partials @echo "building site" npm run clear rm -rf build From 0fc6f29cb0e01b873f6589dfc1afe41e453a9111 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Thu, 16 May 2024 16:53:57 +0100 Subject: [PATCH 11/14] docs: add partials to npm run --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a234708d6..f906a8cb83 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start --host 0.0.0.0 --port 9000", - "build": "npm run generate-api-docs && docusaurus build", + "build": "npm run generate-api-docs && npm run generate-partials && docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", @@ -18,6 +18,7 @@ "generate-api-docs": "npm run run-api-parser && docusaurus gen-api-docs palette && docusaurus gen-api-docs emc", "clean-api-docs": "docusaurus clean-api-docs palette && docusaurus clean-api-docs emc", "run-api-parser": "node utils/api-parser/index.js", + "generate-partials": "./scripts/generate-partials.sh", "lint": "eslint . --ext .js,.ts,.jsx,.tsx", "lint:fix": "npm run lint -- --fix", "format": "prettier --write \"**/*.{js,jsx,json,ts,tsx,md,mdx,css}\"", From 041f8b83c4def8eff644fc9c76cf2a69f71e7f17 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Thu, 16 May 2024 17:38:04 +0100 Subject: [PATCH 12/14] docs: adjust build with partials --- Makefile | 3 --- scripts/generate-partials.sh | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cfa77e2813..9e3b4549b5 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,6 @@ start: ## Start a local development server npm run start build: ## Run npm build - make generate-partials @echo "building site" npm run clear rm -rf build @@ -208,9 +207,7 @@ format-images: ## Format images ###@ Generate _partials/index.ts required to automatic partials usage. generate-partials: ## Generate - @echo "Starting generation of _partials/index.ts." ./scripts/generate-partials.sh - @echo "Completed generation of _partials/index.ts." ###@ Aloglia Indexing diff --git a/scripts/generate-partials.sh b/scripts/generate-partials.sh index 7a03503eb4..5d10b9d5f3 100755 --- a/scripts/generate-partials.sh +++ b/scripts/generate-partials.sh @@ -3,6 +3,8 @@ # Enable error handling set -e +echo "Starting generation of _partials/index.ts." + # # Remove the index.ts file if it exists already. rm -f _partials/index.ts @@ -15,4 +17,6 @@ find _partials -name "*.mdx" -print0 | while read -d $'\0' path do module_name=$(basename ${path} .mdx | tr -d '_' | tr -d '-') echo "export * as ${module_name}${RANDOM} from '@site/${path}';" >> _partials/index.ts -done \ No newline at end of file +done + +echo "Completed generation of _partials/index.ts." From cea1006eb9a8483c7892514e0110155c655b76ab Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Fri, 17 May 2024 18:17:40 +0100 Subject: [PATCH 13/14] docs: demo --- _partials/getting-started/_palette-setup.mdx | 5 ++-- .../_getting-started_aws_palette-setup.mdx | 1 + .../getting-started/getting-started.md | 26 +++++++++++++++---- .../PartialsComponent.tsx | 4 ++- 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 docs/docs-content/_partials/_getting-started_aws_palette-setup.mdx diff --git a/_partials/getting-started/_palette-setup.mdx b/_partials/getting-started/_palette-setup.mdx index 45d963aec7..405f752e7e 100644 --- a/_partials/getting-started/_palette-setup.mdx +++ b/_partials/getting-started/_palette-setup.mdx @@ -1,7 +1,6 @@ ---- +{/* --- partial_category: getting-started partial_name: palette-setup ---- +--- */} This is how we set up Palette with {props.cloud} {props.version}. - diff --git a/docs/docs-content/_partials/_getting-started_aws_palette-setup.mdx b/docs/docs-content/_partials/_getting-started_aws_palette-setup.mdx new file mode 100644 index 0000000000..568b406390 --- /dev/null +++ b/docs/docs-content/_partials/_getting-started_aws_palette-setup.mdx @@ -0,0 +1 @@ +This is how we set up Palette with {props.cloud} {props.version}. diff --git a/docs/docs-content/getting-started/getting-started.md b/docs/docs-content/getting-started/getting-started.md index e2c422bd16..3ae3af3fc5 100644 --- a/docs/docs-content/getting-started/getting-started.md +++ b/docs/docs-content/getting-started/getting-started.md @@ -10,7 +10,21 @@ tags: ["getting-started"] ### Partials test - --> + +#### Approach 2 + + + +#### Approach 3 + + - +/> --> This page gives you an overview of how to get started with Spectro Cloud Palette and begin leveraging its Kubernetes full-stack management at scale. Palette's unique capabilities provide end-to-end declarative cluster management, cluster @@ -65,7 +81,7 @@ The first step towards adopting Palette in your organization is to We have curated the pages in the Getting Started section to give you a gradual introduction to the fundamental concepts and workflows you need to deploy and manage Kubernetes clusters through Palette. -
+
![Overview of the getting started journey rocket](/getting-started/getting-started_getting-started_journey-overview.webp) diff --git a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx index 364fe53943..4902b07fc9 100644 --- a/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx +++ b/src/components/PartialsComponentFrontMatter/PartialsComponent.tsx @@ -18,7 +18,9 @@ interface PartialsComponentDetails { props: InputProperty[]; } -const AllPartials = importPartials() +// !!!!! DISABLED ONLY FOR TEAM DEMO !!!! +// const AllPartials = importPartials() +const AllPartials = {} export default function PartialsComponentFrontMatter(details : PartialsComponentDetails) : React.ReactElement { var mapKey = getMapKey(details.category, details.name) From 6ae60af4a29ed722add27835eb2981be7c8d0b09 Mon Sep 17 00:00:00 2001 From: addetz <43963729+addetz@users.noreply.github.com> Date: Fri, 17 May 2024 18:28:35 +0100 Subject: [PATCH 14/14] docs: demo --- _partials/getting-started/_palette-setup.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_partials/getting-started/_palette-setup.mdx b/_partials/getting-started/_palette-setup.mdx index 405f752e7e..e05717d0d7 100644 --- a/_partials/getting-started/_palette-setup.mdx +++ b/_partials/getting-started/_palette-setup.mdx @@ -4,3 +4,5 @@ partial_name: palette-setup --- */} This is how we set up Palette with {props.cloud} {props.version}. + +[Test](/getting-started/additional-capabilities) \ No newline at end of file