@@ -232,8 +232,10 @@ export interface PanelConfig {
|
||||
filterPredicate: ((entity: Entity) => boolean) | string;
|
||||
// (undocumented)
|
||||
panelCSS?: CSSProperties;
|
||||
// Warning: (ae-forgotten-export) The symbol "PanelProps" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
panelProps?: Record<string, any>;
|
||||
panelProps?: PanelProps;
|
||||
// (undocumented)
|
||||
panelType: PanelType;
|
||||
// (undocumented)
|
||||
@@ -329,7 +331,7 @@ export type TechDocsCustomHomeProps = {
|
||||
filter?: EntityFilterQuery;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
hideSubtitle?: boolean;
|
||||
showSubtitle?: boolean;
|
||||
};
|
||||
|
||||
// @public @deprecated (undocumented)
|
||||
@@ -347,7 +349,7 @@ export type TechDocsIndexPageProps = {
|
||||
actions?: TableProps<DocsTableRow>['actions'];
|
||||
ownerPickerMode?: EntityOwnerPickerProps['mode'];
|
||||
showHeader?: boolean;
|
||||
hideSupport?: boolean;
|
||||
showSupport?: boolean;
|
||||
options?: TableOptions<DocsTableRow>;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
@@ -369,7 +371,7 @@ export type TechDocsPageWrapperProps = {
|
||||
children?: React_2.ReactNode;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
hideSubtitle?: boolean;
|
||||
showSubtitle?: boolean;
|
||||
};
|
||||
|
||||
// @public
|
||||
|
||||
@@ -51,17 +51,17 @@ export const DefaultTechDocsHome = (props: TechDocsIndexPageProps) => {
|
||||
columns,
|
||||
actions,
|
||||
ownerPickerMode,
|
||||
showHeader,
|
||||
showHeader = true,
|
||||
options,
|
||||
title,
|
||||
subtitle,
|
||||
hideSupport,
|
||||
showSupport = true,
|
||||
} = props;
|
||||
const Wrapper = showHeader !== false ? TechDocsPageWrapper : React.Fragment;
|
||||
const Wrapper = showHeader ? TechDocsPageWrapper : React.Fragment;
|
||||
return (
|
||||
<Wrapper title={title} subtitle={subtitle}>
|
||||
<Content>
|
||||
{hideSupport !== true && (
|
||||
{showSupport && (
|
||||
<ContentHeader title="">
|
||||
<SupportButton>
|
||||
Discover documentation in your ecosystem.
|
||||
|
||||
@@ -127,7 +127,7 @@ describe('TechDocsCustomHome', () => {
|
||||
screen.queryByText('Discover documentation in your ecosystem.'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
it('should render SupportButton based on hideSupport prop', async () => {
|
||||
it('should render SupportButton based on showSupport prop', async () => {
|
||||
const tabsConfig = [
|
||||
{
|
||||
label: 'First Tab',
|
||||
@@ -137,7 +137,7 @@ describe('TechDocsCustomHome', () => {
|
||||
description: 'First Tab Description',
|
||||
panelType: 'DocsCardGrid' as PanelType,
|
||||
filterPredicate: () => true,
|
||||
panelProps: { hideSupport: true },
|
||||
panelProps: { showSupport: false },
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -158,7 +158,7 @@ describe('TechDocsCustomHome', () => {
|
||||
screen.queryByText('Discover documentation in your ecosystem.'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
it('should hide subtitle when hideSubtitle is true', async () => {
|
||||
it('should hide subtitle when showSubtitle is false', async () => {
|
||||
const tabsConfig = [
|
||||
{
|
||||
label: 'First Tab',
|
||||
@@ -179,7 +179,7 @@ describe('TechDocsCustomHome', () => {
|
||||
tabsConfig={tabsConfig}
|
||||
title="Custom Title"
|
||||
subtitle="Custom Subtitle"
|
||||
hideSubtitle
|
||||
showSubtitle={false}
|
||||
/>
|
||||
</ApiProvider>,
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
useEntityOwnership,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { DocsTable } from './Tables';
|
||||
import { DocsTable, DocsTableRow } from './Tables';
|
||||
import { DocsCardGrid, InfoCardGrid } from './Grids';
|
||||
import { TechDocsPageWrapper } from './TechDocsPageWrapper';
|
||||
import { TechDocsIndexPage } from './TechDocsIndexPage';
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
WarningPanel,
|
||||
SupportButton,
|
||||
ContentHeader,
|
||||
TableOptions,
|
||||
} from '@backstage/core-components';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';
|
||||
@@ -61,6 +62,19 @@ export type PanelType =
|
||||
| 'TechDocsIndexPage'
|
||||
| 'InfoCardGrid';
|
||||
|
||||
/**
|
||||
* Type representing Panel props
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface PanelProps {
|
||||
showHeader?: boolean;
|
||||
showSupport?: boolean;
|
||||
options?: TableOptions<DocsTableRow>;
|
||||
linkContent?: string | JSX.Element;
|
||||
linkDestination?: (entity: Entity) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type representing a TechDocsCustomHome panel.
|
||||
*
|
||||
@@ -72,7 +86,7 @@ export interface PanelConfig {
|
||||
panelType: PanelType;
|
||||
panelCSS?: CSSProperties;
|
||||
filterPredicate: ((entity: Entity) => boolean) | string;
|
||||
panelProps?: Record<string, any>;
|
||||
panelProps?: PanelProps;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +149,7 @@ export const CustomDocsPanel = ({
|
||||
<>
|
||||
{config.panelProps?.showHeader !== false && (
|
||||
<ContentHeader title={config.title} description={config.description}>
|
||||
{index === 0 && config.panelProps?.hideSupport !== true && (
|
||||
{index === 0 && config.panelProps?.showSupport !== false && (
|
||||
<SupportButton>
|
||||
Discover documentation in your ecosystem.
|
||||
</SupportButton>
|
||||
@@ -163,11 +177,11 @@ export type TechDocsCustomHomeProps = {
|
||||
filter?: EntityFilterQuery;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
hideSubtitle?: boolean;
|
||||
showSubtitle?: boolean;
|
||||
};
|
||||
|
||||
export const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {
|
||||
const { tabsConfig, filter, title, subtitle, hideSubtitle } = props;
|
||||
const { tabsConfig, filter, title, subtitle, showSubtitle = true } = props;
|
||||
const [selectedTab, setSelectedTab] = useState<number>(0);
|
||||
const catalogApi: CatalogApi = useApi(catalogApiRef);
|
||||
|
||||
@@ -202,7 +216,7 @@ export const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {
|
||||
<TechDocsPageWrapper
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
hideSubtitle={hideSubtitle}
|
||||
showSubtitle={showSubtitle}
|
||||
>
|
||||
<Content>
|
||||
<Progress />
|
||||
@@ -216,7 +230,7 @@ export const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {
|
||||
<TechDocsPageWrapper
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
hideSubtitle={hideSubtitle}
|
||||
showSubtitle={showSubtitle}
|
||||
>
|
||||
<Content>
|
||||
<WarningPanel
|
||||
@@ -234,7 +248,7 @@ export const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {
|
||||
<TechDocsPageWrapper
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
hideSubtitle={hideSubtitle}
|
||||
showSubtitle={showSubtitle}
|
||||
>
|
||||
<HeaderTabs
|
||||
selectedIndex={selectedTab}
|
||||
|
||||
@@ -39,7 +39,7 @@ export type TechDocsIndexPageProps = {
|
||||
actions?: TableProps<DocsTableRow>['actions'];
|
||||
ownerPickerMode?: EntityOwnerPickerProps['mode'];
|
||||
showHeader?: boolean;
|
||||
hideSupport?: boolean;
|
||||
showSupport?: boolean;
|
||||
options?: TableOptions<DocsTableRow>;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
|
||||
@@ -28,7 +28,7 @@ export type TechDocsPageWrapperProps = {
|
||||
children?: React.ReactNode;
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
hideSubtitle?: boolean;
|
||||
showSubtitle?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ export type TechDocsPageWrapperProps = {
|
||||
* @public
|
||||
*/
|
||||
export const TechDocsPageWrapper = (props: TechDocsPageWrapperProps) => {
|
||||
const { children, title, subtitle, hideSubtitle } = props;
|
||||
const { children, title, subtitle, showSubtitle = true } = props;
|
||||
const configApi = useApi(configApiRef);
|
||||
const generatedSubtitle =
|
||||
subtitle ||
|
||||
@@ -48,7 +48,7 @@ export const TechDocsPageWrapper = (props: TechDocsPageWrapperProps) => {
|
||||
return (
|
||||
<PageWithHeader
|
||||
title={title || 'Documentation'}
|
||||
subtitle={hideSubtitle ? undefined : generatedSubtitle}
|
||||
subtitle={showSubtitle ? generatedSubtitle : undefined}
|
||||
themeId="documentation"
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user