10000 docs: add API documentation for Coder plugin by Parkreiner · Pull Request #15 · coder/backstage-plugins · GitHub
[go: up one dir, main page]

Skip to content

docs: add API documentation for Coder plugin #15

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

Merged
merged 36 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7153251
docs: finish drafts for hooks/types README files
Parkreiner Mar 4, 2024
6d67225
wip: add stub for components README
Parkreiner Mar 4, 2024
be54ee6
fix: remove typo in main docs
Parkreiner Mar 4, 2024
cb0d816
wip: add stub for component docs
Parkreiner Mar 4, 2024
d0fa96c
wip: add outline for component documentation
Parkreiner Mar 4, 2024
aead300
docs: add documentation for CoderAuthWrapper and CoderErrorBoundary
Parkreiner Mar 5, 2024
d37ae30
docs: finish up section for CoderProvider
Parkreiner Mar 5, 2024
5fed31e
fix: update typo in library name
Parkreiner Mar 5, 2024
89fde98
docs: finish section for CoderAppConfig
Parkreiner Mar 5, 2024
06963f7
fix: export useWorkspacesCardContext
Parkreiner Mar 5, 2024
a2e2e4b
docs: finish section for useWorkspacesCardContext
Parkreiner Mar 5, 2024
c89d7ad
wip: add stubs for CoderWorkspacesCard
Parkreiner Mar 5, 2024
e4d5e0a
fix: update link in main directory README
Parkreiner Mar 5, 2024
3f8c852
docs: add more info to component docs
Parkreiner Mar 6, 2024
4a31ac6
fix: ensure link configs are combined properly
Parkreiner Mar 6, 2024
93bb583
docs: finish docs for CreateWorkspacesLink
Parkreiner Mar 6, 2024
833ad2d
docs: finish section for ExtraActionsButton
Parkreiner Mar 6, 2024
cbca5fb
docs: finish section for HeaderRow
Parkreiner Mar 6, 2024
21f06eb
docs: finish Root
Parkreiner Mar 6, 2024
f3a8dae
docs: finish section for SearchBox
Parkreiner Mar 6, 2024
88bd95d
docs: finish rough draft of API docs
Parkreiner Mar 7, 2024
cfe2c4d
Merge branch 'main' into mes/coder-api-docs
Parkreiner Mar 7, 2024
605b2b9
fix: fill in missing section for CoderProvider
Parkreiner Mar 7, 2024
d5a46af
chore: move API docs up one level
Parkreiner Mar 7, 2024
abfcf0f
docs: fill in link for TODO comment
Parkreiner Mar 7, 2024
799132c
fix: reword docs message for clarity
Parkreiner Mar 7, 2024
8085717
Update plugins/backstage-plugin-coder/docs/README.md
Parkreiner Mar 7, 2024
54c65c2
fix: update version for Coder plugin
Parkreiner Mar 7, 2024
4511773
Merge branch 'mes/coder-api-docs' of github.com:coder/backstage-plugi…
Parkreiner Mar 7, 2024
dd56f00
docs: add info about useCoderEntityConfig
Parkreiner Mar 7, 2024
a899bad
fix: make sure all exported components have unique name values
Parkreiner Mar 8, 2024
af5e67a
fix: make sure all values are properly exported at top-level plugin root
Parkreiner Mar 8, 2024
6d67468
Merge branch 'main' into mes/coder-api-docs
Parkreiner Mar 8, 2024
3a09f9c
fix: remove forwardRef from exported sub-components
Parkreiner Mar 8, 2024
f99a1a4
fix: remove forwardRef from Root
Parkreiner Mar 8, 2024
63a71e8
Merge branch 'main' into mes/coder-api-docs
Parkreiner Mar 11, 2024
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
Prev Previous commit
Next Next commit
fix: remove forwardRef from Root
  • Loading branch information
Parkreiner committed Mar 8, 2024
commit f99a1a485f3430f1591034905ba8f9bef95d7bed
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {
type HTMLAttributes,
createContext,
forwardRef,
useContext,
useState,
} from 'react';
Expand Down Expand Up @@ -61,67 +60,58 @@ export type WorkspacesCardProps = Readonly<
}
>;

export const Root = forwardRef<HTMLDivElement, WorkspacesCardProps>(
(props, ref) => {
const {
children,
className,
queryFilter: outerFilter,
onFilterChange: onOuterFilterChange,
defaultQueryFilter = 'owner:me',
readEntityData = false,
...delegatedProps
} = props;

const hookId = useId();
const [innerFilter, setInnerFilter] = useState(defaultQueryFilter);
const activeFilter = outerFilter ?? innerFilter;

const dynamicConfig = useDynamicEntityConfig(readEntityData);
const workspacesQuery = useCoderWorkspaces(activeFilter, {
repoConfig: dynamicConfig,
});

const headerId = `${hookId}-header`;

return (
<CoderAuthWrapper type="card">
<CardContext.Provider
value={{
headerId,
workspacesQuery,
queryFilter: activeFilter,
entityConfig: dynamicConfig,
onFilterChange: newFilter => {
setInnerFilter(newFilter);
onOuterFilterChange?.(newFilter);
},
}}
>
{/*
* 2024-01-31: This output is a <div>, but that should be changed to a
* <search> once it's supported by more browsers. Setting up
* accessibility markup and landmark behavior manually in the meantime
*/}
<Card
ref={ref}
role="search"
aria-labelledby={headerId}
{...delegatedProps}
>
{/* Want to expose the overall container as a form for good
semantics and screen reader support, but since there isn't an
explicit submission process (queries happen automatically),
CDA4 using a base div with a role override to side-step edge cases
around keyboard input and button children seems like the easiest
approach */}
<div role="form">{children}</div>
</Card>
</CardContext.Provider>
</CoderAuthWrapper>
);
},
);
export const Root = ({
children,
className,
queryFilter: outerFilter,
onFilterChange: onOuterFilterChange,
defaultQueryFilter = 'owner:me',
readEntityData = false,
...delegatedProps
}: WorkspacesCardProps) => {
const hookId = useId();
const [innerFilter, setInnerFilter] = useState(defaultQueryFilter);
const activeFilter = outerFilter ?? innerFilter;

const dynamicConfig = useDynamicEntityConfig(readEntityData);
const workspacesQuery = useCoderWorkspaces(activeFilter, {
repoConfig: dynamicConfig,
});

const headerId = `${hookId}-header`;

return (
<CoderAuthWrapper type="card">
<CardContext.Provider
value={{
headerId,
workspacesQuery,
queryFilter: activeFilter,
entityConfig: dynamicConfig,
onFilterChange: newFilter => {
setInnerFilter(newFilter);
onOuterFilterChange?.(newFilter);
},
}}
>
{/*
* 2024-01-31: This output is a <div>, but that should be changed to a
* <search> once it's supported by more browsers. Setting up
* accessibility markup and landmark behavior manually in the meantime
*/}
<Card role="search" aria-labelledby={headerId} {...delegatedProps}>
{/* Want to expose the overall container as a form for good
semantics and screen reader support, but since there isn't an
explicit submission process (queries happen automatically),
using a base div with a role override to side-step edge cases
around keyboard input and button children seems like the easiest
approach */}
<div role="form">{children}</div>
</Card>
</CardContext.Provider>
</CoderAuthWrapper>
);
};

export function useWorkspacesCardContext(): WorkspacesCardContext {
const contextValue = useContext(CardContext);
Expand Down
0