88
99import _ from 'lodash' ;
1010import { History } from 'history' ;
11- import { NotificationsStart } from 'kibana/public' ;
11+ import { NotificationsStart , IUiSettingsClient } from 'kibana/public' ;
1212import {
1313 createStateContainer ,
1414 createKbnUrlStateStorage ,
@@ -17,6 +17,7 @@ import {
1717 withNotifyOnErrors ,
1818} from '../../../../kibana_utils/public' ;
1919import { esFilters , FilterManager , Filter , Query } from '../../../../data/public' ;
20+ import { handleSourceColumnState } from './helpers' ;
2021
2122export interface AppState {
2223 /**
@@ -73,6 +74,11 @@ interface GetStateParams {
7374 * kbnUrlStateStorage will use it notifying about inner errors
7475 */
7576 toasts ?: NotificationsStart [ 'toasts' ] ;
77+
78+ /**
79+ * core ui settings service
80+ */
81+ uiSettings : IUiSettingsClient ;
7682}
7783
7884interface GetStateReturn {
@@ -123,6 +129,7 @@ export function getState({
123129 storeInSessionStorage = false ,
124130 history,
125131 toasts,
132+ uiSettings,
126133} : GetStateParams ) : GetStateReturn {
127134 const stateStorage = createKbnUrlStateStorage ( {
128135 useHash : storeInSessionStorage ,
@@ -134,7 +141,12 @@ export function getState({
134141 const globalStateContainer = createStateContainer < GlobalState > ( globalStateInitial ) ;
135142
136143 const appStateFromUrl = stateStorage . get ( APP_STATE_URL_KEY ) as AppState ;
137- const appStateInitial = createInitialAppState ( defaultStepSize , timeFieldName , appStateFromUrl ) ;
144+ const appStateInitial = createInitialAppState (
145+ defaultStepSize ,
146+ timeFieldName ,
147+ appStateFromUrl ,
148+ uiSettings
149+ ) ;
138150 const appStateContainer = createStateContainer < AppState > ( appStateInitial ) ;
139151
140152 const { start, stop } = syncStates ( [
@@ -257,7 +269,8 @@ function getFilters(state: AppState | GlobalState): Filter[] {
257269function createInitialAppState (
258270 defaultSize : string ,
259271 timeFieldName : string ,
260- urlState : AppState
272+ urlState : AppState ,
273+ uiSettings : IUiSettingsClient
261274) : AppState {
262275 const defaultState = {
263276 columns : [ '_source' ] ,
@@ -270,8 +283,11 @@ function createInitialAppState(
270283 return defaultState ;
271284 }
272285
273- return {
274- ...defaultState ,
275- ...urlState ,
276- } ;
286+ return handleSourceColumnState (
287+ {
288+ ...defaultState ,
289+ ...urlState ,
290+ } ,
291+ uiSettings
292+ ) ;
277293}
0 commit comments