Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[version-4-3] docs: update url mapper component (#4305) #4310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ The path of the link should be the path of the destination file from the root di

## Palette/VerteX URLs

A special component has been created to handle the generation of URLs for Palette and VertX. The component is called
A special component has been created to handle the generation of URLs for Palette and VerteX. The component is called
[PaletteVertexUrlMapper](./src/components/PaletteVertexUrlMapper/PaletteVertexUrlMapper.tsx). This component is intended
for usage withing partials. You can use the component to change the base path of the URL to either Palette or VerteX.
The component will automatically prefix the path to the URL. The component has the following props:
Expand All @@ -754,6 +754,27 @@ Below is an example of how to use the component:
/> page to learn more about system administrator roles.
```

In cases where Palette and Vertex pages have different URLs beyond the base path, the component will accept the
following props:

- `edition` - The edition of the URL. This can be either `Palette` or `Vertex`. Internally, the component will use this
value to determine the base URL.
- `text` - The text to display for the link.
- `palettePath` - The Palette path to append to the base URL.
- `vertexPath` - The VerteX path to append to the base URL.

Below is an example of how to use the component when the URLs are different:

```mdx
- System administrator permissions, either a Root Administrator or Operations Administrator. Refer to the
<PaletteVertexUrlMapper
edition={props.edition}
text="System Administrators"
palettePath="/system-management/account-management"
vertexPath="/system-management-vertex/account-management"
/> page to learn more about system administrator roles.
```

## Packs Component

The packs component is a custom component that displays all packs available in Palette SaaS by querying the Palette API
Expand Down
4 changes: 2 additions & 2 deletions docs/docs-content/clusters/pcg/pcg.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ existing Kubernetes cluster. Refer to the table below to learn more about the su
| Environment | Palette CLI Install? | Description | Install Guide |
| -------------- | -------------------- | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| MAAS | ✅ | The PCG cluster is deployed into a MAAS environment. | [Deploy to MAAS](deploy-pcg/maas.md) |
| OpenStack | ✅ | The PCG cluster is deployed into an OpenStack environment. | [Deploy a OpenStack](deploy-pcg/openstack.md) |
| OpenStack | ✅ | The PCG cluster is deployed into an OpenStack environment. | [Deploy to OpenStack](deploy-pcg/openstack.md) |
| VMware vSphere | ✅ | The PCG is deployed into a VMware vSphere environment. | [Deploy to VMware vSphere](./deploy-pcg/vmware.md) |
| Other | ❌ | The PCG cluster is deployed into an existing Kubernetes cluster that is not managed by Palette. | [Deploy a PCG to an Existing Kubernetes Cluster](./deploy-pcg-k8s.md) |
| VMware vSphere | ✅ | The PCG is deployed into a VMware vSphere environment. | [Deploy a VMware vSphere](./deploy-pcg/vmware.md) |

## Resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ import VersionedLink from "../VersionedLink/VersionedLink";

// This component is used to generate the correct URL for the palette and vertex versions of the documentation.
// It takes the edition, text, and URL as props and returns the correct URL based on the edition.
// If the vertex and palette pages have different URLs, the component takes palettePath and vertexPath as individual props and returns the correct URL.

interface ComponentProperties {
[key: string]: string;
}

export default function PaletteVertexUrlMapper(props: ComponentProperties) {
const { edition, text, url } = props;
const isPalette = edition?.toLowerCase() === "palette";
const mappedUrl = isPalette ? `/enterprise-version${url}` : `/vertex${url}`;
const { edition, text, url, palettePath, vertexPath } = props;
const normalizedEdition = edition?.toLowerCase();

if (normalizedEdition !== "palette" && normalizedEdition !== "vertex") {
throw new Error("Invalid edition. Please provide either 'palette' or 'vertex'.");
}

const isPalette = normalizedEdition === "palette";
const baseUrl = isPalette ? "/enterprise-version" : "/vertex";

const mappedUrl =
palettePath && vertexPath ? `${baseUrl}${isPalette ? palettePath : vertexPath}` : `${baseUrl}${url}`;

return <VersionedLink url={mappedUrl} text={text} />;
}