Avoid intermediate card component and use InfoCard directly
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+5
-16
@@ -27,18 +27,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="Components">
|
||||
{children}
|
||||
</InfoCard>
|
||||
);
|
||||
};
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
variant?: 'gridItem';
|
||||
@@ -53,21 +42,21 @@ export const HasComponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<ComponentsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Components">
|
||||
<Progress />
|
||||
</ComponentsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !entities) {
|
||||
return (
|
||||
<ComponentsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Components">
|
||||
<WarningPanel
|
||||
severity="error"
|
||||
title="Could not load components"
|
||||
message={<CodeSnippet text={`${error}`} language="text" />}
|
||||
/>
|
||||
</ComponentsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,18 +27,7 @@ import {
|
||||
useEntity,
|
||||
useRelatedEntities,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
|
||||
const SubcomponentsCard = ({
|
||||
children,
|
||||
variant = 'gridItem',
|
||||
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
|
||||
return (
|
||||
<InfoCard variant={variant} title="Subcomponents">
|
||||
{children}
|
||||
</InfoCard>
|
||||
);
|
||||
};
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
variant?: 'gridItem';
|
||||
@@ -53,21 +42,21 @@ export const HasSubcomponentsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<SubcomponentsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Subcomponents">
|
||||
<Progress />
|
||||
</SubcomponentsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !entities) {
|
||||
return (
|
||||
<SubcomponentsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Subcomponents">
|
||||
<WarningPanel
|
||||
severity="error"
|
||||
title="Could not load subcomponents"
|
||||
message={<CodeSnippet text={`${error}`} language="text" />}
|
||||
/>
|
||||
</SubcomponentsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,18 +27,7 @@ import {
|
||||
useEntity,
|
||||
useRelatedEntities,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
|
||||
const SystemsCard = ({
|
||||
children,
|
||||
variant = 'gridItem',
|
||||
}: PropsWithChildren<{ variant?: 'gridItem' }>) => {
|
||||
return (
|
||||
<InfoCard variant={variant} title="Systems">
|
||||
{children}
|
||||
</InfoCard>
|
||||
);
|
||||
};
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
variant?: 'gridItem';
|
||||
@@ -52,21 +41,21 @@ export const HasSystemsCard = ({ variant = 'gridItem' }: Props) => {
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<SystemsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Systems">
|
||||
<Progress />
|
||||
</SystemsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !entities) {
|
||||
return (
|
||||
<SystemsCard variant={variant}>
|
||||
<InfoCard variant={variant} title="Systems">
|
||||
<WarningPanel
|
||||
severity="error"
|
||||
title="Could not load systems"
|
||||
message={<CodeSnippet text={`${error}`} language="text" />}
|
||||
/>
|
||||
</SystemsCard>
|
||||
</InfoCard>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ export const EntityHasComponentsCard = catalogPlugin.provide(
|
||||
createComponentExtension({
|
||||
component: {
|
||||
lazy: () =>
|
||||
import('./components/ComponentsCard').then(m => m.HasComponentsCard),
|
||||
import('./components/HasComponentsCard').then(m => m.HasComponentsCard),
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user