[8.8] [maps] fix Maps don't display darktheme when user has dark theme enabled in profile (#158219) (#158272)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[maps] fix Maps don't display darktheme when user has dark theme
enabled in profile
(#158219)](https://github.com/elastic/kibana/pull/158219)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2023-05-23T14:33:41Z","message":"[maps]
fix Maps don't display darktheme when user has dark theme enabled in
profile (#158219)\n\nFixes
https://github.com/elastic/kibana/issues/158050\r\n\r\nPR updates
`getIsDarkMode` to read value from theme$ instead of\r\nUiSettings,
since UiSettings does not contain profile theming. Part
of\r\nhttps://github.com/elastic/kibana/issues/158201\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"bb1cf6609a4cf5c8208318b803f6a7cdc0f2e913","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","Feature:Maps","v8.9.0","v8.8.1"],"number":158219,"url":"https://github.com/elastic/kibana/pull/158219","mergeCommit":{"message":"[maps]
fix Maps don't display darktheme when user has dark theme enabled in
profile (#158219)\n\nFixes
https://github.com/elastic/kibana/issues/158050\r\n\r\nPR updates
`getIsDarkMode` to read value from theme$ instead of\r\nUiSettings,
since UiSettings does not contain profile theming. Part
of\r\nhttps://github.com/elastic/kibana/issues/158201\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"bb1cf6609a4cf5c8208318b803f6a7cdc0f2e913"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158219","number":158219,"mergeCommit":{"message":"[maps]
fix Maps don't display darktheme when user has dark theme enabled in
profile (#158219)\n\nFixes
https://github.com/elastic/kibana/issues/158050\r\n\r\nPR updates
`getIsDarkMode` to read value from theme$ instead of\r\nUiSettings,
since UiSettings does not contain profile theming. Part
of\r\nhttps://github.com/elastic/kibana/issues/158201\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"bb1cf6609a4cf5c8208318b803f6a7cdc0f2e913"}},{"branch":"8.8","label":"v8.8.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-23 11:52:55 -04:00 committed by GitHub
parent 363169b907
commit ff4f42a086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import { MapsEmsPluginPublicStart } from '@kbn/maps-ems-plugin/public';
import type { MapsConfigType } from '../config';
import type { MapsPluginStartDependencies } from './plugin';
let isDarkMode = false;
let coreStart: CoreStart;
let pluginsStart: MapsPluginStartDependencies;
let mapsEms: MapsEmsPluginPublicStart;
@ -20,6 +21,10 @@ export function setStartServices(core: CoreStart, plugins: MapsPluginStartDepend
pluginsStart = plugins;
mapsEms = plugins.mapsEms;
emsSettings = mapsEms.createEMSSettings();
core.theme.theme$.subscribe(({ darkMode }) => {
isDarkMode = darkMode;
});
}
let isCloudEnabled = false;
@ -35,7 +40,7 @@ export const getAutocompleteService = () => pluginsStart.unifiedSearch.autocompl
export const getInspector = () => pluginsStart.inspector;
export const getFileUpload = () => pluginsStart.fileUpload;
export const getUiSettings = () => coreStart.uiSettings;
export const getIsDarkMode = () => getUiSettings().get('theme:darkMode', false);
export const getIsDarkMode = () => isDarkMode;
export const getIndexPatternSelectComponent = () =>
pluginsStart.unifiedSearch.ui.IndexPatternSelect;
export const getSearchBar = () => pluginsStart.unifiedSearch.ui.SearchBar;