Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Jul 14, 2020
1 parent 59ad99c commit 84f2cb0
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UpdateSourceEditor } from './update_source_editor';
import { i18n } from '@kbn/i18n';
import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { SOURCE_TYPES } from '../../../../common/constants';
import { getEmsTileLayerId, getUiSettings } from '../../../kibana_services';
import { getEmsTileLayerId, getIsDarkMode } from '../../../kibana_services';
import { registerSource } from '../source_registry';

export const sourceTitle = i18n.translate('xpack.maps.source.emsTileTitle', {
Expand Down Expand Up @@ -122,9 +122,8 @@ export class EMSTMSSource extends AbstractTMSSource {
return this._descriptor.id;
}

const isDarkMode = getUiSettings().get('theme:darkMode', false);
const emsTileLayerId = getEmsTileLayerId();
return isDarkMode ? emsTileLayerId.dark : emsTileLayerId.bright;
return getIsDarkMode() ? emsTileLayerId.dark : emsTileLayerId.bright;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ import {
} from '@elastic/eui';
import { SymbolIcon } from '../legend/symbol_icon';
import { SYMBOL_OPTIONS } from '../../symbol_utils';
import { getUiSettings } from '../../../../../kibana_services';
import { getIsDarkMode } from '../../../../../kibana_services';

function isKeyboardEvent(event) {
return typeof event === 'object' && 'keyCode' in event;
}

function getIsDarkMode() {
return getUiSettings().get('theme:darkMode', false);
}

export class IconSelect extends Component {
state = {
isPopoverOpen: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@

jest.mock('../../../../../kibana_services', () => {
return {
getUiSettings() {
return {
get(key) {
if (key === 'theme:darkMode') {
return false;
}
throw new Error(`Unexpected ui settings key: ${key}`);
},
};
getIsDarkMode() {
return false;
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { getFirstUnusedSymbol } from './icon_stops';

jest.mock('./icon_select', () => ({
IconSelect: () => {
return <div>mockIconSelect</div>;
Expand All @@ -29,9 +32,6 @@ jest.mock('../../symbol_utils', () => {
};
});

import React from 'react';
import { getFirstUnusedSymbol } from './icon_stops';

describe('getFirstUnusedSymbol', () => {
test('Should return first unused icon from PREFERRED_ICONS', () => {
const iconStops = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import maki from '@elastic/maki';
import xml2js from 'xml2js';
import { parseXmlString } from '../../../../common/parse_xml_string';
import { SymbolIcon } from './components/legend/symbol_icon';
import { getUiSettings } from '../../../kibana_services';
import { getIsDarkMode } from '../../../kibana_services';

export const LARGE_MAKI_ICON_SIZE = 15;
const LARGE_MAKI_ICON_SIZE_AS_STRING = LARGE_MAKI_ICON_SIZE.toString();
Expand Down Expand Up @@ -113,7 +113,7 @@ ICON_PALETTES.forEach((iconPalette) => {
});

export function getIconPaletteOptions() {
const isDarkMode = getUiSettings().get('theme:darkMode', false);
const isDarkMode = getIsDarkMode();
return ICON_PALETTES.map(({ id, icons }) => {
const iconsDisplay = icons.map((iconId) => {
const style = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
*/

jest.mock('../../../kibana_services', () => {
const mockUiSettings = {
get: () => {
return undefined;
},
};
return {
getUiSettings: () => {
return mockUiSettings;
getIsDarkMode() {
return false;
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {
CATEGORICAL_COLOR_PALETTES,
} from '../color_palettes';
import { VectorStylePropertiesDescriptor } from '../../../../common/descriptor_types';
// @ts-ignore
import { getUiSettings } from '../../../kibana_services';
import { getIsDarkMode } from '../../../kibana_services';

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

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

return {
[VECTOR_STYLES.ICON]: {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/kibana_services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function getVisualizations(): any;
export function getDocLinks(): any;
export function getCoreChrome(): any;
export function getUiSettings(): any;
export function getIsDarkMode(): boolean;
export function getCoreOverlays(): any;
export function getData(): any;
export function getUiActions(): any;
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/maps/public/kibana_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const getFileUploadComponent = () => {
let uiSettings;
export const setUiSettings = (coreUiSettings) => (uiSettings = coreUiSettings);
export const getUiSettings = () => uiSettings;
export const getIsDarkMode = () => {
return getUiSettings().get('theme:darkMode', false);
};

let indexPatternSelectComponent;
export const setIndexPatternSelect = (indexPatternSelect) =>
Expand Down

0 comments on commit 84f2cb0

Please sign in to comment.