auto-update notifications on the status bar (#5361)

* auto-update notifications on the status bar

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* integrated with new and improved autoupdate code

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* lint

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* refactored to include AutoUpdateComponent in the statusBarItemsInjectable

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* refactor to use a registrator

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* fix lint, remove unused code

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* refactored for the simplified logic for injecting many instances PR

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* using the update syncBox injectables directly for status bar notifications

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* removed update broadcasting/listening, updated snapshots

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* fixing tests

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* fixed tests

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* cleanup after rebase to master

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* address review comments

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* fixed incorrect injectable id

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* address review comments

Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>

* Tweak code-style

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Jim EhrismannandJanne Savolainen authored and GitHub committed 2022-07-01 14:09:00 +03:00
1 parent 165bf57380
commit 3480b517c1
47 files changed
+1999 -792

No files matched your search

@@ -1,23 +0,0 @@
/**
* 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 type { ApplicationUpdateStatusChannelMessage } from "../../../common/application-update/application-update-status-channel.injectable";
import { messageToChannelInjectionToken } from "../../../common/utils/channel/message-to-channel-injection-token";
import applicationUpdateStatusChannelInjectable from "../../../common/application-update/application-update-status-channel.injectable";
const broadcastChangeInUpdatingStatusInjectable = getInjectable({
id: "broadcast-change-in-updating-status",
instantiate: (di) => {
const messageToChannel = di.inject(messageToChannelInjectionToken);
const applicationUpdateStatusChannel = di.inject(applicationUpdateStatusChannelInjectable);
return (data: ApplicationUpdateStatusChannelMessage) => {
messageToChannel(applicationUpdateStatusChannel, data);
};
},
});
export default broadcastChangeInUpdatingStatusInjectable;
@@ -8,7 +8,6 @@ import updatesAreBeingDiscoveredInjectable from "../../../common/application-upd
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
import { runInAction } from "mobx";
import downloadUpdateInjectable from "../download-update/download-update.injectable";
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
@@ -20,7 +19,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
instantiate: (di) => {
const downloadUpdate = di.inject(downloadUpdateInjectable);
const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable);
const broadcastChangeInUpdatingStatus = di.inject(broadcastChangeInUpdatingStatusInjectable);
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
@@ -34,8 +32,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
params: { currentDateTime: getCurrentDateTime(), source },
});
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
runInAction(() => {
checkingForUpdatesState.set(true);
});
@@ -43,8 +39,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
const result = await checkForUpdatesStartingFromChannel(selectedUpdateChannel.value.get());
if (!result.updateWasDiscovered) {
broadcastChangeInUpdatingStatus({ eventId: "no-updates-available" });
runInAction(() => {
discoveredVersionState.set(null);
checkingForUpdatesState.set(false);
@@ -61,11 +55,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
params: { version, currentDateTime: getCurrentDateTime() },
});
broadcastChangeInUpdatingStatus({
eventId: "download-for-update-started",
version,
});
runInAction(() => {
discoveredVersionState.set({
version,
@@ -75,15 +64,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
checkingForUpdatesState.set(false);
});
withOrphanPromise(async () => {
const { downloadWasSuccessful } = await downloadUpdate();
if (!downloadWasSuccessful) {
broadcastChangeInUpdatingStatus({
eventId: "download-for-update-failed",
});
}
})();
withOrphanPromise(async () => await downloadUpdate())();
};
},
});
@@ -38,6 +38,7 @@ const downloadUpdateInjectable = getInjectable({
runInAction(() => {
if (!downloadWasSuccessful) {
progressOfUpdateDownload.set({ percentage: 0, failed: "Download of update failed" });
discoveredVersionState.set(null);
}