Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Manual Backport 2.x] Feat (core): Make theme settings user-specific and user-configurable (#5652) (#6681)" #6736

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multiple Datasource] Able to Hide "Local Cluster" option from datasource DropDown ([#5827](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5827))
- [Multiple Datasource] Add api registry and allow it to be added into client config in data source plugin ([#5895](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5895))
- [Multiple Datasource] Refactor client and legacy client to use authentication registry ([#5881](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5881))
- [Theme] Make theme and dark mode settings user/device specific (in local storage), with opt-out ([#5652](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5652))

### 🐛 Bug Fixes

Expand Down
131 changes: 0 additions & 131 deletions docs/theme.md

This file was deleted.

1 change: 0 additions & 1 deletion src/core/public/osd_bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { __osdBootstrap__ } from './';
describe('osd_bootstrap', () => {
beforeAll(() => {
const metadata = {
branding: { darkMode: 'true' },
i18n: { translationsUrl: 'http://localhost' },
vars: { apmConfig: null },
};
Expand Down
5 changes: 0 additions & 5 deletions src/core/public/osd_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ export async function __osdBootstrap__() {
document.querySelector('osd-injected-metadata')!.getAttribute('data')!
);

const globals: any = typeof window === 'undefined' ? {} : window;
const themeTag: string = globals.__osdThemeTag__ || '';

injectedMetadata.branding.darkMode = themeTag.endsWith('dark');

let i18nError: Error | undefined;
const apmSystem = new ApmSystem(injectedMetadata.vars.apmConfig, injectedMetadata.basePath);

Expand Down
43 changes: 2 additions & 41 deletions src/core/public/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ export class UiSettingsClient implements IUiSettingsClient {
this.defaults = cloneDeep(params.defaults);
this.cache = defaultsDeep({}, this.defaults, cloneDeep(params.initialSettings));

if (
this.cache['theme:enableUserControl']?.userValue ??
this.cache['theme:enableUserControl']?.value
) {
this.cache = defaultsDeep(this.cache, this.getBrowserStoredSettings());
}

params.done$.subscribe({
complete: () => {
this.update$.complete();
Expand Down Expand Up @@ -180,28 +173,6 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r
return this.updateErrors$.asObservable();
}

private getBrowserStoredSettings() {
const uiSettingsJSON = window.localStorage.getItem('uiSettings') || '{}';
try {
return JSON.parse(uiSettingsJSON);
} catch (error) {
this.updateErrors$.next(error);
}
return {};
}

private setBrowserStoredSettings(key: string, newVal: any) {
const oldSettings = this.getBrowserStoredSettings();
const newSettings = cloneDeep(oldSettings);
if (newVal === null) {
delete newSettings[key];
} else {
newSettings[key] = { userValue: newVal };
}
window.localStorage.setItem(`uiSettings`, JSON.stringify(newSettings));
return { settings: newSettings };
}

private assertUpdateAllowed(key: string) {
if (this.isOverridden(key)) {
throw new Error(
Expand All @@ -227,18 +198,8 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r
this.setLocally(key, newVal);

try {
if (
this.cache['theme:enableUserControl']?.userValue ??
this.cache['theme:enableUserControl']?.value
) {
const { settings } = this.cache[key]?.preferBrowserSetting
? this.setBrowserStoredSettings(key, newVal)
: (await this.api.batchSet(key, newVal)) || {};
this.cache = defaultsDeep({}, defaults, this.getBrowserStoredSettings(), settings);
} else {
const { settings } = (await this.api.batchSet(key, newVal)) || {};
this.cache = defaultsDeep({}, defaults, settings);
}
const { settings } = await this.api.batchSet(key, newVal);
this.cache = defaultsDeep({}, defaults, settings);
this.saved$.next({ key, newValue: newVal, oldValue: initialVal });
return true;
} catch (error) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading