mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add displaying @k8slens/* versions in about when not latest (#7257)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6df01ba468
commit
6ca4af8284
@ -24,6 +24,7 @@ export const applicationInformationFakeInjectable = getInjectable({
|
||||
welcomeRoute: "/welcome",
|
||||
copyright: "some-copyright-information",
|
||||
description: "some-descriptive-text",
|
||||
dependencies: {},
|
||||
}),
|
||||
|
||||
injectionToken: applicationInformationToken,
|
||||
|
||||
@ -2,22 +2,34 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { applicationInformationToken } from "@k8slens/application";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { bundledExtensionInjectionToken } from "../../../../../../common/library";
|
||||
import { object } from "../../../../../../common/utils";
|
||||
import buildSemanticVersionInjectable from "../../../../../../common/vars/build-semantic-version.injectable";
|
||||
|
||||
const aboutBundledExtensionsInjectable = getInjectable({
|
||||
id: "about-bundled-extensions",
|
||||
const specificVersionsInjectable = getInjectable({
|
||||
id: "specific-versions",
|
||||
instantiate: (di) => {
|
||||
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
||||
const bundledExtensions = di.injectMany(bundledExtensionInjectionToken);
|
||||
const applicationInformation = di.inject(applicationInformationToken);
|
||||
|
||||
if (buildSemanticVersion.get().prerelease[0] === "latest") {
|
||||
return [];
|
||||
}
|
||||
|
||||
return bundledExtensions.map(ext => `${ext.manifest.name}: ${ext.manifest.version}`);
|
||||
const corePackageVersions = object.entries(applicationInformation.dependencies)
|
||||
.filter(([name]) => name.startsWith("@k8slens/"))
|
||||
.map(([name, version]) => `${name}: ${version}`);
|
||||
const bundledExtensionVersions = bundledExtensions
|
||||
.map(ext => `${ext.manifest.name}: ${ext.manifest.version}`);
|
||||
|
||||
return [
|
||||
...corePackageVersions,
|
||||
...bundledExtensionVersions,
|
||||
];
|
||||
},
|
||||
});
|
||||
|
||||
export default aboutBundledExtensionsInjectable;
|
||||
export default specificVersionsInjectable;
|
||||
|
||||
@ -10,7 +10,7 @@ import productNameInjectable from "../../../../../../common/vars/product-name.in
|
||||
import buildVersionInjectable from "../../../../../../main/vars/build-version/build-version.injectable";
|
||||
import extensionApiVersionInjectable from "../../../../../../common/vars/extension-api-version.injectable";
|
||||
import applicationCopyrightInjectable from "../../../../../../common/vars/application-copyright.injectable";
|
||||
import aboutBundledExtensionsInjectable from "./about-bundled-extensions.injectable";
|
||||
import specificVersionsInjectable from "./about-bundled-extensions.injectable";
|
||||
|
||||
const showAboutInjectable = getInjectable({
|
||||
id: "show-about",
|
||||
@ -23,7 +23,7 @@ const showAboutInjectable = getInjectable({
|
||||
const appName = di.inject(appNameInjectable);
|
||||
const productName = di.inject(productNameInjectable);
|
||||
const applicationCopyright = di.inject(applicationCopyrightInjectable);
|
||||
const aboutBundledExtensions = di.inject(aboutBundledExtensionsInjectable);
|
||||
const specificVersions = di.inject(specificVersionsInjectable);
|
||||
|
||||
return () => {
|
||||
const appInfo = [
|
||||
@ -32,14 +32,26 @@ const showAboutInjectable = getInjectable({
|
||||
`Electron: ${process.versions.electron}`,
|
||||
`Chrome: ${process.versions.chrome}`,
|
||||
`Node: ${process.versions.node}`,
|
||||
...aboutBundledExtensions,
|
||||
applicationCopyright,
|
||||
];
|
||||
|
||||
if (specificVersions.length > 0) {
|
||||
appInfo.push(
|
||||
"",
|
||||
"",
|
||||
...specificVersions,
|
||||
);
|
||||
}
|
||||
|
||||
showMessagePopup(
|
||||
`${isWindows ? " ".repeat(2) : ""}${appName}`,
|
||||
productName,
|
||||
appInfo.join("\r\n"),
|
||||
{
|
||||
textWidth: specificVersions.length > 0
|
||||
? 300
|
||||
: undefined,
|
||||
},
|
||||
);
|
||||
};
|
||||
},
|
||||
|
||||
@ -5,7 +5,11 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import electronDialogInjectable from "./electron-dialog.injectable";
|
||||
|
||||
export type ShowMessagePopup = (title: string, message: string, detail: string) => void;
|
||||
export interface ShowMessagePopupOptions {
|
||||
textWidth?: number;
|
||||
}
|
||||
|
||||
export type ShowMessagePopup = (title: string, message: string, detail: string, options?: ShowMessagePopupOptions) => void;
|
||||
|
||||
const showMessagePopupInjectable = getInjectable({
|
||||
id: "show-message-popup",
|
||||
@ -13,13 +17,14 @@ const showMessagePopupInjectable = getInjectable({
|
||||
instantiate: (di): ShowMessagePopup => {
|
||||
const dialog = di.inject(electronDialogInjectable);
|
||||
|
||||
return async (title, message, detail) => {
|
||||
return async (title, message, detail, options = {}) => {
|
||||
await dialog.showMessageBox({
|
||||
title,
|
||||
message,
|
||||
detail,
|
||||
type: "info",
|
||||
buttons: ["Close"],
|
||||
...options,
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
@ -8,12 +8,9 @@ import { applicationInformationToken } from "@k8slens/application";
|
||||
|
||||
const applicationInformationInjectable = getInjectable({
|
||||
id: "application-information",
|
||||
injectionToken: applicationInformationToken,
|
||||
|
||||
instantiate: () => {
|
||||
const {
|
||||
version,
|
||||
|
||||
config: {
|
||||
bundledHelmVersion,
|
||||
bundledKubectlVersion,
|
||||
@ -22,12 +19,12 @@ const applicationInformationInjectable = getInjectable({
|
||||
sentryDsn,
|
||||
welcomeRoute,
|
||||
},
|
||||
|
||||
productName,
|
||||
build,
|
||||
copyright,
|
||||
description,
|
||||
name,
|
||||
dependencies,
|
||||
} = packageJson;
|
||||
|
||||
return {
|
||||
@ -43,9 +40,11 @@ const applicationInformationInjectable = getInjectable({
|
||||
contentSecurityPolicy,
|
||||
welcomeRoute,
|
||||
updatingIsEnabled: (build as any)?.publish?.length > 0,
|
||||
dependencies,
|
||||
};
|
||||
},
|
||||
causesSideEffects: true,
|
||||
injectionToken: applicationInformationToken,
|
||||
});
|
||||
|
||||
export default applicationInformationInjectable;
|
||||
|
||||
@ -17,6 +17,7 @@ export type ApplicationInformation = {
|
||||
contentSecurityPolicy: string,
|
||||
welcomeRoute: string,
|
||||
updatingIsEnabled: boolean;
|
||||
dependencies: Partial<Record<string, string>>;
|
||||
}
|
||||
|
||||
export const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user