diff --git a/plugins/backstage-plugin-coder/README.md b/plugins/backstage-plugin-coder/README.md index eea90e07..5ddc8519 100644 --- a/plugins/backstage-plugin-coder/README.md +++ b/plugins/backstage-plugin-coder/README.md @@ -89,7 +89,7 @@ the devcontainer. ); ``` - + **Note:** You can also wrap a single page or component with `CoderProvider` if you only need Coder in a specific part of your app. See our [API reference](./docs/README.md) (particularly the section on [the `CoderProvider` component](./docs/components.md#coderprovider)) for more details. 1. Add the `CoderWorkspacesCard` card to the entity page in your app: diff --git a/plugins/backstage-plugin-coder/docs/README.md b/plugins/backstage-plugin-coder/docs/README.md new file mode 100644 index 00000000..7ca73a4e --- /dev/null +++ b/plugins/backstage-plugin-coder/docs/README.md @@ -0,0 +1,9 @@ +# Plugin API Reference – Coder for Backstage + +For users who need more information about how to extend and modify the Coder plugin. For general setup, please see our main [README](../README.md). + +## Documentation directory + +- [Components](./components.md) +- [Custom React hooks](./hooks.md) +- [Important types](./types.md) diff --git a/plugins/backstage-plugin-coder/docs/components.md b/plugins/backstage-plugin-coder/docs/components.md new file mode 100644 index 00000000..e37aff20 --- /dev/null +++ b/plugins/backstage-plugin-coder/docs/components.md @@ -0,0 +1,540 @@ +# Plugin API reference – React components + +This is the main documentation page for the Coder plugin's React components. + +## Component list + +- [`CoderAuthWrapper`](#coderauthwrapper) +- [`CoderErrorBoundary`](#codererrorboundary) +- [`CoderProvider`](#coderprovider) +- [`CoderWorkspacesCard`](#coderworkspacescard) + - [`CoderWorkspacesCard.CreateWorkspacesLink`](#coderworkspacescardcreateworkspaceslink) + - [`CoderWorkspacesCard.ExtraActionsButton`](#coderworkspacescardextraactionsbutton) + - [`CoderWorkspacesCard.HeaderRow`](#coderworkspacescardheaderrow) + - [`CoderWorkspacesCard.Root`](#coderworkspacescardroot) + - [`CoderWorkspacesCard.SearchBox`](#coderworkspacescardsearchbox) + - [`CoderWorkspacesCard.WorkspacesList`](#coderworkspacescardworkspaceslist) + - [`CoderWorkspacesCard.WorkspacesListIcon`](#coderworkspacescardworkspaceslisticon) + - [`CoderWorkspacesCard.WorkspacesListItem`](#coderworkspacescardworkspaceslistitem) + +## `CoderAuthWrapper` + +This component is designed to simplify authentication checks for other components that need to be authenticated with Coder. Place any child component inside the wrapper. If the user is authenticated, they will see the children. Otherwise, they will see a form for authenticating themselves. + +### Type signature + +```tsx +type Props = Readonly< + PropsWithChildren<{ + type: 'card'; + }> +>; + +declare function CoderAuthWrapper(props: Props): JSX.Element; +``` + +### Sample usage + +```tsx +function YourComponent() { + // This query requires authentication + const query = useCoderWorkspaces('owner:lil-brudder'); + return
{query.isLoading ? 'Loading' : 'Not loading'}
; +} + +Will never reach this code
; +} + +Your repo URL is {config.repoUrl}
; +} + +// All other components provided via @backstage/plugin-catalog +// and should be statically initialized +const overviewContent = ( +