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

add KibanaThemeProvider support for kibana-app-services #122370

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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

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

Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export const DashboardListing = ({
listingLimit,
tableColumns,
}}
theme={core.theme}
>
<DashboardUnsavedListing
redirectTo={redirectTo}
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/data/public/actions/apply_filter_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { i18n } from '@kbn/i18n';
import { toMountPoint } from '../../../kibana_react/public';
import { Action, createAction, IncompatibleActionError } from '../../../ui_actions/public';
import { getOverlays, getIndexPatterns } from '../services';
import { getOverlays, getTheme, getIndexPatterns } from '../services';
import { applyFiltersPopover } from '../ui/apply_filters';
import { Filter, FilterManager, TimefilterContract, esFilters } from '..';

Expand Down Expand Up @@ -77,7 +77,8 @@ export function createFilterAction(
overlay.close();
resolve(filterSelection);
}
)
),
{ theme$: getTheme().theme$ }
),
{
'data-test-subj': 'test',
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
setNotifications,
setOverlays,
setSearchService,
setTheme,
setUiSettings,
} from './services';
import { createSearchBar } from './ui/search_bar/create_search_bar';
Expand Down Expand Up @@ -82,6 +83,7 @@ export class DataPublicPlugin
const startServices = createStartServicesGetter(core.getStartServices);

this.usageCollection = usageCollection;
setTheme(core.theme);

const searchService = this.searchService.setup(core, {
bfetch,
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/data/public/search/fetch/handle_response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EuiSpacer } from '@elastic/eui';
import { IKibanaSearchResponse } from 'src/plugins/data/common';
import { ShardFailureOpenModalButton } from '../../ui/shard_failure_modal';
import { toMountPoint } from '../../../../kibana_react/public';
import { getNotifications } from '../../services';
import { getNotifications, getTheme } from '../../services';
import type { SearchRequest } from '..';

export function handleResponse(request: SearchRequest, response: IKibanaSearchResponse) {
Expand Down Expand Up @@ -46,7 +46,8 @@ export function handleResponse(request: SearchRequest, response: IKibanaSearchRe
{description}
<EuiSpacer size="s" />
<ShardFailureOpenModalButton request={request.body} response={rawResponse} title={title} />
</>
</>,
{ theme$: getTheme().theme$ }
);

getNotifications().toasts.addWarning({ title, text });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { ISessionService, SearchSessionState } from '../session';
import { SearchResponseCache } from './search_response_cache';
import { createRequestHash } from './utils';
import { SearchAbortController } from './search_abort_controller';
import { getTheme } from '../../services';

export interface SearchInterceptorDeps {
bfetch: BfetchPublicSetup;
Expand Down Expand Up @@ -377,7 +378,7 @@ export class SearchInterceptor {
private showTimeoutErrorToast = (e: SearchTimeoutError, sessionId?: string) => {
this.deps.toasts.addDanger({
title: 'Timed out',
text: toMountPoint(e.getErrorMessage(this.application)),
text: toMountPoint(e.getErrorMessage(this.application), { theme$: getTheme().theme$ }),
});
};

Expand All @@ -392,7 +393,9 @@ export class SearchInterceptor {
this.deps.toasts.addWarning(
{
title: 'Your search session is still running',
text: toMountPoint(SearchSessionIncompleteWarning(this.docLinks)),
text: toMountPoint(SearchSessionIncompleteWarning(this.docLinks), {
theme$: getTheme().theme$,
}),
},
{
toastLifeTimeMs: 60000,
Expand Down Expand Up @@ -423,14 +426,14 @@ export class SearchInterceptor {
title: i18n.translate('data.search.esErrorTitle', {
defaultMessage: 'Cannot retrieve search results',
}),
text: toMountPoint(e.getErrorMessage(this.application)),
text: toMountPoint(e.getErrorMessage(this.application), { theme$: getTheme().theme$ }),
});
} else if (e.constructor.name === 'HttpFetchError') {
this.deps.toasts.addDanger({
title: i18n.translate('data.search.httpErrorTitle', {
defaultMessage: 'Cannot retrieve your data',
}),
text: toMountPoint(getHttpError(e.message)),
text: toMountPoint(getHttpError(e.message), { theme$: getTheme().theme$ }),
});
} else {
this.deps.toasts.addError(e, {
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { NotificationsStart, CoreStart } from 'src/core/public';
import { NotificationsStart, CoreStart, ThemeServiceStart } from 'src/core/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { IndexPatternsContract } from './data_views';
import { DataPublicPluginStart } from './types';
Expand All @@ -24,3 +24,5 @@ export const [getIndexPatterns, setIndexPatterns] =

export const [getSearchService, setSearchService] =
createGetterSetter<DataPublicPluginStart['search']>('Search');

export const [getTheme, setTheme] = createGetterSetter<ThemeServiceStart>('Theme');
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import type { PersistedLog } from '../../query';
import type { SuggestionsListSize } from '../typeahead/suggestions_component';
import { SuggestionsComponent } from '..';
import { KIBANA_USER_QUERY_LANGUAGE_KEY, getFieldSubtypeNested } from '../../../common';
import { getTheme } from '../../services';

export interface QueryStringInputProps {
indexPatterns: Array<IIndexPattern | string>;
Expand Down Expand Up @@ -475,7 +476,8 @@ export default class QueryStringInputUI extends Component<Props, State> {
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</div>
</div>,
{ theme$: getTheme().theme$ }
),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { EuiButton, EuiTextAlign } from '@elastic/eui';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { getOverlays } from '../../services';
import { getOverlays, getTheme } from '../../services';
import { toMountPoint } from '../../../../kibana_react/public';
import { ShardFailureModal } from './shard_failure_modal';
import { ShardFailureRequest } from './shard_failure_types';
Expand All @@ -38,7 +38,8 @@ export default function ShardFailureOpenModalButton({
response={response}
title={title}
onClose={() => modal.close()}
/>
/>,
{ theme$: getTheme().theme$ }
),
{
className: 'shardFailureModal',
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data_view_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export const getEditorOpener =
requireTimestampField={requireTimestampField}
/>
</I18nProvider>
</KibanaReactContextProvider>
</KibanaReactContextProvider>,
{ theme$: core.theme.theme$ }
),
{
hideCloseButton: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export const getFieldDeleteModalOpener =
fieldsToDelete={fieldsToDelete}
closeModal={closeModal}
confirmDelete={onConfirmDelete}
/>
/>,
{ theme$: core.theme.theme$ }
)
);

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data_view_field_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export const getFieldEditorOpener =
fieldFormats={fieldFormats}
uiSettings={uiSettings}
/>
</KibanaReactContextProvider>
</KibanaReactContextProvider>,
{ theme$: core.theme.theme$ }
),
{
className: euiFlyoutClassname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { toMountPoint } from '../../../../../../../kibana_react/public';

import { IIndexPattern } from '../../../../../../../data/public';
import { IndexedFieldItem } from '../../types';
import { getTheme } from '../../../../../';

// localized labels
const additionalInfoAriaLabel = i18n.translate(
Expand Down Expand Up @@ -322,7 +323,8 @@ const getConflictBtn = (
},
fieldName,
conflictDescriptions,
})
}),
{ theme$: getTheme().theme$ }
)
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/data_view_management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
* in the setup/start interfaces in `plugin.ts`. The remaining items exported here are
* either types, or static code.
*/
import { PluginInitializerContext } from 'src/core/public';
import { PluginInitializerContext, ThemeServiceStart } from 'src/core/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { IndexPatternManagementPlugin } from './plugin';
export type { IndexPatternManagementSetup, IndexPatternManagementStart } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
return new IndexPatternManagementPlugin(initializerContext);
}

export const [getTheme, setTheme] = createGetterSetter<ThemeServiceStart>('Theme');
shivindera marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n-react';
import { StartServicesAccessor } from 'src/core/public';

import { KibanaContextProvider } from '../../../kibana_react/public';
import { KibanaContextProvider, KibanaThemeProvider } from '../../../kibana_react/public';
import { ManagementAppMountParams } from '../../../management/public';
import {
IndexPatternTableWithRouter,
Expand Down Expand Up @@ -67,25 +67,27 @@ export async function mountManagementSection(

ReactDOM.render(
<KibanaContextProvider services={deps}>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<IndexPatternTableWithRouter canSave={canSave} showCreateDialog={true} />
</Route>
<Route path={['/dataView/:id/field/:fieldName', '/dataView/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/dataView/:id']}>
<EditIndexPatternContainer />
</Route>
<Redirect path={'/patterns*'} to={'dataView*'} />
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Switch>
</Router>
</I18nProvider>
<KibanaThemeProvider theme$={params.theme$}>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<IndexPatternTableWithRouter canSave={canSave} showCreateDialog={true} />
</Route>
<Route path={['/dataView/:id/field/:fieldName', '/dataView/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/dataView/:id']}>
<EditIndexPatternContainer />
</Route>
<Redirect path={'/patterns*'} to={'dataView*'} />
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Switch>
</Router>
</I18nProvider>
</KibanaThemeProvider>
</KibanaContextProvider>,
params.element
);
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UrlForwardingSetup } from '../../url_forwarding/public';
import { ManagementSetup } from '../../management/public';
import { IndexPatternFieldEditorStart } from '../../data_view_field_editor/public';
import { DataViewEditorStart } from '../../data_view_editor/public';
import { setTheme } from '.';

export interface IndexPatternManagementSetupDependencies {
management: ManagementSetup;
Expand Down Expand Up @@ -54,6 +55,7 @@ export class IndexPatternManagementPlugin
{ management, urlForwarding }: IndexPatternManagementSetupDependencies
) {
const kibanaSection = management.sections.section.kibana;
setTheme(core.theme);

if (!kibanaSection) {
throw new Error('`kibana` management section not found.');
Expand Down
Loading