Preferences: Add preferences kind and remove unused navbar settings (#59621)

This commit is contained in:
Ryan McKinley
2023-01-25 11:00:32 -08:00
committed by GitHub
parent 8b574e22b5
commit a0405912a8
24 changed files with 420 additions and 144 deletions

View File

@@ -5,7 +5,7 @@ import TestProvider from 'test/helpers/TestProvider';
import { assertInstanceOf } from 'test/helpers/asserts';
import { getSelectParent, selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { UserPreferencesDTO } from 'app/types';
import { Preferences as UserPreferencesDTO } from '@grafana/schema/src/raw/preferences/x/preferences_types.gen';
import SharedPreferences from './SharedPreferences';

View File

@@ -4,6 +4,7 @@ import React, { PureComponent } from 'react';
import { FeatureState, SelectableValue } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { config, reportInteraction } from '@grafana/runtime';
import { Preferences as UserPreferencesDTO } from '@grafana/schema/src/raw/preferences/x/preferences_types.gen';
import {
Button,
Field,
@@ -21,7 +22,6 @@ 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 { UserPreferencesDTO } from 'app/types';
export interface Props {
resourceUri: string;
@@ -130,6 +130,10 @@ export class SharedPreferences extends PureComponent<Props, State> {
const { disabled } = this.props;
const styles = getStyles();
const languages = getLanguageOptions();
let currentThemeOption = this.themeOptions[0].value;
if (theme?.length) {
currentThemeOption = this.themeOptions.find((item) => item.value === theme)?.value;
}
return (
<Form onSubmit={this.onSubmitForm}>
@@ -139,7 +143,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
<Field label={t('shared-preferences.fields.theme-label', 'UI Theme')}>
<RadioButtonGroup
options={this.themeOptions}
value={this.themeOptions.find((item) => item.value === theme)?.value}
value={currentThemeOption}
onChange={this.onThemeChanged}
/>
</Field>
@@ -181,7 +185,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
data-testid={selectors.components.WeekStartPicker.containerV2}
>
<WeekStartPicker
value={weekStart}
value={weekStart || ''}
onChange={this.onWeekStartChanged}
inputId={'shared-preferences-week-start-picker'}
/>