mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add sync box files allowing to restart & install
update from renderer process Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
6284e6cd9a
commit
5aa8718f90
@ -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 { MessageChannel, messageChannelInjectionToken } from "../../utils/channel/message-channel-injection-token";
|
||||
|
||||
export type RestartAndInstallUpdateChannel = MessageChannel;
|
||||
|
||||
const restartAndInstallUpdateChannel = getInjectable({
|
||||
id: "restart-and-install-update-channel",
|
||||
|
||||
instantiate: (): RestartAndInstallUpdateChannel => ({
|
||||
id: "restart-and-install-update-channel",
|
||||
}),
|
||||
|
||||
injectionToken: messageChannelInjectionToken,
|
||||
});
|
||||
|
||||
export default restartAndInstallUpdateChannel;
|
||||
@ -1,6 +1,6 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import createSyncBoxInjectable from "../utils/sync-box/create-sync-box.injectable";
|
||||
import { syncBoxInjectionToken } from "../utils/sync-box/sync-box-injection-token";
|
||||
import createSyncBoxInjectable from "../../utils/sync-box/create-sync-box.injectable";
|
||||
import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-token";
|
||||
|
||||
const updateWarningLevelInjectable = getInjectable({
|
||||
id: "update-warning-level",
|
||||
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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 restartAndInstallUpdateChannel from "../../../common/application-update/update-warning-level/restart-and-install-update-channel.injectable";
|
||||
import { messageChannelListenerInjectionToken } from "../../../common/utils/channel/message-channel-listener-injection-token";
|
||||
import quitAndInstallUpdateInjectable from "../quit-and-install-update.injectable";
|
||||
|
||||
const restartAndInstallUpdateListenerInjectable = getInjectable({
|
||||
id: "restart-and-install-update-listener",
|
||||
|
||||
instantiate: (di) => {
|
||||
const quitAndInstall = di.inject(quitAndInstallUpdateInjectable);
|
||||
const channel = di.inject(restartAndInstallUpdateChannel);
|
||||
|
||||
return {
|
||||
channel,
|
||||
handler: quitAndInstall,
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: messageChannelListenerInjectionToken,
|
||||
});
|
||||
|
||||
export default restartAndInstallUpdateListenerInjectable;
|
||||
@ -1,7 +1,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
|
||||
import { UpdateWarningLevelCalculator } from "./update-warning-level-calculator";
|
||||
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level.injectable";
|
||||
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable";
|
||||
|
||||
const setUpdateWarningLevelInjectable = getInjectable({
|
||||
id: "set-update-warning",
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import restartAndInstallUpdateChannel from "../../../common/application-update/update-warning-level/restart-and-install-update-channel.injectable";
|
||||
import messageToChannelInjectable from "../../utils/channel/message-to-channel.injectable";
|
||||
|
||||
const restartAndInstallUpdateInjectable = getInjectable({
|
||||
id: "restart-and-install-update",
|
||||
|
||||
instantiate: (di) => {
|
||||
const messageToChannel = di.inject(messageToChannelInjectable);
|
||||
const channel = di.inject(restartAndInstallUpdateChannel);
|
||||
|
||||
return () => {
|
||||
messageToChannel(channel);
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default restartAndInstallUpdateInjectable;
|
||||
@ -8,13 +8,14 @@ import styles from "./styles.module.scss";
|
||||
import type { HTMLAttributes } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Menu, MenuItem } from "../menu";
|
||||
import { cssNames, noop } from "../../utils";
|
||||
import { cssNames } from "../../utils";
|
||||
import type { IconProps } from "../icon";
|
||||
import { Icon } from "../icon";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import { observer } from "mobx-react";
|
||||
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level.injectable";
|
||||
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable";
|
||||
import { computed, IComputedValue } from "mobx";
|
||||
import restartAndInstallUpdateInjectable from "./restart-and-install-update.injectable";
|
||||
|
||||
interface UpdateButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
||||
}
|
||||
@ -74,13 +75,10 @@ export const UpdateButton = withInjectables<Dependencies, UpdateButtonProps>(Non
|
||||
getProps: (di, props) => {
|
||||
const warnignLevel = di.inject(updateWarningLevelInjectable);
|
||||
|
||||
// TODO: quit and install on update();
|
||||
const update = noop;
|
||||
|
||||
return {
|
||||
...props,
|
||||
warningLevel: computed(() => warnignLevel.value.get()),
|
||||
update,
|
||||
update: di.inject(restartAndInstallUpdateInjectable),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user