mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Restructure to monorepo (#6907)
* wip: restructure to monorepo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor create-release-pr to a package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * github workflow fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix typo Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add webpack-env types to core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix github workflows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * refactor/fix integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * lint fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * yarn run dev Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * eslint settings for vscode Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * move templates to right package Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * open-lens build fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * integration test fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix nx task dependencies Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * use bash shell for unit tests in test workflow Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix test:unit for windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix win-ca webpack error in open-lens Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix build:app on windows Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove ELECTRON_BUILDER_EXTRA_ARGS Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * sync src/ from master Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * remove Makefile from core Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import attemptInstallByInfoInjectable from "../../components/+extensions/attempt-install-by-info.injectable";
|
||||
import { bindProtocolAddRouteHandlers } from "./bind-protocol-add-route-handlers";
|
||||
import lensProtocolRouterRendererInjectable from "../lens-protocol-router-renderer/lens-protocol-router-renderer.injectable";
|
||||
import navigateToCatalogInjectable from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import navigateToAddClusterInjectable from "../../../common/front-end-routing/routes/add-cluster/navigate-to-add-cluster.injectable";
|
||||
import navigateToExtensionsInjectable from "../../../common/front-end-routing/routes/extensions/navigate-to-extensions.injectable";
|
||||
import navigateToEntitySettingsInjectable from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||
import navigateToClusterViewInjectable from "../../../common/front-end-routing/routes/cluster-view/navigate-to-cluster-view.injectable";
|
||||
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
|
||||
|
||||
// TODO: Importing from features is not OK. Make protocol-router to comply with Open Closed Principle to allow moving implementation under a feature
|
||||
import navigateToPreferencesInjectable from "../../../features/preferences/common/navigate-to-preferences.injectable";
|
||||
import getClusterByIdInjectable from "../../../common/cluster-store/get-by-id.injectable";
|
||||
import showShortInfoNotificationInjectable from "../../components/notifications/show-short-info.injectable";
|
||||
|
||||
const bindProtocolAddRouteHandlersInjectable = getInjectable({
|
||||
id: "bind-protocol-add-route-handlers",
|
||||
|
||||
instantiate: (di) => bindProtocolAddRouteHandlers({
|
||||
attemptInstallByInfo: di.inject(attemptInstallByInfoInjectable),
|
||||
lensProtocolRouterRenderer: di.inject(lensProtocolRouterRendererInjectable ),
|
||||
navigateToCatalog: di.inject(navigateToCatalogInjectable),
|
||||
navigateToAddCluster: di.inject(navigateToAddClusterInjectable),
|
||||
navigateToExtensions: di.inject(navigateToExtensionsInjectable),
|
||||
navigateToEntitySettings: di.inject(navigateToEntitySettingsInjectable),
|
||||
navigateToClusterView: di.inject(navigateToClusterViewInjectable),
|
||||
navigateToPreferences: di.inject(navigateToPreferencesInjectable),
|
||||
entityRegistry: di.inject(catalogEntityRegistryInjectable),
|
||||
getClusterById: di.inject(getClusterByIdInjectable),
|
||||
showShortInfoNotification: di.inject(showShortInfoNotificationInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
export default bindProtocolAddRouteHandlersInjectable;
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { LensProtocolRouterRenderer } from "../lens-protocol-router-renderer/lens-protocol-router-renderer";
|
||||
import type { CatalogEntityRegistry } from "../../api/catalog/entity/registry";
|
||||
import {
|
||||
EXTENSION_NAME_MATCH,
|
||||
EXTENSION_PUBLISHER_MATCH,
|
||||
LensProtocolRouter,
|
||||
} from "../../../common/protocol-handler";
|
||||
import type { ShowNotification } from "../../components/notifications";
|
||||
import type { NavigateToCatalog } from "../../../common/front-end-routing/routes/catalog/navigate-to-catalog.injectable";
|
||||
import type { NavigateToEntitySettings } from "../../../common/front-end-routing/routes/entity-settings/navigate-to-entity-settings.injectable";
|
||||
import type { NavigateToClusterView } from "../../../common/front-end-routing/routes/cluster-view/navigate-to-cluster-view.injectable";
|
||||
import assert from "assert";
|
||||
import type { AttemptInstallByInfo } from "../../components/+extensions/attempt-install-by-info.injectable";
|
||||
import type { GetClusterById } from "../../../common/cluster-store/get-by-id.injectable";
|
||||
|
||||
interface Dependencies {
|
||||
attemptInstallByInfo: AttemptInstallByInfo;
|
||||
lensProtocolRouterRenderer: LensProtocolRouterRenderer;
|
||||
navigateToCatalog: NavigateToCatalog;
|
||||
navigateToAddCluster: () => void;
|
||||
navigateToExtensions: () => void;
|
||||
navigateToEntitySettings: NavigateToEntitySettings;
|
||||
navigateToClusterView: NavigateToClusterView;
|
||||
navigateToPreferences: (tabId: string) => void;
|
||||
entityRegistry: CatalogEntityRegistry;
|
||||
getClusterById: GetClusterById;
|
||||
showShortInfoNotification: ShowNotification;
|
||||
}
|
||||
|
||||
export const bindProtocolAddRouteHandlers = ({
|
||||
attemptInstallByInfo,
|
||||
lensProtocolRouterRenderer,
|
||||
navigateToCatalog,
|
||||
navigateToAddCluster,
|
||||
navigateToExtensions,
|
||||
navigateToEntitySettings,
|
||||
navigateToClusterView,
|
||||
navigateToPreferences,
|
||||
entityRegistry,
|
||||
getClusterById,
|
||||
showShortInfoNotification,
|
||||
}: Dependencies) => () => {
|
||||
lensProtocolRouterRenderer
|
||||
.addInternalHandler("/preferences", ({ search: { highlight: tabId }}) => {
|
||||
if (tabId) {
|
||||
navigateToPreferences(tabId);
|
||||
}
|
||||
})
|
||||
.addInternalHandler("/", ({ tail }) => {
|
||||
if (tail) {
|
||||
showShortInfoNotification(
|
||||
<p>
|
||||
{"Unknown Action for "}
|
||||
<code>
|
||||
lens://app/
|
||||
{tail}
|
||||
</code>
|
||||
. Are you on the latest version?
|
||||
</p>,
|
||||
);
|
||||
}
|
||||
|
||||
navigateToCatalog();
|
||||
})
|
||||
.addInternalHandler("/landing", () => {
|
||||
navigateToCatalog();
|
||||
})
|
||||
.addInternalHandler("/landing/view/:group/:kind", ({ pathname: { group, kind }}) => {
|
||||
navigateToCatalog({ group, kind });
|
||||
})
|
||||
.addInternalHandler("/cluster", () => {
|
||||
navigateToAddCluster();
|
||||
})
|
||||
.addInternalHandler("/entity/:entityId/settings", ({ pathname: { entityId }}) => {
|
||||
assert(entityId);
|
||||
const entity = entityRegistry.getById(entityId);
|
||||
|
||||
if (entity) {
|
||||
navigateToEntitySettings(entityId);
|
||||
} else {
|
||||
showShortInfoNotification(
|
||||
<p>
|
||||
{"Unknown catalog entity "}
|
||||
<code>{entityId}</code>
|
||||
.
|
||||
</p>,
|
||||
);
|
||||
}
|
||||
})
|
||||
// Handlers below are deprecated and only kept for backward compact purposes
|
||||
.addInternalHandler("/cluster/:clusterId", ({ pathname: { clusterId }}) => {
|
||||
assert(clusterId);
|
||||
const cluster = getClusterById(clusterId);
|
||||
|
||||
if (cluster) {
|
||||
navigateToClusterView(clusterId);
|
||||
} else {
|
||||
showShortInfoNotification(
|
||||
<p>
|
||||
{"Unknown catalog entity "}
|
||||
<code>{clusterId}</code>
|
||||
.
|
||||
</p>,
|
||||
);
|
||||
}
|
||||
})
|
||||
.addInternalHandler("/cluster/:clusterId/settings", ({ pathname: { clusterId }}) => {
|
||||
assert(clusterId);
|
||||
const cluster = getClusterById(clusterId);
|
||||
|
||||
if (cluster) {
|
||||
navigateToEntitySettings(clusterId);
|
||||
} else {
|
||||
showShortInfoNotification(
|
||||
<p>
|
||||
{"Unknown catalog entity "}
|
||||
<code>{clusterId}</code>
|
||||
.
|
||||
</p>,
|
||||
);
|
||||
}
|
||||
})
|
||||
.addInternalHandler("/extensions", () => {
|
||||
navigateToExtensions();
|
||||
})
|
||||
.addInternalHandler(`/extensions/install${LensProtocolRouter.ExtensionUrlSchema}`, ({ pathname, search: { version }}) => {
|
||||
const name = [
|
||||
pathname[EXTENSION_PUBLISHER_MATCH],
|
||||
pathname[EXTENSION_NAME_MATCH],
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join("/");
|
||||
|
||||
navigateToExtensions();
|
||||
attemptInstallByInfo({ name, version, requireConfirmation: true });
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export { LensProtocolRouterRenderer } from "./lens-protocol-router-renderer/lens-protocol-router-renderer";
|
||||
export { bindProtocolAddRouteHandlers } from "./bind-protocol-add-route-handlers/bind-protocol-add-route-handlers";
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
|
||||
import { LensProtocolRouterRenderer } from "./lens-protocol-router-renderer";
|
||||
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import showErrorNotificationInjectable from "../../components/notifications/show-error-notification.injectable";
|
||||
import showShortInfoNotificationInjectable from "../../components/notifications/show-short-info.injectable";
|
||||
|
||||
const lensProtocolRouterRendererInjectable = getInjectable({
|
||||
id: "lens-protocol-router-renderer",
|
||||
|
||||
instantiate: (di) => new LensProtocolRouterRenderer({
|
||||
extensionLoader: di.inject(extensionLoaderInjectable),
|
||||
extensionsStore: di.inject(extensionsStoreInjectable),
|
||||
logger: di.inject(loggerInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||
showShortInfoNotification: di.inject(showShortInfoNotificationInjectable),
|
||||
}),
|
||||
});
|
||||
|
||||
export default lensProtocolRouterRendererInjectable;
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { ipcRenderer } from "electron";
|
||||
import * as proto from "../../../common/protocol-handler";
|
||||
import Url from "url-parse";
|
||||
import type { LensProtocolRouterDependencies } from "../../../common/protocol-handler";
|
||||
import { foldAttemptResults, ProtocolHandlerInvalid, RouteAttempt } from "../../../common/protocol-handler";
|
||||
import type { ShowNotification } from "../../components/notifications";
|
||||
|
||||
interface Dependencies extends LensProtocolRouterDependencies {
|
||||
showShortInfoNotification: ShowNotification;
|
||||
showErrorNotification: ShowNotification;
|
||||
}
|
||||
|
||||
export class LensProtocolRouterRenderer extends proto.LensProtocolRouter {
|
||||
constructor(protected readonly dependencies: Dependencies) {
|
||||
super(dependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is needed to be called early on in the renderers lifetime.
|
||||
*/
|
||||
public init(): void {
|
||||
ipcRenderer.on(proto.ProtocolHandlerInternal, (event, rawUrl: string, mainAttemptResult: RouteAttempt) => {
|
||||
const rendererAttempt = this._routeToInternal(new Url(rawUrl, true));
|
||||
|
||||
if (foldAttemptResults(mainAttemptResult, rendererAttempt) === RouteAttempt.MISSING) {
|
||||
this.dependencies.showShortInfoNotification((
|
||||
<p>
|
||||
{"Unknown action "}
|
||||
<code>{rawUrl}</code>
|
||||
{". Are you on the latest version?"}
|
||||
</p>
|
||||
));
|
||||
}
|
||||
});
|
||||
ipcRenderer.on(proto.ProtocolHandlerExtension, async (event, rawUrl: string, mainAttemptResult: RouteAttempt) => {
|
||||
const rendererAttempt = await this._routeToExtension(new Url(rawUrl, true));
|
||||
|
||||
switch (foldAttemptResults(mainAttemptResult, rendererAttempt)) {
|
||||
case RouteAttempt.MISSING:
|
||||
this.dependencies.showShortInfoNotification((
|
||||
<p>
|
||||
{"Unknown action "}
|
||||
<code>{rawUrl}</code>
|
||||
{". Are you on the latest version of the extension?"}
|
||||
</p>
|
||||
));
|
||||
break;
|
||||
case RouteAttempt.MISSING_EXTENSION:
|
||||
this.dependencies.showShortInfoNotification((
|
||||
<p>
|
||||
{"Missing extension for action "}
|
||||
<code>{rawUrl}</code>
|
||||
{". Not able to find extension in our known list. Try installing it manually."}
|
||||
</p>
|
||||
));
|
||||
break;
|
||||
}
|
||||
});
|
||||
ipcRenderer.on(ProtocolHandlerInvalid, (event, error: string, rawUrl: string) => {
|
||||
this.dependencies.showErrorNotification((
|
||||
<>
|
||||
<p>
|
||||
{"Failed to route "}
|
||||
<code>{rawUrl}</code>
|
||||
.
|
||||
</p>
|
||||
<p>
|
||||
<b>Error:</b>
|
||||
{" "}
|
||||
{error}
|
||||
</p>
|
||||
</>
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user