@backstage/plugin-catalog-react 1.11.3-next.1 → 1.11.4-next.0

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.
Files changed (145) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/alpha/package.json +1 -1
  3. package/dist/alpha.esm.js +4 -47
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/api.esm.js +8 -0
  6. package/dist/api.esm.js.map +1 -0
  7. package/dist/apis/EntityPresentationApi/EntityPresentationApi.esm.js +8 -0
  8. package/dist/apis/EntityPresentationApi/EntityPresentationApi.esm.js.map +1 -0
  9. package/dist/apis/EntityPresentationApi/defaultEntityPresentation.esm.js +86 -0
  10. package/dist/apis/EntityPresentationApi/defaultEntityPresentation.esm.js.map +1 -0
  11. package/dist/apis/EntityPresentationApi/useEntityPresentation.esm.js +35 -0
  12. package/dist/apis/EntityPresentationApi/useEntityPresentation.esm.js.map +1 -0
  13. package/dist/apis/EntityPresentationApi/useUpdatingObservable.esm.js +23 -0
  14. package/dist/apis/EntityPresentationApi/useUpdatingObservable.esm.js.map +1 -0
  15. package/dist/apis/StarredEntitiesApi/MockStarredEntitiesApi.esm.js +35 -0
  16. package/dist/apis/StarredEntitiesApi/MockStarredEntitiesApi.esm.js.map +1 -0
  17. package/dist/apis/StarredEntitiesApi/StarredEntitiesApi.esm.js +8 -0
  18. package/dist/apis/StarredEntitiesApi/StarredEntitiesApi.esm.js.map +1 -0
  19. package/dist/components/CatalogFilterLayout/CatalogFilterLayout.esm.js +60 -0
  20. package/dist/components/CatalogFilterLayout/CatalogFilterLayout.esm.js.map +1 -0
  21. package/dist/components/DefaultFilters/DefaultFilters.esm.js +27 -0
  22. package/dist/components/DefaultFilters/DefaultFilters.esm.js.map +1 -0
  23. package/dist/components/EntityAutocompletePicker/EntityAutocompletePicker.esm.js +105 -0
  24. package/dist/components/EntityAutocompletePicker/EntityAutocompletePicker.esm.js.map +1 -0
  25. package/dist/components/EntityAutocompletePicker/EntityAutocompletePickerInput.esm.js +27 -0
  26. package/dist/components/EntityAutocompletePicker/EntityAutocompletePickerInput.esm.js.map +1 -0
  27. package/dist/components/EntityAutocompletePicker/EntityAutocompletePickerOption.esm.js +26 -0
  28. package/dist/components/EntityAutocompletePicker/EntityAutocompletePickerOption.esm.js.map +1 -0
  29. package/dist/components/EntityDisplayName/EntityDisplayName.esm.js +42 -0
  30. package/dist/components/EntityDisplayName/EntityDisplayName.esm.js.map +1 -0
  31. package/dist/components/EntityKindPicker/EntityKindPicker.esm.js +92 -0
  32. package/dist/components/EntityKindPicker/EntityKindPicker.esm.js.map +1 -0
  33. package/dist/components/EntityKindPicker/kindFilterUtils.esm.js +42 -0
  34. package/dist/components/EntityKindPicker/kindFilterUtils.esm.js.map +1 -0
  35. package/dist/components/EntityLifecyclePicker/EntityLifecyclePicker.esm.js +31 -0
  36. package/dist/components/EntityLifecyclePicker/EntityLifecyclePicker.esm.js.map +1 -0
  37. package/dist/components/EntityNamespacePicker/EntityNamespacePicker.esm.js +31 -0
  38. package/dist/components/EntityNamespacePicker/EntityNamespacePicker.esm.js.map +1 -0
  39. package/dist/components/EntityOwnerPicker/EntityOwnerPicker.esm.js +183 -0
  40. package/dist/components/EntityOwnerPicker/EntityOwnerPicker.esm.js.map +1 -0
  41. package/dist/components/EntityOwnerPicker/useFacetsEntities.esm.js +88 -0
  42. package/dist/components/EntityOwnerPicker/useFacetsEntities.esm.js.map +1 -0
  43. package/dist/components/EntityOwnerPicker/useFetchEntities.esm.js +59 -0
  44. package/dist/components/EntityOwnerPicker/useFetchEntities.esm.js.map +1 -0
  45. package/dist/components/EntityOwnerPicker/useQueryEntities.esm.js +48 -0
  46. package/dist/components/EntityOwnerPicker/useQueryEntities.esm.js.map +1 -0
  47. package/dist/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.esm.js +20 -0
  48. package/dist/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.esm.js.map +1 -0
  49. package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js +24 -0
  50. package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js.map +1 -0
  51. package/dist/components/EntityPeekAheadPopover/CardActionComponents/GroupCardActions.esm.js +11 -0
  52. package/dist/components/EntityPeekAheadPopover/CardActionComponents/GroupCardActions.esm.js.map +1 -0
  53. package/dist/components/EntityPeekAheadPopover/CardActionComponents/UserCardActions.esm.js +11 -0
  54. package/dist/components/EntityPeekAheadPopover/CardActionComponents/UserCardActions.esm.js.map +1 -0
  55. package/dist/components/EntityPeekAheadPopover/EntityPeekAheadPopover.esm.js +110 -0
  56. package/dist/components/EntityPeekAheadPopover/EntityPeekAheadPopover.esm.js.map +1 -0
  57. package/dist/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.esm.js +98 -0
  58. package/dist/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.esm.js.map +1 -0
  59. package/dist/components/EntityRefLink/EntityRefLink.esm.js +64 -0
  60. package/dist/components/EntityRefLink/EntityRefLink.esm.js.map +1 -0
  61. package/dist/components/EntityRefLink/EntityRefLinks.esm.js +14 -0
  62. package/dist/components/EntityRefLink/EntityRefLinks.esm.js.map +1 -0
  63. package/dist/components/EntityRefLink/humanize.esm.js +43 -0
  64. package/dist/components/EntityRefLink/humanize.esm.js.map +1 -0
  65. package/dist/components/EntitySearchBar/EntitySearchBar.esm.js +77 -0
  66. package/dist/components/EntitySearchBar/EntitySearchBar.esm.js.map +1 -0
  67. package/dist/components/EntityTable/EntityTable.esm.js +56 -0
  68. package/dist/components/EntityTable/EntityTable.esm.js.map +1 -0
  69. package/dist/components/EntityTable/columns.esm.js +123 -0
  70. package/dist/components/EntityTable/columns.esm.js.map +1 -0
  71. package/dist/components/EntityTable/presets.esm.js +19 -0
  72. package/dist/components/EntityTable/presets.esm.js.map +1 -0
  73. package/dist/components/EntityTagPicker/EntityTagPicker.esm.js +26 -0
  74. package/dist/components/EntityTagPicker/EntityTagPicker.esm.js.map +1 -0
  75. package/dist/components/EntityTypePicker/EntityTypePicker.esm.js +44 -0
  76. package/dist/components/EntityTypePicker/EntityTypePicker.esm.js.map +1 -0
  77. package/dist/components/FavoriteEntity/FavoriteEntity.esm.js +37 -0
  78. package/dist/components/FavoriteEntity/FavoriteEntity.esm.js.map +1 -0
  79. package/dist/components/InspectEntityDialog/InspectEntityDialog.esm.js +99 -0
  80. package/dist/components/InspectEntityDialog/InspectEntityDialog.esm.js.map +1 -0
  81. package/dist/components/InspectEntityDialog/components/AncestryPage.esm.js +171 -0
  82. package/dist/components/InspectEntityDialog/components/AncestryPage.esm.js.map +1 -0
  83. package/dist/components/InspectEntityDialog/components/ColocatedPage.esm.js +101 -0
  84. package/dist/components/InspectEntityDialog/components/ColocatedPage.esm.js.map +1 -0
  85. package/dist/components/InspectEntityDialog/components/EntityKindIcon.esm.js +36 -0
  86. package/dist/components/InspectEntityDialog/components/EntityKindIcon.esm.js.map +1 -0
  87. package/dist/components/InspectEntityDialog/components/JsonPage.esm.js +18 -0
  88. package/dist/components/InspectEntityDialog/components/JsonPage.esm.js.map +1 -0
  89. package/dist/components/InspectEntityDialog/components/OverviewPage.esm.js +78 -0
  90. package/dist/components/InspectEntityDialog/components/OverviewPage.esm.js.map +1 -0
  91. package/dist/components/InspectEntityDialog/components/YamlPage.esm.js +19 -0
  92. package/dist/components/InspectEntityDialog/components/YamlPage.esm.js.map +1 -0
  93. package/dist/components/InspectEntityDialog/components/common.esm.js +74 -0
  94. package/dist/components/InspectEntityDialog/components/common.esm.js.map +1 -0
  95. package/dist/components/InspectEntityDialog/components/util.esm.js +8 -0
  96. package/dist/components/InspectEntityDialog/components/util.esm.js.map +1 -0
  97. package/dist/components/MissingAnnotationEmptyState/MissingAnnotationEmptyState.esm.js +95 -0
  98. package/dist/components/MissingAnnotationEmptyState/MissingAnnotationEmptyState.esm.js.map +1 -0
  99. package/dist/components/UnregisterEntityDialog/UnregisterEntityDialog.esm.js +162 -0
  100. package/dist/components/UnregisterEntityDialog/UnregisterEntityDialog.esm.js.map +1 -0
  101. package/dist/components/UnregisterEntityDialog/useUnregisterEntityDialogState.esm.js +73 -0
  102. package/dist/components/UnregisterEntityDialog/useUnregisterEntityDialogState.esm.js.map +1 -0
  103. package/dist/components/UserListPicker/UserListPicker.esm.js +199 -0
  104. package/dist/components/UserListPicker/UserListPicker.esm.js.map +1 -0
  105. package/dist/components/UserListPicker/useAllEntitiesCount.esm.js +51 -0
  106. package/dist/components/UserListPicker/useAllEntitiesCount.esm.js.map +1 -0
  107. package/dist/components/UserListPicker/useOwnedEntitiesCount.esm.js +98 -0
  108. package/dist/components/UserListPicker/useOwnedEntitiesCount.esm.js.map +1 -0
  109. package/dist/components/UserListPicker/useStarredEntitiesCount.esm.js +73 -0
  110. package/dist/components/UserListPicker/useStarredEntitiesCount.esm.js.map +1 -0
  111. package/dist/filters.esm.js +239 -0
  112. package/dist/filters.esm.js.map +1 -0
  113. package/dist/{esm/useEntity-DuPQWZpR.esm.js → hooks/useEntity.esm.js} +3 -14
  114. package/dist/hooks/useEntity.esm.js.map +1 -0
  115. package/dist/hooks/useEntityListProvider.esm.js +192 -0
  116. package/dist/hooks/useEntityListProvider.esm.js.map +1 -0
  117. package/dist/hooks/useEntityOwnership.esm.js +35 -0
  118. package/dist/hooks/useEntityOwnership.esm.js.map +1 -0
  119. package/dist/hooks/useEntityPermission.esm.js +29 -0
  120. package/dist/hooks/useEntityPermission.esm.js.map +1 -0
  121. package/dist/hooks/useEntityTypeFilter.esm.js +83 -0
  122. package/dist/hooks/useEntityTypeFilter.esm.js.map +1 -0
  123. package/dist/hooks/useRelatedEntities.esm.js +36 -0
  124. package/dist/hooks/useRelatedEntities.esm.js.map +1 -0
  125. package/dist/hooks/useStarredEntities.esm.js +35 -0
  126. package/dist/hooks/useStarredEntities.esm.js.map +1 -0
  127. package/dist/hooks/useStarredEntity.esm.js +36 -0
  128. package/dist/hooks/useStarredEntity.esm.js.map +1 -0
  129. package/dist/index.d.ts +2 -1
  130. package/dist/index.esm.js +42 -3338
  131. package/dist/index.esm.js.map +1 -1
  132. package/dist/routes.esm.js +22 -0
  133. package/dist/routes.esm.js.map +1 -0
  134. package/dist/testUtils/providers.esm.js +45 -0
  135. package/dist/testUtils/providers.esm.js.map +1 -0
  136. package/dist/utils/filters.esm.js +38 -0
  137. package/dist/utils/filters.esm.js.map +1 -0
  138. package/dist/utils/getEntityRelations.esm.js +15 -0
  139. package/dist/utils/getEntityRelations.esm.js.map +1 -0
  140. package/dist/utils/getEntitySourceLocation.esm.js +22 -0
  141. package/dist/utils/getEntitySourceLocation.esm.js.map +1 -0
  142. package/dist/utils/isOwnerOf.esm.js +23 -0
  143. package/dist/utils/isOwnerOf.esm.js.map +1 -0
  144. package/package.json +17 -17
  145. package/dist/esm/useEntity-DuPQWZpR.esm.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 1.11.4-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/catalog-model@1.5.0-next.0
9
+ - @backstage/core-components@0.14.5-next.0
10
+ - @backstage/catalog-client@1.6.5-next.0
11
+ - @backstage/plugin-catalog-common@1.0.23-next.0
12
+ - @backstage/core-plugin-api@1.9.2
13
+ - @backstage/errors@1.2.4
14
+ - @backstage/frontend-plugin-api@0.6.5-next.0
15
+ - @backstage/integration-react@1.1.26
16
+ - @backstage/types@1.1.1
17
+ - @backstage/version-bridge@1.0.8
18
+ - @backstage/plugin-permission-common@0.7.13
19
+ - @backstage/plugin-permission-react@0.4.22
20
+
21
+ ## 1.11.3
22
+
23
+ ### Patch Changes
24
+
25
+ - 47dec6f: Added the `no-top-level-material-ui-4-imports` ESLint rule to aid with the migration to Material UI v5
26
+ - b863830: Change behavior in EntityAutoCompletePicker to only hide filter if there are no available options. Previously the filter was hidden if there were <= 1 available options.
27
+ - abfbcfc: Updated dependency `@testing-library/react` to `^15.0.0`.
28
+ - cb1e3b0: Updated dependency `@testing-library/dom` to `^10.0.0`.
29
+ - Updated dependencies
30
+ - @backstage/core-components@0.14.4
31
+ - @backstage/core-plugin-api@1.9.2
32
+ - @backstage/frontend-plugin-api@0.6.4
33
+ - @backstage/version-bridge@1.0.8
34
+ - @backstage/plugin-permission-react@0.4.22
35
+ - @backstage/integration-react@1.1.26
36
+ - @backstage/catalog-client@1.6.4
37
+ - @backstage/catalog-model@1.4.5
38
+ - @backstage/errors@1.2.4
39
+ - @backstage/types@1.1.1
40
+ - @backstage/plugin-catalog-common@1.0.22
41
+ - @backstage/plugin-permission-common@0.7.13
42
+
3
43
  ## 1.11.3-next.1
4
44
 
5
45
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "1.11.3-next.1",
3
+ "version": "1.11.4-next.0",
4
4
  "main": "../dist/alpha.esm.js",
5
5
  "module": "../dist/alpha.esm.js",
6
6
  "types": "../dist/alpha.d.ts"
package/dist/alpha.esm.js CHANGED
@@ -1,51 +1,8 @@
1
1
  import { createExtensionDataRef, createSchemaFromZod, createExtension, coreExtensionData, ExtensionBoundary } from '@backstage/frontend-plugin-api';
2
2
  import React, { lazy } from 'react';
3
- import { RELATION_MEMBER_OF, getCompoundEntityRef, stringifyEntityRef, RELATION_OWNED_BY } from '@backstage/catalog-model';
4
- import { usePermission } from '@backstage/plugin-permission-react';
5
- import { g as getEntityRelations, a as useAsyncEntity } from './esm/useEntity-DuPQWZpR.esm.js';
6
- import '@backstage/core-plugin-api';
7
- import '@backstage/version-bridge';
8
-
9
- function isOwnerOf(owner, entity) {
10
- const possibleOwners = new Set(
11
- [
12
- ...getEntityRelations(owner, RELATION_MEMBER_OF, { kind: "group" }),
13
- ...owner ? [getCompoundEntityRef(owner)] : []
14
- ].map(stringifyEntityRef)
15
- );
16
- const owners = getEntityRelations(entity, RELATION_OWNED_BY).map(
17
- stringifyEntityRef
18
- );
19
- for (const ownerItem of owners) {
20
- if (possibleOwners.has(ownerItem)) {
21
- return true;
22
- }
23
- }
24
- return false;
25
- }
26
-
27
- function useEntityPermission(permission) {
28
- const {
29
- entity,
30
- loading: loadingEntity,
31
- error: entityError
32
- } = useAsyncEntity();
33
- const {
34
- allowed,
35
- loading: loadingPermission,
36
- error: permissionError
37
- } = usePermission({
38
- permission,
39
- resourceRef: entity ? stringifyEntityRef(entity) : void 0
40
- });
41
- if (loadingEntity || loadingPermission) {
42
- return { loading: true, allowed: false };
43
- }
44
- if (entityError) {
45
- return { loading: false, allowed: false, error: entityError };
46
- }
47
- return { loading: false, allowed, error: permissionError };
48
- }
3
+ export { useEntityPermission } from './hooks/useEntityPermission.esm.js';
4
+ import '@backstage/catalog-model';
5
+ export { isOwnerOf } from './utils/isOwnerOf.esm.js';
49
6
 
50
7
  const catalogExtensionData = {
51
8
  entityContentTitle: createExtensionDataRef(
@@ -145,5 +102,5 @@ function mergeFilters(inputs) {
145
102
  return {};
146
103
  }
147
104
 
148
- export { catalogExtensionData, createEntityCardExtension, createEntityContentExtension, isOwnerOf, useEntityPermission };
105
+ export { catalogExtensionData, createEntityCardExtension, createEntityContentExtension };
149
106
  //# sourceMappingURL=alpha.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.esm.js","sources":["../src/utils/isOwnerOf.ts","../src/hooks/useEntityPermission.ts","../src/alpha.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 Entity,\n getCompoundEntityRef,\n RELATION_MEMBER_OF,\n RELATION_OWNED_BY,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { getEntityRelations } from './getEntityRelations';\n\n/**\n * Returns true if the `owner` argument is a direct owner on the `entity` argument.\n *\n * @alpha\n * @remarks\n *\n * Note that this ownership is not the same as using the claims in the auth-resolver, it only will take into account ownership as expressed by direct entity relations.\n * It doesn't know anything about the additional groups that a user might belong to which the claims contain.\n */\nexport function isOwnerOf(owner: Entity, entity: Entity) {\n const possibleOwners = new Set(\n [\n ...getEntityRelations(owner, RELATION_MEMBER_OF, { kind: 'group' }),\n ...(owner ? [getCompoundEntityRef(owner)] : []),\n ].map(stringifyEntityRef),\n );\n\n const owners = getEntityRelations(entity, RELATION_OWNED_BY).map(\n stringifyEntityRef,\n );\n\n for (const ownerItem of owners) {\n if (possibleOwners.has(ownerItem)) {\n return true;\n }\n }\n\n return false;\n}\n","/*\n * Copyright 2022 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 { stringifyEntityRef } from '@backstage/catalog-model';\nimport { ResourcePermission } from '@backstage/plugin-permission-common';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { useAsyncEntity } from './useEntity';\n\n/**\n * A thin wrapper around the\n * {@link @backstage/plugin-permission-react#usePermission} hook which uses the\n * current entity in context to make an authorization request for the given\n * {@link @backstage/plugin-catalog-common#CatalogEntityPermission}.\n *\n * Note: this hook blocks the permission request until the entity has loaded in\n * context. If you have the entityRef and need concurrent requests, use the\n * `usePermission` hook directly.\n * @alpha\n */\nexport function useEntityPermission(\n // TODO(joeporpeglia) Replace with `CatalogEntityPermission` when the issue described in\n // https://github.com/backstage/backstage/pull/10128 is fixed.\n permission: ResourcePermission<'catalog-entity'>,\n): {\n loading: boolean;\n allowed: boolean;\n error?: Error;\n} {\n const {\n entity,\n loading: loadingEntity,\n error: entityError,\n } = useAsyncEntity();\n const {\n allowed,\n loading: loadingPermission,\n error: permissionError,\n } = usePermission({\n permission,\n resourceRef: entity ? stringifyEntityRef(entity) : undefined,\n });\n\n if (loadingEntity || loadingPermission) {\n return { loading: true, allowed: false };\n }\n if (entityError) {\n return { loading: false, allowed: false, error: entityError };\n }\n return { loading: false, allowed, error: permissionError };\n}\n","/*\n * Copyright 2023 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 AnyExtensionInputMap,\n ExtensionBoundary,\n PortableSchema,\n ResolvedExtensionInputs,\n RouteRef,\n coreExtensionData,\n createExtension,\n createExtensionDataRef,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport React, { lazy } from 'react';\nimport { Entity } from '@backstage/catalog-model';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { Expand } from '../../../packages/frontend-plugin-api/src/types';\n\nexport { useEntityPermission } from './hooks/useEntityPermission';\nexport { isOwnerOf } from './utils';\n\n/** @alpha */\nexport const catalogExtensionData = {\n entityContentTitle: createExtensionDataRef<string>(\n 'catalog.entity-content-title',\n ),\n entityFilterFunction: createExtensionDataRef<(entity: Entity) => boolean>(\n 'catalog.entity-filter-function',\n ),\n entityFilterExpression: createExtensionDataRef<string>(\n 'catalog.entity-filter-expression',\n ),\n};\n\n// TODO: Figure out how to merge with provided config schema\n/** @alpha */\nexport function createEntityCardExtension<\n TConfig extends { filter?: string },\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({\n filter: z.string().optional(),\n }),\n ) as PortableSchema<TConfig>);\n return createExtension({\n kind: 'entity-card',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'entity-content:catalog/overview',\n input: 'cards',\n },\n disabled: options.disabled ?? true,\n output: {\n element: coreExtensionData.reactElement,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema,\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs, config })\n .then(element => ({ default: () => element })),\n );\n\n return {\n element: (\n <ExtensionBoundary node={node}>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/** @alpha */\nexport function createEntityContentExtension<\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n routeRef?: RouteRef;\n defaultPath: string;\n defaultTitle: string;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n return createExtension({\n kind: 'entity-content',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'page:catalog/entity',\n input: 'contents',\n },\n disabled: options.disabled ?? true,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n title: catalogExtensionData.entityContentTitle,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema: createSchemaFromZod(z =>\n z.object({\n path: z.string().default(options.defaultPath),\n title: z.string().default(options.defaultTitle),\n filter: z.string().optional(),\n }),\n ),\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs })\n .then(element => ({ default: () => element })),\n );\n\n return {\n path: config.path,\n title: config.title,\n routeRef: options.routeRef,\n element: (\n <ExtensionBoundary node={node} routable>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/**\n * Decides what filter outputs to produce, given some options and config\n */\nfunction mergeFilters(inputs: {\n options: {\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n };\n config: {\n filter?: string;\n };\n}): {\n filterFunction?: typeof catalogExtensionData.entityFilterFunction.T;\n filterExpression?: typeof catalogExtensionData.entityFilterExpression.T;\n} {\n const { options, config } = inputs;\n if (config.filter) {\n return { filterExpression: config.filter };\n } else if (typeof options.filter === 'string') {\n return { filterExpression: options.filter };\n } else if (typeof options.filter === 'function') {\n return { filterFunction: options.filter };\n }\n return {};\n}\n"],"names":[],"mappings":";;;;;;;;AAkCgB,SAAA,SAAA,CAAU,OAAe,MAAgB,EAAA;AACvD,EAAA,MAAM,iBAAiB,IAAI,GAAA;AAAA,IACzB;AAAA,MACE,GAAG,kBAAmB,CAAA,KAAA,EAAO,oBAAoB,EAAE,IAAA,EAAM,SAAS,CAAA;AAAA,MAClE,GAAI,KAAQ,GAAA,CAAC,qBAAqB,KAAK,CAAC,IAAI,EAAC;AAAA,KAC/C,CAAE,IAAI,kBAAkB,CAAA;AAAA,GAC1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AAW,QAAU,EAAA;AAC7C,IAAO,OAAA,EAAE,gBAAkB,EAAA,OAAA,CAAQ,MAAO,EAAA,CAAA;AAAA,GACjC,MAAA,IAAA,OAAO,OAAQ,CAAA,MAAA,KAAW,UAAY,EAAA;AAC/C,IAAO,OAAA,EAAE,cAAgB,EAAA,OAAA,CAAQ,MAAO,EAAA,CAAA;AAAA,GAC1C;AACA,EAAA,OAAO,EAAC,CAAA;AACV;;;;"}
1
+ {"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 AnyExtensionInputMap,\n ExtensionBoundary,\n PortableSchema,\n ResolvedExtensionInputs,\n RouteRef,\n coreExtensionData,\n createExtension,\n createExtensionDataRef,\n createSchemaFromZod,\n} from '@backstage/frontend-plugin-api';\nimport React, { lazy } from 'react';\nimport { Entity } from '@backstage/catalog-model';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { Expand } from '../../../packages/frontend-plugin-api/src/types';\n\nexport { useEntityPermission } from './hooks/useEntityPermission';\nexport { isOwnerOf } from './utils';\n\n/** @alpha */\nexport const catalogExtensionData = {\n entityContentTitle: createExtensionDataRef<string>(\n 'catalog.entity-content-title',\n ),\n entityFilterFunction: createExtensionDataRef<(entity: Entity) => boolean>(\n 'catalog.entity-filter-function',\n ),\n entityFilterExpression: createExtensionDataRef<string>(\n 'catalog.entity-filter-expression',\n ),\n};\n\n// TODO: Figure out how to merge with provided config schema\n/** @alpha */\nexport function createEntityCardExtension<\n TConfig extends { filter?: string },\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n const configSchema =\n 'configSchema' in options\n ? options.configSchema\n : (createSchemaFromZod(z =>\n z.object({\n filter: z.string().optional(),\n }),\n ) as PortableSchema<TConfig>);\n return createExtension({\n kind: 'entity-card',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'entity-content:catalog/overview',\n input: 'cards',\n },\n disabled: options.disabled ?? true,\n output: {\n element: coreExtensionData.reactElement,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema,\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs, config })\n .then(element => ({ default: () => element })),\n );\n\n return {\n element: (\n <ExtensionBoundary node={node}>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/** @alpha */\nexport function createEntityContentExtension<\n TInputs extends AnyExtensionInputMap,\n>(options: {\n namespace?: string;\n name?: string;\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n routeRef?: RouteRef;\n defaultPath: string;\n defaultTitle: string;\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n loader: (options: {\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<JSX.Element>;\n}) {\n return createExtension({\n kind: 'entity-content',\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo ?? {\n id: 'page:catalog/entity',\n input: 'contents',\n },\n disabled: options.disabled ?? true,\n output: {\n element: coreExtensionData.reactElement,\n path: coreExtensionData.routePath,\n routeRef: coreExtensionData.routeRef.optional(),\n title: catalogExtensionData.entityContentTitle,\n filterFunction: catalogExtensionData.entityFilterFunction.optional(),\n filterExpression: catalogExtensionData.entityFilterExpression.optional(),\n },\n inputs: options.inputs,\n configSchema: createSchemaFromZod(z =>\n z.object({\n path: z.string().default(options.defaultPath),\n title: z.string().default(options.defaultTitle),\n filter: z.string().optional(),\n }),\n ),\n factory({ config, inputs, node }) {\n const ExtensionComponent = lazy(() =>\n options\n .loader({ inputs })\n .then(element => ({ default: () => element })),\n );\n\n return {\n path: config.path,\n title: config.title,\n routeRef: options.routeRef,\n element: (\n <ExtensionBoundary node={node} routable>\n <ExtensionComponent />\n </ExtensionBoundary>\n ),\n ...mergeFilters({ config, options }),\n };\n },\n });\n}\n\n/**\n * Decides what filter outputs to produce, given some options and config\n */\nfunction mergeFilters(inputs: {\n options: {\n filter?:\n | typeof catalogExtensionData.entityFilterFunction.T\n | typeof catalogExtensionData.entityFilterExpression.T;\n };\n config: {\n filter?: string;\n };\n}): {\n filterFunction?: typeof catalogExtensionData.entityFilterFunction.T;\n filterExpression?: typeof catalogExtensionData.entityFilterExpression.T;\n} {\n const { options, config } = inputs;\n if (config.filter) {\n return { filterExpression: config.filter };\n } else if (typeof options.filter === 'string') {\n return { filterExpression: options.filter };\n } else if (typeof options.filter === 'function') {\n return { filterFunction: options.filter };\n }\n return {};\n}\n"],"names":[],"mappings":";;;;;;AAoCO,MAAM,oBAAuB,GAAA;AAAA,EAClC,kBAAoB,EAAA,sBAAA;AAAA,IAClB,8BAAA;AAAA,GACF;AAAA,EACA,oBAAsB,EAAA,sBAAA;AAAA,IACpB,gCAAA;AAAA,GACF;AAAA,EACA,sBAAwB,EAAA,sBAAA;AAAA,IACtB,kCAAA;AAAA,GACF;AACF,EAAA;AAIO,SAAS,0BAGd,OAcC,EAAA;AAnEH,EAAA,IAAA,EAAA,EAAA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AAA,KAAW,UAAY,EAAA;AAC/C,IAAO,OAAA,EAAE,cAAgB,EAAA,OAAA,CAAQ,MAAO,EAAA,CAAA;AAAA,GAC1C;AACA,EAAA,OAAO,EAAC,CAAA;AACV;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const catalogApiRef = createApiRef({
4
+ id: "plugin.catalog.service"
5
+ });
6
+
7
+ export { catalogApiRef };
8
+ //# sourceMappingURL=api.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"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 { CatalogApi } from '@backstage/catalog-client';\nimport { createApiRef } from '@backstage/core-plugin-api';\n\n/**\n * The API reference for the {@link @backstage/catalog-client#CatalogApi}.\n * @public\n */\nexport const catalogApiRef = createApiRef<CatalogApi>({\n id: 'plugin.catalog.service',\n});\n"],"names":[],"mappings":";;AAuBO,MAAM,gBAAgB,YAAyB,CAAA;AAAA,EACpD,EAAI,EAAA,wBAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const entityPresentationApiRef = createApiRef({
4
+ id: "plugin.catalog.entity-presentation"
5
+ });
6
+
7
+ export { entityPresentationApiRef };
8
+ //# sourceMappingURL=EntityPresentationApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityPresentationApi.esm.js","sources":["../../../src/apis/EntityPresentationApi/EntityPresentationApi.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { Entity } from '@backstage/catalog-model';\nimport {\n ApiRef,\n IconComponent,\n createApiRef,\n} from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\n\n/**\n * An API that handles how to represent entities in the interface.\n *\n * @public\n */\nexport const entityPresentationApiRef: ApiRef<EntityPresentationApi> =\n createApiRef({\n id: 'plugin.catalog.entity-presentation',\n });\n\n/**\n * The visual presentation of an entity reference at some point in time.\n *\n * @public\n */\nexport interface EntityRefPresentationSnapshot {\n /**\n * The ref to the entity that this snapshot represents.\n *\n * @remarks\n *\n * Note that when the input data was broken or had missing vital pieces of\n * information, this string may contain placeholders such as \"unknown\". You\n * can therefore not necessarily assume that the ref is completely valid and\n * usable for example for forming a clickable link to the entity.\n */\n entityRef: string;\n /**\n * A string that can be used as a plain representation of the entity, for\n * example in a header or a link.\n *\n * @remarks\n *\n * The title may be short and not contain all of the information that the\n * entity holds. When rendering the primary title, you may also want to\n * make sure to add more contextual information nearby such as the icon or\n * secondary title, since the primary could for example just be the\n * `metadata.name` of the entity which might be ambiguous to the reader.\n */\n primaryTitle: string;\n /**\n * Optionally, some additional textual information about the entity, to be\n * used as a clarification on top of the primary title.\n *\n * @remarks\n *\n * This text can for example be rendered in a tooltip or be used as a\n * subtitle. It may not be sufficient to display on its own; it should\n * typically be used in conjunction with the primary title. It can contain\n * such information as the entity ref and/or a `spec.type` etc.\n */\n secondaryTitle?: string;\n /**\n * Optionally, an icon that represents the kind/type of entity.\n *\n * @remarks\n *\n * This icon should ideally be easily recognizable as the kind of entity, and\n * be used consistently throughout the Backstage interface. It can be rendered\n * both in larger formats such as in a header, or in smaller formats such as\n * inline with regular text, so bear in mind that the legibility should be\n * high in both cases.\n *\n * A value of `false` here indicates the desire to not have an icon present\n * for the given implementation. A value of `undefined` leaves it at the\n * discretion of the display layer to choose what to do (such as for example\n * showing a fallback icon).\n */\n Icon?: IconComponent | undefined | false;\n}\n\n/**\n * The visual presentation of an entity reference.\n *\n * @public\n */\nexport interface EntityRefPresentation {\n /**\n * The representation that's suitable to use for this entity right now.\n */\n snapshot: EntityRefPresentationSnapshot;\n /**\n * Some presentation implementations support emitting updated snapshots over\n * time, for example after retrieving additional data from the catalog or\n * elsewhere.\n */\n update$?: Observable<EntityRefPresentationSnapshot>;\n}\n\n/**\n * An API that decides how to visually represent entities in the interface.\n *\n * @remarks\n *\n * Most consumers will want to use the {@link useEntityPresentation} hook\n * instead of this interface directly.\n *\n * @public\n */\nexport interface EntityPresentationApi {\n /**\n * Fetches the presentation for an entity.\n *\n * @param entityOrRef - Either an entity, or a string ref to it. If you pass\n * in an entity, it is assumed that it is not a partial one - i.e. only pass\n * in an entity if you know that it was fetched in such a way that it\n * contains all of the fields that the representation renderer needs.\n * @param context - Contextual information that may affect the presentation.\n */\n forEntity(\n entityOrRef: Entity | string,\n context?: {\n defaultKind?: string;\n defaultNamespace?: string;\n },\n ): EntityRefPresentation;\n}\n"],"names":[],"mappings":";;AA6BO,MAAM,2BACX,YAAa,CAAA;AAAA,EACX,EAAI,EAAA,oCAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,86 @@
1
+ import { stringifyEntityRef, DEFAULT_NAMESPACE } from '@backstage/catalog-model';
2
+ import get from 'lodash/get';
3
+
4
+ function defaultEntityPresentation(entityOrRef, context) {
5
+ const { kind, namespace, name, title, description, displayName, type } = getParts(entityOrRef);
6
+ const entityRef = stringifyEntityRef({
7
+ kind: kind || "unknown",
8
+ namespace: namespace || DEFAULT_NAMESPACE,
9
+ name: name || "unknown"
10
+ });
11
+ const shortRef = getShortRef({ kind, namespace, name, context });
12
+ const primary = [displayName, title, shortRef].find(
13
+ (candidate) => candidate && typeof candidate === "string"
14
+ );
15
+ const secondary = [
16
+ primary !== entityRef ? entityRef : void 0,
17
+ type,
18
+ description
19
+ ].filter((candidate) => candidate && typeof candidate === "string").join(" | ");
20
+ return {
21
+ entityRef,
22
+ primaryTitle: primary,
23
+ secondaryTitle: secondary || void 0,
24
+ Icon: void 0
25
+ // leave it up to the presentation API to handle
26
+ };
27
+ }
28
+ function getParts(entityOrRef) {
29
+ if (typeof entityOrRef === "string") {
30
+ let colonI = entityOrRef.indexOf(":");
31
+ const slashI = entityOrRef.indexOf("/");
32
+ if (slashI !== -1 && slashI < colonI) {
33
+ colonI = -1;
34
+ }
35
+ const kind = colonI === -1 ? void 0 : entityOrRef.slice(0, colonI);
36
+ const namespace = slashI === -1 ? void 0 : entityOrRef.slice(colonI + 1, slashI);
37
+ const name = entityOrRef.slice(Math.max(colonI + 1, slashI + 1));
38
+ return { kind, namespace, name };
39
+ }
40
+ if (typeof entityOrRef === "object" && entityOrRef !== null) {
41
+ const kind = [get(entityOrRef, "kind")].find(
42
+ (candidate) => candidate && typeof candidate === "string"
43
+ );
44
+ const namespace = [
45
+ get(entityOrRef, "metadata.namespace"),
46
+ get(entityOrRef, "namespace")
47
+ ].find((candidate) => candidate && typeof candidate === "string");
48
+ const name = [
49
+ get(entityOrRef, "metadata.name"),
50
+ get(entityOrRef, "name")
51
+ ].find((candidate) => candidate && typeof candidate === "string");
52
+ const title = [get(entityOrRef, "metadata.title")].find(
53
+ (candidate) => candidate && typeof candidate === "string"
54
+ );
55
+ const description = [get(entityOrRef, "metadata.description")].find(
56
+ (candidate) => candidate && typeof candidate === "string"
57
+ );
58
+ const displayName = [get(entityOrRef, "spec.profile.displayName")].find(
59
+ (candidate) => candidate && typeof candidate === "string"
60
+ );
61
+ const type = [get(entityOrRef, "spec.type")].find(
62
+ (candidate) => candidate && typeof candidate === "string"
63
+ );
64
+ return { kind, namespace, name, title, description, displayName, type };
65
+ }
66
+ return {};
67
+ }
68
+ function getShortRef(options) {
69
+ var _a, _b, _c, _d, _e;
70
+ const kind = ((_a = options.kind) == null ? void 0 : _a.toLocaleLowerCase("en-US")) || "unknown";
71
+ const namespace = options.namespace || DEFAULT_NAMESPACE;
72
+ const name = options.name || "unknown";
73
+ const defaultKindLower = (_c = (_b = options.context) == null ? void 0 : _b.defaultKind) == null ? void 0 : _c.toLocaleLowerCase("en-US");
74
+ const defaultNamespaceLower = (_e = (_d = options.context) == null ? void 0 : _d.defaultNamespace) == null ? void 0 : _e.toLocaleLowerCase("en-US");
75
+ let result = name;
76
+ if (defaultNamespaceLower && namespace.toLocaleLowerCase("en-US") !== defaultNamespaceLower || namespace !== DEFAULT_NAMESPACE) {
77
+ result = `${namespace}/${result}`;
78
+ }
79
+ if (defaultKindLower && kind.toLocaleLowerCase("en-US") !== defaultKindLower) {
80
+ result = `${kind}:${result}`;
81
+ }
82
+ return result;
83
+ }
84
+
85
+ export { defaultEntityPresentation };
86
+ //# sourceMappingURL=defaultEntityPresentation.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultEntityPresentation.esm.js","sources":["../../../src/apis/EntityPresentationApi/defaultEntityPresentation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport get from 'lodash/get';\nimport { EntityRefPresentationSnapshot } from './EntityPresentationApi';\n\n/**\n * This returns the default representation of an entity.\n *\n * @public\n * @param entityOrRef - Either an entity, or a ref to it.\n * @param context - Contextual information that may affect the presentation.\n */\nexport function defaultEntityPresentation(\n entityOrRef: Entity | CompoundEntityRef | string,\n context?: {\n defaultKind?: string;\n defaultNamespace?: string;\n },\n): EntityRefPresentationSnapshot {\n // NOTE(freben): This code may look convoluted, but it tries its very best to\n // be defensive and handling any type of malformed input and still producing\n // some form of result without crashing.\n const { kind, namespace, name, title, description, displayName, type } =\n getParts(entityOrRef);\n\n const entityRef: string = stringifyEntityRef({\n kind: kind || 'unknown',\n namespace: namespace || DEFAULT_NAMESPACE,\n name: name || 'unknown',\n });\n\n const shortRef = getShortRef({ kind, namespace, name, context });\n\n const primary = [displayName, title, shortRef].find(\n candidate => candidate && typeof candidate === 'string',\n )!;\n\n const secondary = [\n primary !== entityRef ? entityRef : undefined,\n type,\n description,\n ]\n .filter(candidate => candidate && typeof candidate === 'string')\n .join(' | ');\n\n return {\n entityRef,\n primaryTitle: primary,\n secondaryTitle: secondary || undefined,\n Icon: undefined, // leave it up to the presentation API to handle\n };\n}\n\n// Try to extract display-worthy parts of an entity or ref as best we can, without throwing\nfunction getParts(entityOrRef: Entity | CompoundEntityRef | string): {\n kind?: string;\n namespace?: string;\n name?: string;\n title?: string;\n description?: string;\n displayName?: string;\n type?: string;\n} {\n if (typeof entityOrRef === 'string') {\n let colonI = entityOrRef.indexOf(':');\n const slashI = entityOrRef.indexOf('/');\n\n // If the / is ahead of the :, treat the rest as the name\n if (slashI !== -1 && slashI < colonI) {\n colonI = -1;\n }\n\n const kind = colonI === -1 ? undefined : entityOrRef.slice(0, colonI);\n const namespace =\n slashI === -1 ? undefined : entityOrRef.slice(colonI + 1, slashI);\n const name = entityOrRef.slice(Math.max(colonI + 1, slashI + 1));\n\n return { kind, namespace, name };\n }\n\n if (typeof entityOrRef === 'object' && entityOrRef !== null) {\n const kind = [get(entityOrRef, 'kind')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const namespace = [\n get(entityOrRef, 'metadata.namespace'),\n get(entityOrRef, 'namespace'),\n ].find(candidate => candidate && typeof candidate === 'string');\n\n const name = [\n get(entityOrRef, 'metadata.name'),\n get(entityOrRef, 'name'),\n ].find(candidate => candidate && typeof candidate === 'string');\n\n const title = [get(entityOrRef, 'metadata.title')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const description = [get(entityOrRef, 'metadata.description')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const displayName = [get(entityOrRef, 'spec.profile.displayName')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n const type = [get(entityOrRef, 'spec.type')].find(\n candidate => candidate && typeof candidate === 'string',\n );\n\n return { kind, namespace, name, title, description, displayName, type };\n }\n\n return {};\n}\n\nfunction getShortRef(options: {\n kind?: string;\n namespace?: string;\n name?: string;\n context?: { defaultKind?: string; defaultNamespace?: string };\n}): string {\n const kind = options.kind?.toLocaleLowerCase('en-US') || 'unknown';\n const namespace = options.namespace || DEFAULT_NAMESPACE;\n const name = options.name || 'unknown';\n const defaultKindLower =\n options.context?.defaultKind?.toLocaleLowerCase('en-US');\n const defaultNamespaceLower =\n options.context?.defaultNamespace?.toLocaleLowerCase('en-US');\n\n let result = name;\n\n if (\n (defaultNamespaceLower &&\n namespace.toLocaleLowerCase('en-US') !== defaultNamespaceLower) ||\n namespace !== DEFAULT_NAMESPACE\n ) {\n result = `${namespace}/${result}`;\n }\n\n if (\n defaultKindLower &&\n kind.toLocaleLowerCase('en-US') !== defaultKindLower\n ) {\n result = `${kind}:${result}`;\n }\n\n return result;\n}\n"],"names":[],"mappings":";;;AAgCgB,SAAA,yBAAA,CACd,aACA,OAI+B,EAAA;AAI/B,EAAM,MAAA,EAAE,IAAM,EAAA,SAAA,EAAW,IAAM,EAAA,KAAA,EAAO,aAAa,WAAa,EAAA,IAAA,EAC9D,GAAA,QAAA,CAAS,WAAW,CAAA,CAAA;AAEtB,EAAA,MAAM,YAAoB,kBAAmB,CAAA;AAAA,IAC3C,MAAM,IAAQ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A,OAAA,CAAA,OAAA,KAAR,IAAiB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,gBAAA,KAAjB,mBAAmC,iBAAkB,CAAA,OAAA,CAAA,CAAA;AAEvD,EAAA,IAAI,MAAS,GAAA,IAAA,CAAA;AAEb,EAAA,IACG,yBACC,SAAU,CAAA,iBAAA,CAAkB,OAAO,CAAM,KAAA,qBAAA,IAC3C,cAAc,iBACd,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GACjC;AAEA,EAAA,IACE,gBACA,IAAA,IAAA,CAAK,iBAAkB,CAAA,OAAO,MAAM,gBACpC,EAAA;AACA,IAAS,MAAA,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,CAAA,CAAA;AAAA,GAC5B;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,35 @@
1
+ import { stringifyEntityRef } from '@backstage/catalog-model';
2
+ import { useApiHolder } from '@backstage/core-plugin-api';
3
+ import { useMemo } from 'react';
4
+ import { entityPresentationApiRef } from './EntityPresentationApi.esm.js';
5
+ import { defaultEntityPresentation } from './defaultEntityPresentation.esm.js';
6
+ import { useUpdatingObservable } from './useUpdatingObservable.esm.js';
7
+
8
+ function useEntityPresentation(entityOrRef, context) {
9
+ const apis = useApiHolder();
10
+ const entityPresentationApi = apis.get(entityPresentationApiRef);
11
+ const deps = [
12
+ entityPresentationApi,
13
+ JSON.stringify(entityOrRef),
14
+ JSON.stringify(context || null)
15
+ ];
16
+ const presentation = useMemo(
17
+ () => {
18
+ if (!entityPresentationApi) {
19
+ return { snapshot: defaultEntityPresentation(entityOrRef, context) };
20
+ }
21
+ return entityPresentationApi.forEntity(
22
+ typeof entityOrRef === "string" || "metadata" in entityOrRef ? entityOrRef : stringifyEntityRef(entityOrRef),
23
+ context
24
+ );
25
+ },
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ deps
28
+ );
29
+ return useUpdatingObservable(presentation.snapshot, presentation.update$, [
30
+ presentation
31
+ ]);
32
+ }
33
+
34
+ export { useEntityPresentation };
35
+ //# sourceMappingURL=useEntityPresentation.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityPresentation.esm.js","sources":["../../../src/apis/EntityPresentationApi/useEntityPresentation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 CompoundEntityRef,\n Entity,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApiHolder } from '@backstage/core-plugin-api';\nimport { useMemo } from 'react';\nimport {\n EntityRefPresentation,\n EntityRefPresentationSnapshot,\n entityPresentationApiRef,\n} from './EntityPresentationApi';\nimport { defaultEntityPresentation } from './defaultEntityPresentation';\nimport { useUpdatingObservable } from './useUpdatingObservable';\n\n/**\n * Returns information about how to represent an entity in the interface.\n *\n * @public\n * @param entityOrRef - The entity to represent, or an entity ref to it. If you\n * pass in an entity, it is assumed that it is NOT a partial one - i.e. only\n * pass in an entity if you know that it was fetched in such a way that it\n * contains all of the fields that the representation renderer needs.\n * @param context - Optional context that control details of the presentation.\n * @returns A snapshot of the entity presentation, which may change over time\n */\nexport function useEntityPresentation(\n entityOrRef: Entity | CompoundEntityRef | string,\n context?: {\n defaultKind?: string;\n defaultNamespace?: string;\n },\n): EntityRefPresentationSnapshot {\n // Defensively allow for a missing presentation API, which makes this hook\n // safe to use in tests.\n const apis = useApiHolder();\n const entityPresentationApi = apis.get(entityPresentationApiRef);\n\n const deps = [\n entityPresentationApi,\n JSON.stringify(entityOrRef),\n JSON.stringify(context || null),\n ];\n\n const presentation = useMemo<EntityRefPresentation>(\n () => {\n if (!entityPresentationApi) {\n return { snapshot: defaultEntityPresentation(entityOrRef, context) };\n }\n\n return entityPresentationApi.forEntity(\n typeof entityOrRef === 'string' || 'metadata' in entityOrRef\n ? entityOrRef\n : stringifyEntityRef(entityOrRef),\n context,\n );\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n deps,\n );\n\n // NOTE(freben): We intentionally do not use the plain useObservable from the\n // react-use library here. That hook does not support a dependencies array,\n // and also it only subscribes once to the initially passed in observable and\n // won't properly react when either initial value or the actual observable\n // changes.\n return useUpdatingObservable(presentation.snapshot, presentation.update$, [\n presentation,\n ]);\n}\n"],"names":[],"mappings":";;;;;;;AA0CgB,SAAA,qBAAA,CACd,aACA,OAI+B,EAAA;AAG/B,EAAA,MAAM,OAAO,YAAa,EAAA,CAAA;AAC1B,EAAM,MAAA,qBAAA,GAAwB,IAAK,CAAA,GAAA,CAAI,wBAAwB,CAAA,CAAA;AAE/D,EAAA,MAAM,IAAO,GAAA;AAAA,IACX,qBAAA;AAAA,IACA,IAAA,CAAK,UAAU,WAAW,CAAA;AAAA,IAC1B,IAAA,CAAK,SAAU,CAAA,OAAA,IAAW,IAAI,CAAA;AAAA,GAChC,CAAA;AAEA,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,MAAM;AACJ,MAAA,IAAI,CAAC,qBAAuB,EAAA;AAC1B,QAAA,OAAO,EAAE,QAAA,EAAU,yBAA0B,CAAA,WAAA,EAAa,OAAO,CAAE,EAAA,CAAA;AAAA,OACrE;AAEA,MAAA,OAAO,qBAAsB,CAAA,SAAA;AAAA,QAC3B,OAAO,WAAgB,KAAA,QAAA,IAAY,cAAc,WAC7C,GAAA,WAAA,GACA,mBAAmB,WAAW,CAAA;AAAA,QAClC,OAAA;AAAA,OACF,CAAA;AAAA,KACF;AAAA;AAAA,IAEA,IAAA;AAAA,GACF,CAAA;AAOA,EAAA,OAAO,qBAAsB,CAAA,YAAA,CAAa,QAAU,EAAA,YAAA,CAAa,OAAS,EAAA;AAAA,IACxE,YAAA;AAAA,GACD,CAAA,CAAA;AACH;;;;"}
@@ -0,0 +1,23 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function useUpdatingObservable(value, observable, deps) {
4
+ const [snapshot, setSnapshot] = useState(value);
5
+ useEffect(() => {
6
+ setSnapshot(value);
7
+ const subscription = observable == null ? void 0 : observable.subscribe({
8
+ next: (updatedValue) => {
9
+ setSnapshot(updatedValue);
10
+ },
11
+ complete: () => {
12
+ subscription == null ? void 0 : subscription.unsubscribe();
13
+ }
14
+ });
15
+ return () => {
16
+ subscription == null ? void 0 : subscription.unsubscribe();
17
+ };
18
+ }, deps);
19
+ return snapshot;
20
+ }
21
+
22
+ export { useUpdatingObservable };
23
+ //# sourceMappingURL=useUpdatingObservable.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUpdatingObservable.esm.js","sources":["../../../src/apis/EntityPresentationApi/useUpdatingObservable.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { Observable } from '@backstage/types';\nimport { DependencyList, useEffect, useState } from 'react';\n\n/**\n * Subscribe to an observable and return the latest value from it.\n *\n * @remarks\n *\n * This implementation differs in a few important ways from the plain\n * useObservable from the react-use library. That hook does not support a\n * dependencies array, and also it only subscribes once to the initially passed\n * in observable and won't properly react when either initial value or the\n * actual observable changes.\n *\n * This hook will ensure to resubscribe and reconsider the initial value,\n * whenever the dependencies change.\n */\nexport function useUpdatingObservable<T>(\n value: T,\n observable: Observable<T> | undefined,\n deps: DependencyList,\n): T {\n const [snapshot, setSnapshot] = useState(value);\n\n useEffect(() => {\n setSnapshot(value);\n\n const subscription = observable?.subscribe({\n next: updatedValue => {\n setSnapshot(updatedValue);\n },\n complete: () => {\n subscription?.unsubscribe();\n },\n });\n\n return () => {\n subscription?.unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return snapshot;\n}\n"],"names":[],"mappings":";;AAiCgB,SAAA,qBAAA,CACd,KACA,EAAA,UAAA,EACA,IACG,EAAA;AACH,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAE9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AAEjB,IAAM,MAAA,YAAA,GAAe,yCAAY,SAAU,CAAA;AAAA,MACzC,MAAM,CAAgB,YAAA,KAAA;AACpB,QAAA,WAAA,CAAY,YAAY,CAAA,CAAA;AAAA,OAC1B;AAAA,MACA,UAAU,MAAM;AACd,QAAc,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAA,WAAA,EAAA,CAAA;AAAA,OAChB;AAAA,KACF,CAAA,CAAA;AAEA,IAAA,OAAO,MAAM;AACX,MAAc,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAA,WAAA,EAAA,CAAA;AAAA,KAChB,CAAA;AAAA,KAEC,IAAI,CAAA,CAAA;AAEP,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,35 @@
1
+ import ObservableImpl from 'zen-observable';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
+ var __publicField = (obj, key, value) => {
6
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ return value;
8
+ };
9
+ class MockStarredEntitiesApi {
10
+ constructor() {
11
+ __publicField(this, "starredEntities", /* @__PURE__ */ new Set());
12
+ __publicField(this, "subscribers", /* @__PURE__ */ new Set());
13
+ __publicField(this, "observable", new ObservableImpl((subscriber) => {
14
+ subscriber.next(new Set(this.starredEntities));
15
+ this.subscribers.add(subscriber);
16
+ return () => {
17
+ this.subscribers.delete(subscriber);
18
+ };
19
+ }));
20
+ }
21
+ async toggleStarred(entityRef) {
22
+ if (!this.starredEntities.delete(entityRef)) {
23
+ this.starredEntities.add(entityRef);
24
+ }
25
+ for (const subscription of this.subscribers) {
26
+ subscription.next(new Set(this.starredEntities));
27
+ }
28
+ }
29
+ starredEntitie$() {
30
+ return this.observable;
31
+ }
32
+ }
33
+
34
+ export { MockStarredEntitiesApi };
35
+ //# sourceMappingURL=MockStarredEntitiesApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockStarredEntitiesApi.esm.js","sources":["../../../src/apis/StarredEntitiesApi/MockStarredEntitiesApi.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { Observable } from '@backstage/types';\nimport ObservableImpl from 'zen-observable';\nimport { StarredEntitiesApi } from './StarredEntitiesApi';\n\n/**\n * An in-memory mock implementation of the StarredEntitiesApi.\n *\n * @public\n */\nexport class MockStarredEntitiesApi implements StarredEntitiesApi {\n private readonly starredEntities = new Set<string>();\n private readonly subscribers = new Set<\n ZenObservable.SubscriptionObserver<Set<string>>\n >();\n\n private readonly observable = new ObservableImpl<Set<string>>(subscriber => {\n subscriber.next(new Set(this.starredEntities));\n\n this.subscribers.add(subscriber);\n return () => {\n this.subscribers.delete(subscriber);\n };\n });\n\n async toggleStarred(entityRef: string): Promise<void> {\n if (!this.starredEntities.delete(entityRef)) {\n this.starredEntities.add(entityRef);\n }\n\n for (const subscription of this.subscribers) {\n subscription.next(new Set(this.starredEntities));\n }\n }\n\n starredEntitie$(): Observable<Set<string>> {\n return this.observable;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAyBO,MAAM,sBAAqD,CAAA;AAAA,EAA3D,WAAA,GAAA;AACL,IAAiB,aAAA,CAAA,IAAA,EAAA,iBAAA,sBAAsB,GAAY,EAAA,CAAA,CAAA;AACnD,IAAiB,aAAA,CAAA,IAAA,EAAA,aAAA,sBAAkB,GAEjC,EAAA,CAAA,CAAA;AAEF,IAAiB,aAAA,CAAA,IAAA,EAAA,YAAA,EAAa,IAAI,cAAA,CAA4B,CAAc,UAAA,KAAA;AAC1E,MAAA,UAAA,CAAW,IAAK,CAAA,IAAI,GAAI,CAAA,IAAA,CAAK,eAAe,CAAC,CAAA,CAAA;AAE7C,MAAK,IAAA,CAAA,WAAA,CAAY,IAAI,UAAU,CAAA,CAAA;AAC/B,MAAA,OAAO,MAAM;AACX,QAAK,IAAA,CAAA,WAAA,CAAY,OAAO,UAAU,CAAA,CAAA;AAAA,OACpC,CAAA;AAAA,KACD,CAAA,CAAA,CAAA;AAAA,GAAA;AAAA,EAED,MAAM,cAAc,SAAkC,EAAA;AACpD,IAAA,IAAI,CAAC,IAAA,CAAK,eAAgB,CAAA,MAAA,CAAO,SAAS,CAAG,EAAA;AAC3C,MAAK,IAAA,CAAA,eAAA,CAAgB,IAAI,SAAS,CAAA,CAAA;AAAA,KACpC;AAEA,IAAW,KAAA,MAAA,YAAA,IAAgB,KAAK,WAAa,EAAA;AAC3C,MAAA,YAAA,CAAa,IAAK,CAAA,IAAI,GAAI,CAAA,IAAA,CAAK,eAAe,CAAC,CAAA,CAAA;AAAA,KACjD;AAAA,GACF;AAAA,EAEA,eAA2C,GAAA;AACzC,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GACd;AACF;;;;"}
@@ -0,0 +1,8 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const starredEntitiesApiRef = createApiRef({
4
+ id: "catalog-react.starred-entities"
5
+ });
6
+
7
+ export { starredEntitiesApiRef };
8
+ //# sourceMappingURL=StarredEntitiesApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StarredEntitiesApi.esm.js","sources":["../../../src/apis/StarredEntitiesApi/StarredEntitiesApi.ts"],"sourcesContent":["/*\n * Copyright 2021 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 { ApiRef, createApiRef } from '@backstage/core-plugin-api';\nimport { Observable } from '@backstage/types';\n\n/**\n * An API to store starred entities\n *\n * @public\n */\nexport const starredEntitiesApiRef: ApiRef<StarredEntitiesApi> = createApiRef({\n id: 'catalog-react.starred-entities',\n});\n\n/**\n * An API to store and retrieve starred entities\n *\n * @public\n */\nexport interface StarredEntitiesApi {\n /**\n * Toggle the star state of the entity\n *\n * @param entityRef - an entity reference to toggle\n */\n toggleStarred(entityRef: string): Promise<void>;\n\n /**\n * Observe the set of starred entity references.\n */\n starredEntitie$(): Observable<Set<string>>;\n}\n"],"names":[],"mappings":";;AAwBO,MAAM,wBAAoD,YAAa,CAAA;AAAA,EAC5E,EAAI,EAAA,gCAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,60 @@
1
+ import React, { useState } from 'react';
2
+ import Box from '@material-ui/core/Box';
3
+ import Button from '@material-ui/core/Button';
4
+ import Drawer from '@material-ui/core/Drawer';
5
+ import Grid from '@material-ui/core/Grid';
6
+ import Typography from '@material-ui/core/Typography';
7
+ import useMediaQuery from '@material-ui/core/useMediaQuery';
8
+ import { useTheme } from '@material-ui/core/styles';
9
+ import FilterListIcon from '@material-ui/icons/FilterList';
10
+
11
+ const Filters = (props) => {
12
+ var _a, _b;
13
+ const isScreenSmallerThanBreakpoint = useMediaQuery(
14
+ (theme2) => {
15
+ var _a2, _b2;
16
+ return theme2.breakpoints.down((_b2 = (_a2 = props.options) == null ? void 0 : _a2.drawerBreakpoint) != null ? _b2 : "md");
17
+ }
18
+ );
19
+ const theme = useTheme();
20
+ const [filterDrawerOpen, setFilterDrawerOpen] = useState(false);
21
+ return isScreenSmallerThanBreakpoint ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
22
+ Button,
23
+ {
24
+ style: { marginTop: theme.spacing(1), marginLeft: theme.spacing(1) },
25
+ onClick: () => setFilterDrawerOpen(true),
26
+ startIcon: /* @__PURE__ */ React.createElement(FilterListIcon, null)
27
+ },
28
+ "Filters"
29
+ ), /* @__PURE__ */ React.createElement(
30
+ Drawer,
31
+ {
32
+ open: filterDrawerOpen,
33
+ onClose: () => setFilterDrawerOpen(false),
34
+ anchor: (_b = (_a = props.options) == null ? void 0 : _a.drawerAnchor) != null ? _b : "left",
35
+ disableAutoFocus: true,
36
+ keepMounted: true,
37
+ variant: "temporary"
38
+ },
39
+ /* @__PURE__ */ React.createElement(Box, { m: 2 }, /* @__PURE__ */ React.createElement(
40
+ Typography,
41
+ {
42
+ variant: "h6",
43
+ component: "h2",
44
+ style: { marginBottom: theme.spacing(1) }
45
+ },
46
+ "Filters"
47
+ ), props.children)
48
+ )) : /* @__PURE__ */ React.createElement(Grid, { item: true, lg: 2 }, props.children);
49
+ };
50
+ const Content = (props) => {
51
+ return /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12, lg: 10 }, props.children);
52
+ };
53
+ const CatalogFilterLayout = (props) => {
54
+ return /* @__PURE__ */ React.createElement(Grid, { container: true, style: { position: "relative" } }, props.children);
55
+ };
56
+ CatalogFilterLayout.Filters = Filters;
57
+ CatalogFilterLayout.Content = Content;
58
+
59
+ export { CatalogFilterLayout, Content, Filters };
60
+ //# sourceMappingURL=CatalogFilterLayout.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogFilterLayout.esm.js","sources":["../../../src/components/CatalogFilterLayout/CatalogFilterLayout.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 React, { useState } from 'react';\nimport Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport Drawer from '@material-ui/core/Drawer';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { Theme, useTheme } from '@material-ui/core/styles';\nimport FilterListIcon from '@material-ui/icons/FilterList';\n\n/** @public */\nexport const Filters = (props: {\n children: React.ReactNode;\n options?: {\n drawerBreakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;\n drawerAnchor?: 'left' | 'right' | 'top' | 'bottom';\n };\n}) => {\n const isScreenSmallerThanBreakpoint = useMediaQuery((theme: Theme) =>\n theme.breakpoints.down(props.options?.drawerBreakpoint ?? 'md'),\n );\n const theme = useTheme();\n const [filterDrawerOpen, setFilterDrawerOpen] = useState<boolean>(false);\n\n return isScreenSmallerThanBreakpoint ? (\n <>\n <Button\n style={{ marginTop: theme.spacing(1), marginLeft: theme.spacing(1) }}\n onClick={() => setFilterDrawerOpen(true)}\n startIcon={<FilterListIcon />}\n >\n Filters\n </Button>\n <Drawer\n open={filterDrawerOpen}\n onClose={() => setFilterDrawerOpen(false)}\n anchor={props.options?.drawerAnchor ?? 'left'}\n disableAutoFocus\n keepMounted\n variant=\"temporary\"\n >\n <Box m={2}>\n <Typography\n variant=\"h6\"\n component=\"h2\"\n style={{ marginBottom: theme.spacing(1) }}\n >\n Filters\n </Typography>\n {props.children}\n </Box>\n </Drawer>\n </>\n ) : (\n <Grid item lg={2}>\n {props.children}\n </Grid>\n );\n};\n\n/** @public */\nexport const Content = (props: { children: React.ReactNode }) => {\n return (\n <Grid item xs={12} lg={10}>\n {props.children}\n </Grid>\n );\n};\n\n/** @public */\nexport const CatalogFilterLayout = (props: { children: React.ReactNode }) => {\n return (\n <Grid container style={{ position: 'relative' }}>\n {props.children}\n </Grid>\n );\n};\n\nCatalogFilterLayout.Filters = Filters;\nCatalogFilterLayout.Content = Content;\n"],"names":["theme","_a","_b"],"mappings":";;;;;;;;;;AA2Ba,MAAA,OAAA,GAAU,CAAC,KAMlB,KAAA;AAjCN,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAkCE,EAAA,MAAM,6BAAgC,GAAA,aAAA;AAAA,IAAc,CAACA,MAAc,KAAA;AAlCrE,MAAA,IAAAC,GAAAC,EAAAA,GAAAA,CAAAA;AAmCI,MAAA,OAAAF,MAAM,CAAA,WAAA,CAAY,IAAKE,CAAAA,CAAAA,GAAAA,GAAAA,CAAAD,GAAA,GAAA,KAAA,CAAM,OAAN,KAAA,IAAA,GAAA,KAAA,CAAA,GAAAA,GAAe,CAAA,gBAAA,KAAf,IAAAC,GAAAA,GAAAA,GAAmC,IAAI,CAAA,CAAA;AAAA,KAAA;AAAA,GAChE,CAAA;AACA,EAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AACvB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAkB,KAAK,CA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A,EAAK,MAAI,IAAC,EAAA,EAAA,EAAI,CACZ,EAAA,EAAA,KAAA,CAAM,QACT,CAAA,CAAA;AAEJ,EAAA;AAGa,MAAA,OAAA,GAAU,CAAC,KAAyC,KAAA;AAC/D,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,IAAI,EAAI,EAAA,EAAA,EAAI,EACpB,EAAA,EAAA,KAAA,CAAM,QACT,CAAA,CAAA;AAEJ,EAAA;AAGa,MAAA,mBAAA,GAAsB,CAAC,KAAyC,KAAA;AAC3E,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAS,IAAC,EAAA,KAAA,EAAO,EAAE,QAAU,EAAA,UAAA,EAChC,EAAA,EAAA,KAAA,CAAM,QACT,CAAA,CAAA;AAEJ,EAAA;AAEA,mBAAA,CAAoB,OAAU,GAAA,OAAA,CAAA;AAC9B,mBAAA,CAAoB,OAAU,GAAA,OAAA;;;;"}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { EntityKindPicker } from '../EntityKindPicker/EntityKindPicker.esm.js';
3
+ import { EntityLifecyclePicker } from '../EntityLifecyclePicker/EntityLifecyclePicker.esm.js';
4
+ import { EntityNamespacePicker } from '../EntityNamespacePicker/EntityNamespacePicker.esm.js';
5
+ import { EntityOwnerPicker } from '../EntityOwnerPicker/EntityOwnerPicker.esm.js';
6
+ import { EntityProcessingStatusPicker } from '../EntityProcessingStatusPicker/EntityProcessingStatusPicker.esm.js';
7
+ import { EntityTagPicker } from '../EntityTagPicker/EntityTagPicker.esm.js';
8
+ import { EntityTypePicker } from '../EntityTypePicker/EntityTypePicker.esm.js';
9
+ import { UserListPicker } from '../UserListPicker/UserListPicker.esm.js';
10
+
11
+ const DefaultFilters = (props) => {
12
+ const {
13
+ initialKind,
14
+ initiallySelectedFilter,
15
+ ownerPickerMode,
16
+ initiallySelectedNamespaces
17
+ } = props;
18
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(EntityKindPicker, { initialFilter: initialKind }), /* @__PURE__ */ React.createElement(EntityTypePicker, null), /* @__PURE__ */ React.createElement(UserListPicker, { initialFilter: initiallySelectedFilter }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, { mode: ownerPickerMode }), /* @__PURE__ */ React.createElement(EntityLifecyclePicker, null), /* @__PURE__ */ React.createElement(EntityTagPicker, null), /* @__PURE__ */ React.createElement(EntityProcessingStatusPicker, null), /* @__PURE__ */ React.createElement(
19
+ EntityNamespacePicker,
20
+ {
21
+ initiallySelectedNamespaces
22
+ }
23
+ ));
24
+ };
25
+
26
+ export { DefaultFilters };
27
+ //# sourceMappingURL=DefaultFilters.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultFilters.esm.js","sources":["../../../src/components/DefaultFilters/DefaultFilters.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 React from 'react';\nimport { UserListFilterKind } from '../../types';\nimport { EntityKindPicker } from '../EntityKindPicker';\nimport { EntityLifecyclePicker } from '../EntityLifecyclePicker';\nimport { EntityNamespacePicker } from '../EntityNamespacePicker';\nimport {\n EntityOwnerPickerProps,\n EntityOwnerPicker,\n} from '../EntityOwnerPicker';\nimport { EntityProcessingStatusPicker } from '../EntityProcessingStatusPicker';\nimport { EntityTagPicker } from '../EntityTagPicker';\nimport { EntityTypePicker } from '../EntityTypePicker';\nimport { UserListPicker } from '../UserListPicker';\n\n/**\n * Props for default filters.\n *\n * @public\n */\nexport type DefaultFiltersProps = {\n initialKind?: string;\n initiallySelectedFilter?: UserListFilterKind;\n ownerPickerMode?: EntityOwnerPickerProps['mode'];\n initiallySelectedNamespaces?: string[];\n};\n\n/** @public */\nexport const DefaultFilters = (props: DefaultFiltersProps) => {\n const {\n initialKind,\n initiallySelectedFilter,\n ownerPickerMode,\n initiallySelectedNamespaces,\n } = props;\n return (\n <>\n <EntityKindPicker initialFilter={initialKind} />\n <EntityTypePicker />\n <UserListPicker initialFilter={initiallySelectedFilter} />\n <EntityOwnerPicker mode={ownerPickerMode} />\n <EntityLifecyclePicker />\n <EntityTagPicker />\n <EntityProcessingStatusPicker />\n <EntityNamespacePicker\n initiallySelectedNamespaces={initiallySelectedNamespaces}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA2Ca,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,uBAAA;AAAA,IACA,eAAA;AAAA,IACA,2BAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EACE,uBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBACG,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAiB,aAAe,EAAA,WAAA,EAAa,CAC9C,kBAAA,KAAA,CAAA,aAAA,CAAC,gBAAiB,EAAA,IAAA,CAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,EAAe,aAAe,EAAA,uBAAA,EAAyB,CACxD,kBAAA,KAAA,CAAA,aAAA,CAAC,iBAAkB,EAAA,EAAA,IAAA,EAAM,eAAiB,EAAA,CAAA,kBACzC,KAAA,CAAA,aAAA,CAAA,qBAAA,EAAA,IAAsB,CACvB,kBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,IAAA,CAAA,kBAChB,KAAA,CAAA,aAAA,CAAA,4BAAA,EAAA,IAA6B,CAC9B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,2BAAA;AAAA,KAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}