fix: pass down withSearch from EntityTechdocsContent component

Signed-off-by: Yasser Hennawi <yahennawi@gmail.com>
This commit is contained in:
Yasser Hennawi
2025-01-03 17:08:40 +01:00
parent 41ab5cf4a0
commit 3710b3507f
3 changed files with 28 additions and 11 deletions
+5
View File
@@ -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.
+12 -6
View File
@@ -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: (
@@ -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;
+11 -5
View File
@@ -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: '*',
@@ -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} />;
};