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",
|
welcomeRoute: "/welcome",
|
||||||
copyright: "some-copyright-information",
|
copyright: "some-copyright-information",
|
||||||
description: "some-descriptive-text",
|
description: "some-descriptive-text",
|
||||||
|
dependencies: {},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
injectionToken: applicationInformationToken,
|
injectionToken: applicationInformationToken,
|
||||||
|
|||||||
@ -2,22 +2,34 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
import { applicationInformationToken } from "@k8slens/application";
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { bundledExtensionInjectionToken } from "../../../../../../common/library";
|
import { bundledExtensionInjectionToken } from "../../../../../../common/library";
|
||||||
|
import { object } from "../../../../../../common/utils";
|
||||||
import buildSemanticVersionInjectable from "../../../../../../common/vars/build-semantic-version.injectable";
|
import buildSemanticVersionInjectable from "../../../../../../common/vars/build-semantic-version.injectable";
|
||||||
|
|
||||||
const aboutBundledExtensionsInjectable = getInjectable({
|
const specificVersionsInjectable = getInjectable({
|
||||||
id: "about-bundled-extensions",
|
id: "specific-versions",
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
const buildSemanticVersion = di.inject(buildSemanticVersionInjectable);
|
||||||
const bundledExtensions = di.injectMany(bundledExtensionInjectionToken);
|
const bundledExtensions = di.injectMany(bundledExtensionInjectionToken);
|
||||||
|
const applicationInformation = di.inject(applicationInformationToken);
|
||||||
|
|
||||||
if (buildSemanticVersion.get().prerelease[0] === "latest") {
|
if (buildSemanticVersion.get().prerelease[0] === "latest") {
|
||||||
return [];
|
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 buildVersionInjectable from "../../../../../../main/vars/build-version/build-version.injectable";
|
||||||
import extensionApiVersionInjectable from "../../../../../../common/vars/extension-api-version.injectable";
|
import extensionApiVersionInjectable from "../../../../../../common/vars/extension-api-version.injectable";
|
||||||
import applicationCopyrightInjectable from "../../../../../../common/vars/application-copyright.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({
|
const showAboutInjectable = getInjectable({
|
||||||
id: "show-about",
|
id: "show-about",
|
||||||
@ -23,7 +23,7 @@ const showAboutInjectable = getInjectable({
|
|||||||
const appName = di.inject(appNameInjectable);
|
const appName = di.inject(appNameInjectable);
|
||||||
const productName = di.inject(productNameInjectable);
|
const productName = di.inject(productNameInjectable);
|
||||||
const applicationCopyright = di.inject(applicationCopyrightInjectable);
|
const applicationCopyright = di.inject(applicationCopyrightInjectable);
|
||||||
const aboutBundledExtensions = di.inject(aboutBundledExtensionsInjectable);
|
const specificVersions = di.inject(specificVersionsInjectable);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const appInfo = [
|
const appInfo = [
|
||||||
@ -32,14 +32,26 @@ const showAboutInjectable = getInjectable({
|
|||||||
`Electron: ${process.versions.electron}`,
|
`Electron: ${process.versions.electron}`,
|
||||||
`Chrome: ${process.versions.chrome}`,
|
`Chrome: ${process.versions.chrome}`,
|
||||||
`Node: ${process.versions.node}`,
|
`Node: ${process.versions.node}`,
|
||||||
...aboutBundledExtensions,
|
|
||||||
applicationCopyright,
|
applicationCopyright,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (specificVersions.length > 0) {
|
||||||
|
appInfo.push(
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
...specificVersions,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
showMessagePopup(
|
showMessagePopup(
|
||||||
`${isWindows ? " ".repeat(2) : ""}${appName}`,
|
`${isWindows ? " ".repeat(2) : ""}${appName}`,
|
||||||
productName,
|
productName,
|
||||||
appInfo.join("\r\n"),
|
appInfo.join("\r\n"),
|
||||||
|
{
|
||||||
|
textWidth: specificVersions.length > 0
|
||||||
|
? 300
|
||||||
|
: undefined,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,11 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import electronDialogInjectable from "./electron-dialog.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({
|
const showMessagePopupInjectable = getInjectable({
|
||||||
id: "show-message-popup",
|
id: "show-message-popup",
|
||||||
@ -13,13 +17,14 @@ const showMessagePopupInjectable = getInjectable({
|
|||||||
instantiate: (di): ShowMessagePopup => {
|
instantiate: (di): ShowMessagePopup => {
|
||||||
const dialog = di.inject(electronDialogInjectable);
|
const dialog = di.inject(electronDialogInjectable);
|
||||||
|
|
||||||
return async (title, message, detail) => {
|
return async (title, message, detail, options = {}) => {
|
||||||
await dialog.showMessageBox({
|
await dialog.showMessageBox({
|
||||||
title,
|
title,
|
||||||
message,
|
message,
|
||||||
detail,
|
detail,
|
||||||
type: "info",
|
type: "info",
|
||||||
buttons: ["Close"],
|
buttons: ["Close"],
|
||||||
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,12 +8,9 @@ import { applicationInformationToken } from "@k8slens/application";
|
|||||||
|
|
||||||
const applicationInformationInjectable = getInjectable({
|
const applicationInformationInjectable = getInjectable({
|
||||||
id: "application-information",
|
id: "application-information",
|
||||||
injectionToken: applicationInformationToken,
|
|
||||||
|
|
||||||
instantiate: () => {
|
instantiate: () => {
|
||||||
const {
|
const {
|
||||||
version,
|
version,
|
||||||
|
|
||||||
config: {
|
config: {
|
||||||
bundledHelmVersion,
|
bundledHelmVersion,
|
||||||
bundledKubectlVersion,
|
bundledKubectlVersion,
|
||||||
@ -22,12 +19,12 @@ const applicationInformationInjectable = getInjectable({
|
|||||||
sentryDsn,
|
sentryDsn,
|
||||||
welcomeRoute,
|
welcomeRoute,
|
||||||
},
|
},
|
||||||
|
|
||||||
productName,
|
productName,
|
||||||
build,
|
build,
|
||||||
copyright,
|
copyright,
|
||||||
description,
|
description,
|
||||||
name,
|
name,
|
||||||
|
dependencies,
|
||||||
} = packageJson;
|
} = packageJson;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -43,9 +40,11 @@ const applicationInformationInjectable = getInjectable({
|
|||||||
contentSecurityPolicy,
|
contentSecurityPolicy,
|
||||||
welcomeRoute,
|
welcomeRoute,
|
||||||
updatingIsEnabled: (build as any)?.publish?.length > 0,
|
updatingIsEnabled: (build as any)?.publish?.length > 0,
|
||||||
|
dependencies,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
causesSideEffects: true,
|
causesSideEffects: true,
|
||||||
|
injectionToken: applicationInformationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default applicationInformationInjectable;
|
export default applicationInformationInjectable;
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export type ApplicationInformation = {
|
|||||||
contentSecurityPolicy: string,
|
contentSecurityPolicy: string,
|
||||||
welcomeRoute: string,
|
welcomeRoute: string,
|
||||||
updatingIsEnabled: boolean;
|
updatingIsEnabled: boolean;
|
||||||
|
dependencies: Partial<Record<string, string>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
export const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user