Introduce a tray item for updating application

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen committed 2022-05-20 14:07:53 +03:00
1 parent 8d3bc40aa9
commit 84ac22904d
13 files changed
+359 -2

No files matched your search

@@ -0,0 +1,35 @@
/**
* 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 { computed } from "mobx";
import { trayMenuItemInjectionToken } from "../tray/tray-menu-item/tray-menu-item-injection-token";
import updateIsAvailableInjectable from "./update-is-available.injectable";
import triggerApplicationUpdateInjectable from "./trigger-application-update.injectable";
const triggerApplicationUpdateTrayItemInjectable = getInjectable({
id: "trigger-application-update-tray-item",
instantiate: (di) => {
const updateIsAvailable = di.inject(updateIsAvailableInjectable);
const triggerApplicationUpdate = di.inject(triggerApplicationUpdateInjectable);
return {
id: "trigger-application-update",
parentId: null,
orderNumber: 50,
label: "Trigger update",
enabled: computed(() => true),
visible: computed(() => updateIsAvailable.get()),
click: () => {
triggerApplicationUpdate();
},
};
},
injectionToken: trayMenuItemInjectionToken,
});
export default triggerApplicationUpdateTrayItemInjectable;
@@ -0,0 +1,20 @@
/**
* 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 quitAndInstallUpdateInjectable from "../electron-app/features/quit-and-install-update.injectable";
const triggerApplicationUpdateInjectable = getInjectable({
id: "trigger-application-update",
instantiate: (di) => {
const quitAndInstallUpdate = di.inject(quitAndInstallUpdateInjectable);
return () => {
quitAndInstallUpdate();
};
},
});
export default triggerApplicationUpdateInjectable;
@@ -0,0 +1,13 @@
/**
* 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 { observable } from "mobx";
const updateIsAvailableState = getInjectable({
id: "update-is-available-state",
instantiate: () => observable.box<boolean>(false),
});
export default updateIsAvailableState;
@@ -0,0 +1,19 @@
/**
* 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 { computed } from "mobx";
import updateIsAvailableStateInjectable from "./update-is-available-state.injectable";
const updateIsAvailableInjectable = getInjectable({
id: "update-is-available",
instantiate: (di) => {
const updateIsAvailableState = di.inject(updateIsAvailableStateInjectable);
return computed(() => updateIsAvailableState.get());
},
});
export default updateIsAvailableInjectable;