mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
|
import { computed } from "mobx";
|
|
import routeIsActiveInjectable from "../../../../routes/route-is-active.injectable";
|
|
import preferencesRouteInjectable from "../../../../../features/preferences/common/preferences-route.injectable";
|
|
import routePathParametersInjectable from "../../../../routes/route-path-parameters.injectable";
|
|
|
|
const preferenceTabIsActiveInjectable = getInjectable({
|
|
id: "preference-tab-is-active",
|
|
|
|
instantiate: (di, tabId: string) => {
|
|
const route = di.inject(preferencesRouteInjectable);
|
|
const routeIsActive = di.inject(routeIsActiveInjectable, route);
|
|
const pathParameters = di.inject(routePathParametersInjectable, route);
|
|
|
|
return computed(
|
|
() =>
|
|
routeIsActive.get() && pathParameters.get().preferenceTabId === tabId,
|
|
);
|
|
},
|
|
|
|
lifecycle: lifecycleEnum.keyedSingleton({
|
|
getInstanceKey: (di, tabId: string) => tabId,
|
|
}),
|
|
});
|
|
|
|
export default preferenceTabIsActiveInjectable;
|