@backstage/plugin-catalog-react 0.5.2 → 0.6.3
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 +58 -0
- package/dist/index.cjs.js +157 -53
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +87 -6
- package/dist/index.esm.js +153 -55
- package/dist/index.esm.js.map +1 -1
- package/package.json +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 03b47a476d: export `loadIdentityOwnerRefs` and `loadCatalogOwnerRefs` all the way
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.7.3
|
|
10
|
+
- @backstage/catalog-client@0.5.1
|
|
11
|
+
- @backstage/core-plugin-api@0.1.13
|
|
12
|
+
- @backstage/core-app-api@0.1.20
|
|
13
|
+
|
|
14
|
+
## 0.6.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- f9cc2509f8: EntityTypePicker can be hidden and have an initial filter value set, similar to EntityKindPicker
|
|
19
|
+
- 10615525f3: Switch to use the json and observable types from `@backstage/types`
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @backstage/errors@0.1.4
|
|
22
|
+
- @backstage/integration@0.6.9
|
|
23
|
+
- @backstage/core-components@0.7.2
|
|
24
|
+
- @backstage/catalog-model@0.9.6
|
|
25
|
+
- @backstage/core-app-api@0.1.19
|
|
26
|
+
- @backstage/core-plugin-api@0.1.12
|
|
27
|
+
|
|
28
|
+
## 0.6.1
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 36e67d2f24: Internal updates to apply more strict checks to throw errors.
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @backstage/core-components@0.7.1
|
|
35
|
+
- @backstage/errors@0.1.3
|
|
36
|
+
- @backstage/core-app-api@0.1.18
|
|
37
|
+
- @backstage/core-plugin-api@0.1.11
|
|
38
|
+
- @backstage/catalog-model@0.9.5
|
|
39
|
+
|
|
40
|
+
## 0.6.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- 82fbda923e: Introduce a new `StarredEntitiesApi` that is used in the `useStarredEntities` hook.
|
|
45
|
+
The `@backstage/plugin-catalog` installs a default implementation that is backed by the `StorageApi`, but one can also override the `starredEntitiesApiRef`.
|
|
46
|
+
|
|
47
|
+
This change also updates the storage format from a custom string to an entity reference and moves the location in the local storage.
|
|
48
|
+
A migration will convert the previously starred entities to the location on the first load of Backstage.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 0366c9b667: Introduce a `useStarredEntity` hook to check if a single entity is starred.
|
|
53
|
+
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.
|
|
54
|
+
- 4aca84f86b: Support `material-ui` overrides in plugin-catalog-react components
|
|
55
|
+
- b03b9f19e0: added sorting in entity `Name` column by `metadata.title` if present
|
|
56
|
+
- Updated dependencies
|
|
57
|
+
- @backstage/integration@0.6.8
|
|
58
|
+
- @backstage/core-app-api@0.1.17
|
|
59
|
+
- @backstage/core-components@0.7.0
|
|
60
|
+
|
|
3
61
|
## 0.5.2
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,13 +4,14 @@ 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
17
|
var core = require('@material-ui/core');
|
|
@@ -21,13 +22,15 @@ 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,
|
|
@@ -598,43 +664,43 @@ function useRelatedEntities(entity, {type, kind}) {
|
|
|
598
664
|
};
|
|
599
665
|
}
|
|
600
666
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
const
|
|
608
|
-
const
|
|
609
|
-
const rawStarredEntityKeys = (_a = settingsStore.get("starredEntities")) != null ? _a : [];
|
|
610
|
-
const [starredEntities, setStarredEntities] = React.useState(new Set(rawStarredEntityKeys));
|
|
611
|
-
const observedItems = reactUse.useObservable(settingsStore.observe$("starredEntities"));
|
|
612
|
-
React.useEffect(() => {
|
|
613
|
-
var _a2;
|
|
614
|
-
if (observedItems == null ? void 0 : observedItems.newValue) {
|
|
615
|
-
const currentValue = (_a2 = observedItems == null ? void 0 : observedItems.newValue) != null ? _a2 : [];
|
|
616
|
-
setStarredEntities(new Set(currentValue));
|
|
617
|
-
}
|
|
618
|
-
}, [observedItems == null ? void 0 : observedItems.newValue]);
|
|
619
|
-
const toggleStarredEntity = React.useCallback((entity) => {
|
|
620
|
-
const entityKey = buildEntityKey(entity);
|
|
621
|
-
if (starredEntities.has(entityKey)) {
|
|
622
|
-
starredEntities.delete(entityKey);
|
|
623
|
-
} else {
|
|
624
|
-
starredEntities.add(entityKey);
|
|
625
|
-
}
|
|
626
|
-
settingsStore.set("starredEntities", Array.from(starredEntities));
|
|
627
|
-
}, [starredEntities, settingsStore]);
|
|
628
|
-
const isStarredEntity = React.useCallback((entity) => {
|
|
629
|
-
const entityKey = buildEntityKey(entity);
|
|
630
|
-
return starredEntities.has(entityKey);
|
|
631
|
-
}, [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]);
|
|
632
675
|
return {
|
|
633
676
|
starredEntities,
|
|
634
677
|
toggleStarredEntity,
|
|
635
678
|
isStarredEntity
|
|
636
679
|
};
|
|
637
|
-
}
|
|
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
|
+
}
|
|
638
704
|
|
|
639
705
|
function extendUserId(id) {
|
|
640
706
|
try {
|
|
@@ -723,6 +789,11 @@ const EntityKindPicker = ({
|
|
|
723
789
|
}, "Kind filter not yet available");
|
|
724
790
|
};
|
|
725
791
|
|
|
792
|
+
const useStyles$6 = core.makeStyles({
|
|
793
|
+
input: {}
|
|
794
|
+
}, {
|
|
795
|
+
name: "CatalogReactEntityLifecyclePicker"
|
|
796
|
+
});
|
|
726
797
|
const icon$2 = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
727
798
|
fontSize: "small"
|
|
728
799
|
});
|
|
@@ -731,6 +802,7 @@ const checkedIcon$2 = /* @__PURE__ */ React__default['default'].createElement(Ch
|
|
|
731
802
|
});
|
|
732
803
|
const EntityLifecyclePicker = () => {
|
|
733
804
|
var _a, _b;
|
|
805
|
+
const classes = useStyles$6();
|
|
734
806
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
735
807
|
const queryParamLifecycles = [queryParameters.lifecycles].flat().filter(Boolean);
|
|
736
808
|
const [selectedLifecycles, setSelectedLifecycles] = React.useState(queryParamLifecycles.length ? queryParamLifecycles : (_b = (_a = filters.lifecycles) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -772,11 +844,17 @@ const EntityLifecyclePicker = () => {
|
|
|
772
844
|
}),
|
|
773
845
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
774
846
|
...params,
|
|
847
|
+
className: classes.input,
|
|
775
848
|
variant: "outlined"
|
|
776
849
|
})
|
|
777
850
|
}));
|
|
778
851
|
};
|
|
779
852
|
|
|
853
|
+
const useStyles$5 = core.makeStyles({
|
|
854
|
+
input: {}
|
|
855
|
+
}, {
|
|
856
|
+
name: "CatalogReactEntityOwnerPicker"
|
|
857
|
+
});
|
|
780
858
|
const icon$1 = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
781
859
|
fontSize: "small"
|
|
782
860
|
});
|
|
@@ -785,6 +863,7 @@ const checkedIcon$1 = /* @__PURE__ */ React__default['default'].createElement(Ch
|
|
|
785
863
|
});
|
|
786
864
|
const EntityOwnerPicker = () => {
|
|
787
865
|
var _a, _b;
|
|
866
|
+
const classes = useStyles$5();
|
|
788
867
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
789
868
|
const queryParamOwners = [queryParameters.owners].flat().filter(Boolean);
|
|
790
869
|
const [selectedOwners, setSelectedOwners] = React.useState(queryParamOwners.length ? queryParamOwners : (_b = (_a = filters.owners) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -823,20 +902,24 @@ const EntityOwnerPicker = () => {
|
|
|
823
902
|
}),
|
|
824
903
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
825
904
|
...params,
|
|
905
|
+
className: classes.input,
|
|
826
906
|
variant: "outlined"
|
|
827
907
|
})
|
|
828
908
|
}));
|
|
829
909
|
};
|
|
830
910
|
|
|
831
|
-
const useStyles$
|
|
911
|
+
const useStyles$4 = core.makeStyles((_theme) => ({
|
|
832
912
|
searchToolbar: {
|
|
833
913
|
paddingLeft: 0,
|
|
834
914
|
paddingRight: 0
|
|
835
|
-
}
|
|
836
|
-
}
|
|
915
|
+
},
|
|
916
|
+
input: {}
|
|
917
|
+
}), {
|
|
918
|
+
name: "CatalogReactEntitySearchBar"
|
|
919
|
+
});
|
|
837
920
|
const EntitySearchBar = () => {
|
|
838
921
|
var _a, _b;
|
|
839
|
-
const
|
|
922
|
+
const classes = useStyles$4();
|
|
840
923
|
const {filters, updateFilters} = useEntityListProvider();
|
|
841
924
|
const [search, setSearch] = React.useState((_b = (_a = filters.text) == null ? void 0 : _a.value) != null ? _b : "");
|
|
842
925
|
reactUse.useDebounce(() => {
|
|
@@ -845,9 +928,10 @@ const EntitySearchBar = () => {
|
|
|
845
928
|
});
|
|
846
929
|
}, 250, [search, updateFilters]);
|
|
847
930
|
return /* @__PURE__ */ React__default['default'].createElement(core.Toolbar, {
|
|
848
|
-
className:
|
|
931
|
+
className: classes.searchToolbar
|
|
849
932
|
}, /* @__PURE__ */ React__default['default'].createElement(core.FormControl, null, /* @__PURE__ */ React__default['default'].createElement(core.Input, {
|
|
850
933
|
id: "input-with-icon-adornment",
|
|
934
|
+
className: classes.input,
|
|
851
935
|
placeholder: "Search",
|
|
852
936
|
autoComplete: "off",
|
|
853
937
|
onChange: (event) => setSearch(event.target.value),
|
|
@@ -870,7 +954,8 @@ function createEntityRefColumn({
|
|
|
870
954
|
defaultKind
|
|
871
955
|
}) {
|
|
872
956
|
function formatContent(entity) {
|
|
873
|
-
|
|
957
|
+
var _a;
|
|
958
|
+
return ((_a = entity.metadata) == null ? void 0 : _a.title) || formatEntityRefTitle(entity, {
|
|
874
959
|
defaultKind
|
|
875
960
|
});
|
|
876
961
|
}
|
|
@@ -1000,7 +1085,7 @@ const componentEntityColumns = [
|
|
|
1000
1085
|
createMetadataDescriptionColumn()
|
|
1001
1086
|
];
|
|
1002
1087
|
|
|
1003
|
-
const useStyles$
|
|
1088
|
+
const useStyles$3 = core.makeStyles((theme) => ({
|
|
1004
1089
|
empty: {
|
|
1005
1090
|
padding: theme.spacing(2),
|
|
1006
1091
|
display: "flex",
|
|
@@ -1014,7 +1099,7 @@ function EntityTable({
|
|
|
1014
1099
|
variant = "gridItem",
|
|
1015
1100
|
columns
|
|
1016
1101
|
}) {
|
|
1017
|
-
const classes = useStyles$
|
|
1102
|
+
const classes = useStyles$3();
|
|
1018
1103
|
const tableStyle = {
|
|
1019
1104
|
minWidth: "0",
|
|
1020
1105
|
width: "100%"
|
|
@@ -1042,6 +1127,11 @@ EntityTable.columns = columnFactories;
|
|
|
1042
1127
|
EntityTable.systemEntityColumns = systemEntityColumns;
|
|
1043
1128
|
EntityTable.componentEntityColumns = componentEntityColumns;
|
|
1044
1129
|
|
|
1130
|
+
const useStyles$2 = core.makeStyles({
|
|
1131
|
+
input: {}
|
|
1132
|
+
}, {
|
|
1133
|
+
name: "CatalogReactEntityTagPicker"
|
|
1134
|
+
});
|
|
1045
1135
|
const icon = /* @__PURE__ */ React__default['default'].createElement(CheckBoxOutlineBlankIcon__default['default'], {
|
|
1046
1136
|
fontSize: "small"
|
|
1047
1137
|
});
|
|
@@ -1050,6 +1140,7 @@ const checkedIcon = /* @__PURE__ */ React__default['default'].createElement(Chec
|
|
|
1050
1140
|
});
|
|
1051
1141
|
const EntityTagPicker = () => {
|
|
1052
1142
|
var _a, _b;
|
|
1143
|
+
const classes = useStyles$2();
|
|
1053
1144
|
const {updateFilters, backendEntities, filters, queryParameters} = useEntityListProvider();
|
|
1054
1145
|
const queryParamTags = [queryParameters.tags].flat().filter(Boolean);
|
|
1055
1146
|
const [selectedTags, setSelectedTags] = React.useState(queryParamTags.length ? queryParamTags : (_b = (_a = filters.tags) == null ? void 0 : _a.values) != null ? _b : []);
|
|
@@ -1088,13 +1179,15 @@ const EntityTagPicker = () => {
|
|
|
1088
1179
|
}),
|
|
1089
1180
|
renderInput: (params) => /* @__PURE__ */ React__default['default'].createElement(core.TextField, {
|
|
1090
1181
|
...params,
|
|
1182
|
+
className: classes.input,
|
|
1091
1183
|
variant: "outlined"
|
|
1092
1184
|
})
|
|
1093
1185
|
}));
|
|
1094
1186
|
};
|
|
1095
1187
|
|
|
1096
|
-
const EntityTypePicker = () => {
|
|
1188
|
+
const EntityTypePicker = (props) => {
|
|
1097
1189
|
var _a;
|
|
1190
|
+
const {hidden, initialFilter} = props;
|
|
1098
1191
|
const alertApi = corePluginApi.useApi(corePluginApi.alertApiRef);
|
|
1099
1192
|
const {error, availableTypes, selectedTypes, setSelectedTypes} = useEntityTypeFilter();
|
|
1100
1193
|
React.useEffect(() => {
|
|
@@ -1104,7 +1197,10 @@ const EntityTypePicker = () => {
|
|
|
1104
1197
|
severity: "error"
|
|
1105
1198
|
});
|
|
1106
1199
|
}
|
|
1107
|
-
|
|
1200
|
+
if (initialFilter) {
|
|
1201
|
+
setSelectedTypes([initialFilter]);
|
|
1202
|
+
}
|
|
1203
|
+
}, [error, alertApi, initialFilter, setSelectedTypes]);
|
|
1108
1204
|
if (availableTypes.length === 0 || error)
|
|
1109
1205
|
return null;
|
|
1110
1206
|
const items = [
|
|
@@ -1114,7 +1210,7 @@ const EntityTypePicker = () => {
|
|
|
1114
1210
|
label: capitalize__default['default'](type)
|
|
1115
1211
|
}))
|
|
1116
1212
|
];
|
|
1117
|
-
return /* @__PURE__ */ React__default['default'].createElement(core.Box, {
|
|
1213
|
+
return hidden ? null : /* @__PURE__ */ React__default['default'].createElement(core.Box, {
|
|
1118
1214
|
pb: 1,
|
|
1119
1215
|
pt: 1
|
|
1120
1216
|
}, /* @__PURE__ */ React__default['default'].createElement(coreComponents.Select, {
|
|
@@ -1133,15 +1229,14 @@ const YellowStar = core.withStyles({
|
|
|
1133
1229
|
const favoriteEntityTooltip = (isStarred) => isStarred ? "Remove from favorites" : "Add to favorites";
|
|
1134
1230
|
const favoriteEntityIcon = (isStarred) => isStarred ? /* @__PURE__ */ React__default['default'].createElement(YellowStar, null) : /* @__PURE__ */ React__default['default'].createElement(StarBorder__default['default'], null);
|
|
1135
1231
|
const FavoriteEntity = (props) => {
|
|
1136
|
-
const {toggleStarredEntity, isStarredEntity} =
|
|
1137
|
-
const isStarred = isStarredEntity(props.entity);
|
|
1232
|
+
const {toggleStarredEntity, isStarredEntity} = useStarredEntity(props.entity);
|
|
1138
1233
|
return /* @__PURE__ */ React__default['default'].createElement(core.IconButton, {
|
|
1139
1234
|
color: "inherit",
|
|
1140
1235
|
...props,
|
|
1141
|
-
onClick: () => toggleStarredEntity(
|
|
1236
|
+
onClick: () => toggleStarredEntity()
|
|
1142
1237
|
}, /* @__PURE__ */ React__default['default'].createElement(core.Tooltip, {
|
|
1143
|
-
title: favoriteEntityTooltip(
|
|
1144
|
-
}, favoriteEntityIcon(
|
|
1238
|
+
title: favoriteEntityTooltip(isStarredEntity)
|
|
1239
|
+
}, favoriteEntityIcon(isStarredEntity)));
|
|
1145
1240
|
};
|
|
1146
1241
|
|
|
1147
1242
|
function useUnregisterEntityDialogState(entity) {
|
|
@@ -1226,6 +1321,7 @@ const Contents = ({
|
|
|
1226
1321
|
await state.unregisterLocation();
|
|
1227
1322
|
onConfirm();
|
|
1228
1323
|
} catch (err) {
|
|
1324
|
+
errors.assertError(err);
|
|
1229
1325
|
alertApi.post({message: err.message});
|
|
1230
1326
|
} finally {
|
|
1231
1327
|
setBusy(false);
|
|
@@ -1239,6 +1335,7 @@ const Contents = ({
|
|
|
1239
1335
|
await state.deleteEntity();
|
|
1240
1336
|
onConfirm();
|
|
1241
1337
|
} catch (err) {
|
|
1338
|
+
errors.assertError(err);
|
|
1242
1339
|
alertApi.post({message: err.message});
|
|
1243
1340
|
} finally {
|
|
1244
1341
|
setBusy(false);
|
|
@@ -1358,7 +1455,9 @@ const useStyles = core.makeStyles((theme) => ({
|
|
|
1358
1455
|
groupWrapper: {
|
|
1359
1456
|
margin: theme.spacing(1, 1, 2, 1)
|
|
1360
1457
|
}
|
|
1361
|
-
})
|
|
1458
|
+
}), {
|
|
1459
|
+
name: "CatalogReactUserListPicker"
|
|
1460
|
+
});
|
|
1362
1461
|
function getFilterGroups(orgName) {
|
|
1363
1462
|
return [
|
|
1364
1463
|
{
|
|
@@ -1490,6 +1589,7 @@ Object.defineProperty(exports, 'CATALOG_FILTER_EXISTS', {
|
|
|
1490
1589
|
}
|
|
1491
1590
|
});
|
|
1492
1591
|
exports.AsyncEntityProvider = AsyncEntityProvider;
|
|
1592
|
+
exports.DefaultStarredEntitiesApi = DefaultStarredEntitiesApi;
|
|
1493
1593
|
exports.EntityContext = EntityContext;
|
|
1494
1594
|
exports.EntityKindFilter = EntityKindFilter;
|
|
1495
1595
|
exports.EntityKindPicker = EntityKindPicker;
|
|
@@ -1527,9 +1627,12 @@ exports.getEntityMetadataViewUrl = getEntityMetadataViewUrl;
|
|
|
1527
1627
|
exports.getEntityRelations = getEntityRelations;
|
|
1528
1628
|
exports.getEntitySourceLocation = getEntitySourceLocation;
|
|
1529
1629
|
exports.isOwnerOf = isOwnerOf;
|
|
1630
|
+
exports.loadCatalogOwnerRefs = loadCatalogOwnerRefs;
|
|
1631
|
+
exports.loadIdentityOwnerRefs = loadIdentityOwnerRefs;
|
|
1530
1632
|
exports.reduceCatalogFilters = reduceCatalogFilters;
|
|
1531
1633
|
exports.reduceEntityFilters = reduceEntityFilters;
|
|
1532
1634
|
exports.rootRoute = rootRoute;
|
|
1635
|
+
exports.starredEntitiesApiRef = starredEntitiesApiRef;
|
|
1533
1636
|
exports.useEntity = useEntity;
|
|
1534
1637
|
exports.useEntityCompoundName = useEntityCompoundName;
|
|
1535
1638
|
exports.useEntityFromUrl = useEntityFromUrl;
|
|
@@ -1540,4 +1643,5 @@ exports.useEntityTypeFilter = useEntityTypeFilter;
|
|
|
1540
1643
|
exports.useOwnUser = useOwnUser;
|
|
1541
1644
|
exports.useRelatedEntities = useRelatedEntities;
|
|
1542
1645
|
exports.useStarredEntities = useStarredEntities;
|
|
1646
|
+
exports.useStarredEntity = useStarredEntity;
|
|
1543
1647
|
//# sourceMappingURL=index.cjs.js.map
|