Skip to content

Commit

Permalink
#139 add support for default project in event-store
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Jul 28, 2024
1 parent 1ee0a55 commit 25a0740
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/shared/stores/events/events-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const useEventsStore = defineStore("eventsStore", {
projects: {
available: [] as TProjects['data'],
activeKey: null as string | null,
default: null as string | null,
}
}),
getters: {
Expand Down Expand Up @@ -217,6 +218,9 @@ export const useEventsStore = defineStore("eventsStore", {
this.projects.activeKey = null;

removeStoredProject();
},
setDefaultProject(key: string) {
this.projects.default = key;
}
},
});
9 changes: 8 additions & 1 deletion src/shared/stores/settings/settings-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {defineStore} from "pinia";
import {useSettings} from "../../lib/use-settings";
import type { TSettings } from "../../types";
import {useEventsStore} from "../events/events-store";
import {THEME_MODES} from "./constants";
import {
getStoredEventsCountVisibility,
Expand All @@ -26,8 +27,9 @@ export const useSettingsStore = defineStore("settingsStore", {
actions: {
initialize() {
const {api: { getSettings }} = useSettings();
const { setDefaultProject } = useEventsStore();

getSettings().then(({ version, auth } = {} as TSettings) => {
getSettings().then(({ version, auth, project } = {} as TSettings) => {
if (version) {
this.apiVersion = version
}
Expand All @@ -36,6 +38,11 @@ export const useSettingsStore = defineStore("settingsStore", {
this.auth.isEnabled = auth.enabled;
this.auth.loginUrl = auth.login_url;
}

if (project.default) {
// TODO: need to load default project within project request
setDefaultProject(project.default)
}
})
},
changeTheme() {
Expand Down
3 changes: 3 additions & 0 deletions src/shared/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export type TSettings = {
login_url: string,
},
version: string,
project: {
default: string,
}
}


Expand Down

0 comments on commit 25a0740

Please sign in to comment.