Allow tableOptions prop on API cards
Signed-off-by: Michael Haley <mike.f.haley@gmail.com>
This commit is contained in:
@@ -14,7 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ApiEntity, RELATION_CONSUMES_API } from '@backstage/catalog-model';
|
||||
import {
|
||||
ApiEntity,
|
||||
Entity,
|
||||
RELATION_CONSUMES_API,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Typography } from '@material-ui/core';
|
||||
import {
|
||||
EntityTable,
|
||||
@@ -29,14 +33,19 @@ import {
|
||||
InfoCardVariants,
|
||||
Link,
|
||||
Progress,
|
||||
TableProps,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
type Props = {
|
||||
type Props<T extends Entity> = {
|
||||
variant?: InfoCardVariants;
|
||||
tableOptions?: TableProps<T>['options'];
|
||||
};
|
||||
|
||||
export const ConsumedApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
export const ConsumedApisCard = ({
|
||||
variant = 'gridItem',
|
||||
tableOptions = {},
|
||||
}: Props<ApiEntity>) => {
|
||||
const { entity } = useEntity();
|
||||
const { entities, loading, error } = useRelatedEntities(entity, {
|
||||
type: RELATION_CONSUMES_API,
|
||||
@@ -81,6 +90,7 @@ export const ConsumedApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
}
|
||||
columns={apiEntityColumns}
|
||||
entities={entities as ApiEntity[]}
|
||||
tableOptions={tableOptions}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ApiEntity, RELATION_HAS_PART } from '@backstage/catalog-model';
|
||||
import { ApiEntity, Entity, RELATION_HAS_PART } from '@backstage/catalog-model';
|
||||
import { Typography } from '@material-ui/core';
|
||||
import {
|
||||
EntityTable,
|
||||
@@ -30,11 +30,13 @@ import {
|
||||
Link,
|
||||
Progress,
|
||||
TableColumn,
|
||||
TableProps,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
type Props = {
|
||||
type Props<T extends Entity> = {
|
||||
variant?: InfoCardVariants;
|
||||
tableOptions?: TableProps<T>['options'];
|
||||
};
|
||||
|
||||
const columns: TableColumn<ApiEntity>[] = [
|
||||
@@ -45,7 +47,10 @@ const columns: TableColumn<ApiEntity>[] = [
|
||||
EntityTable.columns.createMetadataDescriptionColumn(),
|
||||
];
|
||||
|
||||
export const HasApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
export const HasApisCard = ({
|
||||
variant = 'gridItem',
|
||||
tableOptions = {},
|
||||
}: Props<ApiEntity>) => {
|
||||
const { entity } = useEntity();
|
||||
const { entities, loading, error } = useRelatedEntities(entity, {
|
||||
type: RELATION_HAS_PART,
|
||||
@@ -91,6 +96,7 @@ export const HasApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
}
|
||||
columns={columns}
|
||||
entities={entities as ApiEntity[]}
|
||||
tableOptions={tableOptions}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ApiEntity, RELATION_PROVIDES_API } from '@backstage/catalog-model';
|
||||
import {
|
||||
ApiEntity,
|
||||
Entity,
|
||||
RELATION_PROVIDES_API,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Typography } from '@material-ui/core';
|
||||
import {
|
||||
EntityTable,
|
||||
@@ -29,14 +33,19 @@ import {
|
||||
InfoCardVariants,
|
||||
Link,
|
||||
Progress,
|
||||
TableProps,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
type Props = {
|
||||
type Props<T extends Entity> = {
|
||||
variant?: InfoCardVariants;
|
||||
tableOptions?: TableProps<T>['options'];
|
||||
};
|
||||
|
||||
export const ProvidedApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
export const ProvidedApisCard = ({
|
||||
variant = 'gridItem',
|
||||
tableOptions = {},
|
||||
}: Props<ApiEntity>) => {
|
||||
const { entity } = useEntity();
|
||||
const { entities, loading, error } = useRelatedEntities(entity, {
|
||||
type: RELATION_PROVIDES_API,
|
||||
@@ -81,6 +90,7 @@ export const ProvidedApisCard = ({ variant = 'gridItem' }: Props) => {
|
||||
}
|
||||
columns={apiEntityColumns}
|
||||
entities={entities as ApiEntity[]}
|
||||
tableOptions={tableOptions}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import {
|
||||
ComponentEntity,
|
||||
Entity,
|
||||
RELATION_API_CONSUMED_BY,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Typography } from '@material-ui/core';
|
||||
@@ -31,14 +32,19 @@ import {
|
||||
InfoCardVariants,
|
||||
Link,
|
||||
Progress,
|
||||
TableProps,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
type Props = {
|
||||
type Props<T extends Entity> = {
|
||||
variant?: InfoCardVariants;
|
||||
tableOptions?: TableProps<T>['options'];
|
||||
};
|
||||
|
||||
export const ConsumingComponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
export const ConsumingComponentsCard = ({
|
||||
variant = 'gridItem',
|
||||
tableOptions = {},
|
||||
}: Props<ComponentEntity>) => {
|
||||
const { entity } = useEntity();
|
||||
const { entities, loading, error } = useRelatedEntities(entity, {
|
||||
type: RELATION_API_CONSUMED_BY,
|
||||
@@ -82,6 +88,7 @@ export const ConsumingComponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
}
|
||||
columns={EntityTable.componentEntityColumns}
|
||||
entities={entities as ComponentEntity[]}
|
||||
tableOptions={tableOptions}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import {
|
||||
ComponentEntity,
|
||||
Entity,
|
||||
RELATION_API_PROVIDED_BY,
|
||||
} from '@backstage/catalog-model';
|
||||
import { Typography } from '@material-ui/core';
|
||||
@@ -31,14 +32,19 @@ import {
|
||||
InfoCardVariants,
|
||||
Link,
|
||||
Progress,
|
||||
TableProps,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
type Props = {
|
||||
type Props<T extends Entity> = {
|
||||
variant?: InfoCardVariants;
|
||||
tableOptions?: TableProps<T>['options'];
|
||||
};
|
||||
|
||||
export const ProvidingComponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
export const ProvidingComponentsCard = ({
|
||||
variant = 'gridItem',
|
||||
tableOptions = {},
|
||||
}: Props<ComponentEntity>) => {
|
||||
const { entity } = useEntity();
|
||||
const { entities, loading, error } = useRelatedEntities(entity, {
|
||||
type: RELATION_API_PROVIDED_BY,
|
||||
@@ -82,6 +88,7 @@ export const ProvidingComponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
}
|
||||
columns={EntityTable.componentEntityColumns}
|
||||
entities={entities as ComponentEntity[]}
|
||||
tableOptions={tableOptions}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ export const EntityTable = <T extends Entity>(props: EntityTableProps<T>) => {
|
||||
emptyContent,
|
||||
variant = 'gridItem',
|
||||
columns,
|
||||
tableOptions,
|
||||
tableOptions = {},
|
||||
} = props;
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ export function DependencyOfComponentsCard(
|
||||
const {
|
||||
variant = 'gridItem',
|
||||
title = 'Dependency of components',
|
||||
tableOptions,
|
||||
tableOptions = {},
|
||||
} = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
|
||||
@@ -35,7 +35,7 @@ export function DependsOnComponentsCard(props: DependsOnComponentsCardProps) {
|
||||
const {
|
||||
variant = 'gridItem',
|
||||
title = 'Depends on components',
|
||||
tableOptions,
|
||||
tableOptions = {},
|
||||
} = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface DependsOnResourcesCardProps {
|
||||
}
|
||||
|
||||
export function DependsOnResourcesCard(props: DependsOnResourcesCardProps) {
|
||||
const { variant = 'gridItem', tableOptions } = props;
|
||||
const { variant = 'gridItem', tableOptions = {} } = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
variant={variant}
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface HasComponentsCardProps {
|
||||
}
|
||||
|
||||
export function HasComponentsCard(props: HasComponentsCardProps) {
|
||||
const { variant = 'gridItem', tableOptions } = props;
|
||||
const { variant = 'gridItem', tableOptions = {} } = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
variant={variant}
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface HasResourcesCardProps {
|
||||
}
|
||||
|
||||
export function HasResourcesCard(props: HasResourcesCardProps) {
|
||||
const { variant = 'gridItem', tableOptions } = props;
|
||||
const { variant = 'gridItem', tableOptions = {} } = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
variant={variant}
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface HasSubcomponentsCardProps {
|
||||
}
|
||||
|
||||
export function HasSubcomponentsCard(props: HasSubcomponentsCardProps) {
|
||||
const { variant = 'gridItem', tableOptions } = props;
|
||||
const { variant = 'gridItem', tableOptions = {} } = props;
|
||||
return (
|
||||
<RelatedEntitiesCard
|
||||
variant={variant}
|
||||
|
||||
@@ -68,7 +68,7 @@ export function RelatedEntitiesCard<T extends Entity>(
|
||||
relationType,
|
||||
emptyMessage,
|
||||
emptyHelpLink,
|
||||
tableOptions,
|
||||
tableOptions = {},
|
||||
asRenderableEntities,
|
||||
} = props;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user