Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
Remove version warnings in Tabs components (#404)
Browse files Browse the repository at this point in the history
The Tabs component displays the VersionWarning component instead of the
TabItem configured by the page if a TabItem's scope is set to `cloud`
and the current docs version is not the same as the latest docs version.

This warning is unhelpful, since the "latest" version configured for the
docs site is often one major version ahead of the Teleport Cloud
version. In addition, since we have removed scope switching from the
docs engine, the `scope` prop is supposed to be no-op until we remove
all instances of this prop from the docs site.

Also updates yarn.lock, which was out of date in earlier commits.
  • Loading branch information
ptgott authored Oct 6, 2023
1 parent d4dac70 commit 0f2dfd8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 45 deletions.
9 changes: 1 addition & 8 deletions components/Tabs/TabItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { VersionWarning } from "layouts/DocsPage";
import { TabItemProps, TabItemsListProps } from "./types";
import styles from "./TabItem.module.css";

Expand Down Expand Up @@ -47,13 +46,7 @@ export const TabItemList = ({

return (
<div key={tab.props.label + tab.props.options} className={labeClassName}>
{tab.props.scope === "cloud" && latestDocVers !== currentDocVers ? (
<TabItem label={tab.props.label}>
<VersionWarning />
</TabItem>
) : (
tab
)}
{tab}
</div>
);
});
Expand Down
40 changes: 40 additions & 0 deletions components/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { expect } from "@storybook/jest";
import { default as Pre } from "../MDX/Pre";
import { TabContextProvider } from "./TabContext";
import { DocsContextProvider } from "layouts/DocsPage/context";
import { default as DocsPage } from "layouts/DocsPage/DocsPage";
import type { ScopesInMeta } from "layouts/DocsPage/types";

import { TabItem } from "./TabItem";
import { Tabs } from "./Tabs";
Expand Down Expand Up @@ -318,3 +320,41 @@ export const TabsWithDropdownViewChangeTogether: Story = {
).not.toContain("hidden");
},
};

export const TabsWithNonLatestVersionAndCloud: Story = {
render: () => {
const meta = {
h1: "My Page",
title: "My Page",
description: "Provides content for testing.",
versions: {
current: "13.x",
latest: "14.x",
available: ["13.x", "14.x"],
},
scopes: ["oss", "cloud"] as ScopesInMeta,
navigation: [],
keywords: [],
githubUrl: "",
};
return (
<DocsPage meta={meta} tableOfContents={[]}>
<TabContextProvider>
<Tabs>
<TabItem scope="cloud" label="Cloud Instructions">
Here are Cloud instructions.
</TabItem>
<TabItem scope="oss" label="OSS Instructions">
OSS Instructions
</TabItem>
</Tabs>
</TabContextProvider>
</DocsPage>
);
},
play: async ({ canvasElement, step }) => {
const canvas = within(canvasElement);
const tabs = canvas.getAllByTestId("tabitem");
expect(tabs[0].textContent).not.toContain("Cloud is not available");
},
};
9 changes: 0 additions & 9 deletions layouts/DocsPage/VersionWarning.module.css

This file was deleted.

24 changes: 0 additions & 24 deletions layouts/DocsPage/VersionWarning.tsx

This file was deleted.

1 change: 0 additions & 1 deletion layouts/DocsPage/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default } from "./DocsPage";
export { VersionWarning } from "./VersionWarning";

export type { NavigationCategory, PageMeta } from "./types";
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11270,7 +11270,7 @@ graphql-ws@^5.12.0:
resolved "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.0.tgz#766f249f3974fc2c48fae0d1fb20c2c4c79cd591"
integrity sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g==

graphql@^16.8.1:
graphql@^16.6.0, graphql@^16.8.1:
version "16.8.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07"
integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw==
Expand Down Expand Up @@ -16189,7 +16189,7 @@ react-docgen@^5.0.0:
node-dir "^0.1.10"
strip-indent "^3.0.0"

react-dom@^18.2.0:
[email protected]:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d"
integrity sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==
Expand Down Expand Up @@ -16369,7 +16369,7 @@ react-use@^17.3.1:
ts-easing "^0.2.0"
tslib "^2.1.0"

react@^18.2.0:
[email protected]:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
Expand Down

1 comment on commit 0f2dfd8

@vercel
Copy link

@vercel vercel bot commented on 0f2dfd8 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.