From cc3047b22b32874afb6031eaa92a1a34be992292 Mon Sep 17 00:00:00 2001 From: copyhold Date: Tue, 15 Oct 2024 11:38:06 +0300 Subject: [PATCH 1/2] Remove logz modifications' --- .../SharedPreferences/SharedPreferences.tsx | 43 +++---------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/public/app/core/components/SharedPreferences/SharedPreferences.tsx b/public/app/core/components/SharedPreferences/SharedPreferences.tsx index e224877db9e89..b161d788b8fe7 100644 --- a/public/app/core/components/SharedPreferences/SharedPreferences.tsx +++ b/public/app/core/components/SharedPreferences/SharedPreferences.tsx @@ -20,9 +20,7 @@ import { DashboardPicker } from 'app/core/components/Select/DashboardPicker'; import { t, Trans } from 'app/core/internationalization'; import { LANGUAGES } from 'app/core/internationalization/constants'; import { PreferencesService } from 'app/core/services/PreferencesService'; -import { backendSrv } from "app/core/services/backend_srv";// LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard import { changeTheme } from 'app/core/services/theme'; -import { DashboardSearchItem } from 'app/features/search/types'; export interface Props { resourceUri: string; @@ -31,7 +29,7 @@ export interface Props { onConfirm?: () => Promise; } -export type State = UserPreferencesDTO & { homeDashboardId?: number; dashboards: Array}; // LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard +export type State = UserPreferencesDTO; function getLanguageOptions(): Array> { const languageOptions = LANGUAGES.map((v) => ({ @@ -64,7 +62,6 @@ export class SharedPreferences extends PureComponent { weekStart: '', language: '', queryHistory: { homeTab: '' }, - dashboards: [], }; this.themeOptions = getBuiltInThemes(config.featureToggles.extraThemes).map((theme) => ({ @@ -77,35 +74,16 @@ export class SharedPreferences extends PureComponent { } async componentDidMount() { - // LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard - const prefs = await backendSrv.get(`/api/${this.props.resourceUri.toLowerCase()}/preferences`); - const dashboards = await backendSrv.search({ starred: true }); - // - // this.setState({ - // homeDashboardUID: prefs.homeDashboardUID, - // theme: prefs.theme, - // timezone: prefs.timezone, - // weekStart: prefs.weekStart, - // language: prefs.language, - // queryHistory: prefs.queryHistory, - // }); - - if (prefs.homeDashboardId > 0 && !dashboards.find((d) => d.id === prefs.homeDashboardId)) { - const missing = await backendSrv.search({ dashboardIds: [prefs.homeDashboardId] }); - if (missing && missing.length > 0) { - dashboards.push(missing[0]); - } - } + const prefs = await this.service.load(); this.setState({ - homeDashboardId: prefs.homeDashboardId, homeDashboardUID: prefs.homeDashboardUID, theme: prefs.theme, timezone: prefs.timezone, weekStart: prefs.weekStart, - dashboards, + language: prefs.language, + queryHistory: prefs.queryHistory, }); - // LOGZ.IO GRAFANA CHANGE :: DEV-20609 Remove default dashboard end } onSubmitForm = async (event: React.FormEvent) => { @@ -113,15 +91,8 @@ export class SharedPreferences extends PureComponent { const confirmationResult = this.props.onConfirm ? await this.props.onConfirm() : true; if (confirmationResult) { - // LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard - const { homeDashboardUID, theme, timezone } = this.state; - const homeDashboard = this.state.dashboards.find(d => d.uid === homeDashboardUID); - await backendSrv.put(`/api/${this.props.resourceUri.toLowerCase()}/preferences`, { - homeDashboardId: homeDashboard?.id || null, - theme, - timezone, - }); - // LOGZ.IO GRAFANA CHANGE :: end + const { homeDashboardUID, theme, timezone, weekStart, language, queryHistory } = this.state; + await this.service.update({ homeDashboardUID, theme, timezone, weekStart, language, queryHistory }); window.location.reload(); } }; @@ -221,7 +192,7 @@ export class SharedPreferences extends PureComponent {