Avoid intermediate card component and use InfoCard directly

This commit is contained in:
Oliver Sand
2021-02-16 14:46:49 +01:00
parent dd95e2efd6
commit ec08562289
11 changed files with 41 additions and 129 deletions
@@ -31,20 +31,9 @@ import {
useEntity,
useRelatedEntities,
} from '@backstage/plugin-catalog-react';
import React, { PropsWithChildren } from 'react';
import React from 'react';
import { apiEntityColumns } from './presets';
const ApisCard = ({
children,
variant = 'gridItem',
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
return (
<InfoCard variant={variant} title="Consumed APIs">
{children}
</InfoCard>
);
};
type Props = {
/** @deprecated The entity is now grabbed from context instead */
entity?: Entity;
@@ -59,21 +48,21 @@ export const ConsumedApisCard = ({ variant = 'gridItem' }: Props) => {
if (loading) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="Consumed APIs">
<Progress />
</ApisCard>
</InfoCard>
);
}
if (error || !entities) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="Consumed APIs">
<WarningPanel
severity="error"
title="Could not load APIs"
message={<CodeSnippet text={`${error}`} language="text" />}
/>
</ApisCard>
</InfoCard>
);
}
@@ -27,20 +27,9 @@ import {
useEntity,
useRelatedEntities,
} from '@backstage/plugin-catalog-react';
import React, { PropsWithChildren } from 'react';
import React from 'react';
import { apiEntityColumns } from './presets';
const ApisCard = ({
children,
variant = 'gridItem',
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
return (
<InfoCard variant={variant} title="APIs">
{children}
</InfoCard>
);
};
type Props = {
variant?: 'gridItem';
};
@@ -54,21 +43,21 @@ export const HasApisCard = ({ variant = 'gridItem' }: Props) => {
if (loading) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="APIs">
<Progress />
</ApisCard>
</InfoCard>
);
}
if (error || !entities) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="APIs">
<WarningPanel
severity="error"
title="Could not load APIs"
message={<CodeSnippet text={`${error}`} language="text" />}
/>
</ApisCard>
</InfoCard>
);
}
@@ -31,20 +31,9 @@ import {
useEntity,
useRelatedEntities,
} from '@backstage/plugin-catalog-react';
import React, { PropsWithChildren } from 'react';
import React from 'react';
import { apiEntityColumns } from './presets';
const ApisCard = ({
children,
variant = 'gridItem',
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
return (
<InfoCard variant={variant} title="Provided APIs">
{children}
</InfoCard>
);
};
type Props = {
/** @deprecated The entity is now grabbed from context instead */
entity?: Entity;
@@ -59,21 +48,21 @@ export const ProvidedApisCard = ({ variant = 'gridItem' }: Props) => {
if (loading) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="Provided APIs">
<Progress />
</ApisCard>
</InfoCard>
);
}
if (error || !entities) {
return (
<ApisCard variant={variant}>
<InfoCard variant={variant} title="Provided APIs">
<WarningPanel
severity="error"
title="Could not load APIs"
message={<CodeSnippet text={`${error}`} language="text" />}
/>
</ApisCard>
</InfoCard>
);
}
@@ -31,18 +31,7 @@ import {
useEntity,
useRelatedEntities,
} from '@backstage/plugin-catalog-react';
import React, { PropsWithChildren } from 'react';
const ComponentsCard = ({
children,
variant = 'gridItem',
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
return (
<InfoCard variant={variant} title="Consumers">
{children}
</InfoCard>
);
};
import React from 'react';
type Props = {
/** @deprecated The entity is now grabbed from context instead */
@@ -58,21 +47,21 @@ export const ConsumingComponentsCard = ({ variant = 'gridItem' }: Props) => {
if (loading) {
return (
<ComponentsCard variant={variant}>
<InfoCard variant={variant} title="Consumers">
<Progress />
</ComponentsCard>
</InfoCard>
);
}
if (error || !entities) {
return (
<ComponentsCard variant={variant}>
<InfoCard variant={variant} title="Consumers">
<WarningPanel
severity="error"
title="Could not load components"
message={<CodeSnippet text={`${error}`} language="text" />}
/>
</ComponentsCard>
</InfoCard>
);
}
@@ -31,18 +31,7 @@ import {
useEntity,
useRelatedEntities,
} from '@backstage/plugin-catalog-react';
import React, { PropsWithChildren } from 'react';
const ComponentsCard = ({
children,
variant = 'gridItem',
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
return (
<InfoCard variant={variant} title="Providers">
{children}
</InfoCard>
);
};
import React from 'react';
type Props = {
/** @deprecated The entity is now grabbed from context instead */
@@ -58,21 +47,21 @@ export const ProvidingComponentsCard = ({ variant = 'gridItem' }: Props) => {
if (loading) {
return (
<ComponentsCard variant={variant}>
<InfoCard variant={variant} title="Providers">
<Progress />
</ComponentsCard>
</InfoCard>
);
}
if (error || !entities) {
return (
<ComponentsCard variant={variant}>
<InfoCard variant={variant} title="Providers">
<WarningPanel
severity="error"
title="Could not load components"
message={<CodeSnippet text={`${error}`} language="text" />}
/>
</ComponentsCard>
</InfoCard>
);
}