Allow pre-release versions of Lens}
+ value={preferences.allowPrereleaseVersions}
+ onChange={v => preferences.allowPrereleaseVersions = v}
+ />
+
+ Allow upgrading Lens to pre-release versions. This means that the update checker will ask about pre release versions but won't auto upgrade to them.
+
);
diff --git a/src/renderer/components/notifications/notifications.store.ts b/src/renderer/components/notifications/notifications.store.tsx
similarity index 54%
rename from src/renderer/components/notifications/notifications.store.ts
rename to src/renderer/components/notifications/notifications.store.tsx
index 1873ae91a4..fff996e954 100644
--- a/src/renderer/components/notifications/notifications.store.ts
+++ b/src/renderer/components/notifications/notifications.store.tsx
@@ -4,6 +4,10 @@ import { autobind } from "../../utils";
import isObject from "lodash/isObject"
import uniqueId from "lodash/uniqueId";
import { JsonApiErrorParsed } from "../../api/json-api";
+import logger from "../../../main/logger";
+import { ipcRenderer } from "electron";
+import { IpcChannel, NotificationChannelAdd } from "../../../common/ipc";
+import { Button, ButtonProps } from "../button";
export type IMessageId = string | number;
export type IMessage = React.ReactNode | React.ReactNode[] | JsonApiErrorParsed;
@@ -19,6 +23,39 @@ export interface INotification {
message: IMessage;
status?: NotificationStatus;
timeout?: number; // auto-hiding timeout in milliseconds, 0 = no hide
+ onClose?(): void; // additonal logic on when the notification times out or is closed by the "x"
+}
+
+export interface MainNotification {
+ title: string;
+ body: string;
+ buttons?: ({
+ backchannel: IpcChannel;
+ } & ButtonProps)[];
+ status: NotificationStatus;
+ timeout?: number;
+ closeChannel?: IpcChannel;
+}
+
+function renderButtons(id: IpcChannel, buttons?: MainNotification["buttons"]): React.ReactNode {
+ if (!buttons) {
+ return null;
+ }
+
+ return (
+ <>
+
+
+ {buttons.map(({ backchannel, ...props}) => (
+
+ >
+ )
}
@autobind()
@@ -27,6 +64,29 @@ export class NotificationsStore {
protected autoHideTimers = new Map();
+ registerIpcListener(): void {
+ logger.info(`[NOTIFICATION-STORE] start to listen for notifications requests from main`);
+ ipcRenderer.on(NotificationChannelAdd, (event, model: MainNotification) => {
+ console.log(model);
+ const id = uniqueId("notification_");
+ this.add({
+ message: (
+ <>
+ {model.title}
+ {model.body}
+ {renderButtons(id, model.buttons)}
+ >
+ ),
+ id,
+ status: model.status,
+ timeout: model.timeout,
+ onClose: () => {
+ model.closeChannel && ipcRenderer.send(model.closeChannel);
+ }
+ });
+ })
+ }
+
addAutoHideTimer(notification: INotification) {
this.removeAutoHideTimer(notification);
const { id, timeout } = notification;
diff --git a/src/renderer/components/notifications/notifications.tsx b/src/renderer/components/notifications/notifications.tsx
index 35c741505c..6ca687fee4 100644
--- a/src/renderer/components/notifications/notifications.tsx
+++ b/src/renderer/components/notifications/notifications.tsx
@@ -84,7 +84,10 @@ export class Notifications extends React.Component {
remove(notification))}
+ onClick={prevDefault(() => {
+ remove(notification);
+ notification.onClose?.();
+ })}
/>
diff --git a/src/renderer/theme.store.ts b/src/renderer/theme.store.ts
index 5245d2a728..992c280f6c 100644
--- a/src/renderer/theme.store.ts
+++ b/src/renderer/theme.store.ts
@@ -29,12 +29,8 @@ export class ThemeStore {
{ id: "kontena-light", type: ThemeType.LIGHT },
];
- @computed get activeThemeId() {
- return userStore.preferences.colorTheme;
- }
-
@computed get activeTheme(): Theme {
- const activeTheme = this.themes.find(theme => theme.id === this.activeThemeId) || this.themes[0];
+ const activeTheme = this.themes.find(theme => theme.id === userStore.preferences.colorTheme) || this.themes[0];
return {
colors: {},
...activeTheme,
@@ -43,9 +39,9 @@ export class ThemeStore {
constructor() {
// auto-apply active theme
- reaction(() => this.activeThemeId, async themeId => {
+ reaction(() => this.activeTheme, async ({ id }) => {
try {
- await this.loadTheme(themeId);
+ await this.loadTheme(id);
this.applyTheme();
} catch (err) {
userStore.resetTheme();
diff --git a/webpack.renderer.ts b/webpack.renderer.ts
index 74978bd152..6112d1af36 100755
--- a/webpack.renderer.ts
+++ b/webpack.renderer.ts
@@ -159,4 +159,4 @@ export default function (): webpack.Configuration {
}),
],
}
-}
\ No newline at end of file
+}
diff --git a/yarn.lock b/yarn.lock
index 300efc58ce..f9b04e5896 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1723,6 +1723,11 @@
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-3.1.47.tgz#36e549dd3f1322742a3a738e7c113ebe48221860"
integrity sha512-eI6gvpcGHLk3dAuHYnRCAjX+41gMv1nz/VP55wAe5HtmAKDOoPSfr3f6vkMc08ov1S0NsjvUBxDtHHxqQY1LGA==
+"@types/dateformat@^3.0.1":
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/@types/dateformat/-/dateformat-3.0.1.tgz#98d747a2e5e9a56070c6bf14e27bff56204e34cc"
+ integrity sha512-KlPPdikagvL6ELjWsljbyDIPzNCeliYkqRpI+zea99vBBbCIA5JNshZAwQKTON139c87y9qvTFVgkFd14rtS4g==
+
"@types/debug@^4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
@@ -1966,6 +1971,13 @@
dependencies:
"@types/node" "*"
+"@types/node-notifier@^8.0.0":
+ version "8.0.0"
+ resolved "https://registry.yarnpkg.com/@types/node-notifier/-/node-notifier-8.0.0.tgz#51100d67155ed1500a8aaa633987109f59a0637d"
+ integrity sha512-CseIDQOC/I+yvj/4ItpG4ATcwooQlGPDDJweII8nspjjZg4ZBuvkyHg9P81QkElgU9FpYlb5A27BRggD3idTCQ==
+ dependencies:
+ "@types/node" "*"
+
"@types/node@*":
version "14.0.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.11.tgz#61d4886e2424da73b7b25547f59fdcb534c165a3"
@@ -4299,6 +4311,11 @@ date-fns@^2.0.1, date-fns@^2.14.0:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
integrity sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw==
+dateformat@^4.3.1:
+ version "4.3.1"
+ resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.3.1.tgz#e010ca5915f0c7d47e5b4e4287dd5ecb41125a96"
+ integrity sha512-xhq1wI5BQ0TMJDvio0BLP8lNeYlhAvmh/7H52H9n6kfzqSmRpIhH5KEIjJ7onFEAh5CQVrAP2MAG8wZ6j0BKzQ==
+
debounce-fn@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"
@@ -6760,7 +6777,7 @@ is-wsl@^1.1.0:
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=
-is-wsl@^2.1.1:
+is-wsl@^2.1.1, is-wsl@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
@@ -8419,6 +8436,18 @@ node-notifier@^7.0.0:
uuid "^7.0.3"
which "^2.0.2"
+node-notifier@^9.0.0:
+ version "9.0.0"
+ resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-9.0.0.tgz#46c5bbecbb796d4a803f646cea5bc91403f2ff38"
+ integrity sha512-SkwNwGnMMlSPrcoeH4CSo9XyWe72acAHEJGDdPdB+CyBVHsIYaTQ4U/1wk3URsyzC75xZLg2vzU2YaALlqDF1Q==
+ dependencies:
+ growly "^1.3.0"
+ is-wsl "^2.2.0"
+ semver "^7.3.2"
+ shellwords "^0.1.1"
+ uuid "^8.3.0"
+ which "^2.0.2"
+
node-pty@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.9.0.tgz#8f9bcc0d1c5b970a3184ffd533d862c7eb6590a6"
@@ -11758,6 +11787,11 @@ uuid@^8.1.0:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.1.0.tgz#6f1536eb43249f473abc6bd58ff983da1ca30d8d"
integrity sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==
+uuid@^8.3.0:
+ version "8.3.2"
+ resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
+ integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
+
v8-compile-cache@2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe"