mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Highlight expandable items only if they collapsed
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
f32b9e6261
commit
0dcf890d5f
@ -17,6 +17,8 @@ import {
|
|||||||
orderBy,
|
orderBy,
|
||||||
some,
|
some,
|
||||||
} from "lodash/fp";
|
} from "lodash/fp";
|
||||||
|
import sidebarStorageInjectable, { SidebarStorageState } from "./sidebar-storage/sidebar-storage.injectable";
|
||||||
|
import type { StorageLayer } from "../../utils";
|
||||||
|
|
||||||
export interface SidebarItemRegistration {
|
export interface SidebarItemRegistration {
|
||||||
id: string;
|
id: string;
|
||||||
@ -44,7 +46,7 @@ const sidebarItemsInjectable = getInjectable({
|
|||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const computedInjectMany = di.inject(computedInjectManyInjectable);
|
const computedInjectMany = di.inject(computedInjectManyInjectable);
|
||||||
|
const sidebarStorage: StorageLayer<SidebarStorageState> = di.inject(sidebarStorageInjectable)
|
||||||
const sidebarItemRegistrations = computedInjectMany(sidebarItemsInjectionToken);
|
const sidebarItemRegistrations = computedInjectMany(sidebarItemsInjectionToken);
|
||||||
|
|
||||||
return computed((): HierarchicalSidebarItem[] => {
|
return computed((): HierarchicalSidebarItem[] => {
|
||||||
@ -63,6 +65,8 @@ const sidebarItemsInjectable = getInjectable({
|
|||||||
map((registration) => {
|
map((registration) => {
|
||||||
const children = _getSidebarItemsHierarchy(registration.id);
|
const children = _getSidebarItemsHierarchy(registration.id);
|
||||||
|
|
||||||
|
const parentExpanded = () => Boolean(sidebarStorage.get().expanded[registration.id])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
registration,
|
registration,
|
||||||
children,
|
children,
|
||||||
@ -76,6 +80,7 @@ const sidebarItemsInjectable = getInjectable({
|
|||||||
children,
|
children,
|
||||||
invokeMap("isActive.get"),
|
invokeMap("isActive.get"),
|
||||||
some(identity),
|
some(identity),
|
||||||
|
(identityFound) => identityFound && !parentExpanded(),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user