diff --git a/client/src/Features/UI/uiSlice.ts b/client/src/Features/UI/uiSlice.ts index 630523e9e..198ed8389 100644 --- a/client/src/Features/UI/uiSlice.ts +++ b/client/src/Features/UI/uiSlice.ts @@ -1,9 +1,4 @@ import { createSlice, type PayloadAction } from "@reduxjs/toolkit"; -import { - DASHBOARD_CARD_IDS, - defaultVisibleCards, - type DashboardCardId, -} from "@/Pages/Dashboard/dashboardCards"; type ThemeMode = "light" | "dark"; type ChartType = "histogram" | "line"; @@ -40,8 +35,6 @@ interface UIState { language: string; starPromptOpen: boolean; chartType: ChartType; - dashboardCards: Record; - dashboardCardOrder: DashboardCardId[]; } const initialMode: ThemeMode = window?.matchMedia?.("(prefers-color-scheme: dark)") @@ -81,8 +74,6 @@ const initialState: UIState = { language: "en", starPromptOpen: true, chartType: "histogram", - dashboardCards: { ...defaultVisibleCards }, - dashboardCardOrder: [...DASHBOARD_CARD_IDS], }; const uiSlice = createSlice({ @@ -111,7 +102,6 @@ const uiSlice = createSlice({ setShowURL: (state, action: PayloadAction) => { state.showURL = action.payload; }, - setTimezone: (state, action: PayloadAction<{ timezone: string }>) => { if (action.payload.timezone) { state.timezone = action.payload.timezone; @@ -126,27 +116,6 @@ const uiSlice = createSlice({ setChartType: (state, action: PayloadAction) => { state.chartType = action.payload; }, - setDashboardCards: ( - state, - action: PayloadAction> - ) => { - state.dashboardCards = action.payload; - }, - setDashboardCardsVisibility: ( - state, - action: PayloadAction<{ id: DashboardCardId; visible: boolean }> - ) => { - state.dashboardCards[action.payload.id] = action.payload.visible; - }, - toggleDashboardCard: (state, action: PayloadAction) => { - state.dashboardCards[action.payload] = !state.dashboardCards[action.payload]; - }, - resetDashboardCards: (state) => { - state.dashboardCards = { ...defaultVisibleCards }; - }, - setDashboardCardOrder: (state, action: PayloadAction) => { - state.dashboardCardOrder = action.payload; - }, }, }); @@ -163,9 +132,4 @@ export const { setLanguage, setStarPromptOpen, setChartType, - setDashboardCards, - setDashboardCardsVisibility, - toggleDashboardCard, - resetDashboardCards, - setDashboardCardOrder, } = uiSlice.actions; diff --git a/client/src/Pages/Dashboard/dashboardCards.ts b/client/src/Pages/Dashboard/dashboardCards.ts deleted file mode 100644 index f8e1469a6..000000000 --- a/client/src/Pages/Dashboard/dashboardCards.ts +++ /dev/null @@ -1,90 +0,0 @@ -export const DASHBOARD_CARD_IDS = [ - "monitorStatus", - "currentlyDown", - "slowestMonitors", - "lowestUptime", - "monitorsByType", - "monitorsByGroup", - "busiestServers", - "recentIncidents", - "incidentStats", - "notificationChannels", - "maintenanceWindows", - "statusPages", - "failedChecks", - "checkmateServer", - "checkQueue", - "recentErrors", - "teamMembers", -] as const; - -export type DashboardCardId = (typeof DASHBOARD_CARD_IDS)[number]; - -export const defaultVisibleCards: Record = { - monitorStatus: true, - currentlyDown: true, - slowestMonitors: true, - lowestUptime: true, - monitorsByType: true, - monitorsByGroup: true, - busiestServers: false, - recentIncidents: false, - incidentStats: false, - notificationChannels: false, - maintenanceWindows: false, - statusPages: false, - failedChecks: false, - checkmateServer: false, - checkQueue: false, - recentErrors: false, - teamMembers: false, -}; - -export const cardCategories: { - labelKey: string; - cards: DashboardCardId[]; -}[] = [ - { - labelKey: "pages.dashboard.modal.categories.uptime", - cards: [ - "monitorStatus", - "currentlyDown", - "slowestMonitors", - "lowestUptime", - "monitorsByType", - "monitorsByGroup", - ], - }, - { - labelKey: "pages.dashboard.modal.categories.infrastructure", - cards: ["busiestServers"], - }, - { - labelKey: "pages.dashboard.modal.categories.incidents", - cards: ["recentIncidents", "incidentStats"], - }, - { - labelKey: "pages.dashboard.modal.categories.notifications", - cards: ["notificationChannels"], - }, - { - labelKey: "pages.dashboard.modal.categories.maintenance", - cards: ["maintenanceWindows"], - }, - { - labelKey: "pages.dashboard.modal.categories.statusPages", - cards: ["statusPages"], - }, - { - labelKey: "pages.dashboard.modal.categories.checks", - cards: ["failedChecks"], - }, - { - labelKey: "pages.dashboard.modal.categories.system", - cards: ["checkmateServer", "checkQueue", "recentErrors"], - }, - { - labelKey: "pages.dashboard.modal.categories.settings", - cards: ["teamMembers"], - }, -]; diff --git a/client/src/Pages/Dashboard/hooks/useDashboardData.ts b/client/src/Pages/Dashboard/hooks/useDashboardData.ts index 983cae295..742377869 100644 --- a/client/src/Pages/Dashboard/hooks/useDashboardData.ts +++ b/client/src/Pages/Dashboard/hooks/useDashboardData.ts @@ -25,11 +25,6 @@ export const useDashboardData = () => { isLoading, error, summary: data?.summary ?? EMPTY_SUMMARY, - monitors: data?.monitors ?? [], - slowestMonitors: data?.slowestMonitors ?? [], - lowestUptimeMonitors: data?.lowestUptimeMonitors ?? [], - downMonitors: data?.downMonitors ?? [], monitorsByType: data?.monitorsByType ?? [], - monitorsByGroup: data?.monitorsByGroup ?? [], }; }; diff --git a/client/src/Types/state.ts b/client/src/Types/state.ts index 6d3976ed7..d8d291fc7 100644 --- a/client/src/Types/state.ts +++ b/client/src/Types/state.ts @@ -1,6 +1,5 @@ import type { ChartType } from "@/Features/UI/uiSlice"; import type { User } from "./User"; -import type { DashboardCardId } from "@/Pages/Dashboard/dashboardCards"; export interface AuthState { isLoading: boolean; @@ -40,8 +39,6 @@ export interface UIState { language: string; starPromptOpen: boolean; chartType: ChartType; - dashboardCards: Record; - dashboardCardOrder: DashboardCardId[]; } export interface RootState { diff --git a/client/src/locales/en.json b/client/src/locales/en.json index cc4cd1dda..32c7a07d4 100644 --- a/client/src/locales/en.json +++ b/client/src/locales/en.json @@ -1887,54 +1887,14 @@ } }, "dashboard": { - "editCards": "Edit cards", "error": "Failed to load data", "monitorStatus": { "ofUp": "of {{total}} up" }, - "emptyStates": { - "allMonitorsUp": "All monitors are up. No incidents open.", - "noGroups": "No groups yet. Groups are set per monitor.", - "topOf": "Top {{count}} of {{total}}" - }, "cards": { "monitorStatus": "Monitor status", - "currentlyDown": "Currently down", - "slowestMonitors": "Slowest monitors", - "lowestUptime": "Lowest uptime", - "monitorsByType": "Monitors by type", - "monitorsByGroup": "Monitors by group", - "busiestServers": "Busiest servers", - "recentIncidents": "Recent incidents", - "incidentStats": "Incident statistics", - "notificationChannels": "Notification channels", - "maintenanceWindows": "Maintenance windows", - "statusPages": "Status pages", - "failedChecks": "Failed checks", - "checkmateServer": "Checkmate server", - "checkQueue": "Check queue", - "recentErrors": "Recent errors", - "teamMembers": "Team members" + "monitorsByType": "Monitors by type" }, - "modal": { - "title": "Edit dashboard cards", - "description": "Choose which cards to display on your dashboard.", - "categories": { - "uptime": "Uptime", - "infrastructure": "Infrastructure", - "incidents": "Incidents", - "notifications": "Notifications", - "maintenance": "Maintenance", - "statusPages": "Status pages", - "checks": "Checks", - "system": "System", - "settings": "Settings" - }, - "resetToDefaults": "Reset to defaults", - "selectAll": "Select all", - "done": "Done" - }, - "comingSoon": "Coming soon", "header": { "title": "Dashboard", "description": "See every monitor type in one place and spot what needs attention." diff --git a/client/src/store.ts b/client/src/store.ts index 6c8d1b53c..706a58da2 100644 --- a/client/src/store.ts +++ b/client/src/store.ts @@ -7,14 +7,9 @@ import { persistReducer, persistStore, createTransform, - createMigrate, PERSIST, REHYDRATE, } from "redux-persist"; -import { - defaultVisibleCards, - DASHBOARD_CARD_IDS, -} from "@/Pages/Dashboard/dashboardCards"; const authTransform = createTransform( (inboundState: Record) => { @@ -25,44 +20,12 @@ const authTransform = createTransform( { whitelist: ["auth"] } ); -const migrations = { - 0: (state: any) => ({ - ...state, - ui: { - ...state?.ui, - dashboardCards: state?.ui?.dashboardCards ?? { ...defaultVisibleCards }, - }, - }), - 1: (state: any) => { - const cards = state?.ui?.dashboardCards; - const hasAnyVisible = cards && Object.values(cards).some((v) => v); - return { - ...state, - ui: { - ...state?.ui, - dashboardCards: hasAnyVisible ? cards : { ...defaultVisibleCards }, - }, - }; - }, - 2: (state: any) => { - const cards = state?.ui?.dashboardCards ?? { ...defaultVisibleCards }; - const stubCards = DASHBOARD_CARD_IDS.filter((id) => !defaultVisibleCards[id]); - const resetCards = { ...cards }; - stubCards.forEach((id) => { - resetCards[id] = false; - }); - return { ...state, ui: { ...state?.ui, dashboardCards: resetCards } }; - }, -}; - const persistConfig = { key: "root", - version: 2, storage, whitelist: ["auth", "ui"], transforms: [authTransform], stateReconciler: autoMergeLevel2, - migrate: createMigrate(migrations, { debug: false }), }; const rootReducer = combineReducers({