@backstage/plugin-api-docs 0.13.5-next.1 → 0.13.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,12 +2,16 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { RELATION_CONSUMES_API } from '@backstage/catalog-model';
3
3
  import Typography from '@material-ui/core/Typography';
4
4
  import { useEntity, useRelatedEntities, EntityTable } from '@backstage/plugin-catalog-react';
5
- import { getApiEntityColumns } from './presets.esm.js';
5
+ import { EntityRelationCard } from '@backstage/plugin-catalog-react/alpha';
6
+ import { getApiEntityColumnConfig, getApiEntityColumns } from './presets.esm.js';
6
7
  import { InfoCard, Progress, WarningPanel, CodeSnippet, Link } from '@backstage/core-components';
7
8
  import { useTranslationRef } from '@backstage/frontend-plugin-api';
8
9
  import { apiDocsTranslationRef } from '../../translation.esm.js';
9
10
 
10
- const ConsumedApisCard = (props) => {
11
+ function isLegacyProps(props) {
12
+ return "variant" in props || "columns" in props || "tableOptions" in props;
13
+ }
14
+ function ConsumedApisCardLegacy(props) {
11
15
  const { t } = useTranslationRef(apiDocsTranslationRef);
12
16
  const {
13
17
  variant = "gridItem",
@@ -55,6 +59,31 @@ const ConsumedApisCard = (props) => {
55
59
  entities
56
60
  }
57
61
  );
62
+ }
63
+ const ConsumedApisCard = (props) => {
64
+ const { t } = useTranslationRef(apiDocsTranslationRef);
65
+ const { entity } = useEntity();
66
+ if (isLegacyProps(props)) {
67
+ return /* @__PURE__ */ jsx(ConsumedApisCardLegacy, { ...props });
68
+ }
69
+ const {
70
+ title = t("consumedApisCard.title"),
71
+ columnConfig = getApiEntityColumnConfig(t)
72
+ } = props;
73
+ return /* @__PURE__ */ jsx(
74
+ EntityRelationCard,
75
+ {
76
+ title,
77
+ relationType: RELATION_CONSUMES_API,
78
+ columnConfig,
79
+ emptyState: {
80
+ message: t("consumedApisCard.emptyContent.title", {
81
+ entity: entity.kind.toLocaleLowerCase("en-US")
82
+ }),
83
+ helpLink: "https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional"
84
+ }
85
+ }
86
+ );
58
87
  };
59
88
 
60
89
  export { ConsumedApisCard };
@@ -1 +1 @@
1
- {"version":3,"file":"ConsumedApisCard.esm.js","sources":["../../../src/components/ApisCards/ConsumedApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_CONSUMES_API } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport { getApiEntityColumns } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/**\n * @public\n */\nexport const ConsumedApisCard = (props: {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ApiEntity>[];\n tableOptions?: TableOptions;\n}) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('consumedApisCard.title'),\n columns = getApiEntityColumns(t),\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_CONSUMES_API,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('consumedApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('consumedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link\n to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional\"\n externalLinkIcon\n >\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ApiEntity[]}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAwCO,MAAM,gBAAA,GAAmB,CAAC,KAAA,KAK3B;AACJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,wBAAwB,CAAA;AAAA,IAClC,OAAA,GAAU,oBAAoB,CAAC,CAAA;AAAA,IAC/B,eAAe;AAAC,GAClB,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,EAAE,QAAA,EAAU,OAAA,EAAS,KAAA,EAAM,GAAI,mBAAmB,MAAA,EAAQ;AAAA,IAC9D,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,2BACG,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,YAAS,CAAA,EACZ,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,KAAA,IAAS,CAAC,QAAA,EAAU;AACtB,IAAA,uBACE,GAAA,CAAC,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,QAAA,EAAS,OAAA;AAAA,QACT,KAAA,EAAO,EAAE,8BAA8B,CAAA;AAAA,QACvC,OAAA,sBAAU,WAAA,EAAA,EAAY,IAAA,EAAM,GAAG,KAAK,CAAA,CAAA,EAAI,UAAS,MAAA,EAAO;AAAA;AAAA,KAC1D,EACF,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,OAAA;AAAA,MACA,8BACE,IAAA,CAAC,KAAA,EAAA,EAAI,OAAO,EAAE,SAAA,EAAW,UAAS,EAChC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EACjB,QAAA,EAAA,CAAA,CAAE,qCAAA,EAAuC;AAAA,UACxC,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,iBAAA,CAAkB,OAAO;AAAA,SAC9C,CAAA,EACH,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAClB,QAAA,kBAAA,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,EAAA,EAAG,iGAAA;AAAA,YACH,gBAAA,EAAgB,IAAA;AAAA,YAEf,YAAE,uBAAuB;AAAA;AAAA,SAC5B,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"ConsumedApisCard.esm.js","sources":["../../../src/components/ApisCards/ConsumedApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_CONSUMES_API } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityRelationCard,\n EntityColumnConfig,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { getApiEntityColumns, getApiEntityColumnConfig } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport interface ConsumedApisCardProps {\n title?: string;\n columnConfig?: EntityColumnConfig[];\n}\n\n/**\n * Props for the legacy MUI-based rendering.\n * @deprecated Use {@link ConsumedApisCardProps} instead.\n * @public\n */\nexport interface ConsumedApisCardLegacyProps {\n title?: string;\n /** @deprecated Use `columnConfig` instead. */\n variant?: InfoCardVariants;\n /** @deprecated Use `columnConfig` instead. */\n columns?: TableColumn<ApiEntity>[];\n /** @deprecated Use `columnConfig` instead. */\n tableOptions?: TableOptions;\n}\n\nfunction isLegacyProps(\n props: ConsumedApisCardProps | ConsumedApisCardLegacyProps,\n): props is ConsumedApisCardLegacyProps {\n return 'variant' in props || 'columns' in props || 'tableOptions' in props;\n}\n\nfunction ConsumedApisCardLegacy(props: ConsumedApisCardLegacyProps) {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('consumedApisCard.title'),\n columns = getApiEntityColumns(t),\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_CONSUMES_API,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('consumedApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('consumedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link\n to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional\"\n externalLinkIcon\n >\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ApiEntity[]}\n />\n );\n}\n\n/**\n * @public\n */\nexport const ConsumedApisCard = (\n props: ConsumedApisCardProps | ConsumedApisCardLegacyProps,\n) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const { entity } = useEntity();\n\n if (isLegacyProps(props)) {\n return <ConsumedApisCardLegacy {...props} />;\n }\n\n const {\n title = t('consumedApisCard.title'),\n columnConfig = getApiEntityColumnConfig(t),\n } = props;\n\n return (\n <EntityRelationCard\n title={title}\n relationType={RELATION_CONSUMES_API}\n columnConfig={columnConfig}\n emptyState={{\n message: t('consumedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n }),\n helpLink:\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional',\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA8DA,SAAS,cACP,KAAA,EACsC;AACtC,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,SAAA,IAAa,KAAA,IAAS,cAAA,IAAkB,KAAA;AACvE;AAEA,SAAS,uBAAuB,KAAA,EAAoC;AAClE,EAAA,MAAM,EAAE,CAA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, jsxs } from 'react/jsx-runtime';
2
2
  import { RELATION_HAS_PART } from '@backstage/catalog-model';
3
3
  import Typography from '@material-ui/core/Typography';
4
- import { EntityTable, useEntity, useRelatedEntities } from '@backstage/plugin-catalog-react';
4
+ import { useEntity, EntityTable, useRelatedEntities } from '@backstage/plugin-catalog-react';
5
+ import { EntityRelationCard } from '@backstage/plugin-catalog-react/alpha';
5
6
  import { useMemo } from 'react';
6
- import { createSpecApiTypeColumn } from './presets.esm.js';
7
+ import { getHasApisColumnConfig, createSpecApiTypeColumn } from './presets.esm.js';
7
8
  import { InfoCard, Progress, WarningPanel, CodeSnippet, Link } from '@backstage/core-components';
8
9
  import { useTranslationRef } from '@backstage/frontend-plugin-api';
9
10
  import { apiDocsTranslationRef } from '../../translation.esm.js';
10
11
 
11
- const HasApisCard = (props) => {
12
+ function isLegacyProps(props) {
13
+ return "variant" in props || "columns" in props || "tableOptions" in props;
14
+ }
15
+ function HasApisCardLegacy(props) {
12
16
  const { t } = useTranslationRef(apiDocsTranslationRef);
13
17
  const presetColumns = useMemo(() => {
14
18
  return [
@@ -59,6 +63,32 @@ const HasApisCard = (props) => {
59
63
  entities
60
64
  }
61
65
  );
66
+ }
67
+ const HasApisCard = (props) => {
68
+ const { t } = useTranslationRef(apiDocsTranslationRef);
69
+ const { entity } = useEntity();
70
+ if (isLegacyProps(props)) {
71
+ return /* @__PURE__ */ jsx(HasApisCardLegacy, { ...props });
72
+ }
73
+ const {
74
+ title = t("hasApisCard.title"),
75
+ columnConfig = getHasApisColumnConfig(t)
76
+ } = props;
77
+ return /* @__PURE__ */ jsx(
78
+ EntityRelationCard,
79
+ {
80
+ title,
81
+ entityKind: "API",
82
+ relationType: RELATION_HAS_PART,
83
+ columnConfig,
84
+ emptyState: {
85
+ message: t("hasApisCard.emptyContent.title", {
86
+ entity: entity.kind.toLocaleLowerCase("en-US")
87
+ }),
88
+ helpLink: "https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api"
89
+ }
90
+ }
91
+ );
62
92
  };
63
93
 
64
94
  export { HasApisCard };
@@ -1 +1 @@
1
- {"version":3,"file":"HasApisCard.esm.js","sources":["../../../src/components/ApisCards/HasApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_HAS_PART } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport { useMemo } from 'react';\nimport { createSpecApiTypeColumn } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/**\n * @public\n */\nexport const HasApisCard = (props: {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ApiEntity>[];\n tableOptions?: TableOptions;\n}) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const presetColumns: TableColumn<ApiEntity>[] = useMemo(() => {\n return [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'API' }),\n EntityTable.columns.createOwnerColumn(),\n createSpecApiTypeColumn(t),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n ];\n }, [t]);\n const {\n variant = 'gridItem',\n title = t('hasApisCard.title'),\n columns = presetColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_HAS_PART,\n kind: 'API',\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('hasApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('hasApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ApiEntity[]}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyCO,MAAM,WAAA,GAAc,CAAC,KAAA,KAKtB;AACJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM,aAAA,GAA0C,QAAQ,MAAM;AAC5D,IAAA,OAAO;AAAA,MACL,YAAY,OAAA,CAAQ,qBAAA,CAAsB,EAAE,WAAA,EAAa,OAAO,CAAA;AAAA,MAChE,WAAA,CAAY,QAAQ,iBAAA,EAAkB;AAAA,MACtC,wBAAwB,CAAC,CAAA;AAAA,MACzB,WAAA,CAAY,QAAQ,yBAAA,EAA0B;AAAA,MAC9C,WAAA,CAAY,QAAQ,+BAAA;AAAgC,KACtD;AAAA,EACF,CAAA,EAAG,CAAC,CAAC,CAAC,CAAA;AACN,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,mBAAmB,CAAA;AAAA,IAC7B,OAAA,GAAU,aAAA;AAAA,IACV,eAAe;AAAC,GAClB,GAA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BAAA,GAAA,CAAC,IAAA,EAAA,EAAK,EAAA,EAAG,gFAAA,EACN,QAAA,EAAA,CAAA,CAAE,uBAAuB,CAAA,EAC5B,CAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"HasApisCard.esm.js","sources":["../../../src/components/ApisCards/HasApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_HAS_PART } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityRelationCard,\n EntityColumnConfig,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { useMemo } from 'react';\nimport { createSpecApiTypeColumn, getHasApisColumnConfig } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport interface HasApisCardProps {\n title?: string;\n columnConfig?: EntityColumnConfig[];\n}\n\n/**\n * Props for the legacy MUI-based rendering.\n * @deprecated Use {@link HasApisCardProps} instead.\n * @public\n */\nexport interface HasApisCardLegacyProps {\n title?: string;\n /** @deprecated Use `columnConfig` instead. */\n variant?: InfoCardVariants;\n /** @deprecated Use `columnConfig` instead. */\n columns?: TableColumn<ApiEntity>[];\n /** @deprecated Use `columnConfig` instead. */\n tableOptions?: TableOptions;\n}\n\nfunction isLegacyProps(\n props: HasApisCardProps | HasApisCardLegacyProps,\n): props is HasApisCardLegacyProps {\n return 'variant' in props || 'columns' in props || 'tableOptions' in props;\n}\n\nfunction HasApisCardLegacy(props: HasApisCardLegacyProps) {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const presetColumns: TableColumn<ApiEntity>[] = useMemo(() => {\n return [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'API' }),\n EntityTable.columns.createOwnerColumn(),\n createSpecApiTypeColumn(t),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n ];\n }, [t]);\n const {\n variant = 'gridItem',\n title = t('hasApisCard.title'),\n columns = presetColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_HAS_PART,\n kind: 'API',\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('hasApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('hasApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ApiEntity[]}\n />\n );\n}\n\n/**\n * @public\n */\nexport const HasApisCard = (\n props: HasApisCardProps | HasApisCardLegacyProps,\n) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const { entity } = useEntity();\n\n if (isLegacyProps(props)) {\n return <HasApisCardLegacy {...props} />;\n }\n\n const {\n title = t('hasApisCard.title'),\n columnConfig = getHasApisColumnConfig(t),\n } = props;\n\n return (\n <EntityRelationCard\n title={title}\n entityKind=\"API\"\n relationType={RELATION_HAS_PART}\n columnConfig={columnConfig}\n emptyState={{\n message: t('hasApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n }),\n helpLink:\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api',\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA+DA,SAAS,cACP,KAAA,EACiC;AACjC,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,SAAA,IAAa,KAAA,IAAS,cAAA,IAAkB,KAAA;AACvE;AAEA,SAAS,kBAAkB,KAAA,EAA+B;AACxD,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM,aAAA,GAA0C,QAAQ,MAAM;AAC5D,IAAA,OAAO;AAAA,MACL,YAAY,OAAA,CAAQ,qBAAA,CAAsB,EAAE,WAAA,EAAa,OAAO,CAAA;AAAA,MAChE,WAAA,CAAY,QAAQ,iBAAA,EAAkB;AAAA,MACtC,wBAAwB,CAAC,CAAA;AAAA,MACzB,WAAA,CAAY,QAAQ,yBAAA,EAA0B;AAAA,MAC9C,WAAA,CAAY,QAAQ,+BAAA;AAAgC,KACtD;AAAA,EACF,CAAA,EAAG,CAAC,CAAC,CAAC,CAAA;AACN,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,mBAAmB,CAAA;AAAA,IAC7B,OAAA,GAAU,aAAA;AAAA,IACV,eAAe;AAAC,GAClB,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM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AE,uBAAuB,CAAA,EAC5B,CAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;AAKO,MAAM,WAAA,GAAc,CACzB,KAAA,KACG;AACH,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAE7B,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,uBAAO,GAAA,CAAC,iBAAA,EAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAAA,EACvC;AAEA,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,EAAE,mBAAmB,CAAA;AAAA,IAC7B,YAAA,GAAe,uBAAuB,CAAC;AAAA,GACzC,GAAI,KAAA;AAEJ,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,UAAA,EAAW,KAAA;AAAA,MACX,YAAA,EAAc,iBAAA;AAAA,MACd,YAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,OAAA,EAAS,EAAE,gCAAA,EAAkC;AAAA,UAC3C,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,iBAAA,CAAkB,OAAO;AAAA,SAC9C,CAAA;AAAA,QACD,QAAA,EACE;AAAA;AACJ;AAAA,GACF;AAEJ;;;;"}
@@ -2,12 +2,16 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { RELATION_PROVIDES_API } from '@backstage/catalog-model';
3
3
  import Typography from '@material-ui/core/Typography';
4
4
  import { useEntity, useRelatedEntities, EntityTable } from '@backstage/plugin-catalog-react';
5
- import { getApiEntityColumns } from './presets.esm.js';
5
+ import { EntityRelationCard } from '@backstage/plugin-catalog-react/alpha';
6
+ import { getApiEntityColumnConfig, getApiEntityColumns } from './presets.esm.js';
6
7
  import { InfoCard, Progress, WarningPanel, CodeSnippet, Link } from '@backstage/core-components';
7
8
  import { useTranslationRef } from '@backstage/frontend-plugin-api';
8
9
  import { apiDocsTranslationRef } from '../../translation.esm.js';
9
10
 
10
- const ProvidedApisCard = (props) => {
11
+ function isLegacyProps(props) {
12
+ return "variant" in props || "columns" in props || "tableOptions" in props;
13
+ }
14
+ function ProvidedApisCardLegacy(props) {
11
15
  const { t } = useTranslationRef(apiDocsTranslationRef);
12
16
  const {
13
17
  variant = "gridItem",
@@ -55,6 +59,31 @@ const ProvidedApisCard = (props) => {
55
59
  entities
56
60
  }
57
61
  );
62
+ }
63
+ const ProvidedApisCard = (props) => {
64
+ const { t } = useTranslationRef(apiDocsTranslationRef);
65
+ const { entity } = useEntity();
66
+ if (isLegacyProps(props)) {
67
+ return /* @__PURE__ */ jsx(ProvidedApisCardLegacy, { ...props });
68
+ }
69
+ const {
70
+ title = t("providedApisCard.title"),
71
+ columnConfig = getApiEntityColumnConfig(t)
72
+ } = props;
73
+ return /* @__PURE__ */ jsx(
74
+ EntityRelationCard,
75
+ {
76
+ title,
77
+ relationType: RELATION_PROVIDES_API,
78
+ columnConfig,
79
+ emptyState: {
80
+ message: t("providedApisCard.emptyContent.title", {
81
+ entity: entity.kind.toLocaleLowerCase("en-US")
82
+ }),
83
+ helpLink: "https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional"
84
+ }
85
+ }
86
+ );
58
87
  };
59
88
 
60
89
  export { ProvidedApisCard };
@@ -1 +1 @@
1
- {"version":3,"file":"ProvidedApisCard.esm.js","sources":["../../../src/components/ApisCards/ProvidedApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_PROVIDES_API } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport { getApiEntityColumns } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/**\n * @public\n */\nexport const ProvidedApisCard = (props: {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ApiEntity>[];\n tableOptions?: TableOptions;\n}) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('providedApisCard.title'),\n columns = getApiEntityColumns(t),\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_PROVIDES_API,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('providedApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('providedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link\n to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional\"\n externalLinkIcon\n >\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n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AAA,EAAW,UAAS,EAChC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EACjB,QAAA,EAAA,CAAA,CAAE,qCAAA,EAAuC;AAAA,UACxC,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,iBAAA,CAAkB,OAAO;AAAA,SAC9C,CAAA,EACH,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAClB,QAAA,kBAAA,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,EAAA,EAAG,iGAAA;AAAA,YACH,gBAAA,EAAgB,IAAA;AAAA,YAEf,YAAE,uBAAuB;AAAA;AAAA,SAC5B,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"ProvidedApisCard.esm.js","sources":["../../../src/components/ApisCards/ProvidedApisCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity, RELATION_PROVIDES_API } from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityRelationCard,\n EntityColumnConfig,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { getApiEntityColumns, getApiEntityColumnConfig } from './presets';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport interface ProvidedApisCardProps {\n title?: string;\n columnConfig?: EntityColumnConfig[];\n}\n\n/**\n * Props for the legacy MUI-based rendering.\n * @deprecated Use {@link ProvidedApisCardProps} instead.\n * @public\n */\nexport interface ProvidedApisCardLegacyProps {\n title?: string;\n /** @deprecated Use `columnConfig` instead. */\n variant?: InfoCardVariants;\n /** @deprecated Use `columnConfig` instead. */\n columns?: TableColumn<ApiEntity>[];\n /** @deprecated Use `columnConfig` instead. */\n tableOptions?: TableOptions;\n}\n\nfunction isLegacyProps(\n props: ProvidedApisCardProps | ProvidedApisCardLegacyProps,\n): props is ProvidedApisCardLegacyProps {\n return 'variant' in props || 'columns' in props || 'tableOptions' in props;\n}\n\nfunction ProvidedApisCardLegacy(props: ProvidedApisCardLegacyProps) {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('providedApisCard.title'),\n columns = getApiEntityColumns(t),\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_PROVIDES_API,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('providedApisCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('providedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n })}\n </Typography>\n <Typography variant=\"body2\">\n <Link\n to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional\"\n externalLinkIcon\n >\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ApiEntity[]}\n />\n );\n}\n\n/**\n * @public\n */\nexport const ProvidedApisCard = (\n props: ProvidedApisCardProps | ProvidedApisCardLegacyProps,\n) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const { entity } = useEntity();\n\n if (isLegacyProps(props)) {\n return <ProvidedApisCardLegacy {...props} />;\n }\n\n const {\n title = t('providedApisCard.title'),\n columnConfig = getApiEntityColumnConfig(t),\n } = props;\n\n return (\n <EntityRelationCard\n title={title}\n relationType={RELATION_PROVIDES_API}\n columnConfig={columnConfig}\n emptyState={{\n message: t('providedApisCard.emptyContent.title', {\n entity: entity.kind.toLocaleLowerCase('en-US'),\n }),\n helpLink:\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional',\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA8DA,SAAS,cACP,KAAA,EACsC;AACtC,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,SAAA,IAAa,KAAA,IAAS,cAAA,IAAkB,KAAA;AACvE;AAEA,SAAS,uBAAuB,KAAA,EAAoC;AAClE,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,wBAAwB,CAAA;AAAA,IAClC,OAAA,GAAU,oBAAoB,CAAC,CAAA;AAAA,IAC/B,eAAe;AAAC,GAClB,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,EAAE,QAAA,EAAU,OAAA,EAAS,KAAA,EAAM,GAAI,mBAAmB,MAAA,EAAQ;AAAA,IAC9D,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,IAAI,OAAA,EAAS;AACX,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,gBAAA,GAAmB,CAC9B,KAAA,KACG;AACH,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAE7B,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,uBAAO,GAAA,CAAC,sBAAA,EAAA,EAAwB,GAAG,KAAA,EAAO,CAAA;AAAA,EAC5C;AAEA,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,EAAE,wBAAwB,CAAA;AAAA,IAClC,YAAA,GAAe,yBAAyB,CAAC;AAAA,GAC3C,GAAI,KAAA;AAEJ,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,YAAA,EAAc,qBAAA;AAAA,MACd,YAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,OAAA,EAAS,EAAE,qCAAA,EAAuC;AAAA,UAChD,MAAA,EAAQ,MAAA,CAAO,IAAA,CAAK,iBAAA,CAAkB,OAAO;AAAA,SAC9C,CAAA;AAAA,QACD,QAAA,EACE;AAAA;AACJ;AAAA,GACF;AAEJ;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { EntityTable } from '@backstage/plugin-catalog-react';
3
- import ExtensionIcon from '@material-ui/icons/Extension';
4
- import ToggleButton from '@material-ui/lab/ToggleButton';
3
+ import { entityDataTableColumns } from '@backstage/plugin-catalog-react/alpha';
4
+ import { Cell, ButtonIcon } from '@backstage/ui';
5
+ import { RiPuzzleLine } from '@remixicon/react';
5
6
  import { useState } from 'react';
6
7
  import '@backstage/core-components';
7
8
  import '@backstage/core-plugin-api';
@@ -29,12 +30,13 @@ const ApiDefinitionButton = ({ apiEntity }) => {
29
30
  const { t } = useTranslationRef(apiDocsTranslationRef);
30
31
  return /* @__PURE__ */ jsxs(Fragment, { children: [
31
32
  /* @__PURE__ */ jsx(
32
- ToggleButton,
33
+ ButtonIcon,
33
34
  {
34
35
  "aria-label": t("apiDefinitionDialog.toggleButtonAriaLabel"),
35
- onClick: () => setDialogOpen(!dialogOpen),
36
- value: dialogOpen,
37
- children: /* @__PURE__ */ jsx(ExtensionIcon, {})
36
+ onPress: () => setDialogOpen(!dialogOpen),
37
+ variant: "tertiary",
38
+ size: "small",
39
+ icon: /* @__PURE__ */ jsx(RiPuzzleLine, {})
38
40
  }
39
41
  ),
40
42
  /* @__PURE__ */ jsx(
@@ -64,6 +66,42 @@ const getApiEntityColumns = (t) => {
64
66
  createApiDefinitionColumn(t)
65
67
  ];
66
68
  };
69
+ function createSpecApiTypeColumnConfig(t) {
70
+ return {
71
+ id: "apiType",
72
+ label: t("apiEntityColumns.typeTitle"),
73
+ isSortable: true,
74
+ cell: (entity) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(ApiTypeTitle, { apiEntity: entity }) }),
75
+ sortValue: (entity) => entity.spec?.type ?? ""
76
+ };
77
+ }
78
+ function createApiDefinitionColumnConfig(t) {
79
+ return {
80
+ id: "apiDefinition",
81
+ label: t("apiEntityColumns.apiDefinitionTitle"),
82
+ cell: (entity) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(ApiDefinitionButton, { apiEntity: entity }) })
83
+ };
84
+ }
85
+ function getApiEntityColumnConfig(t) {
86
+ return [
87
+ entityDataTableColumns.createEntityRefColumn({ defaultKind: "API" }),
88
+ entityDataTableColumns.createSystemColumn(),
89
+ entityDataTableColumns.createOwnerColumn(),
90
+ createSpecApiTypeColumnConfig(t),
91
+ entityDataTableColumns.createSpecLifecycleColumn(),
92
+ entityDataTableColumns.createMetadataDescriptionColumn(),
93
+ createApiDefinitionColumnConfig(t)
94
+ ];
95
+ }
96
+ function getHasApisColumnConfig(t) {
97
+ return [
98
+ entityDataTableColumns.createEntityRefColumn({ defaultKind: "API" }),
99
+ entityDataTableColumns.createOwnerColumn(),
100
+ createSpecApiTypeColumnConfig(t),
101
+ entityDataTableColumns.createSpecLifecycleColumn(),
102
+ entityDataTableColumns.createMetadataDescriptionColumn()
103
+ ];
104
+ }
67
105
 
68
- export { createSpecApiTypeColumn, getApiEntityColumns };
106
+ export { createSpecApiTypeColumn, getApiEntityColumnConfig, getApiEntityColumns, getHasApisColumnConfig };
69
107
  //# sourceMappingURL=presets.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"presets.esm.js","sources":["../../../src/components/ApisCards/presets.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity } from '@backstage/catalog-model';\nimport { TableColumn } from '@backstage/core-components';\nimport { EntityTable } from '@backstage/plugin-catalog-react';\nimport ExtensionIcon from '@material-ui/icons/Extension';\nimport ToggleButton from '@material-ui/lab/ToggleButton';\nimport { useState } from 'react';\nimport { ApiTypeTitle } from '../ApiDefinitionCard';\nimport { ApiDefinitionDialog } from '../ApiDefinitionDialog';\nimport {\n TranslationFunction,\n useTranslationRef,\n} from '@backstage/core-plugin-api/alpha';\nimport { apiDocsTranslationRef } from '../../translation';\n\nexport function createSpecApiTypeColumn(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity> {\n return {\n title: t('apiEntityColumns.typeTitle'),\n field: 'spec.type',\n render: entity => <ApiTypeTitle apiEntity={entity} />,\n };\n}\n\nconst ApiDefinitionButton = ({ apiEntity }: { apiEntity: ApiEntity }) => {\n const [dialogOpen, setDialogOpen] = useState(false);\n const { t } = useTranslationRef(apiDocsTranslationRef);\n return (\n <>\n <ToggleButton\n aria-label={t('apiDefinitionDialog.toggleButtonAriaLabel')}\n onClick={() => setDialogOpen(!dialogOpen)}\n value={dialogOpen}\n >\n <ExtensionIcon />\n </ToggleButton>\n <ApiDefinitionDialog\n entity={apiEntity}\n open={dialogOpen}\n onClose={() => setDialogOpen(false)}\n />\n </>\n );\n};\n\nfunction createApiDefinitionColumn(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity> {\n return {\n title: t('apiEntityColumns.apiDefinitionTitle'),\n render: entity => <ApiDefinitionButton apiEntity={entity} />,\n };\n}\n\nexport const getApiEntityColumns = (\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity>[] => {\n return [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'API' }),\n EntityTable.columns.createSystemColumn(),\n EntityTable.columns.createOwnerColumn(),\n createSpecApiTypeColumn(t),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n createApiDefinitionColumn(t),\n ];\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA8BO,SAAS,wBACd,CAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,EAAE,4BAA4B,CAAA;AAAA,IACrC,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,CAAA,MAAA,qBAAU,GAAA,CAAC,YAAA,EAAA,EAAa,WAAW,MAAA,EAAQ;AAAA,GACrD;AACF;AAEA,MAAM,mBAAA,GAAsB,CAAC,EAAE,SAAA,EAAU,KAAgC;AACvE,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,KAAK,CAAA;AAClD,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,YAAA,EAAY,EAAE,2CAA2C,CAAA;AAAA,QACzD,OAAA,EAAS,MAAM,aAAA,CAAc,CAAC,UAAU,CAAA;AAAA,QACxC,KAAA,EAAO,UAAA;AAAA,QAEP,8BAAC,aAAA,EAAA,EAAc;AAAA;AAAA,KACjB;AAAA,oBACA,GAAA;AAAA,MAAC,mBAAA;AAAA,MAAA;AAAA,QACC,MAAA,EAAQ,SAAA;AAAA,QACR,IAAA,EAAM,UAAA;AAAA,QACN,OAAA,EAAS,MAAM,aAAA,CAAc,KAAK;AAAA;AAAA;AACpC,GAAA,EACF,CAAA;AAEJ,CAAA;AAEA,SAAS,0BACP,CAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,EAAE,qCAAqC,CAAA;AAAA,IAC9C,MAAA,EAAQ,CAAA,MAAA,qBAAU,GAAA,CAAC,mBAAA,EAAA,EAAoB,WAAW,MAAA,EAAQ;AAAA,GAC5D;AACF;AAEO,MAAM,mBAAA,GAAsB,CACjC,CAAA,KAC6B;AAC7B,EAAA,OAAO;AAAA,IACL,YAAY,OAAA,CAAQ,qBAAA,CAAsB,EAAE,WAAA,EAAa,OAAO,CAAA;AAAA,IAChE,WAAA,CAAY,QAAQ,kBAAA,EAAmB;AAAA,IACvC,WAAA,CAAY,QAAQ,iBAAA,EAAkB;AAAA,IACtC,wBAAwB,CAAC,CAAA;AAAA,IACzB,WAAA,CAAY,QAAQ,yBAAA,EAA0B;AAAA,IAC9C,WAAA,CAAY,QAAQ,+BAAA,EAAgC;AAAA,IACpD,0BAA0B,CAAC;AAAA,GAC7B;AACF;;;;"}
1
+ {"version":3,"file":"presets.esm.js","sources":["../../../src/components/ApisCards/presets.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ApiEntity } from '@backstage/catalog-model';\nimport { TableColumn } from '@backstage/core-components';\nimport { EntityTable } from '@backstage/plugin-catalog-react';\nimport {\n EntityColumnConfig,\n entityDataTableColumns,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { ButtonIcon, Cell } from '@backstage/ui';\nimport { RiPuzzleLine } from '@remixicon/react';\nimport { useState } from 'react';\nimport { ApiTypeTitle } from '../ApiDefinitionCard';\nimport { ApiDefinitionDialog } from '../ApiDefinitionDialog';\nimport {\n TranslationFunction,\n useTranslationRef,\n} from '@backstage/core-plugin-api/alpha';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @deprecated Use `getApiEntityColumnConfig` instead. */\nexport function createSpecApiTypeColumn(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity> {\n return {\n title: t('apiEntityColumns.typeTitle'),\n field: 'spec.type',\n render: entity => <ApiTypeTitle apiEntity={entity} />,\n };\n}\n\nconst ApiDefinitionButton = ({ apiEntity }: { apiEntity: ApiEntity }) => {\n const [dialogOpen, setDialogOpen] = useState(false);\n const { t } = useTranslationRef(apiDocsTranslationRef);\n return (\n <>\n <ButtonIcon\n aria-label={t('apiDefinitionDialog.toggleButtonAriaLabel')}\n onPress={() => setDialogOpen(!dialogOpen)}\n variant=\"tertiary\"\n size=\"small\"\n icon={<RiPuzzleLine />}\n />\n <ApiDefinitionDialog\n entity={apiEntity}\n open={dialogOpen}\n onClose={() => setDialogOpen(false)}\n />\n </>\n );\n};\n\nfunction createApiDefinitionColumn(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity> {\n return {\n title: t('apiEntityColumns.apiDefinitionTitle'),\n render: entity => <ApiDefinitionButton apiEntity={entity} />,\n };\n}\n\n/** @deprecated Use `getApiEntityColumnConfig` instead. */\nexport const getApiEntityColumns = (\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): TableColumn<ApiEntity>[] => {\n return [\n EntityTable.columns.createEntityRefColumn({ defaultKind: 'API' }),\n EntityTable.columns.createSystemColumn(),\n EntityTable.columns.createOwnerColumn(),\n createSpecApiTypeColumn(t),\n EntityTable.columns.createSpecLifecycleColumn(),\n EntityTable.columns.createMetadataDescriptionColumn(),\n createApiDefinitionColumn(t),\n ];\n};\n\n// Column config presets\n\nfunction createSpecApiTypeColumnConfig(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): EntityColumnConfig {\n return {\n id: 'apiType',\n label: t('apiEntityColumns.typeTitle'),\n isSortable: true,\n cell: entity => (\n <Cell>\n <ApiTypeTitle apiEntity={entity as unknown as ApiEntity} />\n </Cell>\n ),\n sortValue: entity =>\n (entity.spec as Record<string, string> | undefined)?.type ?? '',\n };\n}\n\nfunction createApiDefinitionColumnConfig(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): EntityColumnConfig {\n return {\n id: 'apiDefinition',\n label: t('apiEntityColumns.apiDefinitionTitle'),\n cell: entity => (\n <Cell>\n <ApiDefinitionButton apiEntity={entity as unknown as ApiEntity} />\n </Cell>\n ),\n };\n}\n\nexport function getApiEntityColumnConfig(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): EntityColumnConfig[] {\n return [\n entityDataTableColumns.createEntityRefColumn({ defaultKind: 'API' }),\n entityDataTableColumns.createSystemColumn(),\n entityDataTableColumns.createOwnerColumn(),\n createSpecApiTypeColumnConfig(t),\n entityDataTableColumns.createSpecLifecycleColumn(),\n entityDataTableColumns.createMetadataDescriptionColumn(),\n createApiDefinitionColumnConfig(t),\n ];\n}\n\nexport function getHasApisColumnConfig(\n t: TranslationFunction<typeof apiDocsTranslationRef.T>,\n): EntityColumnConfig[] {\n return [\n entityDataTableColumns.createEntityRefColumn({ defaultKind: 'API' }),\n entityDataTableColumns.createOwnerColumn(),\n createSpecApiTypeColumnConfig(t),\n entityDataTableColumns.createSpecLifecycleColumn(),\n entityDataTableColumns.createMetadataDescriptionColumn(),\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCO,SAAS,wBACd,CAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,EAAE,4BAA4B,CAAA;AAAA,IACrC,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,CAAA,MAAA,qBAAU,GAAA,CAAC,YAAA,EAAA,EAAa,WAAW,MAAA,EAAQ;AAAA,GACrD;AACF;AAEA,MAAM,mBAAA,GAAsB,CAAC,EAAE,SAAA,EAAU,KAAgC;AACvE,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAS,KAAK,CAAA;AAClD,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,YAAA,EAAY,EAAE,2CAA2C,CAAA;AAAA,QACzD,OAAA,EAAS,MAAM,aAAA,CAAc,CAAC,UAAU,CAAA;AAAA,QACxC,OAAA,EAAQ,UAAA;AAAA,QACR,IAAA,EAAK,OAAA;AAAA,QACL,IAAA,sBAAO,YAAA,EAAA,EAAa;AAAA;AAAA,KACtB;AAAA,oBACA,GAAA;AAAA,MAAC,mBAAA;AAAA,MAAA;AAAA,QACC,MAAA,EAAQ,SAAA;AAAA,QACR,IAAA,EAAM,UAAA;AAAA,QACN,OAAA,EAAS,MAAM,aAAA,CAAc,KAAK;AAAA;AAAA;AACpC,GAAA,EACF,CAAA;AAEJ,CAAA;AAEA,SAAS,0BACP,CAAA,EACwB;AACxB,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,EAAE,qCAAqC,CAAA;AAAA,IAC9C,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A,EAAa,OAAO,CAAA;AAAA,IACnE,uBAAuB,kBAAA,EAAmB;AAAA,IAC1C,uBAAuB,iBAAA,EAAkB;AAAA,IACzC,8BAA8B,CAAC,CAAA;AAAA,IAC/B,uBAAuB,yBAAA,EAA0B;AAAA,IACjD,uBAAuB,+BAAA,EAAgC;AAAA,IACvD,gCAAgC,CAAC;AAAA,GACnC;AACF;AAEO,SAAS,uBACd,CAAA,EACsB;AACtB,EAAA,OAAO;AAAA,IACL,sBAAA,CAAuB,qBAAA,CAAsB,EAAE,WAAA,EAAa,OAAO,CAAA;AAAA,IACnE,uBAAuB,iBAAA,EAAkB;AAAA,IACzC,8BAA8B,CAAC,CAAA;AAAA,IAC/B,uBAAuB,yBAAA,EAA0B;AAAA,IACjD,uBAAuB,+BAAA;AAAgC,GACzD;AACF;;;;"}
@@ -2,11 +2,15 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { RELATION_API_CONSUMED_BY } from '@backstage/catalog-model';
3
3
  import Typography from '@material-ui/core/Typography';
4
4
  import { EntityTable, useEntity, useRelatedEntities } from '@backstage/plugin-catalog-react';
5
+ import { entityColumnPresets, EntityRelationCard } from '@backstage/plugin-catalog-react/alpha';
5
6
  import { InfoCard, Progress, WarningPanel, CodeSnippet, Link } from '@backstage/core-components';
6
7
  import { useTranslationRef } from '@backstage/frontend-plugin-api';
7
8
  import { apiDocsTranslationRef } from '../../translation.esm.js';
8
9
 
9
- const ConsumingComponentsCard = (props) => {
10
+ function isLegacyProps(props) {
11
+ return "variant" in props || "columns" in props || "tableOptions" in props;
12
+ }
13
+ function ConsumingComponentsCardLegacy(props) {
10
14
  const { t } = useTranslationRef(apiDocsTranslationRef);
11
15
  const {
12
16
  variant = "gridItem",
@@ -45,6 +49,28 @@ const ConsumingComponentsCard = (props) => {
45
49
  entities
46
50
  }
47
51
  );
52
+ }
53
+ const ConsumingComponentsCard = (props) => {
54
+ const { t } = useTranslationRef(apiDocsTranslationRef);
55
+ if (isLegacyProps(props)) {
56
+ return /* @__PURE__ */ jsx(ConsumingComponentsCardLegacy, { ...props });
57
+ }
58
+ const {
59
+ title = t("consumingComponentsCard.title"),
60
+ columnConfig = entityColumnPresets.component.columns
61
+ } = props;
62
+ return /* @__PURE__ */ jsx(
63
+ EntityRelationCard,
64
+ {
65
+ title,
66
+ relationType: RELATION_API_CONSUMED_BY,
67
+ columnConfig,
68
+ emptyState: {
69
+ message: t("consumingComponentsCard.emptyContent.title"),
70
+ helpLink: "https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional"
71
+ }
72
+ }
73
+ );
48
74
  };
49
75
 
50
76
  export { ConsumingComponentsCard };
@@ -1 +1 @@
1
- {"version":3,"file":"ConsumingComponentsCard.esm.js","sources":["../../../src/components/ComponentsCards/ConsumingComponentsCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ComponentEntity,\n RELATION_API_CONSUMED_BY,\n} from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/**\n * @public\n */\nexport const ConsumingComponentsCard = (props: {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ComponentEntity>[];\n tableOptions?: TableOptions;\n}) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('consumingComponentsCard.title'),\n columns = EntityTable.componentEntityColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_API_CONSUMED_BY,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('consumingComponentsCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('consumingComponentsCard.emptyContent.title')}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ComponentEntity[]}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA0CO,MAAM,uBAAA,GAA0B,CAAC,KAAA,KAKlC;AACJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,+BAA+B,CAAA;AAAA,IACzC,UAAU,WAAA,CAAY,sBAAA;AAAA,IACtB,eAAe;AAAC,GAClB,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,EAAE,QAAA,EAAU,OAAA,EAAS,KAAA,EAAM,GAAI,mBAAmB,MAAA,EAAQ;AAAA,IAC9D,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,2BACG,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,YAAS,CAAA,EACZ,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,KAAA,IAAS,CAAC,QAAA,EAAU;AACtB,IAAA,uBACE,GAAA,CAAC,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,QAAA,EAAS,OAAA;AAAA,QACT,KAAA,EAAO,EAAE,qCAAqC,CAAA;AAAA,QAC9C,OAAA,sBAAU,WAAA,EAAA,EAAY,IAAA,EAAM,GAAG,KAAK,CAAA,CAAA,EAAI,UAAS,MAAA,EAAO;AAAA;AAAA,KAC1D,EACF,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,OAAA;AAAA,MACA,8BACE,IAAA,CAAC,KAAA,EAAA,EAAI,OAAO,EAAE,SAAA,EAAW,UAAS,EAChC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EACjB,QAAA,EAAA,CAAA,CAAE,4CAA4C,CAAA,EACjD,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,EAAA,EAAG,iGAAA,EACN,QAAA,EAAA,CAAA,CAAE,uBAAuB,CAAA,EAC5B,CAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"ConsumingComponentsCard.esm.js","sources":["../../../src/components/ComponentsCards/ConsumingComponentsCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ComponentEntity,\n RELATION_API_CONSUMED_BY,\n} from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityRelationCard,\n EntityColumnConfig,\n entityColumnPresets,\n} from '@backstage/plugin-catalog-react/alpha';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport interface ConsumingComponentsCardProps {\n title?: string;\n columnConfig?: EntityColumnConfig[];\n}\n\n/**\n * Props for the legacy MUI-based rendering.\n * @deprecated Use {@link ConsumingComponentsCardProps} instead.\n * @public\n */\nexport interface ConsumingComponentsCardLegacyProps {\n title?: string;\n /** @deprecated Use `columnConfig` instead. */\n variant?: InfoCardVariants;\n /** @deprecated Use `columnConfig` instead. */\n columns?: TableColumn<ComponentEntity>[];\n /** @deprecated Use `columnConfig` instead. */\n tableOptions?: TableOptions;\n}\n\nfunction isLegacyProps(\n props: ConsumingComponentsCardProps | ConsumingComponentsCardLegacyProps,\n): props is ConsumingComponentsCardLegacyProps {\n return 'variant' in props || 'columns' in props || 'tableOptions' in props;\n}\n\nfunction ConsumingComponentsCardLegacy(\n props: ConsumingComponentsCardLegacyProps,\n) {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('consumingComponentsCard.title'),\n columns = EntityTable.componentEntityColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_API_CONSUMED_BY,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('consumingComponentsCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('consumingComponentsCard.emptyContent.title')}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ComponentEntity[]}\n />\n );\n}\n\n/**\n * @public\n */\nexport const ConsumingComponentsCard = (\n props: ConsumingComponentsCardProps | ConsumingComponentsCardLegacyProps,\n) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n\n if (isLegacyProps(props)) {\n return <ConsumingComponentsCardLegacy {...props} />;\n }\n\n const {\n title = t('consumingComponentsCard.title'),\n columnConfig = entityColumnPresets.component.columns,\n } = props;\n\n return (\n <EntityRelationCard\n title={title}\n relationType={RELATION_API_CONSUMED_BY}\n columnConfig={columnConfig}\n emptyState={{\n message: t('consumingComponentsCard.emptyContent.title'),\n helpLink:\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#specconsumesapis-optional',\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAiEA,SAAS,cACP,KAAA,EAC6C;AAC7C,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,SAAA,IAAa,KAAA,IAAS,cAAA,IAAkB,KAAA;AACvE;AAEA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Q,OAAA,EACjB,QAAA,EAAA,CAAA,CAAE,4CAA4C,CAAA,EACjD,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,EAAA,EAAG,iGAAA,EACN,QAAA,EAAA,CAAA,CAAE,uBAAuB,CAAA,EAC5B,CAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;AAKO,MAAM,uBAAA,GAA0B,CACrC,KAAA,KACG;AACH,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AAErD,EAAA,IAAI,aAAA,CAAc,KAAK,CAAA,EAAG;AACxB,IAAA,uBAAO,GAAA,CAAC,6BAAA,EAAA,EAA+B,GAAG,KAAA,EAAO,CAAA;AAAA,EACnD;AAEA,EAAA,MAAM;AAAA,IACJ,KAAA,GAAQ,EAAE,+BAA+B,CAAA;AAAA,IACzC,YAAA,GAAe,oBAAoB,SAAA,CAAU;AAAA,GAC/C,GAAI,KAAA;AAEJ,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,YAAA,EAAc,wBAAA;AAAA,MACd,YAAA;AAAA,MACA,UAAA,EAAY;AAAA,QACV,OAAA,EAAS,EAAE,4CAA4C,CAAA;AAAA,QACvD,QAAA,EACE;AAAA;AACJ;AAAA,GACF;AAEJ;;;;"}
@@ -2,11 +2,15 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { RELATION_API_PROVIDED_BY } from '@backstage/catalog-model';
3
3
  import Typography from '@material-ui/core/Typography';
4
4
  import { EntityTable, useEntity, useRelatedEntities } from '@backstage/plugin-catalog-react';
5
+ import { entityColumnPresets, EntityRelationCard } from '@backstage/plugin-catalog-react/alpha';
5
6
  import { InfoCard, Progress, WarningPanel, CodeSnippet, Link } from '@backstage/core-components';
6
7
  import { useTranslationRef } from '@backstage/frontend-plugin-api';
7
8
  import { apiDocsTranslationRef } from '../../translation.esm.js';
8
9
 
9
- const ProvidingComponentsCard = (props) => {
10
+ function isLegacyProps(props) {
11
+ return "variant" in props || "columns" in props || "tableOptions" in props;
12
+ }
13
+ function ProvidingComponentsCardLegacy(props) {
10
14
  const { t } = useTranslationRef(apiDocsTranslationRef);
11
15
  const {
12
16
  variant = "gridItem",
@@ -45,6 +49,28 @@ const ProvidingComponentsCard = (props) => {
45
49
  entities
46
50
  }
47
51
  );
52
+ }
53
+ const ProvidingComponentsCard = (props) => {
54
+ const { t } = useTranslationRef(apiDocsTranslationRef);
55
+ if (isLegacyProps(props)) {
56
+ return /* @__PURE__ */ jsx(ProvidingComponentsCardLegacy, { ...props });
57
+ }
58
+ const {
59
+ title = t("providingComponentsCard.title"),
60
+ columnConfig = entityColumnPresets.component.columns
61
+ } = props;
62
+ return /* @__PURE__ */ jsx(
63
+ EntityRelationCard,
64
+ {
65
+ title,
66
+ relationType: RELATION_API_PROVIDED_BY,
67
+ columnConfig,
68
+ emptyState: {
69
+ message: t("providingComponentsCard.emptyContent.title"),
70
+ helpLink: "https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional"
71
+ }
72
+ }
73
+ );
48
74
  };
49
75
 
50
76
  export { ProvidingComponentsCard };
@@ -1 +1 @@
1
- {"version":3,"file":"ProvidingComponentsCard.esm.js","sources":["../../../src/components/ComponentsCards/ProvidingComponentsCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ComponentEntity,\n RELATION_API_PROVIDED_BY,\n} from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport const ProvidingComponentsCard = (props: {\n variant?: InfoCardVariants;\n title?: string;\n columns?: TableColumn<ComponentEntity>[];\n tableOptions?: TableOptions;\n}) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('providingComponentsCard.title'),\n columns = EntityTable.componentEntityColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_API_PROVIDED_BY,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('providingComponentsCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('providingComponentsCard.emptyContent.title')}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ComponentEntity[]}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAwCO,MAAM,uBAAA,GAA0B,CAAC,KAAA,K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AAA,EAAA,CAAA,CAAE,4CAA4C,CAAA,EACjD,CAAA;AAAA,wBACA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,IAAA,EAAA,EAAK,EAAA,EAAG,iGAAA,EACN,QAAA,EAAA,CAAA,CAAE,uBAAuB,CAAA,EAC5B,CAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA,MAEF,OAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"ProvidingComponentsCard.esm.js","sources":["../../../src/components/ComponentsCards/ProvidingComponentsCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ComponentEntity,\n RELATION_API_PROVIDED_BY,\n} from '@backstage/catalog-model';\nimport Typography from '@material-ui/core/Typography';\nimport {\n EntityTable,\n useEntity,\n useRelatedEntities,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityRelationCard,\n EntityColumnConfig,\n entityColumnPresets,\n} from '@backstage/plugin-catalog-react/alpha';\nimport {\n CodeSnippet,\n InfoCard,\n InfoCardVariants,\n Link,\n Progress,\n TableColumn,\n TableOptions,\n WarningPanel,\n} from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { apiDocsTranslationRef } from '../../translation';\n\n/** @public */\nexport interface ProvidingComponentsCardProps {\n title?: string;\n columnConfig?: EntityColumnConfig[];\n}\n\n/**\n * Props for the legacy MUI-based rendering.\n * @deprecated Use {@link ProvidingComponentsCardProps} instead.\n * @public\n */\nexport interface ProvidingComponentsCardLegacyProps {\n title?: string;\n /** @deprecated Use `columnConfig` instead. */\n variant?: InfoCardVariants;\n /** @deprecated Use `columnConfig` instead. */\n columns?: TableColumn<ComponentEntity>[];\n /** @deprecated Use `columnConfig` instead. */\n tableOptions?: TableOptions;\n}\n\nfunction isLegacyProps(\n props: ProvidingComponentsCardProps | ProvidingComponentsCardLegacyProps,\n): props is ProvidingComponentsCardLegacyProps {\n return 'variant' in props || 'columns' in props || 'tableOptions' in props;\n}\n\nfunction ProvidingComponentsCardLegacy(\n props: ProvidingComponentsCardLegacyProps,\n) {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n const {\n variant = 'gridItem',\n title = t('providingComponentsCard.title'),\n columns = EntityTable.componentEntityColumns,\n tableOptions = {},\n } = props;\n const { entity } = useEntity();\n const { entities, loading, error } = useRelatedEntities(entity, {\n type: RELATION_API_PROVIDED_BY,\n });\n\n if (loading) {\n return (\n <InfoCard variant={variant} title={title}>\n <Progress />\n </InfoCard>\n );\n }\n\n if (error || !entities) {\n return (\n <InfoCard variant={variant} title={title}>\n <WarningPanel\n severity=\"error\"\n title={t('providingComponentsCard.error.title')}\n message={<CodeSnippet text={`${error}`} language=\"text\" />}\n />\n </InfoCard>\n );\n }\n\n return (\n <EntityTable\n title={title}\n variant={variant}\n emptyContent={\n <div style={{ textAlign: 'center' }}>\n <Typography variant=\"body1\">\n {t('providingComponentsCard.emptyContent.title')}\n </Typography>\n <Typography variant=\"body2\">\n <Link to=\"https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional\">\n {t('apisCardHelpLinkTitle')}\n </Link>\n </Typography>\n </div>\n }\n columns={columns}\n tableOptions={tableOptions}\n entities={entities as ComponentEntity[]}\n />\n );\n}\n\n/** @public */\nexport const ProvidingComponentsCard = (\n props: ProvidingComponentsCardProps | ProvidingComponentsCardLegacyProps,\n) => {\n const { t } = useTranslationRef(apiDocsTranslationRef);\n\n if (isLegacyProps(props)) {\n return <ProvidingComponentsCardLegacy {...props} />;\n }\n\n const {\n title = t('providingComponentsCard.title'),\n columnConfig = entityColumnPresets.component.columns,\n } = props;\n\n return (\n <EntityRelationCard\n title={title}\n relationType={RELATION_API_PROVIDED_BY}\n columnConfig={columnConfig}\n emptyState={{\n message: t('providingComponentsCard.emptyContent.title'),\n helpLink:\n 'https://backstage.io/docs/features/software-catalog/descriptor-format#specprovidesapis-optional',\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAiEA,SAAS,cACP,KAAA,EAC6C;AAC7C,EAAA,OAAO,SAAA,IAAa,KAAA,IAAS,SAAA,IAAa,KAAA,IAAS,cAAA,IAAkB,KAAA;AACvE;AAEA,SAAS,8BACP,KAAA,EACA;AACA,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,qBAAqB,CAAA;AACrD,EAAA,MAAM;AAAA,IACJ,OAAA,GAAU,UAAA;AAAA,IACV,KAAA,GAAQ,EAAE,+BAA+B,CAAA;AAAA,IACzC,UAAU,WAAA,CAAY,sBAAA;AAAA,IACtB,eAAe;AAAC,GAClB,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,SAAA,EAAU;AAC7B,EAAA,MAAM,EAAE,QAAA,EAAU,OAAA,EAAS,KAAA,EAAM,GAAI,mBAAmB,MAAA,EAAQ;AAAA,IAC9D,IAAA,EAAM;AAAA,GACP,CAAA;AAED,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,2BACG,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA,CAAC,YAAS,CAAA,EACZ,CAAA;AAAA,EAEJ;AAEA,EAAA,IAAI,KAAA,IAAS,CAAC,QAAA,EAAU;AACtB,IAAA,uBACE,GAAA,CAAC,QAAA,EAAA,EAAS,OAAA,EAAkB,KAAA,EAC1B,QAAA,kBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,QA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