Skip to content

Commit

Permalink
Merge branch 'main' into disable-java-attacher-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Jan 4, 2022
2 parents f629517 + 649853d commit e0e0fcc
Show file tree
Hide file tree
Showing 66 changed files with 770 additions and 47,148 deletions.
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Kibana source code with Kibana X-Pack source code
Copyright 2012-2021 Elasticsearch B.V.
Copyright 2012-2022 Elasticsearch B.V.

---
Pretty handling of logarithmic axes.
Expand Down
2 changes: 1 addition & 1 deletion src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const storybookAliases = {
expression_shape: 'src/plugins/expression_shape/.storybook',
expression_tagcloud: 'src/plugins/chart_expressions/expression_tagcloud/.storybook',
expression_metric_vis: 'src/plugins/chart_expressions/expression_metric/.storybook',
fleet: 'x-pack/plugins/fleet/storybook',
fleet: 'x-pack/plugins/fleet/.storybook',
infra: 'x-pack/plugins/infra/.storybook',
security_solution: 'x-pack/plugins/security_solution/.storybook',
ui_actions_enhanced: 'x-pack/plugins/ui_actions_enhanced/.storybook',
Expand Down
14 changes: 10 additions & 4 deletions src/plugins/kibana_react/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
* Side Public License, v 1.
*/

// TODO: https://github.com/elastic/kibana/issues/109898
/* eslint-disable @kbn/eslint/no_export_all */

export * from './eui_styled_components';
export type { EuiTheme } from './eui_styled_components';
export {
EuiThemeProviderDecorator,
css,
euiStyled,
EuiThemeProvider,
createGlobalStyle,
keyframes,
withTheme,
} from './eui_styled_components';
82 changes: 67 additions & 15 deletions src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,80 @@
* Side Public License, v 1.
*/

// TODO: https://github.com/elastic/kibana/issues/109898
/* eslint-disable @kbn/eslint/no_export_all */

export * from './code_editor';
export * from './url_template_editor';
export * from './exit_full_screen_button';
export * from './context';
export * from './overview_page';
export * from './overlays';
export * from './ui_settings';
export * from './table_list_view';
export * from './toolbar_button';
export * from './react_router_navigate';
export * from './page_template';
export type { CodeEditorProps } from './code_editor';
export {
CssLang,
MarkdownLang,
YamlLang,
HandlebarsLang,
HJsonLang,
CodeEditor,
CodeEditorField,
} from './code_editor';

export type { UrlTemplateEditorVariable, UrlTemplateEditorProps } from './url_template_editor';
export { UrlTemplateEditor } from './url_template_editor';

export type { ExitFullScreenButtonProps } from './exit_full_screen_button';
export { ExitFullScreenButton } from './exit_full_screen_button';

export type { KibanaReactContext, KibanaReactContextValue, KibanaServices } from './context';
export {
context,
createKibanaReactContext,
KibanaContextProvider,
useKibana,
withKibana,
} from './context';

export { overviewPageActions, OverviewPageFooter } from './overview_page';

export type { KibanaReactOverlays } from './overlays';
export { createReactOverlays } from './overlays';

export { useUiSetting, useUiSetting$ } from './ui_settings';

export type { TableListViewProps, TableListViewState } from './table_list_view';
export { TableListView } from './table_list_view';

export type { ToolbarButtonProps } from './toolbar_button';
export { POSITIONS, WEIGHTS, TOOLBAR_BUTTON_SIZES, ToolbarButton } from './toolbar_button';

export { reactRouterNavigate, reactRouterOnClickHandler } from './react_router_navigate';

export type {
KibanaPageTemplateProps,
NoDataPageActions,
NoDataPageActionsProps,
NoDataPageProps,
ElasticAgentCardProps,
} from './page_template';
export {
KibanaPageTemplate,
KibanaPageTemplateSolutionNavAvatar,
NO_DATA_PAGE_MAX_WIDTH,
NO_DATA_PAGE_TEMPLATE_PROPS,
NO_DATA_RECOMMENDED,
NoDataPage,
ElasticAgentCard,
NoDataCard,
} from './page_template';

export type { Value } from './validated_range';
export { ValidatedDualRange } from './validated_range';
export * from './notifications';

export type { ToastInput, KibanaReactNotifications } from './notifications';
export { createNotifications } from './notifications';

export { Markdown, MarkdownSimple } from './markdown';

export { reactToUiComponent, uiToReactComponent } from './adapters';

export { toMountPoint, MountPointPortal } from './util';
export type { ToMountPointOptions } from './util';

export { RedirectAppLinks } from './app_links';

export { wrapWithTheme, KibanaThemeProvider } from './theme';

/** dummy plugin, we just want kibanaReact to have its own bundle */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('isCompatible', () => {
uiActionsEnhanced.getActionFactories.mockImplementation(() => [
{
supportedTriggers: () => actionFactoriesTriggers,
isCompatibleLicense: () => true,
} as unknown as UiActionsEnhancedActionFactory,
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ export class FlyoutCreateDrilldownAction implements Action<EmbeddableContext> {
return 'plusInCircle';
}

private isEmbeddableCompatible(context: EmbeddableContext) {
private isEmbeddableCompatible(context: EmbeddableContext): boolean {
if (!isEnhancedEmbeddable(context.embeddable)) return false;
const supportedTriggers = context.embeddable.supportedTriggers();
if (!supportedTriggers || !supportedTriggers.length) return false;
if (context.embeddable.getRoot().type !== 'dashboard') return false;
const supportedTriggers = [
CONTEXT_MENU_TRIGGER,
...(context.embeddable.supportedTriggers() || []),
];

/**
* Check if there is an intersection between all registered drilldowns possible triggers that they could be attached to
Expand All @@ -61,7 +63,7 @@ export class FlyoutCreateDrilldownAction implements Action<EmbeddableContext> {
const allPossibleTriggers = this.params
.start()
.plugins.uiActionsEnhanced.getActionFactories()
.map((factory) => factory.supportedTriggers())
.map((factory) => (factory.isCompatibleLicense() ? factory.supportedTriggers() : []))
.reduce((res, next) => res.concat(next), []);

return ensureNestedTriggers(supportedTriggers).some((trigger) =>
Expand Down Expand Up @@ -90,13 +92,17 @@ export class FlyoutCreateDrilldownAction implements Action<EmbeddableContext> {
closed$.next(true);
handle.close();
};
const triggers = [
...ensureNestedTriggers(embeddable.supportedTriggers()),
CONTEXT_MENU_TRIGGER,
];
const handle = core.overlays.openFlyout(
toMountPoint(
<plugins.uiActionsEnhanced.DrilldownManager
closeAfterCreate
initialRoute={'/new'}
dynamicActionManager={embeddable.enhancements.dynamicActions}
triggers={[...ensureNestedTriggers(embeddable.supportedTriggers()), CONTEXT_MENU_TRIGGER]}
triggers={triggers}
placeContext={{ embeddable }}
templates={templates}
onClose={close}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
* 2.0.
*/

import { defaultConfigWebFinal } from '@kbn/storybook';
import { defaultConfig } from '@kbn/storybook';

module.exports = {
...defaultConfigWebFinal,
addons: ['@storybook/addon-essentials'],
babel: () => ({
presets: [require.resolve('@kbn/babel-preset/webpack_preset')],
}),
};
module.exports = defaultConfig;
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
},
"include": [
// add all the folders containg files to be compiled
".storybook/**/*",
"common/**/*",
"public/**/*",
"server/**/*",
"server/**/*.json",
"scripts/**/*",
"package.json",
"storybook/**/*",
"../../../typings/**/*"
],
"references": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type TestSubjects =
| 'deleteTemplatesConfirmation'
| 'documentationLink'
| 'emptyPrompt'
| 'forcemergeIndexMenuButton'
| 'filterList.filterItem'
| 'ilmPolicyLink'
| 'includeStatsSwitch'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IndicesTestBed extends TestBed<TestSubjects> {
clickDataStreamAt: (index: number) => void;
clickManageContextMenuButton: () => void;
clickContextMenuOption: (optionDataTestSubject: string) => void;
clickModalConfirm: () => void;
};
findDataStreamDetailPanel: () => ReactWrapper;
findDataStreamDetailPanelTitle: () => string;
Expand Down Expand Up @@ -97,6 +98,15 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
component.update();
};

const clickModalConfirm = async () => {
const { find, component } = testBed;

await act(async () => {
find('confirmModalConfirmButton').simulate('click');
});
component.update();
};

const findDataStreamDetailPanel = () => {
const { find } = testBed;
return find('dataStreamDetailPanel');
Expand All @@ -116,6 +126,7 @@ export const setup = async (overridingDependencies: any = {}): Promise<IndicesTe
clickDataStreamAt,
clickManageContextMenuButton,
clickContextMenuOption,
clickModalConfirm,
},
findDataStreamDetailPanel,
findDataStreamDetailPanelTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('<IndexManagementHome />', () => {

test("should be able to clear an index's cache", async () => {
const { actions } = testBed;
actions.clickManageContextMenuButton();
await actions.clickManageContextMenuButton();

await actions.clickManageContextMenuButton();
await actions.clickContextMenuOption('clearCacheIndexMenuButton');
Expand Down Expand Up @@ -291,6 +291,26 @@ describe('<IndexManagementHome />', () => {
// The unfreeze action should not be present anymore
expect(exists('unfreezeIndexMenuButton')).toBe(false);
});

test('should be able to force merge an index', async () => {
const { actions, exists } = testBed;

httpRequestsMockHelpers.setReloadIndicesResponse([{ ...indexMockA, isFrozen: false }]);

// Open context menu
await actions.clickManageContextMenuButton();
// Check that the force merge action exists for the current index and merge it
expect(exists('forcemergeIndexMenuButton')).toBe(true);
await actions.clickContextMenuOption('forcemergeIndexMenuButton');

await actions.clickModalConfirm();

const requestsCount = server.requests.length;
expect(server.requests[requestsCount - 2].url).toBe(`${API_BASE_PATH}/indices/forcemerge`);
// After the index is force merged, we immediately do a reload. So we need to expect to see
// a reload server call also.
expect(server.requests[requestsCount - 1].url).toBe(`${API_BASE_PATH}/indices/reload`);
});
});

describe('Edit index settings', () => {
Expand Down
16 changes: 10 additions & 6 deletions x-pack/plugins/monitoring/common/types/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface ElasticsearchSourceKibanaStats {
};
transport_address?: string;
host?: string;
version?: string;
};
os?: {
memory?: {
Expand Down Expand Up @@ -416,7 +417,9 @@ export interface ElasticsearchMetricbeatNode {
export interface ElasticsearchMetricbeatSource {
'@timestamp'?: string;
service?: {
id?: string;
address?: string;
version?: string;
};
elasticsearch?: {
node?: ElasticsearchLegacySource['source_node'] & ElasticsearchMetricbeatNode;
Expand Down Expand Up @@ -534,15 +537,16 @@ export interface ElasticsearchMetricbeatSource {
};
};
kibana?: {
kibana?: {
transport_address?: string;
stats?: {
name?: string;
host?: string;
uuid?: string;
index?: string;
status?: string;
};
stats?: {
transport_address?: string;
concurrent_connections?: number;
snapshot?: boolean;
host?: {
name?: string;
};
process?: {
uptime?: {
ms?: number;
Expand Down
35 changes: 35 additions & 0 deletions x-pack/plugins/monitoring/server/lib/kibana/build_kibana_info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ElasticsearchResponseHit } from '../../../common/types/es';

export interface KibanaInfo {
transport_address?: string;
name?: string;
index?: string;
host?: string;
uuid?: string;
status?: string;
snapshot?: boolean;
version?: string;
}

export const buildKibanaInfo = (hit: ElasticsearchResponseHit): KibanaInfo => {
const source = hit._source;
if (source.kibana_stats) return source.kibana_stats.kibana as KibanaInfo;

return {
name: source.kibana?.stats?.name,
host: source.kibana?.stats?.host?.name,
status: source.kibana?.stats?.status,
transport_address: source.kibana?.stats?.transport_address,
uuid: source.service?.id,
snapshot: source.kibana?.stats?.snapshot,
index: source.kibana?.stats?.index,
version: source.service?.version,
};
};
Loading

0 comments on commit e0e0fcc

Please sign in to comment.