/** * Copyright (c) 2021 OpenLens Authors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import { IComputedValue, makeObservable, observable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; import { matchPath, Redirect, Route, RouteProps, Switch } from "react-router"; import { appRoute, appURL, editorURL, kubernetesRoute, kubernetesURL, preferencesURL, proxyRoute, proxyURL, editorRoute, telemetryRoute, telemetryURL, extensionSettingsURL, } from "../../../common/routes"; import { AppPreferenceRegistry } from "../../../extensions/registries/app-preference-registry"; import { navigateWithoutHistoryChange, navigation } from "../../navigation"; import { SettingLayout } from "../layout/setting-layout"; import { Tab, Tabs } from "../tabs"; import { Application } from "./application"; import { Kubernetes } from "./kubernetes"; import { Editor } from "./editor"; import { LensProxy } from "./proxy"; import { Telemetry } from "./telemetry"; import { sentryDsn } from "../../../common/vars"; import { withInjectables } from "@ogre-tools/injectable-react"; import type { InstalledExtension } from "../../../extensions/extension-discovery"; import userExtensionsInjectable from "../+extensions/user-extensions/user-extensions.injectable"; import { ExtensionSettingsPage } from "./extension-settings-page"; import { Icon } from "../icon"; import { uniqBy } from "lodash"; interface Dependencies { userExtensions: IComputedValue; } @observer class Preferences extends React.Component { @observable historyLength: number | undefined; constructor(props: Dependencies) { super(props); makeObservable(this); } renderNavigation() { const preferenceRegistries = uniqBy(AppPreferenceRegistry.getInstance().getItems(), "extensionId"); const telemetryExtensions = preferenceRegistries.filter(e => e.showInPreferencesTab == "telemetry"); const currentLocation = navigation.location.pathname; const isActive = (route: RouteProps) => !!matchPath(currentLocation, { path: route.path, exact: route.exact }); const extensionsWithSettings = this.props.userExtensions.get().filter(extension => preferenceRegistries.some(registry => registry.extensionId.includes(extension.manifest.name) && !registry.showInPreferencesTab), ); return ( { navigateWithoutHistoryChange({ pathname: url }); }}>
Preferences
{(telemetryExtensions.length > 0 || !!sentryDsn) && } {extensionsWithSettings.length > 0 && (

Custom settings
{extensionsWithSettings.map(extension => ( ))}
)}
); } render() { return ( ); } } export default withInjectables( Preferences, { getProps: (di) => ({ userExtensions: di.inject(userExtensionsInjectable), }), }, );