diff --git a/src/shared/lib/use-events/normalize-unknown-event.ts b/src/shared/lib/use-events/normalize-unknown-event.ts index 11916a88..b698850b 100644 --- a/src/shared/lib/use-events/normalize-unknown-event.ts +++ b/src/shared/lib/use-events/normalize-unknown-event.ts @@ -3,7 +3,7 @@ import type { ServerEvent, NormalizedEvent } from "../../types"; export const normalizeUnknownEvent = (event: ServerEvent): NormalizedEvent => ({ id: event.uuid, type: 'unknown', - labels: [event.type], + labels: [String(event.type)], origin: null, serverName: "", date: event.timestamp ? new Date(event.timestamp * 1000) : null, diff --git a/src/shared/stores/events/events-store.ts b/src/shared/stores/events/events-store.ts index f751ed4b..db529ddc 100644 --- a/src/shared/stores/events/events-store.ts +++ b/src/shared/stores/events/events-store.ts @@ -3,6 +3,7 @@ import {PAGE_TYPES} from "../../constants"; import {useSettings} from "../../lib/use-settings"; import type {EventId, EventType, ServerEvent, TEventsGroup, TProjects} from '../../types'; import {EVENT_TYPES} from "../../types"; +import {useSettingsStore} from "../settings"; import { getStoredLockedIds, setStoredCachedIds, @@ -84,13 +85,20 @@ export const useEventsStore = defineStore("eventsStore", { }, // events initializeEvents (events: ServerEvent[]): void { - this.events = events.slice(0, MAX_EVENTS_COUNT); + const { availableEvents } = useSettingsStore(); + + this.events = events + .filter((el) => availableEvents.includes(el.type as EventType)) + .slice(0, MAX_EVENTS_COUNT); this.syncCachedWithActive(events.map(({ uuid }) => uuid)); this.initActiveProjectKey(); }, addList(events: ServerEvent[]): void { - events.forEach((event) => { + const { availableEvents } = useSettingsStore(); + events + .filter((el) => availableEvents.includes(el.type as EventType)) + .forEach((event) => { const isExistedEvent: boolean = this.events.some((el): boolean => el.uuid === event.uuid); if (!isExistedEvent) { this.events.unshift(event) diff --git a/src/shared/stores/settings/settings-store.ts b/src/shared/stores/settings/settings-store.ts index 814f6487..8e368c31 100644 --- a/src/shared/stores/settings/settings-store.ts +++ b/src/shared/stores/settings/settings-store.ts @@ -1,6 +1,6 @@ import {defineStore} from "pinia"; import {REST_API_URL} from "../../lib/io/constants"; -import type { TSettings } from "../../types"; +import {EVENT_TYPES, type EventType, type TSettings} from "../../types"; import {THEME_MODES} from "./constants"; import { getStoredEventsCountVisibility, @@ -23,6 +23,7 @@ export const useSettingsStore = defineStore("settingsStore", { themeType: getStoredActiveTheme(), isFixedHeader: getStoredFixedHeader(), isVisibleEventCounts: getStoredEventsCountVisibility(), + availableEvents: [] as EventType[], }), actions: { async fetchSettings() { @@ -44,6 +45,9 @@ export const useSettingsStore = defineStore("settingsStore", { this.authLogicUrl = settings.auth.login_url; } + // TODO: meed to move to the events store + this.availableEvents = settings?.client?.events ?? Object.values(EVENT_TYPES); + this.isFetched = true return settings diff --git a/src/shared/types/events.ts b/src/shared/types/events.ts index 4331c36f..1e98cdb5 100644 --- a/src/shared/types/events.ts +++ b/src/shared/types/events.ts @@ -21,7 +21,7 @@ export type EventType = OneOfValues; export interface ServerEvent { uuid: EventId, - type: EventType | string, + type: EventType | unknown, payload: T, project: string | null, timestamp: number // unavailable for some ray dump events diff --git a/src/shared/types/settings.ts b/src/shared/types/settings.ts index 8f4f4c00..b2607b73 100644 --- a/src/shared/types/settings.ts +++ b/src/shared/types/settings.ts @@ -1,3 +1,5 @@ +import {type EventType} from "./events"; + export type TProfile = { username: string, email: string, @@ -10,6 +12,9 @@ export type TSettings = { login_url: string, }, version: string, + client: { + events: EventType[], + } } diff --git a/src/widgets/ui/layout-sidebar/layout-sidebar.vue b/src/widgets/ui/layout-sidebar/layout-sidebar.vue index a571b144..50529604 100644 --- a/src/widgets/ui/layout-sidebar/layout-sidebar.vue +++ b/src/widgets/ui/layout-sidebar/layout-sidebar.vue @@ -104,7 +104,7 @@ const logout = () => { const path = computed(() => useRoute().path); -const { apiVersion } = storeToRefs(useSettingsStore()); +const { apiVersion, availableEvents } = storeToRefs(useSettingsStore()); const clientVersion = ref( !version || version === "0.0.1" ? "@dev" : `v${version}`, @@ -122,6 +122,10 @@ const setProject = (projectKey: string) => { isVisibleProjects.value = false; }; +const filteredNavOrder = computed(() => + EVENTS_NAV_ORDER.filter((type) => availableEvents.value.includes(type)), +); + const makeShortTitle = (title: string) => (title || "").substring(0, 2); const generateRadialGradient = (input: string) => `linear-gradient(to right, ${textToColors(input || "").join(", ")})`; @@ -170,7 +174,7 @@ const generateRadialGradient = (input: string) => -