@backstage/plugin-catalog-react 1.12.2-next.0 → 1.12.2-next.1
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.
- package/CHANGELOG.md +19 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +57 -1
- package/dist/alpha.esm.js +1 -0
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/CatalogFilterLayout/CatalogFilterLayout.esm.js +5 -2
- package/dist/components/CatalogFilterLayout/CatalogFilterLayout.esm.js.map +1 -1
- package/dist/components/EntityKindPicker/EntityKindPicker.esm.js +6 -3
- package/dist/components/EntityKindPicker/EntityKindPicker.esm.js.map +1 -1
- package/dist/components/EntityLifecyclePicker/EntityLifecyclePicker.esm.js +4 -1
- package/dist/components/EntityLifecyclePicker/EntityLifecyclePicker.esm.js.map +1 -1
- package/dist/components/EntityNamespacePicker/EntityNamespacePicker.esm.js +4 -1
- package/dist/components/EntityNamespacePicker/EntityNamespacePicker.esm.js.map +1 -1
- package/dist/components/EntityOwnerPicker/EntityOwnerPicker.esm.js +4 -1
- package/dist/components/EntityOwnerPicker/EntityOwnerPicker.esm.js.map +1 -1
- package/dist/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.esm.js +9 -2
- package/dist/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.esm.js.map +1 -1
- package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js +4 -1
- package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js.map +1 -1
- package/dist/components/EntityPeekAheadPopover/EntityPeekAheadPopover.esm.js +4 -1
- package/dist/components/EntityPeekAheadPopover/EntityPeekAheadPopover.esm.js.map +1 -1
- package/dist/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.esm.js +4 -1
- package/dist/components/EntityProcessingStatusPicker/EntityProcessingStatusPicker.esm.js.map +1 -1
- package/dist/components/EntitySearchBar/EntitySearchBar.esm.js +4 -1
- package/dist/components/EntitySearchBar/EntitySearchBar.esm.js.map +1 -1
- package/dist/components/EntityTable/columns.esm.js.map +1 -1
- package/dist/components/EntityTagPicker/EntityTagPicker.esm.js +4 -1
- package/dist/components/EntityTagPicker/EntityTagPicker.esm.js.map +1 -1
- package/dist/components/EntityTypePicker/EntityTypePicker.esm.js +7 -4
- package/dist/components/EntityTypePicker/EntityTypePicker.esm.js.map +1 -1
- package/dist/components/FavoriteEntity/FavoriteEntity.esm.js +4 -1
- package/dist/components/FavoriteEntity/FavoriteEntity.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/InspectEntityDialog.esm.js +5 -2
- package/dist/components/InspectEntityDialog/InspectEntityDialog.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/components/AncestryPage.esm.js +4 -1
- package/dist/components/InspectEntityDialog/components/AncestryPage.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/components/ColocatedPage.esm.js +7 -3
- package/dist/components/InspectEntityDialog/components/ColocatedPage.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/components/JsonPage.esm.js +4 -1
- package/dist/components/InspectEntityDialog/components/JsonPage.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/components/OverviewPage.esm.js +4 -1
- package/dist/components/InspectEntityDialog/components/OverviewPage.esm.js.map +1 -1
- package/dist/components/InspectEntityDialog/components/YamlPage.esm.js +4 -1
- package/dist/components/InspectEntityDialog/components/YamlPage.esm.js.map +1 -1
- package/dist/components/UnregisterEntityDialog/UnregisterEntityDialog.esm.js +27 -16
- package/dist/components/UnregisterEntityDialog/UnregisterEntityDialog.esm.js.map +1 -1
- package/dist/components/UserListPicker/UserListPicker.esm.js +11 -8
- package/dist/components/UserListPicker/UserListPicker.esm.js.map +1 -1
- package/dist/translation.esm.js +107 -0
- package/dist/translation.esm.js.map +1 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 1.12.2-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 06c0956: Support i18n for catalog and catalog-react plugins
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.14.9-next.0
|
|
10
|
+
- @backstage/core-plugin-api@1.9.3
|
|
11
|
+
- @backstage/catalog-client@1.6.5
|
|
12
|
+
- @backstage/catalog-model@1.5.0
|
|
13
|
+
- @backstage/errors@1.2.4
|
|
14
|
+
- @backstage/frontend-plugin-api@0.6.7-next.0
|
|
15
|
+
- @backstage/integration-react@1.1.29-next.0
|
|
16
|
+
- @backstage/types@1.1.1
|
|
17
|
+
- @backstage/version-bridge@1.0.8
|
|
18
|
+
- @backstage/plugin-catalog-common@1.0.24
|
|
19
|
+
- @backstage/plugin-permission-common@0.7.14
|
|
20
|
+
- @backstage/plugin-permission-react@0.4.23
|
|
21
|
+
|
|
3
22
|
## 1.12.2-next.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api'
|
|
|
3
3
|
import { AnyExtensionInputMap, PortableSchema, ResolvedExtensionInputs, RouteRef } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import { Entity } from '@backstage/catalog-model';
|
|
5
5
|
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
|
6
|
+
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Returns true if the `owner` argument is a direct owner on the `entity` argument.
|
|
@@ -40,6 +41,61 @@ declare function useEntityPermission(permission: ResourcePermission<'catalog-ent
|
|
|
40
41
|
error?: Error;
|
|
41
42
|
};
|
|
42
43
|
|
|
44
|
+
/** @alpha */
|
|
45
|
+
declare const catalogReactTranslationRef: _backstage_core_plugin_api_alpha.TranslationRef<"catalog-react", {
|
|
46
|
+
readonly "catalogFilter.title": "Filters";
|
|
47
|
+
readonly "catalogFilter.buttonTitle": "Filters";
|
|
48
|
+
readonly "entityKindPicker.title": "Kind";
|
|
49
|
+
readonly "entityKindPicker.errorMessage": "Failed to load entity kinds";
|
|
50
|
+
readonly "entityLifecyclePicker.title": "Lifecycle";
|
|
51
|
+
readonly "entityNamespacePicker.title": "Namespace";
|
|
52
|
+
readonly "entityOwnerPicker.title": "Owner";
|
|
53
|
+
readonly "entityProcessingStatusPicker.title": "Processing Status";
|
|
54
|
+
readonly "entityTagPicker.title": "Tags";
|
|
55
|
+
readonly "entityPeekAheadPopover.title": "Drill into the entity to see all of the tags.";
|
|
56
|
+
readonly "entityPeekAheadPopover.entityCardActionsTitle": "Show details";
|
|
57
|
+
readonly "entityPeekAheadPopover.emailCardAction.title": "Email {{email}}";
|
|
58
|
+
readonly "entityPeekAheadPopover.emailCardAction.subTitle": "mailto {{email}}";
|
|
59
|
+
readonly "entitySearchBar.placeholder": "Search";
|
|
60
|
+
readonly "entityTypePicker.title": "Type";
|
|
61
|
+
readonly "entityTypePicker.errorMessage": "Failed to load entity types";
|
|
62
|
+
readonly "entityTypePicker.optionAllTitle": "all";
|
|
63
|
+
readonly "favoriteEntity.addToFavorites": "Add to favorites";
|
|
64
|
+
readonly "favoriteEntity.removeFromFavorites": "Remove from favorites";
|
|
65
|
+
readonly "inspectEntityDialog.title": "Entity Inspector";
|
|
66
|
+
readonly "inspectEntityDialog.closeButtonTitle": "Close";
|
|
67
|
+
readonly "inspectEntityDialog.ancestryPage.title": "Ancestry";
|
|
68
|
+
readonly "inspectEntityDialog.colocatedPage.title": "Colocated";
|
|
69
|
+
readonly "inspectEntityDialog.colocatedPage.description": "These are the entities that are colocated with this entity - as in, they originated from the same data source (e.g. came from the same YAML file), or from the same origin (e.g. the originally registered URL).";
|
|
70
|
+
readonly "inspectEntityDialog.colocatedPage.alertNoLocation": "Entity had no location information.";
|
|
71
|
+
readonly "inspectEntityDialog.colocatedPage.alertNoEntity": "There were no other entities on this location.";
|
|
72
|
+
readonly "inspectEntityDialog.jsonPage.title": "Entity as JSON";
|
|
73
|
+
readonly "inspectEntityDialog.jsonPage.description": "This is the raw entity data as received from the catalog, on JSON form.";
|
|
74
|
+
readonly "inspectEntityDialog.overviewPage.title": "Overview";
|
|
75
|
+
readonly "inspectEntityDialog.yamlPage.title": "Entity as YAML";
|
|
76
|
+
readonly "inspectEntityDialog.yamlPage.description": "This is the raw entity data as received from the catalog, on YAML form.";
|
|
77
|
+
readonly "unregisterEntityDialog.title": "Are you sure you want to unregister this entity?";
|
|
78
|
+
readonly "unregisterEntityDialog.cancelButtonTitle": "Cancel";
|
|
79
|
+
readonly "unregisterEntityDialog.deleteButtonTitle": "Delete Entity";
|
|
80
|
+
readonly "unregisterEntityDialog.deleteEntitySuccessMessage": "Removed entity {{entityName}}";
|
|
81
|
+
readonly "unregisterEntityDialog.onlyDeleteStateTitle": "This entity does not seem to originate from a registered location. You therefore only have the option to delete it outright from the catalog.";
|
|
82
|
+
readonly "unregisterEntityDialog.errorStateTitle": "Internal error: Unknown state";
|
|
83
|
+
readonly "unregisterEntityDialog.bootstrapState.title": "You cannot unregister this entity, since it originates from a protected Backstage configuration (location \"{{location}}\"). If you believe this is in error, please contact the {{appTitle}} integrator.";
|
|
84
|
+
readonly "unregisterEntityDialog.bootstrapState.advancedDescription": "You have the option to delete the entity itself from the catalog. Note that this should only be done if you know that the catalog file has been deleted at, or moved from, its origin location. If that is not the case, the entity will reappear shortly as the next refresh round is performed by the catalog.";
|
|
85
|
+
readonly "unregisterEntityDialog.bootstrapState.advancedOptions": "Advanced Options";
|
|
86
|
+
readonly "unregisterEntityDialog.unregisterState.title": "This action will unregister the following entities:";
|
|
87
|
+
readonly "unregisterEntityDialog.unregisterState.description": "To undo, just re-register the entity in {{appTitle}}.";
|
|
88
|
+
readonly "unregisterEntityDialog.unregisterState.subTitle": "Located at the following location:";
|
|
89
|
+
readonly "unregisterEntityDialog.unregisterState.advancedDescription": "You also have the option to delete the entity itself from the catalog. Note that this should only be done if you know that the catalog file has been deleted at, or moved from, its origin location. If that is not the case, the entity will reappear shortly as the next refresh round is performed by the catalog.";
|
|
90
|
+
readonly "unregisterEntityDialog.unregisterState.advancedOptions": "Advanced Options";
|
|
91
|
+
readonly "unregisterEntityDialog.unregisterState.unregisterButtonTitle": "Unregister Location";
|
|
92
|
+
readonly "userListPicker.defaultOrgName": "Company";
|
|
93
|
+
readonly "userListPicker.orgFilterAllLabel": "All";
|
|
94
|
+
readonly "userListPicker.personalFilter.title": "Personal";
|
|
95
|
+
readonly "userListPicker.personalFilter.ownedLabel": "Owned";
|
|
96
|
+
readonly "userListPicker.personalFilter.starredLabel": "Starred";
|
|
97
|
+
}>;
|
|
98
|
+
|
|
43
99
|
/** @alpha */
|
|
44
100
|
declare const catalogExtensionData: {
|
|
45
101
|
entityContentTitle: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<string, {}>;
|
|
@@ -88,4 +144,4 @@ declare function createEntityContentExtension<TInputs extends AnyExtensionInputM
|
|
|
88
144
|
filter?: string | undefined;
|
|
89
145
|
}>;
|
|
90
146
|
|
|
91
|
-
export { catalogExtensionData, createEntityCardExtension, createEntityContentExtension, isOwnerOf, useEntityPermission };
|
|
147
|
+
export { catalogExtensionData, catalogReactTranslationRef, createEntityCardExtension, createEntityContentExtension, isOwnerOf, useEntityPermission };
|
package/dist/alpha.esm.js
CHANGED
|
@@ -3,6 +3,7 @@ import React, { lazy } from 'react';
|
|
|
3
3
|
export { useEntityPermission } from './hooks/useEntityPermission.esm.js';
|
|
4
4
|
import '@backstage/catalog-model';
|
|
5
5
|
export { isOwnerOf } from './utils/isOwnerOf.esm.js';
|
|
6
|
+
export { catalogReactTranslationRef } from './translation.esm.js';
|
|
6
7
|
|
|
7
8
|
const catalogExtensionData = {
|
|
8
9
|
entityContentTitle: createExtensionDataRef(
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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';\nexport * from './translation';\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":";;;;;;;AAqCO,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;AACD,EAAA,MAAM,YACJ,GAAA,cAAA,IAAkB,OACd,GAAA,OAAA,CAAQ,YACP,GAAA,mBAAA;AAAA,IAAoB,CAAA,CAAA,KACnB,EAAE,MAAO,CAAA;AAAA,MACP,MAAQ,EAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAS,EAAA;AAAA,KAC7B,CAAA;AAAA,GACH,CAAA;AACN,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,aAAA;AAAA,IACN,WAAW,OAAQ,CAAA,SAAA;AAAA,IACnB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAA,EAAU,QAAQ,QAAY,IAAA;AAAA,MAC5B,EAAI,EAAA,iCAAA;AAAA,MACJ,KAAO,EAAA,OAAA;AAAA,KACT;AAAA,IACA,QAAA,EAAU,QAAQ,QAAY,IAAA,IAAA;AAAA,IAC9B,MAAQ,EAAA;AAAA,MACN,SAAS,iBAAkB,CAAA,YAAA;AAAA,MAC3B,cAAA,EAAgB,oBAAqB,CAAA,oBAAA,CAAqB,QAAS,EAAA;AAAA,MACnE,gBAAA,EAAkB,oBAAqB,CAAA,sBAAA,CAAuB,QAAS,EAAA;AAAA,KACzE;AAAA,IACA,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,YAAA;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,M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;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;;;;"}
|
|
@@ -7,6 +7,8 @@ import Typography from '@material-ui/core/Typography';
|
|
|
7
7
|
import useMediaQuery from '@material-ui/core/useMediaQuery';
|
|
8
8
|
import { useTheme } from '@material-ui/core/styles';
|
|
9
9
|
import FilterListIcon from '@material-ui/icons/FilterList';
|
|
10
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
11
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
10
12
|
|
|
11
13
|
const Filters = (props) => {
|
|
12
14
|
const isScreenSmallerThanBreakpoint = useMediaQuery(
|
|
@@ -14,6 +16,7 @@ const Filters = (props) => {
|
|
|
14
16
|
);
|
|
15
17
|
const theme = useTheme();
|
|
16
18
|
const [filterDrawerOpen, setFilterDrawerOpen] = useState(false);
|
|
19
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
17
20
|
return isScreenSmallerThanBreakpoint ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
18
21
|
Button,
|
|
19
22
|
{
|
|
@@ -21,7 +24,7 @@ const Filters = (props) => {
|
|
|
21
24
|
onClick: () => setFilterDrawerOpen(true),
|
|
22
25
|
startIcon: /* @__PURE__ */ React.createElement(FilterListIcon, null)
|
|
23
26
|
},
|
|
24
|
-
"
|
|
27
|
+
t("catalogFilter.buttonTitle")
|
|
25
28
|
), /* @__PURE__ */ React.createElement(
|
|
26
29
|
Drawer,
|
|
27
30
|
{
|
|
@@ -39,7 +42,7 @@ const Filters = (props) => {
|
|
|
39
42
|
component: "h2",
|
|
40
43
|
style: { marginBottom: theme.spacing(1) }
|
|
41
44
|
},
|
|
42
|
-
"
|
|
45
|
+
t("catalogFilter.title")
|
|
43
46
|
), props.children)
|
|
44
47
|
)) : /* @__PURE__ */ React.createElement(Grid, { item: true, lg: 2 }, props.children);
|
|
45
48
|
};
|
|
@@ -1 +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
|
|
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';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\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 const { t } = useTranslationRef(catalogReactTranslationRef);\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 {t('catalogFilter.buttonTitle')}\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 {t('catalogFilter.title')}\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"],"mappings":";;;;;;;;;;;;AA6Ba,MAAA,OAAA,GAAU,CAAC,KAMlB,KAAA;AACJ,EAAA,MAAM,6BAAgC,GAAA,aAAA;AAAA,IAAc,CAACA,WACnDA,MAAM,CAAA,WAAA,CAAY,KAAK,KAAM,CAAA,OAAA,EAAS,oBAAoB,IAAI,CAAA;AAAA,GAChE,CAAA;AACA,EAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AACvB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAkB,KAAK,CAAA,CAAA;AACvE,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA,CAAA;AAE1D,EAAA,OAAO,gDAEH,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA,EAAG,UAAY,EAAA,KAAA,CAAM,OAAQ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,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;;;;"}
|
|
@@ -16,6 +16,8 @@ import 'lodash/get';
|
|
|
16
16
|
import '../../apis/StarredEntitiesApi/StarredEntitiesApi.esm.js';
|
|
17
17
|
import 'zen-observable';
|
|
18
18
|
import { filterKinds, useAllKinds } from './kindFilterUtils.esm.js';
|
|
19
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
20
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
19
21
|
|
|
20
22
|
function useEntityKindFilter(opts) {
|
|
21
23
|
const {
|
|
@@ -56,6 +58,7 @@ function useEntityKindFilter(opts) {
|
|
|
56
58
|
}
|
|
57
59
|
const EntityKindPicker = (props) => {
|
|
58
60
|
const { allowedKinds, hidden, initialFilter = "component" } = props;
|
|
61
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
59
62
|
const alertApi = useApi(alertApiRef);
|
|
60
63
|
const { error, allKinds, selectedKind, setSelectedKind } = useEntityKindFilter({
|
|
61
64
|
initialFilter
|
|
@@ -63,11 +66,11 @@ const EntityKindPicker = (props) => {
|
|
|
63
66
|
useEffect(() => {
|
|
64
67
|
if (error) {
|
|
65
68
|
alertApi.post({
|
|
66
|
-
message:
|
|
69
|
+
message: t("entityKindPicker.errorMessage"),
|
|
67
70
|
severity: "error"
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
|
-
}, [error, alertApi]);
|
|
73
|
+
}, [error, alertApi, t]);
|
|
71
74
|
if (error) return null;
|
|
72
75
|
const options = filterKinds(allKinds, allowedKinds, selectedKind);
|
|
73
76
|
const items = Object.keys(options).map((key) => ({
|
|
@@ -77,7 +80,7 @@ const EntityKindPicker = (props) => {
|
|
|
77
80
|
return hidden ? null : /* @__PURE__ */ React.createElement(Box, { pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(
|
|
78
81
|
Select,
|
|
79
82
|
{
|
|
80
|
-
label: "
|
|
83
|
+
label: t("entityKindPicker.title"),
|
|
81
84
|
items,
|
|
82
85
|
selected: selectedKind.toLocaleLowerCase("en-US"),
|
|
83
86
|
onChange: (value) => setSelectedKind(String(value))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityKindPicker.esm.js","sources":["../../../src/components/EntityKindPicker/EntityKindPicker.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 { Select } from '@backstage/core-components';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { EntityKindFilter } from '../../filters';\nimport { useEntityList } from '../../hooks';\nimport { filterKinds, useAllKinds } from './kindFilterUtils';\n\nfunction useEntityKindFilter(opts: { initialFilter: string }): {\n loading: boolean;\n error?: Error;\n allKinds: string[];\n selectedKind: string;\n setSelectedKind: (kind: string) => void;\n} {\n const {\n filters,\n queryParameters: { kind: kindParameter },\n updateFilters,\n } = useEntityList();\n\n const queryParamKind = useMemo(\n () => [kindParameter].flat()[0],\n [kindParameter],\n );\n\n const [selectedKind, setSelectedKind] = useState(\n queryParamKind ?? filters.kind?.value ?? opts.initialFilter,\n );\n\n // Set selected kinds on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamKind) {\n setSelectedKind(queryParamKind);\n }\n }, [queryParamKind]);\n\n // Set selected kind from filters; this happens when the kind filter is\n // updated from another component\n useEffect(() => {\n if (filters.kind?.value) {\n setSelectedKind(filters.kind?.value);\n }\n }, [filters.kind]);\n\n useEffect(() => {\n updateFilters({\n kind: selectedKind ? new EntityKindFilter(selectedKind) : undefined,\n });\n }, [selectedKind, updateFilters]);\n\n const { allKinds, loading, error } = useAllKinds();\n\n return {\n loading,\n error,\n allKinds: allKinds ?? [],\n selectedKind,\n setSelectedKind,\n };\n}\n\n/**\n * Props for {@link EntityKindPicker}.\n *\n * @public\n */\nexport interface EntityKindPickerProps {\n /**\n * Entity kinds to show in the dropdown; by default all kinds are fetched from the catalog and\n * displayed.\n */\n allowedKinds?: string[];\n initialFilter?: string;\n hidden?: boolean;\n}\n\n/** @public */\nexport const EntityKindPicker = (props: EntityKindPickerProps) => {\n const { allowedKinds, hidden, initialFilter = 'component' } = props;\n\n const alertApi = useApi(alertApiRef);\n\n const { error, allKinds, selectedKind, setSelectedKind } =\n useEntityKindFilter({\n initialFilter: initialFilter,\n });\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message:
|
|
1
|
+
{"version":3,"file":"EntityKindPicker.esm.js","sources":["../../../src/components/EntityKindPicker/EntityKindPicker.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 { Select } from '@backstage/core-components';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport Box from '@material-ui/core/Box';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { EntityKindFilter } from '../../filters';\nimport { useEntityList } from '../../hooks';\nimport { filterKinds, useAllKinds } from './kindFilterUtils';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\nfunction useEntityKindFilter(opts: { initialFilter: string }): {\n loading: boolean;\n error?: Error;\n allKinds: string[];\n selectedKind: string;\n setSelectedKind: (kind: string) => void;\n} {\n const {\n filters,\n queryParameters: { kind: kindParameter },\n updateFilters,\n } = useEntityList();\n\n const queryParamKind = useMemo(\n () => [kindParameter].flat()[0],\n [kindParameter],\n );\n\n const [selectedKind, setSelectedKind] = useState(\n queryParamKind ?? filters.kind?.value ?? opts.initialFilter,\n );\n\n // Set selected kinds on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamKind) {\n setSelectedKind(queryParamKind);\n }\n }, [queryParamKind]);\n\n // Set selected kind from filters; this happens when the kind filter is\n // updated from another component\n useEffect(() => {\n if (filters.kind?.value) {\n setSelectedKind(filters.kind?.value);\n }\n }, [filters.kind]);\n\n useEffect(() => {\n updateFilters({\n kind: selectedKind ? new EntityKindFilter(selectedKind) : undefined,\n });\n }, [selectedKind, updateFilters]);\n\n const { allKinds, loading, error } = useAllKinds();\n\n return {\n loading,\n error,\n allKinds: allKinds ?? [],\n selectedKind,\n setSelectedKind,\n };\n}\n\n/**\n * Props for {@link EntityKindPicker}.\n *\n * @public\n */\nexport interface EntityKindPickerProps {\n /**\n * Entity kinds to show in the dropdown; by default all kinds are fetched from the catalog and\n * displayed.\n */\n allowedKinds?: string[];\n initialFilter?: string;\n hidden?: boolean;\n}\n\n/** @public */\nexport const EntityKindPicker = (props: EntityKindPickerProps) => {\n const { allowedKinds, hidden, initialFilter = 'component' } = props;\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const alertApi = useApi(alertApiRef);\n\n const { error, allKinds, selectedKind, setSelectedKind } =\n useEntityKindFilter({\n initialFilter: initialFilter,\n });\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message: t('entityKindPicker.errorMessage'),\n severity: 'error',\n });\n }\n }, [error, alertApi, t]);\n\n if (error) return null;\n\n const options = filterKinds(allKinds, allowedKinds, selectedKind);\n\n const items = Object.keys(options).map(key => ({\n value: key,\n label: options[key],\n }));\n\n return hidden ? null : (\n <Box pb={1} pt={1}>\n <Select\n label={t('entityKindPicker.title')}\n items={items}\n selected={selectedKind.toLocaleLowerCase('en-US')}\n onChange={value => setSelectedKind(String(value))}\n />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0BA,SAAS,oBAAoB,IAM3B,EAAA;AACA,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,eAAA,EAAiB,EAAE,IAAA,EAAM,aAAc,EAAA;AAAA,IACvC,aAAA;AAAA,MACE,aAAc,EAAA,CAAA;AAElB,EAAA,MAAM,cAAiB,GAAA,OAAA;AAAA,IACrB,MAAM,CAAC,aAAa,CAAE,CAAA,IAAA,GAAO,CAAC,CAAA;AAAA,IAC9B,CAAC,aAAa,CAAA;AAAA,GAChB,CAAA;AAEA,EAAM,MAAA,CAAC,YAAc,EAAA,eAAe,CAAI,GAAA,QAAA;AAAA,IACtC,cAAkB,IAAA,OAAA,CAAQ,IAAM,EAAA,KAAA,IAAS,IAAK,CAAA,aAAA;AAAA,GAChD,CAAA;AAIA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,cAAgB,EAAA;AAClB,MAAA,eAAA,CAAgB,cAAc,CAAA,CAAA;AAAA,KAChC;AAAA,GACF,EAAG,CAAC,cAAc,CAAC,CAAA,CAAA;AAInB,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,OAAA,CAAQ,MAAM,KAAO,EAAA;AACvB,MAAgB,eAAA,CAAA,OAAA,CAAQ,MAAM,KAAK,CAAA,CAAA;AAAA,KACrC;AAAA,GACC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MAAM,OAAU,GAAA,WAAA,CAAY,QAAU,EAAA,YAAA,EAAc,YAAY,CAAA,CAAA;AAEhE,EAAA,MAAM,QAAQ,MAAO,CAAA,IAAA,CAAK,OAAO,CAAA,CAAE,IAAI,CAAQ,GAAA,MAAA;AAAA,IAC7C,KAAO,EAAA,GAAA;AAAA,IACP,KAAA,EAAO,QAAQ,GAAG,CAAA;AAAA,GAClB,CAAA,CAAA,CAAA;AAEF,EAAA,OAAO,SAAS,IACd,mBAAA,KAAA,CAAA,aAAA,CAAC,OAAI,EAAI,EAAA,CAAA,EAAG,IAAI,CACd,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,wBAAwB,CAAA;AAAA,MACjC,KAAA;AAAA,MACA,QAAA,EAAU,YAAa,CAAA,iBAAA,CAAkB,OAAO,CAAA;AAAA,MAChD,QAAU,EAAA,CAAA,KAAA,KAAS,eAAgB,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,KAAA;AAAA,GAEpD,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -2,6 +2,8 @@ import { makeStyles } from '@material-ui/core/styles';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { EntityLifecycleFilter } from '../../filters.esm.js';
|
|
4
4
|
import { EntityAutocompletePicker } from '../EntityAutocompletePicker/EntityAutocompletePicker.esm.js';
|
|
5
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
6
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
7
|
|
|
6
8
|
const useStyles = makeStyles(
|
|
7
9
|
{
|
|
@@ -14,10 +16,11 @@ const useStyles = makeStyles(
|
|
|
14
16
|
const EntityLifecyclePicker = (props) => {
|
|
15
17
|
const { initialFilter = [] } = props;
|
|
16
18
|
const classes = useStyles();
|
|
19
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
17
20
|
return /* @__PURE__ */ React.createElement(
|
|
18
21
|
EntityAutocompletePicker,
|
|
19
22
|
{
|
|
20
|
-
label: "
|
|
23
|
+
label: t("entityLifecyclePicker.title"),
|
|
21
24
|
name: "lifecycles",
|
|
22
25
|
path: "spec.lifecycle",
|
|
23
26
|
Filter: EntityLifecycleFilter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityLifecyclePicker.esm.js","sources":["../../../src/components/EntityLifecyclePicker/EntityLifecyclePicker.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 { makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport { EntityLifecycleFilter } from '../../filters';\nimport { EntityAutocompletePicker } from '../EntityAutocompletePicker';\n\n/** @public */\nexport type CatalogReactEntityLifecyclePickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n input: {},\n },\n {\n name: 'CatalogReactEntityLifecyclePicker',\n },\n);\n\n/** @public */\nexport const EntityLifecyclePicker = (props: { initialFilter?: string[] }) => {\n const { initialFilter = [] } = props;\n const classes = useStyles();\n\n return (\n <EntityAutocompletePicker\n label
|
|
1
|
+
{"version":3,"file":"EntityLifecyclePicker.esm.js","sources":["../../../src/components/EntityLifecyclePicker/EntityLifecyclePicker.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 { makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport { EntityLifecycleFilter } from '../../filters';\nimport { EntityAutocompletePicker } from '../EntityAutocompletePicker';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @public */\nexport type CatalogReactEntityLifecyclePickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n input: {},\n },\n {\n name: 'CatalogReactEntityLifecyclePicker',\n },\n);\n\n/** @public */\nexport const EntityLifecyclePicker = (props: { initialFilter?: string[] }) => {\n const { initialFilter = [] } = props;\n const classes = useStyles();\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n return (\n <EntityAutocompletePicker\n label={t('entityLifecyclePicker.title')}\n name=\"lifecycles\"\n path=\"spec.lifecycle\"\n Filter={EntityLifecycleFilter}\n InputProps={{ className: classes.input }}\n initialSelectedOptions={initialFilter}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AA0BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,OAAO,EAAC;AAAA,GACV;AAAA,EACA;AAAA,IACE,IAAM,EAAA,mCAAA;AAAA,GACR;AACF,CAAA,CAAA;AAGa,MAAA,qBAAA,GAAwB,CAAC,KAAwC,KAAA;AAC5E,EAAA,MAAM,EAAE,aAAA,GAAgB,EAAC,EAAM,GAAA,KAAA,CAAA;AAC/B,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA,CAAA;AAE1D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,wBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,6BAA6B,CAAA;AAAA,MACtC,IAAK,EAAA,YAAA;AAAA,MACL,IAAK,EAAA,gBAAA;AAAA,MACL,MAAQ,EAAA,qBAAA;AAAA,MACR,UAAY,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,MACvC,sBAAwB,EAAA,aAAA;AAAA,KAAA;AAAA,GAC1B,CAAA;AAEJ;;;;"}
|
|
@@ -2,6 +2,8 @@ import { makeStyles } from '@material-ui/core/styles';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { EntityNamespaceFilter } from '../../filters.esm.js';
|
|
4
4
|
import { EntityAutocompletePicker } from '../EntityAutocompletePicker/EntityAutocompletePicker.esm.js';
|
|
5
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
6
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
7
|
|
|
6
8
|
const useStyles = makeStyles(
|
|
7
9
|
{
|
|
@@ -14,10 +16,11 @@ const useStyles = makeStyles(
|
|
|
14
16
|
const EntityNamespacePicker = (props) => {
|
|
15
17
|
const { initiallySelectedNamespaces } = props;
|
|
16
18
|
const classes = useStyles();
|
|
19
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
17
20
|
return /* @__PURE__ */ React.createElement(
|
|
18
21
|
EntityAutocompletePicker,
|
|
19
22
|
{
|
|
20
|
-
label: "
|
|
23
|
+
label: t("entityNamespacePicker.title"),
|
|
21
24
|
name: "namespace",
|
|
22
25
|
path: "metadata.namespace",
|
|
23
26
|
Filter: EntityNamespaceFilter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityNamespacePicker.esm.js","sources":["../../../src/components/EntityNamespacePicker/EntityNamespacePicker.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 { makeStyles } from '@material-ui/core/styles';\n\nimport React from 'react';\nimport { EntityNamespaceFilter } from '../../filters';\nimport { EntityAutocompletePicker } from '../EntityAutocompletePicker';\n\n/** @public */\nexport type CatalogReactEntityNamespacePickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n input: {},\n },\n {\n name: 'CatalogReactEntityNamespacePicker',\n },\n);\n\n/**\n * Props for {@link EntityNamespacePicker}.\n *\n * @public\n */\nexport interface EntityNamespacePickerProps {\n initiallySelectedNamespaces?: string[];\n}\n\n/** @public */\nexport const EntityNamespacePicker = (props: EntityNamespacePickerProps) => {\n const { initiallySelectedNamespaces } = props;\n const classes = useStyles();\n return (\n <EntityAutocompletePicker\n label
|
|
1
|
+
{"version":3,"file":"EntityNamespacePicker.esm.js","sources":["../../../src/components/EntityNamespacePicker/EntityNamespacePicker.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 { makeStyles } from '@material-ui/core/styles';\n\nimport React from 'react';\nimport { EntityNamespaceFilter } from '../../filters';\nimport { EntityAutocompletePicker } from '../EntityAutocompletePicker';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @public */\nexport type CatalogReactEntityNamespacePickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n input: {},\n },\n {\n name: 'CatalogReactEntityNamespacePicker',\n },\n);\n\n/**\n * Props for {@link EntityNamespacePicker}.\n *\n * @public\n */\nexport interface EntityNamespacePickerProps {\n initiallySelectedNamespaces?: string[];\n}\n\n/** @public */\nexport const EntityNamespacePicker = (props: EntityNamespacePickerProps) => {\n const { initiallySelectedNamespaces } = props;\n const classes = useStyles();\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n return (\n <EntityAutocompletePicker\n label={t('entityNamespacePicker.title')}\n name=\"namespace\"\n path=\"metadata.namespace\"\n Filter={EntityNamespaceFilter}\n InputProps={{ className: classes.input }}\n initialSelectedOptions={initiallySelectedNamespaces}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AA2BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,OAAO,EAAC;AAAA,GACV;AAAA,EACA;AAAA,IACE,IAAM,EAAA,mCAAA;AAAA,GACR;AACF,CAAA,CAAA;AAYa,MAAA,qBAAA,GAAwB,CAAC,KAAsC,KAAA;AAC1E,EAAM,MAAA,EAAE,6BAAgC,GAAA,KAAA,CAAA;AACxC,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA,CAAA;AAE1D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,wBAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,6BAA6B,CAAA;AAAA,MACtC,IAAK,EAAA,WAAA;AAAA,MACL,IAAK,EAAA,oBAAA;AAAA,MACL,MAAQ,EAAA,qBAAA;AAAA,MACR,UAAY,EAAA,EAAE,SAAW,EAAA,OAAA,CAAQ,KAAM,EAAA;AAAA,MACvC,sBAAwB,EAAA,2BAAA;AAAA,KAAA;AAAA,GAC1B,CAAA;AAEJ;;;;"}
|
|
@@ -23,6 +23,8 @@ import 'lodash/get';
|
|
|
23
23
|
import { useEntityPresentation } from '../../apis/EntityPresentationApi/useEntityPresentation.esm.js';
|
|
24
24
|
import '../../apis/StarredEntitiesApi/StarredEntitiesApi.esm.js';
|
|
25
25
|
import 'zen-observable';
|
|
26
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
27
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
26
28
|
|
|
27
29
|
const useStyles = makeStyles(
|
|
28
30
|
{
|
|
@@ -83,6 +85,7 @@ const EntityOwnerPicker = (props) => {
|
|
|
83
85
|
queryParameters: { owners: ownersParameter }
|
|
84
86
|
} = useEntityList();
|
|
85
87
|
const [text, setText] = useState("");
|
|
88
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
86
89
|
const queryParamOwners = useMemo(
|
|
87
90
|
() => [ownersParameter].flat().filter(Boolean),
|
|
88
91
|
[ownersParameter]
|
|
@@ -112,7 +115,7 @@ const EntityOwnerPicker = (props) => {
|
|
|
112
115
|
)) {
|
|
113
116
|
return null;
|
|
114
117
|
}
|
|
115
|
-
return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { className: classes.label, variant: "button", component: "label" }, "
|
|
118
|
+
return /* @__PURE__ */ React.createElement(Box, { className: classes.root, pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { className: classes.label, variant: "button", component: "label" }, t("entityOwnerPicker.title"), /* @__PURE__ */ React.createElement(
|
|
116
119
|
Autocomplete,
|
|
117
120
|
{
|
|
118
121
|
PopperComponent: (popperProps) => /* @__PURE__ */ React.createElement("div", { ...popperProps }, popperProps.children),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityOwnerPicker.esm.js","sources":["../../../src/components/EntityOwnerPicker/EntityOwnerPicker.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 {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React, { useEffect, useMemo, useState, ReactNode } from 'react';\nimport { useEntityList } from '../../hooks/useEntityListProvider';\nimport { EntityOwnerFilter } from '../../filters';\nimport { useDebouncedEffect } from '@react-hookz/web';\nimport PersonIcon from '@material-ui/icons/Person';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { humanizeEntity, humanizeEntityRef } from '../EntityRefLink/humanize';\nimport { useFetchEntities } from './useFetchEntities';\nimport { withStyles } from '@material-ui/core/styles';\nimport { useEntityPresentation } from '../../apis';\n\n/** @public */\nexport type CatalogReactEntityOwnerPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n root: {},\n label: {},\n input: {},\n fullWidth: { width: '100%' },\n boxLabel: {\n width: '100%',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n },\n },\n {\n name: 'CatalogReactEntityOwnerPicker',\n },\n);\n\nconst FixedWidthFormControlLabel = withStyles(\n _theme => ({\n label: {\n width: '100%',\n },\n root: {\n width: '90%',\n },\n }),\n { name: 'FixedWidthFormControlLabel' },\n)(FormControlLabel);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/**\n * @public\n */\nexport type EntityOwnerPickerProps = {\n mode?: 'owners-only' | 'all';\n};\n\nfunction RenderOptionLabel(props: { entity: Entity; isSelected: boolean }) {\n const classes = useStyles();\n const isGroup = props.entity.kind.toLocaleLowerCase('en-US') === 'group';\n const { primaryTitle: title } = useEntityPresentation(props.entity);\n return (\n <Box className={classes.fullWidth}>\n <FixedWidthFormControlLabel\n className={classes.fullWidth}\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={props.isSelected}\n />\n }\n onClick={event => event.preventDefault()}\n label={\n <Tooltip title={title}>\n <Box display=\"flex\" alignItems=\"center\">\n {isGroup ? (\n <GroupIcon fontSize=\"small\" />\n ) : (\n <PersonIcon fontSize=\"small\" />\n )}\n \n <Box className={classes.boxLabel}>\n <Typography noWrap>{title}</Typography>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Box>\n );\n}\n\n/** @public */\nexport const EntityOwnerPicker = (props?: EntityOwnerPickerProps) => {\n const classes = useStyles();\n const { mode = 'owners-only' } = props || {};\n const {\n updateFilters,\n filters,\n queryParameters: { owners: ownersParameter },\n } = useEntityList();\n\n const [text, setText] = useState('');\n\n const queryParamOwners = useMemo(\n () => [ownersParameter].flat().filter(Boolean) as string[],\n [ownersParameter],\n );\n\n const [selectedOwners, setSelectedOwners] = useState(\n queryParamOwners.length ? queryParamOwners : filters.owners?.values ?? [],\n );\n\n const [{ value, loading }, handleFetch, cache] = useFetchEntities({\n mode,\n initialSelectedOwnersRefs: selectedOwners,\n });\n useDebouncedEffect(() => handleFetch({ text }), [text, handleFetch], 250);\n\n const availableOwners = value?.items || [];\n\n // Set selected owners on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamOwners.length) {\n const filter = new EntityOwnerFilter(queryParamOwners);\n setSelectedOwners(filter.values);\n }\n }, [queryParamOwners]);\n\n useEffect(() => {\n updateFilters({\n owners: selectedOwners.length\n ? new EntityOwnerFilter(selectedOwners)\n : undefined,\n });\n }, [selectedOwners, updateFilters]);\n\n if (\n ['user', 'group'].includes(\n filters.kind?.value.toLocaleLowerCase('en-US') || '',\n )\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <Typography className={classes.label} variant=\"button\" component=\"label\">\n Owner\n <Autocomplete\n PopperComponent={popperProps => (\n <div {...popperProps}>{popperProps.children as ReactNode}</div>\n )}\n multiple\n disableCloseOnSelect\n loading={loading}\n options={availableOwners}\n value={selectedOwners as unknown as Entity[]}\n getOptionSelected={(o, v) => {\n if (typeof v === 'string') {\n return stringifyEntityRef(o) === v;\n }\n return o === v;\n }}\n getOptionLabel={o => {\n const entity =\n typeof o === 'string'\n ? cache.getEntity(o) ||\n parseEntityRef(o, {\n defaultKind: 'group',\n defaultNamespace: 'default',\n })\n : o;\n return humanizeEntity(entity, humanizeEntityRef(entity));\n }}\n onChange={(_: object, owners) => {\n setText('');\n setSelectedOwners(\n owners.map(e => {\n const entityRef =\n typeof e === 'string' ? e : stringifyEntityRef(e);\n\n if (typeof e !== 'string') {\n cache.setEntity(e);\n }\n return entityRef;\n }),\n );\n }}\n filterOptions={x => x}\n renderOption={(entity, { selected }) => {\n return <RenderOptionLabel entity={entity} isSelected={selected} />;\n }}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"owner-picker-expand\" />}\n renderInput={params => (\n <TextField\n {...params}\n className={classes.input}\n onChange={e => {\n setText(e.currentTarget.value);\n }}\n variant=\"outlined\"\n />\n )}\n ListboxProps={{\n onScroll: (e: React.MouseEvent) => {\n const element = e.currentTarget;\n const hasReachedEnd =\n Math.abs(\n element.scrollHeight -\n element.clientHeight -\n element.scrollTop,\n ) < 1;\n\n if (hasReachedEnd && value?.cursor) {\n handleFetch({ items: value.items, cursor: value.cursor });\n }\n },\n 'data-testid': 'owner-picker-listbox',\n }}\n />\n </Typography>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;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A,MAAM,UAAU,CAAE,CAAA,aAAA,CAAA;AAClB,UAAA,MAAM,gBACJ,IAAK,CAAA,GAAA;AAAA,YACH,OAAQ,CAAA,YAAA,GACN,OAAQ,CAAA,YAAA,GACR,OAAQ,CAAA,SAAA;AAAA,WACR,GAAA,CAAA,CAAA;AAEN,UAAI,IAAA,aAAA,IAAiB,OAAO,MAAQ,EAAA;AAClC,YAAA,WAAA,CAAY,EAAE,KAAO,EAAA,KAAA,CAAM,OAAO,MAAQ,EAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,WAC1D;AAAA,SACF;AAAA,QACA,aAAe,EAAA,sBAAA;AAAA,OACjB;AAAA,KAAA;AAAA,GAEJ,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"EntityOwnerPicker.esm.js","sources":["../../../src/components/EntityOwnerPicker/EntityOwnerPicker.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 {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React, { useEffect, useMemo, useState, ReactNode } from 'react';\nimport { useEntityList } from '../../hooks/useEntityListProvider';\nimport { EntityOwnerFilter } from '../../filters';\nimport { useDebouncedEffect } from '@react-hookz/web';\nimport PersonIcon from '@material-ui/icons/Person';\nimport GroupIcon from '@material-ui/icons/Group';\nimport { humanizeEntity, humanizeEntityRef } from '../EntityRefLink/humanize';\nimport { useFetchEntities } from './useFetchEntities';\nimport { withStyles } from '@material-ui/core/styles';\nimport { useEntityPresentation } from '../../apis';\nimport { catalogReactTranslationRef } from '../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/** @public */\nexport type CatalogReactEntityOwnerPickerClassKey = 'input';\n\nconst useStyles = makeStyles(\n {\n root: {},\n label: {},\n input: {},\n fullWidth: { width: '100%' },\n boxLabel: {\n width: '100%',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n },\n },\n {\n name: 'CatalogReactEntityOwnerPicker',\n },\n);\n\nconst FixedWidthFormControlLabel = withStyles(\n _theme => ({\n label: {\n width: '100%',\n },\n root: {\n width: '90%',\n },\n }),\n { name: 'FixedWidthFormControlLabel' },\n)(FormControlLabel);\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/**\n * @public\n */\nexport type EntityOwnerPickerProps = {\n mode?: 'owners-only' | 'all';\n};\n\nfunction RenderOptionLabel(props: { entity: Entity; isSelected: boolean }) {\n const classes = useStyles();\n const isGroup = props.entity.kind.toLocaleLowerCase('en-US') === 'group';\n const { primaryTitle: title } = useEntityPresentation(props.entity);\n return (\n <Box className={classes.fullWidth}>\n <FixedWidthFormControlLabel\n className={classes.fullWidth}\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={props.isSelected}\n />\n }\n onClick={event => event.preventDefault()}\n label={\n <Tooltip title={title}>\n <Box display=\"flex\" alignItems=\"center\">\n {isGroup ? (\n <GroupIcon fontSize=\"small\" />\n ) : (\n <PersonIcon fontSize=\"small\" />\n )}\n \n <Box className={classes.boxLabel}>\n <Typography noWrap>{title}</Typography>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Box>\n );\n}\n\n/** @public */\nexport const EntityOwnerPicker = (props?: EntityOwnerPickerProps) => {\n const classes = useStyles();\n const { mode = 'owners-only' } = props || {};\n const {\n updateFilters,\n filters,\n queryParameters: { owners: ownersParameter },\n } = useEntityList();\n\n const [text, setText] = useState('');\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n const queryParamOwners = useMemo(\n () => [ownersParameter].flat().filter(Boolean) as string[],\n [ownersParameter],\n );\n\n const [selectedOwners, setSelectedOwners] = useState(\n queryParamOwners.length ? queryParamOwners : filters.owners?.values ?? [],\n );\n\n const [{ value, loading }, handleFetch, cache] = useFetchEntities({\n mode,\n initialSelectedOwnersRefs: selectedOwners,\n });\n useDebouncedEffect(() => handleFetch({ text }), [text, handleFetch], 250);\n\n const availableOwners = value?.items || [];\n\n // Set selected owners on query parameter updates; this happens at initial page load and from\n // external updates to the page location.\n useEffect(() => {\n if (queryParamOwners.length) {\n const filter = new EntityOwnerFilter(queryParamOwners);\n setSelectedOwners(filter.values);\n }\n }, [queryParamOwners]);\n\n useEffect(() => {\n updateFilters({\n owners: selectedOwners.length\n ? new EntityOwnerFilter(selectedOwners)\n : undefined,\n });\n }, [selectedOwners, updateFilters]);\n\n if (\n ['user', 'group'].includes(\n filters.kind?.value.toLocaleLowerCase('en-US') || '',\n )\n ) {\n return null;\n }\n\n return (\n <Box className={classes.root} pb={1} pt={1}>\n <Typography className={classes.label} variant=\"button\" component=\"label\">\n {t('entityOwnerPicker.title')}\n <Autocomplete\n PopperComponent={popperProps => (\n <div {...popperProps}>{popperProps.children as ReactNode}</div>\n )}\n multiple\n disableCloseOnSelect\n loading={loading}\n options={availableOwners}\n value={selectedOwners as unknown as Entity[]}\n getOptionSelected={(o, v) => {\n if (typeof v === 'string') {\n return stringifyEntityRef(o) === v;\n }\n return o === v;\n }}\n getOptionLabel={o => {\n const entity =\n typeof o === 'string'\n ? cache.getEntity(o) ||\n parseEntityRef(o, {\n defaultKind: 'group',\n defaultNamespace: 'default',\n })\n : o;\n return humanizeEntity(entity, humanizeEntityRef(entity));\n }}\n onChange={(_: object, owners) => {\n setText('');\n setSelectedOwners(\n owners.map(e => {\n const entityRef =\n typeof e === 'string' ? e : stringifyEntityRef(e);\n\n if (typeof e !== 'string') {\n cache.setEntity(e);\n }\n return entityRef;\n }),\n );\n }}\n filterOptions={x => x}\n renderOption={(entity, { selected }) => {\n return <RenderOptionLabel entity={entity} isSelected={selected} />;\n }}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"owner-picker-expand\" />}\n renderInput={params => (\n <TextField\n {...params}\n className={classes.input}\n onChange={e => {\n setText(e.currentTarget.value);\n }}\n variant=\"outlined\"\n />\n )}\n ListboxProps={{\n onScroll: (e: React.MouseEvent) => {\n const element = e.currentTarget;\n const hasReachedEnd =\n Math.abs(\n element.scrollHeight -\n element.clientHeight -\n element.scrollTop,\n ) < 1;\n\n if (hasReachedEnd && value?.cursor) {\n handleFetch({ items: value.items, cursor: value.cursor });\n }\n },\n 'data-testid': 'owner-picker-listbox',\n }}\n />\n </Typography>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB;AAAA,IACE,MAAM,EAAC;AAAA,IACP,OAAO,EAAC;AAAA,IACR,OAAO,EAAC;AAAA,IACR,SAAA,EAAW,EAAE,KAAA,EAAO,MAAO,EAAA;AAAA,IAC3B,QAAU,EAAA;AAAA,MACR,KAAO,EAAA,MAAA;AAAA,MACP,YAAc,EAAA,UAAA;AAAA,MACd,QAAU,EAAA,QAAA;AAAA,KACZ;AAAA,GACF;AAAA,EACA;AAAA,IACE,IAAM,EAAA,+BAAA;AAAA,GACR;A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EAAE,KAAO,EAAA,KAAA,CAAM,OAAO,MAAQ,EAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,WAC1D;AAAA,SACF;AAAA,QACA,aAAe,EAAA,sBAAA;AAAA,OACjB;AAAA,KAAA;AAAA,GAEJ,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -2,15 +2,22 @@ import IconButton from '@material-ui/core/IconButton';
|
|
|
2
2
|
import EmailIcon from '@material-ui/icons/Email';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Link } from '@backstage/core-components';
|
|
5
|
+
import { catalogReactTranslationRef } from '../../../translation.esm.js';
|
|
6
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
7
|
|
|
6
8
|
const EmailCardAction = (props) => {
|
|
9
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
7
10
|
return /* @__PURE__ */ React.createElement(
|
|
8
11
|
IconButton,
|
|
9
12
|
{
|
|
10
13
|
component: Link,
|
|
11
14
|
"aria-label": "Email",
|
|
12
|
-
title:
|
|
13
|
-
|
|
15
|
+
title: t("entityPeekAheadPopover.emailCardAction.title", {
|
|
16
|
+
email: props.email
|
|
17
|
+
}),
|
|
18
|
+
to: t("entityPeekAheadPopover.emailCardAction.subTitle", {
|
|
19
|
+
email: props.email
|
|
20
|
+
})
|
|
14
21
|
},
|
|
15
22
|
/* @__PURE__ */ React.createElement(EmailIcon, null)
|
|
16
23
|
);
|
package/dist/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailCardAction.esm.js","sources":["../../../../src/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.tsx"],"sourcesContent":["/*\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 IconButton from '@material-ui/core/IconButton';\nimport EmailIcon from '@material-ui/icons/Email';\nimport React from 'react';\nimport { Link } from '@backstage/core-components';\n\n/**\n * Email Card action link\n *\n * @private\n */\nexport const EmailCardAction = (props: { email: string }) => {\n return (\n <IconButton\n component={Link}\n aria-label=\"Email\"\n title={
|
|
1
|
+
{"version":3,"file":"EmailCardAction.esm.js","sources":["../../../../src/components/EntityPeekAheadPopover/CardActionComponents/EmailCardAction.tsx"],"sourcesContent":["/*\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 IconButton from '@material-ui/core/IconButton';\nimport EmailIcon from '@material-ui/icons/Email';\nimport React from 'react';\nimport { Link } from '@backstage/core-components';\nimport { catalogReactTranslationRef } from '../../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Email Card action link\n *\n * @private\n */\nexport const EmailCardAction = (props: { email: string }) => {\n const { t } = useTranslationRef(catalogReactTranslationRef);\n return (\n <IconButton\n component={Link}\n aria-label=\"Email\"\n title={t('entityPeekAheadPopover.emailCardAction.title', {\n email: props.email,\n })}\n to={t('entityPeekAheadPopover.emailCardAction.subTitle', {\n email: props.email,\n })}\n >\n <EmailIcon />\n </IconButton>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA4Ba,MAAA,eAAA,GAAkB,CAAC,KAA6B,KAAA;AAC3D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA,CAAA;AAC1D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA;AAAA,MACX,YAAW,EAAA,OAAA;AAAA,MACX,KAAA,EAAO,EAAE,8CAAgD,EAAA;AAAA,QACvD,OAAO,KAAM,CAAA,KAAA;AAAA,OACd,CAAA;AAAA,MACD,EAAA,EAAI,EAAE,iDAAmD,EAAA;AAAA,QACvD,OAAO,KAAM,CAAA,KAAA;AAAA,OACd,CAAA;AAAA,KAAA;AAAA,wCAEA,SAAU,EAAA,IAAA,CAAA;AAAA,GACb,CAAA;AAEJ;;;;"}
|
package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js
CHANGED
|
@@ -5,15 +5,18 @@ import React from 'react';
|
|
|
5
5
|
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
6
6
|
import { getCompoundEntityRef } from '@backstage/catalog-model';
|
|
7
7
|
import { Link } from '@backstage/core-components';
|
|
8
|
+
import { catalogReactTranslationRef } from '../../../translation.esm.js';
|
|
9
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
8
10
|
|
|
9
11
|
const EntityCardActions = (props) => {
|
|
10
12
|
const entityRoute = useRouteRef(entityRouteRef);
|
|
13
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
11
14
|
return /* @__PURE__ */ React.createElement(
|
|
12
15
|
IconButton,
|
|
13
16
|
{
|
|
14
17
|
component: Link,
|
|
15
18
|
"aria-label": "Show",
|
|
16
|
-
title: "
|
|
19
|
+
title: t("entityPeekAheadPopover.entityCardActionsTitle"),
|
|
17
20
|
to: entityRoute(getCompoundEntityRef(props.entity))
|
|
18
21
|
},
|
|
19
22
|
/* @__PURE__ */ React.createElement(InfoIcon, null)
|
package/dist/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCardActions.esm.js","sources":["../../../../src/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.tsx"],"sourcesContent":["/*\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 { entityRouteRef } from '../../../routes';\nimport IconButton from '@material-ui/core/IconButton';\nimport InfoIcon from '@material-ui/icons/Info';\nimport React from 'react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { Entity, getCompoundEntityRef } from '@backstage/catalog-model';\nimport { Link } from '@backstage/core-components';\n\n/**\n * Card actions that show for all entities\n *\n * @private\n */\nexport const EntityCardActions = (props: { entity: Entity }) => {\n const entityRoute = useRouteRef(entityRouteRef);\n\n return (\n <IconButton\n component={Link}\n aria-label=\"Show\"\n title
|
|
1
|
+
{"version":3,"file":"EntityCardActions.esm.js","sources":["../../../../src/components/EntityPeekAheadPopover/CardActionComponents/EntityCardActions.tsx"],"sourcesContent":["/*\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 { entityRouteRef } from '../../../routes';\nimport IconButton from '@material-ui/core/IconButton';\nimport InfoIcon from '@material-ui/icons/Info';\nimport React from 'react';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { Entity, getCompoundEntityRef } from '@backstage/catalog-model';\nimport { Link } from '@backstage/core-components';\nimport { catalogReactTranslationRef } from '../../../translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\n/**\n * Card actions that show for all entities\n *\n * @private\n */\nexport const EntityCardActions = (props: { entity: Entity }) => {\n const entityRoute = useRouteRef(entityRouteRef);\n const { t } = useTranslationRef(catalogReactTranslationRef);\n\n return (\n <IconButton\n component={Link}\n aria-label=\"Show\"\n title={t('entityPeekAheadPopover.entityCardActionsTitle')}\n to={entityRoute(getCompoundEntityRef(props.entity))}\n >\n <InfoIcon />\n </IconButton>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA+Ba,MAAA,iBAAA,GAAoB,CAAC,KAA8B,KAAA;AAC9D,EAAM,MAAA,WAAA,GAAc,YAAY,cAAc,CAAA,CAAA;AAC9C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA,CAAA;AAE1D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA;AAAA,MACX,YAAW,EAAA,MAAA;AAAA,MACX,KAAA,EAAO,EAAE,+CAA+C,CAAA;AAAA,MACxD,EAAI,EAAA,WAAA,CAAY,oBAAqB,CAAA,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,KAAA;AAAA,wCAEjD,QAAS,EAAA,IAAA,CAAA;AAAA,GACZ,CAAA;AAEJ;;;;"}
|
|
@@ -18,6 +18,8 @@ import { EntityCardActions } from './CardActionComponents/EntityCardActions.esm.
|
|
|
18
18
|
import { GroupCardActions } from './CardActionComponents/GroupCardActions.esm.js';
|
|
19
19
|
import { UserCardActions } from './CardActionComponents/UserCardActions.esm.js';
|
|
20
20
|
import { debounce } from 'lodash';
|
|
21
|
+
import { catalogReactTranslationRef } from '../../translation.esm.js';
|
|
22
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
21
23
|
|
|
22
24
|
const useStyles = makeStyles(() => {
|
|
23
25
|
return {
|
|
@@ -36,6 +38,7 @@ const useStyles = makeStyles(() => {
|
|
|
36
38
|
const maxTagChips = 4;
|
|
37
39
|
const EntityPeekAheadPopover = (props) => {
|
|
38
40
|
const { entityRef, children, delayTime = 500 } = props;
|
|
41
|
+
const { t } = useTranslationRef(catalogReactTranslationRef);
|
|
39
42
|
const classes = useStyles();
|
|
40
43
|
const apiHolder = useApiHolder();
|
|
41
44
|
const popupState = usePopupState({
|
|
@@ -101,7 +104,7 @@ const EntityPeekAheadPopover = (props) => {
|
|
|
101
104
|
entity.metadata.description
|
|
102
105
|
), /* @__PURE__ */ React.createElement(Typography, null, entity.spec?.type?.toString()), /* @__PURE__ */ React.createElement(Box, { marginTop: "0.5em" }, (entity.metadata.tags || []).slice(0, maxTagChips).map((tag) => {
|
|
103
106
|
return /* @__PURE__ */ React.createElement(Chip, { key: tag, size: "small", label: tag });
|
|
104
|
-
}), entity.metadata.tags?.length && entity.metadata.tags?.length > maxTagChips && /* @__PURE__ */ React.createElement(Tooltip, { title: "
|
|
107
|
+
}), entity.metadata.tags?.length && entity.metadata.tags?.length > maxTagChips && /* @__PURE__ */ React.createElement(Tooltip, { title: t("entityPeekAheadPopover.title") }, /* @__PURE__ */ React.createElement(Chip, { key: "other-tags", size: "small", label: "..." }))))), !error && entity && /* @__PURE__ */ React.createElement(CardActions, null, /* @__PURE__ */ React.createElement(React.Fragment, null, isUserEntity(entity) && /* @__PURE__ */ React.createElement(UserCardActions, { entity }), isGroupEntity(entity) && /* @__PURE__ */ React.createElement(GroupCardActions, { entity }), /* @__PURE__ */ React.createElement(EntityCardActions, { entity }))))
|
|
105
108
|
));
|
|
106
109
|
};
|
|
107
110
|
|