Skip to content

Commit

Permalink
Merge pull request backstage#28361 from yasserhennawi/master
Browse files Browse the repository at this point in the history
Pass down `withSearch` from `EntityTechdocsContent` component
  • Loading branch information
awanlin authored Jan 6, 2025
2 parents 41ab5cf + 3710b35 commit 1452040
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-deers-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-techdocs': patch
---

Allow passing down `withSearch` prop to `EntityTechdocsContent` component since it was `true` by default, now user can use the `EntityTechdocsContent` component _without_ showing the search field on top of the content.
18 changes: 12 additions & 6 deletions plugins/techdocs/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ export type DocsTableRow = {
};

// @public
export const EmbeddedDocsRouter: (
props: PropsWithChildren<{}>,
) => React_2.JSX.Element;
export const EmbeddedDocsRouter: ({
children,
withSearch,
}: React_2.PropsWithChildren<{
withSearch?: boolean | undefined;
}>) => React_2.JSX.Element;

// @public
export const EntityListDocsGrid: (
Expand Down Expand Up @@ -191,9 +194,12 @@ export type EntityListDocsTableProps = {
};

// @public
export const EntityTechdocsContent: (props: {
children?: ReactNode;
}) => JSX_2.Element;
export const EntityTechdocsContent: ({
children,
withSearch,
}: PropsWithChildren<{
withSearch?: boolean | undefined;
}>) => JSX_2.Element;

// @public
export const isTechDocsAvailable: (entity: Entity) => boolean;
Expand Down
16 changes: 11 additions & 5 deletions plugins/techdocs/src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ export const Router = () => {
};

export const EmbeddedDocsRouter = (
props: PropsWithChildren<{ emptyState?: React.ReactElement }>,
props: PropsWithChildren<{
emptyState?: React.ReactElement;
withSearch?: boolean;
}>,
) => {
const { children, emptyState } = props;
const { children, emptyState, withSearch = true } = props;
const { entity } = useEntity();

// Using objects instead of <Route> elements, otherwise "outlet" will be null on sub-pages and add-ons won't render
const element = useRoutes([
{
path: '/*',
element: <EntityPageDocs entity={entity} />,
element: <EntityPageDocs entity={entity} withSearch={withSearch} />,
children: [
{
path: '*',
Expand Down Expand Up @@ -96,8 +99,11 @@ export const EmbeddedDocsRouter = (
*
* @public
*/
export const LegacyEmbeddedDocsRouter = (props: PropsWithChildren<{}>) => {
export const LegacyEmbeddedDocsRouter = ({
children,
withSearch = true,
}: PropsWithChildren<{ withSearch?: boolean }>) => {
// Wrap the Router to avoid exposing the emptyState prop in the non-alpha
// public API and make it easier for us to change later.
return <EmbeddedDocsRouter children={props.children} />;
return <EmbeddedDocsRouter children={children} withSearch={withSearch} />;
};

0 comments on commit 1452040

Please sign in to comment.