mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: apply theme on the fly in preferences, theme-store refactoring
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
6fd9b7cf76
commit
407c4fb4d0
15 files changed
+322
-315
No files matched your search
+10
-14
@@ -1,3 +1,4 @@
|
||||
import type { ThemeId } from "../renderer/theme.store";
|
||||
import semver from "semver"
|
||||
import { action, observable, reaction, toJS } from "mobx";
|
||||
import { BaseStore } from "./base-store";
|
||||
@@ -5,20 +6,8 @@ import migrations from "../migrations/user-store"
|
||||
import { getAppVersion } from "./utils/app-version";
|
||||
import { tracker } from "./tracker";
|
||||
|
||||
// todo: merge with config.store.ts + theme.store.ts
|
||||
// fixme: detect new contexts from .kube/config since last open
|
||||
|
||||
export enum ThemeType {
|
||||
LIGHT = "light",
|
||||
DARK = "dark",
|
||||
}
|
||||
|
||||
export interface Theme {
|
||||
name: string;
|
||||
type: ThemeType;
|
||||
colors?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface UserStoreModel {
|
||||
lastSeenAppVersion: string;
|
||||
seenContexts: string[];
|
||||
@@ -27,13 +16,15 @@ export interface UserStoreModel {
|
||||
|
||||
export interface UserPreferences {
|
||||
httpsProxy?: string;
|
||||
colorTheme?: string | "dark" | "light";
|
||||
colorTheme?: string;
|
||||
allowUntrustedCAs?: boolean;
|
||||
allowTelemetry?: boolean;
|
||||
downloadMirror?: string | "default";
|
||||
}
|
||||
|
||||
export class UserStore extends BaseStore<UserStoreModel> {
|
||||
static readonly defaultTheme: ThemeId = "kontena-dark"
|
||||
|
||||
private constructor() {
|
||||
super({
|
||||
// configName: "lens-user-store", // todo: migrate from default filename
|
||||
@@ -53,7 +44,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
@observable preferences: UserPreferences = {
|
||||
allowTelemetry: true,
|
||||
allowUntrustedCAs: false,
|
||||
colorTheme: "dark",
|
||||
colorTheme: UserStore.defaultTheme,
|
||||
downloadMirror: "default",
|
||||
httpsProxy: "",
|
||||
};
|
||||
@@ -62,6 +53,11 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
||||
}
|
||||
|
||||
@action
|
||||
resetTheme() {
|
||||
this.preferences.colorTheme = UserStore.defaultTheme;
|
||||
}
|
||||
|
||||
@action
|
||||
saveLastSeenAppVersion() {
|
||||
tracker.event("app", "whats-new-seen")
|
||||
|
||||
Reference in new issue
Block a user