Fix owner and lifecycle picker
Signed-off-by: Sarah Medeiros <smedeiros@wayfair.com>
This commit is contained in:
+11
-11
@@ -83,17 +83,17 @@ export const EntityLifecyclePicker = () => {
|
||||
});
|
||||
}, [selectedLifecycles, updateFilters]);
|
||||
|
||||
const availableLifecycles = useMemo(
|
||||
() =>
|
||||
[
|
||||
...new Set(
|
||||
backendEntities
|
||||
.map((e: Entity) => e.spec?.lifecycle)
|
||||
.filter(Boolean) as string[],
|
||||
),
|
||||
].sort(),
|
||||
[backendEntities],
|
||||
);
|
||||
const availableLifecycles = useMemo(() => {
|
||||
const lifecycles = [
|
||||
...new Set(
|
||||
backendEntities
|
||||
.map((e: Entity) => e.spec?.lifecycle)
|
||||
.filter(Boolean) as string[],
|
||||
),
|
||||
].sort();
|
||||
if (lifecycles.length === 0) setSelectedLifecycles([]);
|
||||
return lifecycles;
|
||||
}, [backendEntities]);
|
||||
|
||||
if (!availableLifecycles.length) return null;
|
||||
|
||||
|
||||
@@ -83,21 +83,21 @@ export const EntityOwnerPicker = () => {
|
||||
});
|
||||
}, [selectedOwners, updateFilters]);
|
||||
|
||||
const availableOwners = useMemo(
|
||||
() =>
|
||||
[
|
||||
...new Set(
|
||||
backendEntities
|
||||
.flatMap((e: Entity) =>
|
||||
getEntityRelations(e, RELATION_OWNED_BY).map(o =>
|
||||
humanizeEntityRef(o, { defaultKind: 'group' }),
|
||||
),
|
||||
)
|
||||
.filter(Boolean) as string[],
|
||||
),
|
||||
].sort(),
|
||||
[backendEntities],
|
||||
);
|
||||
const availableOwners = useMemo(() => {
|
||||
const owners = [
|
||||
...new Set(
|
||||
backendEntities
|
||||
.flatMap((e: Entity) =>
|
||||
getEntityRelations(e, RELATION_OWNED_BY).map(o =>
|
||||
humanizeEntityRef(o, { defaultKind: 'group' }),
|
||||
),
|
||||
)
|
||||
.filter(Boolean) as string[],
|
||||
),
|
||||
].sort();
|
||||
if (owners.length === 0) setSelectedOwners([]);
|
||||
return owners;
|
||||
}, [backendEntities]);
|
||||
|
||||
if (!availableOwners.length) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user