mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
lint
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
7cab54e6de
commit
5cae38406a
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { makeObservable, observable } from "mobx";
|
import { makeObservable, observable } from "mobx";
|
||||||
|
|
||||||
export type AutoUpdateStateName = "checking" | "available" | "not-available" | "done" | "downloading" | "download-failed" | "download-succeeded" | "idle";
|
export type AutoUpdateStateName = "checking" | "available" | "not-available" | "done" | "downloading" | "download-failed" | "download-succeeded" | "idle";
|
||||||
|
|
||||||
let timerId: NodeJS.Timeout;
|
let timerId: NodeJS.Timeout;
|
||||||
@ -19,7 +19,7 @@ export class AutoUpdateState {
|
|||||||
this._state = state;
|
this._state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() : AutoUpdateStateName {
|
get name(): AutoUpdateStateName {
|
||||||
return this._state;
|
return this._state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ export class AutoUpdateState {
|
|||||||
this.triggerIdle();
|
this.triggerIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
get version() : string | undefined {
|
get version(): string | undefined {
|
||||||
return this._version;
|
return this._version;
|
||||||
}
|
}
|
||||||
|
|
||||||
set version(version: string | undefined ) {
|
set version(version: string | undefined) {
|
||||||
this._version = version;
|
this._version = version;
|
||||||
|
|
||||||
this.triggerIdle();
|
this.triggerIdle();
|
||||||
@ -42,18 +42,18 @@ export class AutoUpdateState {
|
|||||||
private triggerIdle(): void {
|
private triggerIdle(): void {
|
||||||
clearTimeout(timerId);
|
clearTimeout(timerId);
|
||||||
|
|
||||||
switch(this.name) {
|
switch (this.name) {
|
||||||
case "checking":
|
case "checking":
|
||||||
case "available":
|
case "available":
|
||||||
case "downloading":
|
case "downloading":
|
||||||
case "idle":
|
case "idle":
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "done":
|
case "done":
|
||||||
case "not-available":
|
case "not-available":
|
||||||
case "download-failed":
|
case "download-failed":
|
||||||
case "download-succeeded":
|
case "download-succeeded":
|
||||||
timerId = setTimeout(() => this.name = "idle", 5000);
|
timerId = setTimeout(() => this.name = "idle", 5000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,5 +63,5 @@ const AutoUpdateStateInjectable = getInjectable({
|
|||||||
id: "auto-update-state",
|
id: "auto-update-state",
|
||||||
instantiate: () => new AutoUpdateState("idle"),
|
instantiate: () => new AutoUpdateState("idle"),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default AutoUpdateStateInjectable;
|
export default AutoUpdateStateInjectable;
|
||||||
|
|||||||
@ -8,7 +8,8 @@ import React from "react";
|
|||||||
import AutoUpdateStateInjectable from "../../../common/auto-update/auto-update-state.injectable";
|
import AutoUpdateStateInjectable from "../../../common/auto-update/auto-update-state.injectable";
|
||||||
import type { AutoUpdateState } from "../../../common/auto-update/auto-update-state.injectable";
|
import type { AutoUpdateState } from "../../../common/auto-update/auto-update-state.injectable";
|
||||||
import { Spinner } from "../spinner";
|
import { Spinner } from "../spinner";
|
||||||
import progressOfUpdateDownloadInjectable, { ProgressOfDownload } from "../../../common/application-update/progress-of-update-download/progress-of-update-download.injectable";
|
import progressOfUpdateDownloadInjectable from "../../../common/application-update/progress-of-update-download/progress-of-update-download.injectable";
|
||||||
|
import type { ProgressOfDownload } from "../../../common/application-update/progress-of-update-download/progress-of-update-download.injectable";
|
||||||
import type { SyncBox } from "../../../common/utils/sync-box/sync-box-injection-token";
|
import type { SyncBox } from "../../../common/utils/sync-box/sync-box-injection-token";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
@ -16,14 +17,24 @@ interface Dependencies {
|
|||||||
progressOfUpdateDownload: SyncBox<ProgressOfDownload>;
|
progressOfUpdateDownload: SyncBox<ProgressOfDownload>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const checking = () => <><Spinner/><div>{"Checking for updates..."}</div></>;
|
const checking = () => (
|
||||||
|
<>
|
||||||
|
<Spinner/>
|
||||||
|
<div>{"Checking for updates..."}</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
const available = () => <div>{"Update is available"}</div>;
|
const available = () => <div>{"Update is available"}</div>;
|
||||||
const notAvailable = () => <div>{"No new updates available"}</div>;
|
const notAvailable = () => <div>{"No new updates available"}</div>;
|
||||||
const downloading = (state: AutoUpdateState, percentDone: number) => {
|
const downloading = (state: AutoUpdateState, percentDone: number) => {
|
||||||
const {version } = state;
|
const { version } = state;
|
||||||
|
|
||||||
if ( percentDone === 0 ) {
|
if ( percentDone === 0 ) {
|
||||||
return <><div>{`Download for version ${version} started `}</div><Spinner/></>;
|
return (
|
||||||
|
<>
|
||||||
|
<div>{`Download for version ${version} started `}</div>
|
||||||
|
<Spinner/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( percentDone < 100 ) {
|
if ( percentDone < 100 ) {
|
||||||
@ -52,9 +63,11 @@ export const NonInjectedAutoUpdateComponent = observer(({ state, progressOfUpdat
|
|||||||
case "not-available":
|
case "not-available":
|
||||||
return notAvailable();
|
return notAvailable();
|
||||||
|
|
||||||
case "downloading":
|
case "downloading": {
|
||||||
const roundedPercentage = Math.round(progressOfUpdateDownload.value.get().percentage);
|
const roundedPercentage = Math.round(progressOfUpdateDownload.value.get().percentage);
|
||||||
|
|
||||||
return downloading(state, roundedPercentage);
|
return downloading(state, roundedPercentage);
|
||||||
|
}
|
||||||
|
|
||||||
case "done":
|
case "done":
|
||||||
return done();
|
return done();
|
||||||
@ -62,10 +75,10 @@ export const NonInjectedAutoUpdateComponent = observer(({ state, progressOfUpdat
|
|||||||
case "download-failed":
|
case "download-failed":
|
||||||
return downloadFailed(state.version);
|
return downloadFailed(state.version);
|
||||||
|
|
||||||
case "download-succeeded":
|
case "download-succeeded":
|
||||||
return downloadSucceeded(state.version);
|
return downloadSucceeded(state.version);
|
||||||
|
|
||||||
case "idle":
|
case "idle":
|
||||||
return idle();
|
return idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user