mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* dbeaver/pro#6744 refactor: migration to `@wroud/di` * tests: enable settings tests * chore: update syntax * fix: dynamic theme detection * fix: skip not stable test * fix: skip whole test * fix: make theme optional * fix: page reload * tests: skip unstable test * fix: remove optional * fix: load system theme * fix: prevent the system theme from always loading despite not being selected --------- Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2024 DBeaver Corp and others
|
|
*
|
|
* Licensed under the Apache License, Version 2.0.
|
|
* you may not use this file except in compliance with the License.
|
|
*/
|
|
import { computed, makeObservable, observable } from 'mobx';
|
|
|
|
import { injectable } from '@cloudbeaver/core-di';
|
|
import { type IVersion, VersionResource, VersionService } from '@cloudbeaver/core-version';
|
|
|
|
interface IInstructionProps {
|
|
version: IVersion;
|
|
link: string | null;
|
|
containerId?: string;
|
|
className?: string;
|
|
}
|
|
|
|
export type InstructionComponent = React.FunctionComponent<IInstructionProps>;
|
|
|
|
@injectable(() => [VersionService, VersionResource])
|
|
export class VersionUpdateService {
|
|
generalInstructionsGetter: (() => React.FC) | null = null;
|
|
versionInstructionGetter: (() => InstructionComponent) | null;
|
|
instructionLink: string | null;
|
|
|
|
get newVersionAvailable() {
|
|
if (!this.versionService.current || !this.versionResource.latest) {
|
|
return false;
|
|
}
|
|
|
|
return this.versionService.compareVersions(this.versionResource.latest.number, this.versionService.current) === 1;
|
|
}
|
|
|
|
constructor(
|
|
private readonly versionService: VersionService,
|
|
private readonly versionResource: VersionResource,
|
|
) {
|
|
this.versionInstructionGetter = null;
|
|
this.instructionLink = null;
|
|
|
|
makeObservable(this, {
|
|
newVersionAvailable: computed,
|
|
instructionLink: observable.ref,
|
|
});
|
|
}
|
|
|
|
registerInstructionLink(link: string): void {
|
|
this.instructionLink = link;
|
|
}
|
|
|
|
registerVersionInstruction(componentGetter: () => InstructionComponent): void {
|
|
this.versionInstructionGetter = componentGetter;
|
|
}
|
|
|
|
registerGeneralInstruction(componentGetter: (() => React.FC) | null): void {
|
|
this.generalInstructionsGetter = componentGetter;
|
|
}
|
|
}
|