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

Add component for API members that are marked as alpha/beta #11529

Merged
merged 5 commits into from
Jan 26, 2024
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
29 changes: 29 additions & 0 deletions docs/shared/ApiDoc/DocBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export function DocBlock({
example = false,
remarksCollapsible = false,
deprecated = false,
releaseTag = false,
}) {
return (
<Stack spacing="4">
{deprecated && <Deprecated canonicalReference={canonicalReference} />}
{releaseTag && <ReleaseTag canonicalReference={canonicalReference} />}
{summary && <Summary canonicalReference={canonicalReference} />}
{remarks && (
<Remarks
Expand Down Expand Up @@ -130,3 +132,30 @@ Example.propTypes = {
collapsible: PropTypes.bool,
index: PropTypes.number,
};

export function ReleaseTag({ canonicalReference }) {
const getItem = useApiDocContext();
const item = getItem(canonicalReference);
const MDX = useMDXComponents();

if (item.releaseTag === "Public") {
return null;
}

return (
<MDX.ExperimentalFeature>
This is in{" "}
<MDX.PrimaryLink
href="https://www.apollographql.com/docs/resources/product-launch-stages/#alpha--beta"
Copy link
Contributor

Choose a reason for hiding this comment

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

I imagine there may not be a(n easy) way around it, but there have been so many times I've accidentally wound up on the prod docs at some point while browsing a preview and didn't realize it which gets so confusing. If there's a way to avoid the absolute URL here that would be amazing 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya let me see what I can do!

Copy link
Member Author

Choose a reason for hiding this comment

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

Going to hit this in a followup PR. FWIW we used this exact link in our docs prior to 3.8. There's a chance apollographql/docs#719 might fix this as well 🙂

target="_blank"
>
{item.releaseTag.toLowerCase()} stage
</MDX.PrimaryLink>{" "}
and is subject to breaking changes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds a bit scary but is definitely the more efficient way to get the point across :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya I wish we could add messages to the alpha/beta tags in the doc blocks, but unfortunately not, so this was as generic as I could make it to try and cover everything. Oh well 😅

</MDX.ExperimentalFeature>
);
}

ReleaseTag.propTypes = {
canonicalReference: PropTypes.string.isRequired,
};
7 changes: 6 additions & 1 deletion docs/shared/ApiDoc/Function.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ export function FunctionDetails({
headingLevel={headingLevel}
since
/>
<DocBlock canonicalReference={canonicalReference} deprecated remarks />
<DocBlock
canonicalReference={canonicalReference}
deprecated
remarks
releaseTag
/>
{item.comment?.examples.length == 0 ? null : (
<>
<SubHeading
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/ApiDoc/PropertySignatureTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
FunctionSignature,
useApiDocContext,
ApiDocHeading,
SectionHeading,
} from ".";
import { GridItem, Text } from "@chakra-ui/react";
import { ResponsiveGrid } from "./ResponsiveGrid";
Expand Down Expand Up @@ -105,6 +104,7 @@ export function PropertySignatureTable({
summary
remarks
remarkCollapsible
releaseTag
/>
</GridItem>
</React.Fragment>
Expand Down
9 changes: 8 additions & 1 deletion docs/shared/ApiDoc/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export { useApiDocContext } from "./Context";
export { DocBlock, Deprecated, Example, Remarks, Summary } from "./DocBlock";
export {
DocBlock,
Deprecated,
Example,
Remarks,
ReleaseTag,
Summary,
} from "./DocBlock";
export { PropertySignatureTable } from "./PropertySignatureTable";
export { ApiDocHeading, SubHeading, SectionHeading } from "./Heading";
export { InterfaceDetails } from "./InterfaceDetails";
Expand Down
Loading