Skip to content

Commit

Permalink
Add NP dark mode and toast handling. Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Mar 17, 2020
1 parent be6bdd5 commit 223c876
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/maps/public/kibana_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ let dataTimeFilter;
export const setTimeFilter = timeFilter => (dataTimeFilter = timeFilter);
export const getTimeFilter = () => dataTimeFilter;

let toast;
export const setToasts = notificationToast => (toast = notificationToast);
export const getToasts = () => toast;

export async function fetchSearchSourceAndRecordWithInspector({
searchSource,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
DEFAULT_MAX_INNER_RESULT_WINDOW,
INDEX_SETTINGS_API_PATH,
} from '../../../../common/constants';
import { getHttp } from '../../../kibana_services';
import { toastNotifications } from 'ui/notify';
import { getHttp, getToasts } from '../../../kibana_services';
import { i18n } from '@kbn/i18n';

let toastDisplayed = false;
Expand All @@ -28,6 +27,7 @@ export async function loadIndexSettings(indexPatternTitle) {

async function fetchIndexSettings(indexPatternTitle) {
const http = getHttp();
const toasts = getToasts();
try {
const indexSettings = await http.fetch(`../${INDEX_SETTINGS_API_PATH}`, {
method: 'GET',
Expand All @@ -49,7 +49,7 @@ async function fetchIndexSettings(indexPatternTitle) {
if (!toastDisplayed) {
// Only show toast for first failure to avoid flooding user with warnings
toastDisplayed = true;
toastNotifications.addWarning(warningMsg);
toasts.addWarning(warningMsg);
}
console.warn(warningMsg);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';

import chrome from 'ui/chrome';
import { getUiSettings } from '../../../../../kibana_services';
import { StylePropEditor } from '../style_prop_editor';
import { DynamicIconForm } from './dynamic_icon_form';
import { StaticIconForm } from './static_icon_form';
Expand All @@ -16,13 +16,13 @@ export function VectorStyleIconEditor(props) {
const iconForm = props.styleProperty.isDynamic() ? (
<DynamicIconForm
{...props}
isDarkMode={chrome.getUiSettingsClient().get('theme:darkMode', false)}
isDarkMode={getUiSettings().get('theme:darkMode', false)}
symbolOptions={SYMBOL_OPTIONS}
/>
) : (
<StaticIconForm
{...props}
isDarkMode={chrome.getUiSettingsClient().get('theme:darkMode', false)}
isDarkMode={getUiSettings().get('theme:darkMode', false)}
symbolOptions={SYMBOL_OPTIONS}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
DEFAULT_FILL_COLORS,
DEFAULT_LINE_COLORS,
} from '../color_utils';
import chrome from 'ui/chrome';
import { getUiSettings } from '../../../kibana_services';

export const MIN_SIZE = 1;
export const MAX_SIZE = 64;
Expand Down Expand Up @@ -67,7 +67,7 @@ export function getDefaultStaticProperties(mapColors = []) {
const nextFillColor = DEFAULT_FILL_COLORS[nextColorIndex];
const nextLineColor = DEFAULT_LINE_COLORS[nextColorIndex];

const isDarkMode = chrome.getUiSettingsClient().get('theme:darkMode', false);
const isDarkMode = getUiSettings().get('theme:darkMode', false);

return {
[VECTOR_STYLES.ICON]: {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
setTimeFilter,
setUiSettings,
setInjectedVarFunc,
setToasts,
} from './kibana_services';
import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public';
import { LicensingPluginSetup } from '../../../../plugins/licensing/public';
Expand Down Expand Up @@ -61,6 +62,7 @@ export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => {
setHttp(http);
setUiSettings(core.uiSettings);
setInjectedVarFunc(core.injectedMetadata.getInjectedVar);
setToasts(core.notifications.toasts);
};

export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => {
Expand Down

0 comments on commit 223c876

Please sign in to comment.