@backstage/plugin-catalog-react 0.5.1 → 0.6.2
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 +61 -0
- package/dist/index.cjs.js +182 -69
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +61 -6
- package/dist/index.esm.js +180 -71
- package/dist/index.esm.js.map +1 -1
- package/package.json +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f9cc2509f8: EntityTypePicker can be hidden and have an initial filter value set, similar to EntityKindPicker
|
|
8
|
+
- 10615525f3: Switch to use the json and observable types from `@backstage/types`
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/errors@0.1.4
|
|
11
|
+
- @backstage/integration@0.6.9
|
|
12
|
+
- @backstage/core-components@0.7.2
|
|
13
|
+
- @backstage/catalog-model@0.9.6
|
|
14
|
+
- @backstage/core-app-api@0.1.19
|
|
15
|
+
- @backstage/core-plugin-api@0.1.12
|
|
16
|
+
|
|
17
|
+
## 0.6.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 36e67d2f24: Internal updates to apply more strict checks to throw errors.
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @backstage/core-components@0.7.1
|
|
24
|
+
- @backstage/errors@0.1.3
|
|
25
|
+
- @backstage/core-app-api@0.1.18
|
|
26
|
+
- @backstage/core-plugin-api@0.1.11
|
|
27
|
+
- @backstage/catalog-model@0.9.5
|
|
28
|
+
|
|
29
|
+
## 0.6.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 82fbda923e: Introduce a new `StarredEntitiesApi` that is used in the `useStarredEntities` hook.
|
|
34
|
+
The `@backstage/plugin-catalog` installs a default implementation that is backed by the `StorageApi`, but one can also override the `starredEntitiesApiRef`.
|
|
35
|
+
|
|
36
|
+
This change also updates the storage format from a custom string to an entity reference and moves the location in the local storage.
|
|
37
|
+
A migration will convert the previously starred entities to the location on the first load of Backstage.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- 0366c9b667: Introduce a `useStarredEntity` hook to check if a single entity is starred.
|
|
42
|
+
It provides a more efficient implementation compared to the `useStarredEntities` hook, because the rendering is only triggered if the selected entity is starred, not if _any_ entity is starred.
|
|
43
|
+
- 4aca84f86b: Support `material-ui` overrides in plugin-catalog-react components
|
|
44
|
+
- b03b9f19e0: added sorting in entity `Name` column by `metadata.title` if present
|
|
45
|
+
- Updated dependencies
|
|
46
|
+
- @backstage/integration@0.6.8
|
|
47
|
+
- @backstage/core-app-api@0.1.17
|
|
48
|
+
- @backstage/core-components@0.7.0
|
|
49
|
+
|
|
50
|
+
## 0.5.2
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 5aae9bb61e: Name column will now render entity `metadata.title` if its present
|
|
55
|
+
- ca0559444c: Avoid usage of `.to*Case()`, preferring `.toLocale*Case('en-US')` instead.
|
|
56
|
+
- Updated dependencies
|
|
57
|
+
- @backstage/core-components@0.6.1
|
|
58
|
+
- @backstage/core-plugin-api@0.1.10
|
|
59
|
+
- @backstage/core-app-api@0.1.16
|
|
60
|
+
- @backstage/catalog-model@0.9.4
|
|
61
|
+
- @backstage/catalog-client@0.5.0
|
|
62
|
+
- @backstage/integration@0.6.7
|
|
63
|
+
|
|
3
64
|
## 0.5.1
|
|
4
65
|
|
|
5
66
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,30 +4,33 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var catalogClient = require('@backstage/catalog-client');
|
|
6
6
|
var corePluginApi = require('@backstage/core-plugin-api');
|
|
7
|
+
var ObservableImpl = require('zen-observable');
|
|
8
|
+
var catalogModel = require('@backstage/catalog-model');
|
|
9
|
+
var lodash = require('lodash');
|
|
7
10
|
var React = require('react');
|
|
8
11
|
var lab = require('@material-ui/lab');
|
|
9
12
|
var versionBridge = require('@backstage/version-bridge');
|
|
10
13
|
var reactRouter = require('react-router');
|
|
11
14
|
var reactUse = require('react-use');
|
|
12
|
-
var catalogModel = require('@backstage/catalog-model');
|
|
13
|
-
var lodash = require('lodash');
|
|
14
15
|
var qs = require('qs');
|
|
15
16
|
var coreComponents = require('@backstage/core-components');
|
|
16
|
-
var jwtDecoder = require('jwt-decode');
|
|
17
17
|
var core = require('@material-ui/core');
|
|
18
|
+
var jwtDecoder = require('jwt-decode');
|
|
18
19
|
var CheckBoxIcon = require('@material-ui/icons/CheckBox');
|
|
19
20
|
var CheckBoxOutlineBlankIcon = require('@material-ui/icons/CheckBoxOutlineBlank');
|
|
20
21
|
var ExpandMoreIcon = require('@material-ui/icons/ExpandMore');
|
|
21
22
|
var Clear = require('@material-ui/icons/Clear');
|
|
22
23
|
var Search = require('@material-ui/icons/Search');
|
|
23
24
|
var capitalize = require('lodash/capitalize');
|
|
24
|
-
var StarBorder = require('@material-ui/icons/StarBorder');
|
|
25
25
|
var Star = require('@material-ui/icons/Star');
|
|
26
|
+
var StarBorder = require('@material-ui/icons/StarBorder');
|
|
26
27
|
var Alert = require('@material-ui/lab/Alert');
|
|
28
|
+
var errors = require('@backstage/errors');
|
|
27
29
|
var SettingsIcon = require('@material-ui/icons/Settings');
|
|
28
30
|
|
|
29
31
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
30
32
|
|
|
33
|
+
var ObservableImpl__default = /*#__PURE__*/_interopDefaultLegacy(ObservableImpl);
|
|
31
34
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
32
35
|
var qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
|
|
33
36
|
var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
|
|
@@ -37,8 +40,8 @@ var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon)
|
|
|
37
40
|
var Clear__default = /*#__PURE__*/_interopDefaultLegacy(Clear);
|
|
38
41
|
var Search__default = /*#__PURE__*/_interopDefaultLegacy(Search);
|
|
39
42
|
var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
|
|
40
|
-
var StarBorder__default = /*#__PURE__*/_interopDefaultLegacy(StarBorder);
|
|
41
43
|
var Star__default = /*#__PURE__*/_interopDefaultLegacy(Star);
|
|
44
|
+
var StarBorder__default = /*#__PURE__*/_interopDefaultLegacy(StarBorder);
|
|
42
45
|
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
43
46
|
var SettingsIcon__default = /*#__PURE__*/_interopDefaultLegacy(SettingsIcon);
|
|
44
47
|
|
|
@@ -46,6 +49,69 @@ const catalogApiRef = corePluginApi.createApiRef({
|
|
|
46
49
|
id: "plugin.catalog.service"
|
|
47
50
|
});
|
|
48
51
|
|
|
52
|
+
async function performMigrationToTheNewBucket({
|
|
53
|
+
storageApi
|
|
54
|
+
}) {
|
|
55
|
+
var _a;
|
|
56
|
+
const source = storageApi.forBucket("settings");
|
|
57
|
+
const target = storageApi.forBucket("starredEntities");
|
|
58
|
+
const oldStarredEntities = source.get("starredEntities");
|
|
59
|
+
if (!lodash.isArray(oldStarredEntities)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const targetEntities = new Set((_a = target.get("entityRefs")) != null ? _a : []);
|
|
63
|
+
oldStarredEntities.filter(lodash.isString).map((old) => old.split(":")).filter((split) => split.length === 4 && split[0] === "entity").map(([_, kind, namespace, name]) => catalogModel.stringifyEntityRef({kind, namespace, name})).forEach((e) => targetEntities.add(e));
|
|
64
|
+
await target.set("entityRefs", Array.from(targetEntities));
|
|
65
|
+
await source.remove("starredEntities");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class DefaultStarredEntitiesApi {
|
|
69
|
+
constructor(opts) {
|
|
70
|
+
this.subscribers = new Set();
|
|
71
|
+
this.observable = new ObservableImpl__default['default']((subscriber) => {
|
|
72
|
+
subscriber.next(this.starredEntities);
|
|
73
|
+
this.subscribers.add(subscriber);
|
|
74
|
+
return () => {
|
|
75
|
+
this.subscribers.delete(subscriber);
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
var _a;
|
|
79
|
+
performMigrationToTheNewBucket(opts).then();
|
|
80
|
+
this.settingsStore = opts.storageApi.forBucket("starredEntities");
|
|
81
|
+
this.starredEntities = new Set((_a = this.settingsStore.get("entityRefs")) != null ? _a : []);
|
|
82
|
+
this.settingsStore.observe$("entityRefs").subscribe({
|
|
83
|
+
next: (next) => {
|
|
84
|
+
var _a2;
|
|
85
|
+
this.starredEntities = new Set((_a2 = next.newValue) != null ? _a2 : []);
|
|
86
|
+
this.notifyChanges();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async toggleStarred(entityRef) {
|
|
91
|
+
if (this.starredEntities.has(entityRef)) {
|
|
92
|
+
this.starredEntities.delete(entityRef);
|
|
93
|
+
} else {
|
|
94
|
+
this.starredEntities.add(entityRef);
|
|
95
|
+
}
|
|
96
|
+
await this.settingsStore.set("entityRefs", Array.from(this.starredEntities));
|
|
97
|
+
}
|
|
98
|
+
starredEntitie$() {
|
|
99
|
+
return this.observable;
|
|
100
|
+
}
|
|
101
|
+
isStarred(entityRef) {
|
|
102
|
+
return this.starredEntities.has(entityRef);
|
|
103
|
+
}
|
|
104
|
+
notifyChanges() {
|
|
105
|
+
for (const subscription of this.subscribers) {
|
|
106
|
+
subscription.next(this.starredEntities);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const starredEntitiesApiRef = corePluginApi.createApiRef({
|
|
112
|
+
id: "catalog-react.starred-entities"
|
|
113
|
+
});
|
|
114
|
+
|
|
49
115
|
const NoIcon = () => null;
|
|
50
116
|
const rootRoute = corePluginApi.createRouteRef({
|
|
51
117
|
icon: NoIcon,
|
|
@@ -63,8 +129,8 @@ const entityRouteRef = entityRoute;
|
|
|
63
129
|
function entityRouteParams(entity) {
|
|
64
130
|
var _a, _b;
|
|
65
131
|
return {
|
|
66
|
-
kind: entity.kind.
|
|
67
|
-
namespace: (_b = (_a = entity.metadata.namespace) == null ? void 0 : _a.
|
|
132
|
+
kind: entity.kind.toLocaleLowerCase("en-US"),
|
|
133
|
+
namespace: (_b = (_a = entity.metadata.namespace) == null ? void 0 : _a.toLocaleLowerCase("en-US")) != null ? _b : catalogModel.ENTITY_DEFAULT_NAMESPACE,
|
|
68
134
|
name: entity.metadata.name
|
|
69
135
|
};
|
|
70
136
|
}
|
|
@@ -177,7 +243,7 @@ function getEntityRelations(entity, relationType, filter) {
|
|
|
177
243
|
var _a, _b;
|
|
178
244
|
let entityNames = ((_b = (_a = entity == null ? void 0 : entity.relations) == null ? void 0 : _a.filter((r) => r.type === relationType)) == null ? void 0 : _b.map((r) => r.target)) || [];
|
|
179
245
|
if (filter == null ? void 0 : filter.kind) {
|
|
180
|
-
entityNames = entityNames == null ? void 0 : entityNames.filter((e) => e.kind.
|
|
246
|
+
entityNames = entityNames == null ? void 0 : entityNames.filter((e) => e.kind.toLocaleLowerCase("en-US") === filter.kind.toLocaleLowerCase("en-US"));
|
|
181
247
|
}
|
|
182
248
|
return entityNames;
|
|
183
249
|
}
|
|
@@ -317,9 +383,9 @@ function formatEntityRefTitle(entityRef, opts) {
|
|
|
317
383
|
if (namespace === catalogModel.ENTITY_DEFAULT_NAMESPACE) {
|
|
318
384
|
namespace = void 0;
|
|
319
385
|
}
|
|
320
|
-
kind = kind.
|
|
386
|
+
kind = kind.toLocaleLowerCase("en-US");
|
|
321
387
|
return `${catalogModel.serializeEntityRef({
|
|
322
|
-
kind: defaultKind && defaultKind.
|
|
388
|
+
kind: defaultKind && defaultKind.toLocaleLowerCase("en-US") === kind ? void 0 : kind,
|
|
323
389
|
name,
|
|
324
390
|
namespace
|
|
325
391
|
})}`;
|
|
@@ -327,7 +393,8 @@ function formatEntityRefTitle(entityRef, opts) {
|
|
|
327
393
|
|
|
328
394
|
const EntityRefLink = React.forwardRef((props, ref) => {
|
|
329
395
|
var _a;
|
|
330
|
-
const {entityRef, defaultKind, children, ...linkProps} = props;
|
|
396
|
+
const {entityRef, defaultKind, title, children, ...linkProps} = props;
|
|
397
|
+
const entityRoute = corePluginApi.useRouteRef(entityRouteRef);
|
|
331
398
|
let kind;
|
|
332
399
|
let namespace;
|
|
333
400
|
let name;
|
|
@@ -346,11 +413,17 @@ const EntityRefLink = React.forwardRef((props, ref) => {
|
|
|
346
413
|
namespace: (_a = namespace == null ? void 0 : namespace.toLocaleLowerCase("en-US")) != null ? _a : catalogModel.ENTITY_DEFAULT_NAMESPACE,
|
|
347
414
|
name
|
|
348
415
|
};
|
|
349
|
-
|
|
416
|
+
const formattedEntityRefTitle = formatEntityRefTitle(entityRef, {
|
|
417
|
+
defaultKind
|
|
418
|
+
});
|
|
419
|
+
const link = /* @__PURE__ */ React__default['default'].createElement(coreComponents.Link, {
|
|
350
420
|
...linkProps,
|
|
351
421
|
ref,
|
|
352
|
-
to:
|
|
353
|
-
}, children, !children &&
|
|
422
|
+
to: entityRoute(routeParams)
|
|
423
|
+
}, children, !children && (title != null ? title : formattedEntityRefTitle));
|
|
424
|
+
return title ? /* @__PURE__ */ React__default['default'].createElement(core.Tooltip, {
|
|
425
|
+
title: formattedEntityRefTitle
|
|
426
|
+
}, link) : link;
|
|
354
427
|
});
|
|
355
428
|
|
|
356
429
|
const EntityRefLinks = ({
|
|
@@ -556,12 +629,12 @@ function useRelatedEntities(entity, {type, kind}) {
|
|
|
556
629
|
value: entities,
|
|
557
630
|
error
|
|
558
631
|
} = reactUse.useAsync(async () => {
|
|
559
|
-
const relations = entity.relations && entity.relations.filter((r) => (!type || r.type.
|
|
632
|
+
const relations = entity.relations && entity.relations.filter((r) => (!type || r.type.toLocaleLowerCase("en-US") === type.toLocaleLowerCase("en-US")) && (!kind || r.target.kind.toLocaleLowerCase("en-US") === kind.toLocaleLowerCase("en-US")));
|
|
560
633
|
if (!relations) {
|
|
561
634
|
return [];
|
|
562
635
|
}
|
|
563
636
|
const relationsByKindAndNamespace = Object.values(lodash.groupBy(relations, ({target}) => {
|
|
564
|
-
return `${target.kind}:${target.namespace}`.
|
|
637
|
+
return `${target.kind}:${target.namespace}`.toLocaleLowerCase("en-US");
|
|
565
638
|
}));
|
|
566
639
|
const batchedRelationsByKindAndNamespace = [];
|
|
567
640
|
for (const rs of relationsByKindAndNamespace) {
|
|
@@ -591,43 +664,43 @@ function useRelatedEntities(entity, {type, kind}) {
|
|
|
591
664
|
};
|
|
592
665
|
}
|
|
593
666
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
const
|
|
602
|
-
const rawStarredEntityKeys = (_a = settingsStore.get("starredEntities")) != null ? _a : [];
|
|
603
|
-
const [starredEntities, setStarredEntities] = React.useState(new Set(rawStarredEntityKeys));
|
|
604
|
-
const observedItems = reactUse.useObservable(settingsStore.observe$("starredEntities"));
|
|
605
|
-
React.useEffect(() => {
|
|
606
|
-
var _a2;
|
|
607
|
-
if (observedItems == null ? void 0 : observedItems.newValue) {
|
|
608
|
-
const currentValue = (_a2 = observedItems == null ? void 0 : observedItems.newValue) != null ? _a2 : [];
|
|
609
|
-
setStarredEntities(new Set(currentValue));
|
|
610
|
-
}
|
|
611
|
-
}, [observedItems == null ? void 0 : observedItems.newValue]);
|
|
612
|
-
const toggleStarredEntity = React.useCallback((entity) => {
|
|
613
|
-
const entityKey = buildEntityKey(entity);
|
|
614
|
-
if (starredEntities.has(entityKey)) {
|
|
615
|
-
starredEntities.delete(entityKey);
|
|
616
|
-
} else {
|
|
617
|
-
starredEntities.add(entityKey);
|
|
618
|
-
}
|
|
619
|
-
settingsStore.set("starredEntities", Array.from(starredEntities));
|
|
620
|
-
}, [starredEntities, settingsStore]);
|
|
621
|
-
const isStarredEntity = React.useCallback((entity) => {
|
|
622
|
-
const entityKey = buildEntityKey(entity);
|
|
623
|
-
return starredEntities.has(entityKey);
|
|
624
|
-
}, [starredEntities]);
|
|
667
|
+
function getEntityRef$1(entityOrRef) {
|
|
668
|
+
return typeof entityOrRef === "string" ? entityOrRef : catalogModel.stringifyEntityRef(entityOrRef);
|
|
669
|
+
}
|
|
670
|
+
function useStarredEntities() {
|
|
671
|
+
const starredEntitiesApi = corePluginApi.useApi(starredEntitiesApiRef);
|
|
672
|
+
const starredEntities = reactUse.useObservable(starredEntitiesApi.starredEntitie$(), new Set());
|
|
673
|
+
const isStarredEntity = React.useCallback((entityOrRef) => starredEntities.has(getEntityRef$1(entityOrRef)), [starredEntities]);
|
|
674
|
+
const toggleStarredEntity = React.useCallback((entityOrRef) => starredEntitiesApi.toggleStarred(getEntityRef$1(entityOrRef)).then(), [starredEntitiesApi]);
|
|
625
675
|
return {
|
|
626
676
|
starredEntities,
|
|
627
677
|
toggleStarredEntity,
|
|
628
678
|
isStarredEntity
|
|
629
679
|
};
|
|
630
|
-
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function getEntityRef(entityOrRef) {
|
|
683
|
+
return typeof entityOrRef === "string" ? entityOrRef : catalogModel.stringifyEntityRef(entityOrRef);
|
|
684
|
+
}
|
|
685
|
+
function useStarredEntity(entityOrRef) {
|
|
686
|
+
const starredEntitiesApi = corePluginApi.useApi(starredEntitiesApiRef);
|
|
687
|
+
const [isStarredEntity, setIsStarredEntity] = React.useState(false);
|
|
688
|
+
React.useEffect(() => {
|
|
689
|
+
const subscription = starredEntitiesApi.starredEntitie$().subscribe({
|
|
690
|
+
next(starredEntities) {
|
|
691
|
+
setIsStarredEntity(starredEntities.has(getEntityRef(entityOrRef)));
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
return () => {
|
|
695
|
+
subscription.unsubscribe();
|
|
696
|
+
};
|
|
697
|
+
}, [entityOrRef, starredEntitiesApi]);
|
|
698
|
+
const toggleStarredEntity = React.useCallback(() => starredEntitiesApi.toggleStarred(getEntityRef(entityOrRef)).then(), [entityOrRef, starredEntitiesApi]);
|
|
699
|
+
return {
|
|
700
|
+
toggleStarredEntity,
|
|
701
|
+
isStarredEntity
|
|
702
|
+
};
|
|
703
|
+
}
|
|
631
704
|
|
|
632
705
|
function extendUserId(id) {
|
|
633
706
|
try {
|
|
@@ -716,6 +789,11 @@ const EntityKindPicker = ({
|
|
|
716
789
|
}, "Kind filter not yet available");
|
|
717
790
|
};
|
|
718
791
|
|
|
792
|
+
const useStyles$6 = core.makeStyles({
|
|
793
|
+
input: {}
|
|
794
|
+
}, {
|
|
795
|
+
name: "CatalogReactEntityLifecyclePicker"
|
|
796
|
+
});
|
|
719
797
|
const icon$2 = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
720
798
|
fontSize: "small"
|
|
721
799
|
});
|
|
@@ -724,6 +802,7 @@ const checkedIcon$2 = /* @__PURE__ */ React__default['default'].createElement(Ch
|
|
|
724
802
|
});
|
|
725
803
|
const EntityLifecyclePicker = () => {
|
|
726
804
|
var _a, _b;
|
|
805
|
+
const classes = useStyles$6();
|
|
727
806
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
728
807
|
const queryParamLifecycles = [queryParameters.lifecycles].flat().filter(Boolean);
|
|
729
808
|
const [selectedLifecycles, setSelectedLifecycles] = React.useState(queryParamLifecycles.length ? queryParamLifecycles : (_b = (_a = filters.lifecycles) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -765,11 +844,17 @@ const EntityLifecyclePicker = () => {
|
|
|
765
844
|
}),
|
|
766
845
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
767
846
|
...params,
|
|
847
|
+
className: classes.input,
|
|
768
848
|
variant: "outlined"
|
|
769
849
|
})
|
|
770
850
|
}));
|
|
771
851
|
};
|
|
772
852
|
|
|
853
|
+
const useStyles$5 = core.makeStyles({
|
|
854
|
+
input: {}
|
|
855
|
+
}, {
|
|
856
|
+
name: "CatalogReactEntityOwnerPicker"
|
|
857
|
+
});
|
|
773
858
|
const icon$1 = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
774
859
|
fontSize: "small"
|
|
775
860
|
});
|
|
@@ -778,6 +863,7 @@ const checkedIcon$1 = /* @__PURE__ */ React__default['default'].createElement(Ch
|
|
|
778
863
|
});
|
|
779
864
|
const EntityOwnerPicker = () => {
|
|
780
865
|
var _a, _b;
|
|
866
|
+
const classes = useStyles$5();
|
|
781
867
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
782
868
|
const queryParamOwners = [queryParameters.owners].flat().filter(Boolean);
|
|
783
869
|
const [selectedOwners, setSelectedOwners] = React.useState(queryParamOwners.length ? queryParamOwners : (_b = (_a = filters.owners) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -816,20 +902,24 @@ const EntityOwnerPicker = () => {
|
|
|
816
902
|
}),
|
|
817
903
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
818
904
|
...params,
|
|
905
|
+
className: classes.input,
|
|
819
906
|
variant: "outlined"
|
|
820
907
|
})
|
|
821
908
|
}));
|
|
822
909
|
};
|
|
823
910
|
|
|
824
|
-
const useStyles$
|
|
911
|
+
const useStyles$4 = core.makeStyles((_theme) => ({
|
|
825
912
|
searchToolbar: {
|
|
826
913
|
paddingLeft: 0,
|
|
827
914
|
paddingRight: 0
|
|
828
|
-
}
|
|
829
|
-
}
|
|
915
|
+
},
|
|
916
|
+
input: {}
|
|
917
|
+
}), {
|
|
918
|
+
name: "CatalogReactEntitySearchBar"
|
|
919
|
+
});
|
|
830
920
|
const EntitySearchBar = () => {
|
|
831
921
|
var _a, _b;
|
|
832
|
-
const
|
|
922
|
+
const classes = useStyles$4();
|
|
833
923
|
const {filters, updateFilters} = useEntityListProvider();
|
|
834
924
|
const [search, setSearch] = React.useState((_b = (_a = filters.text) == null ? void 0 : _a.value) != null ? _b : "");
|
|
835
925
|
reactUse.useDebounce(() => {
|
|
@@ -838,9 +928,10 @@ const EntitySearchBar = () => {
|
|
|
838
928
|
});
|
|
839
929
|
}, 250, [search, updateFilters]);
|
|
840
930
|
return /* @__PURE__ */ React__default['default'].createElement(core.Toolbar, {
|
|
841
|
-
className:
|
|
931
|
+
className: classes.searchToolbar
|
|
842
932
|
}, /* @__PURE__ */ React__default['default'].createElement(core.FormControl, null, /* @__PURE__ */ React__default['default'].createElement(core.Input, {
|
|
843
933
|
id: "input-with-icon-adornment",
|
|
934
|
+
className: classes.input,
|
|
844
935
|
placeholder: "Search",
|
|
845
936
|
autoComplete: "off",
|
|
846
937
|
onChange: (event) => setSearch(event.target.value),
|
|
@@ -863,7 +954,8 @@ function createEntityRefColumn({
|
|
|
863
954
|
defaultKind
|
|
864
955
|
}) {
|
|
865
956
|
function formatContent(entity) {
|
|
866
|
-
|
|
957
|
+
var _a;
|
|
958
|
+
return ((_a = entity.metadata) == null ? void 0 : _a.title) || formatEntityRefTitle(entity, {
|
|
867
959
|
defaultKind
|
|
868
960
|
});
|
|
869
961
|
}
|
|
@@ -876,10 +968,14 @@ function createEntityRefColumn({
|
|
|
876
968
|
customSort(entity1, entity2) {
|
|
877
969
|
return formatContent(entity1).localeCompare(formatContent(entity2));
|
|
878
970
|
},
|
|
879
|
-
render: (entity) =>
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
971
|
+
render: (entity) => {
|
|
972
|
+
var _a;
|
|
973
|
+
return /* @__PURE__ */ React__default['default'].createElement(EntityRefLink, {
|
|
974
|
+
entityRef: entity,
|
|
975
|
+
defaultKind,
|
|
976
|
+
title: (_a = entity.metadata) == null ? void 0 : _a.title
|
|
977
|
+
});
|
|
978
|
+
}
|
|
883
979
|
};
|
|
884
980
|
}
|
|
885
981
|
function createEntityRelationColumn({
|
|
@@ -989,7 +1085,7 @@ const componentEntityColumns = [
|
|
|
989
1085
|
createMetadataDescriptionColumn()
|
|
990
1086
|
];
|
|
991
1087
|
|
|
992
|
-
const useStyles$
|
|
1088
|
+
const useStyles$3 = core.makeStyles((theme) => ({
|
|
993
1089
|
empty: {
|
|
994
1090
|
padding: theme.spacing(2),
|
|
995
1091
|
display: "flex",
|
|
@@ -1003,7 +1099,7 @@ function EntityTable({
|
|
|
1003
1099
|
variant = "gridItem",
|
|
1004
1100
|
columns
|
|
1005
1101
|
}) {
|
|
1006
|
-
const classes = useStyles$
|
|
1102
|
+
const classes = useStyles$3();
|
|
1007
1103
|
const tableStyle = {
|
|
1008
1104
|
minWidth: "0",
|
|
1009
1105
|
width: "100%"
|
|
@@ -1031,6 +1127,11 @@ EntityTable.columns = columnFactories;
|
|
|
1031
1127
|
EntityTable.systemEntityColumns = systemEntityColumns;
|
|
1032
1128
|
EntityTable.componentEntityColumns = componentEntityColumns;
|
|
1033
1129
|
|
|
1130
|
+
const useStyles$2 = core.makeStyles({
|
|
1131
|
+
input: {}
|
|
1132
|
+
}, {
|
|
1133
|
+
name: "CatalogReactEntityTagPicker"
|
|
1134
|
+
});
|
|
1034
1135
|
const icon = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
1035
1136
|
fontSize: "small"
|
|
1036
1137
|
});
|
|
@@ -1039,6 +1140,7 @@ const checkedIcon = /* @__PURE__ */ React__default['default'].createElement(Chec
|
|
|
1039
1140
|
});
|
|
1040
1141
|
const EntityTagPicker = () => {
|
|
1041
1142
|
var _a, _b;
|
|
1143
|
+
const classes = useStyles$2();
|
|
1042
1144
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
1043
1145
|
const queryParamTags = [queryParameters.tags].flat().filter(Boolean);
|
|
1044
1146
|
const [selectedTags, setSelectedTags] = React.useState(queryParamTags.length ? queryParamTags : (_b = (_a = filters.tags) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -1077,13 +1179,15 @@ const EntityTagPicker = () => {
|
|
|
1077
1179
|
}),
|
|
1078
1180
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
1079
1181
|
...params,
|
|
1182
|
+
className: classes.input,
|
|
1080
1183
|
variant: "outlined"
|
|
1081
1184
|
})
|
|
1082
1185
|
}));
|
|
1083
1186
|
};
|
|
1084
1187
|
|
|
1085
|
-
const EntityTypePicker = () => {
|
|
1188
|
+
const EntityTypePicker = (props) => {
|
|
1086
1189
|
var _a;
|
|
1190
|
+
const {hidden, initialFilter} = props;
|
|
1087
1191
|
const alertApi = corePluginApi.useApi(corePluginApi.alertApiRef);
|
|
1088
1192
|
const {error, availableTypes, selectedTypes, setSelectedTypes} = useEntityTypeFilter();
|
|
1089
1193
|
React.useEffect(() => {
|
|
@@ -1093,7 +1197,10 @@ const EntityTypePicker = () => {
|
|
|
1093
1197
|
severity: "error"
|
|
1094
1198
|
});
|
|
1095
1199
|
}
|
|
1096
|
-
|
|
1200
|
+
if (initialFilter) {
|
|
1201
|
+
setSelectedTypes([initialFilter]);
|
|
1202
|
+
}
|
|
1203
|
+
}, [error, alertApi, initialFilter, setSelectedTypes]);
|
|
1097
1204
|
if (availableTypes.length === 0 || error)
|
|
1098
1205
|
return null;
|
|
1099
1206
|
const items = [
|
|
@@ -1103,7 +1210,7 @@ const EntityTypePicker = () => {
|
|
|
1103
1210
|
label: capitalize__default['default'](type)
|
|
1104
1211
|
}))
|
|
1105
1212
|
];
|
|
1106
|
-
return /* @__PURE__ */ React__default['default'].createElement(core.Box, {
|
|
1213
|
+
return hidden ? null : /* @__PURE__ */ React__default['default'].createElement(core.Box, {
|
|
1107
1214
|
pb: 1,
|
|
1108
1215
|
pt: 1
|
|
1109
1216
|
}, /* @__PURE__ */ React__default['default'].createElement(coreComponents.Select, {
|
|
@@ -1122,15 +1229,14 @@ const YellowStar = core.withStyles({
|
|
|
1122
1229
|
const favoriteEntityTooltip = (isStarred) => isStarred ? "Remove from favorites" : "Add to favorites";
|
|
1123
1230
|
const favoriteEntityIcon = (isStarred) => isStarred ? /* @__PURE__ */ React__default['default'].createElement(YellowStar, null) : /* @__PURE__ */ React__default['default'].createElement(StarBorder__default['default'], null);
|
|
1124
1231
|
const FavoriteEntity = (props) => {
|
|
1125
|
-
const {toggleStarredEntity, isStarredEntity} =
|
|
1126
|
-
const isStarred = isStarredEntity(props.entity);
|
|
1232
|
+
const {toggleStarredEntity, isStarredEntity} = useStarredEntity(props.entity);
|
|
1127
1233
|
return /* @__PURE__ */ React__default['default'].createElement(core.IconButton, {
|
|
1128
1234
|
color: "inherit",
|
|
1129
1235
|
...props,
|
|
1130
|
-
onClick: () => toggleStarredEntity(
|
|
1236
|
+
onClick: () => toggleStarredEntity()
|
|
1131
1237
|
}, /* @__PURE__ */ React__default['default'].createElement(core.Tooltip, {
|
|
1132
|
-
title: favoriteEntityTooltip(
|
|
1133
|
-
}, favoriteEntityIcon(
|
|
1238
|
+
title: favoriteEntityTooltip(isStarredEntity)
|
|
1239
|
+
}, favoriteEntityIcon(isStarredEntity)));
|
|
1134
1240
|
};
|
|
1135
1241
|
|
|
1136
1242
|
function useUnregisterEntityDialogState(entity) {
|
|
@@ -1215,6 +1321,7 @@ const Contents = ({
|
|
|
1215
1321
|
await state.unregisterLocation();
|
|
1216
1322
|
onConfirm();
|
|
1217
1323
|
} catch (err) {
|
|
1324
|
+
errors.assertError(err);
|
|
1218
1325
|
alertApi.post({message: err.message});
|
|
1219
1326
|
} finally {
|
|
1220
1327
|
setBusy(false);
|
|
@@ -1228,6 +1335,7 @@ const Contents = ({
|
|
|
1228
1335
|
await state.deleteEntity();
|
|
1229
1336
|
onConfirm();
|
|
1230
1337
|
} catch (err) {
|
|
1338
|
+
errors.assertError(err);
|
|
1231
1339
|
alertApi.post({message: err.message});
|
|
1232
1340
|
} finally {
|
|
1233
1341
|
setBusy(false);
|
|
@@ -1347,7 +1455,9 @@ const useStyles = core.makeStyles((theme) => ({
|
|
|
1347
1455
|
groupWrapper: {
|
|
1348
1456
|
margin: theme.spacing(1, 1, 2, 1)
|
|
1349
1457
|
}
|
|
1350
|
-
})
|
|
1458
|
+
}), {
|
|
1459
|
+
name: "CatalogReactUserListPicker"
|
|
1460
|
+
});
|
|
1351
1461
|
function getFilterGroups(orgName) {
|
|
1352
1462
|
return [
|
|
1353
1463
|
{
|
|
@@ -1479,6 +1589,7 @@ Object.defineProperty(exports, 'CATALOG_FILTER_EXISTS', {
|
|
|
1479
1589
|
}
|
|
1480
1590
|
});
|
|
1481
1591
|
exports.AsyncEntityProvider = AsyncEntityProvider;
|
|
1592
|
+
exports.DefaultStarredEntitiesApi = DefaultStarredEntitiesApi;
|
|
1482
1593
|
exports.EntityContext = EntityContext;
|
|
1483
1594
|
exports.EntityKindFilter = EntityKindFilter;
|
|
1484
1595
|
exports.EntityKindPicker = EntityKindPicker;
|
|
@@ -1519,6 +1630,7 @@ exports.isOwnerOf = isOwnerOf;
|
|
|
1519
1630
|
exports.reduceCatalogFilters = reduceCatalogFilters;
|
|
1520
1631
|
exports.reduceEntityFilters = reduceEntityFilters;
|
|
1521
1632
|
exports.rootRoute = rootRoute;
|
|
1633
|
+
exports.starredEntitiesApiRef = starredEntitiesApiRef;
|
|
1522
1634
|
exports.useEntity = useEntity;
|
|
1523
1635
|
exports.useEntityCompoundName = useEntityCompoundName;
|
|
1524
1636
|
exports.useEntityFromUrl = useEntityFromUrl;
|
|
@@ -1529,4 +1641,5 @@ exports.useEntityTypeFilter = useEntityTypeFilter;
|
|
|
1529
1641
|
exports.useOwnUser = useOwnUser;
|
|
1530
1642
|
exports.useRelatedEntities = useRelatedEntities;
|
|
1531
1643
|
exports.useStarredEntities = useStarredEntities;
|
|
1644
|
+
exports.useStarredEntity = useStarredEntity;
|
|
1532
1645
|
//# sourceMappingURL=index.cjs.js.map
|