mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: app config store updates
This commit is contained in:
parent
912213e051
commit
d0688e5287
47
web/store/application/app-config.store.ts
Normal file
47
web/store/application/app-config.store.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { observable, action, makeObservable, runInAction } from "mobx";
|
||||||
|
// types
|
||||||
|
import { RootStore } from "./root";
|
||||||
|
import { IAppConfig } from "types/app";
|
||||||
|
// services
|
||||||
|
import { AppConfigService } from "services/app_config.service";
|
||||||
|
|
||||||
|
export interface IAppConfigStore {
|
||||||
|
envConfig: IAppConfig | null;
|
||||||
|
// action
|
||||||
|
fetchAppConfig: () => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppConfigStore implements IAppConfigStore {
|
||||||
|
// observables
|
||||||
|
envConfig: IAppConfig | null = null;
|
||||||
|
|
||||||
|
// root store
|
||||||
|
rootStore;
|
||||||
|
// service
|
||||||
|
appConfigService;
|
||||||
|
|
||||||
|
constructor(_rootStore: RootStore) {
|
||||||
|
makeObservable(this, {
|
||||||
|
// observables
|
||||||
|
envConfig: observable.ref,
|
||||||
|
// actions
|
||||||
|
fetchAppConfig: action,
|
||||||
|
});
|
||||||
|
this.appConfigService = new AppConfigService();
|
||||||
|
|
||||||
|
this.rootStore = _rootStore;
|
||||||
|
}
|
||||||
|
fetchAppConfig = async () => {
|
||||||
|
try {
|
||||||
|
const config = await this.appConfigService.envConfig();
|
||||||
|
runInAction(() => {
|
||||||
|
this.envConfig = config;
|
||||||
|
});
|
||||||
|
return config;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AppConfigStore;
|
0
web/store/application/command-palette.store.ts
Normal file
0
web/store/application/command-palette.store.ts
Normal file
0
web/store/application/event-tracker.store.ts
Normal file
0
web/store/application/event-tracker.store.ts
Normal file
15
web/store/application/index.ts
Normal file
15
web/store/application/index.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export class AppRootStore {
|
||||||
|
config;
|
||||||
|
commandPalette;
|
||||||
|
eventTracker;
|
||||||
|
instance;
|
||||||
|
theme;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.config = new ConfigStore();
|
||||||
|
this.commandPalette = new CommandPaletteStore();
|
||||||
|
this.eventTracker = new EventTrackerStore();
|
||||||
|
this.instance = new InstanceStore();
|
||||||
|
this.theme = new ThemeStore();
|
||||||
|
}
|
||||||
|
}
|
0
web/store/application/instance.store.ts
Normal file
0
web/store/application/instance.store.ts
Normal file
0
web/store/application/theme.store.ts
Normal file
0
web/store/application/theme.store.ts
Normal file
30
web/store/root.store.ts
Normal file
30
web/store/root.store.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { enableStaticRendering } from "mobx-react-lite";
|
||||||
|
// root stores
|
||||||
|
import { AppRootStore } from "./application";
|
||||||
|
|
||||||
|
enableStaticRendering(typeof window === "undefined");
|
||||||
|
|
||||||
|
export class RootStore {
|
||||||
|
app;
|
||||||
|
user;
|
||||||
|
workspace;
|
||||||
|
project;
|
||||||
|
cycle;
|
||||||
|
module;
|
||||||
|
projectView;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.app = new AppRootStore();
|
||||||
|
this.user = new UserRootStore();
|
||||||
|
this.workspace = new WorkspaceRootStore();
|
||||||
|
this.project = new ProjectRootStore();
|
||||||
|
this.cycle = new CycleRootStore();
|
||||||
|
this.module = new ModuleRootStore();
|
||||||
|
this.projectView = new ProjectViewRootStore();
|
||||||
|
this.page = new PageRootStore();
|
||||||
|
this.issue = new IssueRootStore();
|
||||||
|
// independent stores
|
||||||
|
this.label = new labelStore();
|
||||||
|
this.state = new stateStore();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user