Skip to content

Commit

Permalink
Merge branch 'main' of github.com:elastic/kibana into implement/plugi…
Browse files Browse the repository at this point in the history
…n-discovery-package
  • Loading branch information
spalger committed Mar 29, 2022
2 parents c34f231 + ecd2a50 commit 233f300
Show file tree
Hide file tree
Showing 181 changed files with 10,818 additions and 640 deletions.
17 changes: 17 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
dataStreams: `${ELASTICSEARCH_DOCS}data-streams.html`,
deprecationLogging: `${ELASTICSEARCH_DOCS}logging.html#deprecation-logging`,
frozenIndices: `${ELASTICSEARCH_DOCS}frozen-indices.html`,
gettingStarted: `${ELASTICSEARCH_DOCS}getting-started.html`,
hiddenIndices: `${ELASTICSEARCH_DOCS}multi-index.html#hidden`,
ilm: `${ELASTICSEARCH_DOCS}index-lifecycle-management.html`,
ilmForceMerge: `${ELASTICSEARCH_DOCS}ilm-forcemerge.html`,
Expand Down Expand Up @@ -598,15 +599,31 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
clients: {
/** Changes to these URLs must also be synched in src/plugins/custom_integrations/server/language_clients/index.ts */
guide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/index.html`,
goIndex: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/go-api/${DOC_LINK_VERSION}/index.html`,
goOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/go-api/${DOC_LINK_VERSION}/overview.html`,
javaBasicAuthentication: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/java-api-client/${DOC_LINK_VERSION}/_basic_authentication.html`,
javaIndex: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/java-api-client/${DOC_LINK_VERSION}/index.html`,
javaInstallation: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/java-api-client/${DOC_LINK_VERSION}/installation.html`,
javaIntroduction: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/java-api-client/${DOC_LINK_VERSION}/introduction.html`,
javaRestLow: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/java-api-client/${DOC_LINK_VERSION}/java-rest-low.html`,
jsClientConnecting: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/javascript-api/${DOC_LINK_VERSION}/client-connecting.html`,
jsIntro: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/javascript-api/${DOC_LINK_VERSION}/introduction.html`,
netGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/net-api/${DOC_LINK_VERSION}/index.html`,
netIntroduction: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/net-api/${DOC_LINK_VERSION}/introduction.html`,
netNest: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/net-api/${DOC_LINK_VERSION}/nest.html`,
netSingleNode: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/net-api/${DOC_LINK_VERSION}/connecting.html#single-node`,
perlGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/perl-api/${DOC_LINK_VERSION}/index.html`,
phpConnecting: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/php-api/${DOC_LINK_VERSION}/connecting.html`,
phpInstallation: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/php-api/${DOC_LINK_VERSION}/installation.html`,
phpGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/php-api/${DOC_LINK_VERSION}/index.html`,
phpOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/php-api/${DOC_LINK_VERSION}/overview.html`,
pythonAuthentication: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/python-api/${DOC_LINK_VERSION}/connecting.html#authentication`,
pythonGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/python-api/${DOC_LINK_VERSION}/index.html`,
pythonOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/python-api/${DOC_LINK_VERSION}/overview.html`,
rubyAuthentication: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/ruby-api/${DOC_LINK_VERSION}/connecting.html#client-auth`,
rubyOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/ruby-api/${DOC_LINK_VERSION}/ruby_client.html`,
rustGuide: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/rust-api/${DOC_LINK_VERSION}/index.html`,
rustOverview: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/client/rust-api/${DOC_LINK_VERSION}/overview.html`,
},
endpoints: {
troubleshooting: `${ELASTIC_WEBSITE_URL}guide/en/security/${DOC_LINK_VERSION}/ts-management.html#ts-endpoints`,
Expand Down
16 changes: 16 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,31 @@ export interface DocLinks {
};
readonly clients: {
readonly guide: string;
readonly goIndex: string;
readonly goOverview: string;
readonly javaBasicAuthentication: string;
readonly javaIndex: string;
readonly javaInstallation: string;
readonly javaIntroduction: string;
readonly javaRestLow: string;
readonly jsClientConnecting: string;
readonly jsIntro: string;
readonly netGuide: string;
readonly netIntroduction: string;
readonly netNest: string;
readonly netSingleNode: string;
readonly perlGuide: string;
readonly phpGuide: string;
readonly phpConnecting: string;
readonly phpInstallation: string;
readonly phpOverview: string;
readonly pythonAuthentication: string;
readonly pythonGuide: string;
readonly pythonOverview: string;
readonly rubyAuthentication: string;
readonly rubyOverview: string;
readonly rustGuide: string;
readonly rustOverview: string;
};
readonly endpoints: {
readonly troubleshooting: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pageLoadAssetSize:
telemetry: 51957
telemetryManagementSection: 38586
transform: 41007
triggersActionsUi: 100000
triggersActionsUi: 102400
upgradeAssistant: 81241
uptime: 40825
urlForwarding: 32579
Expand Down
12 changes: 12 additions & 0 deletions packages/kbn-securitysolution-rules/src/configuration_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

/**
* Max number of execution events to aggregate in memory for the Rule Execution Log
*/
export const MAX_EXECUTION_EVENTS_DISPLAYED = 1000 as const;
1 change: 1 addition & 0 deletions packages/kbn-securitysolution-rules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

export * from './configuration_constants';
export * from './rule_type_constants';
export * from './rule_type_mappings';
export * from './utils';
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import {
EmbeddableStateWithType,
EmbeddablePersistableStateService,
} from '../../../../embeddable/common';
import { RangeSliderEmbeddableInput } from './types';
import { SavedObjectReference } from '../../../../../core/types';
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../../../data_views/common';

type RangeSliderInputWithType = Partial<RangeSliderEmbeddableInput> & { type: string };
const dataViewReferenceName = 'optionsListDataView';

export const createRangeSliderInject = (): EmbeddablePersistableStateService['inject'] => {
return (state: EmbeddableStateWithType, references: SavedObjectReference[]) => {
const workingState = { ...state } as EmbeddableStateWithType | RangeSliderInputWithType;
references.forEach((reference) => {
if (reference.name === dataViewReferenceName) {
(workingState as RangeSliderInputWithType).dataViewId = reference.id;
}
});
return workingState as EmbeddableStateWithType;
};
};

export const createRangeSliderExtract = (): EmbeddablePersistableStateService['extract'] => {
return (state: EmbeddableStateWithType) => {
const workingState = { ...state } as EmbeddableStateWithType | RangeSliderInputWithType;
const references: SavedObjectReference[] = [];

if ('dataViewId' in workingState) {
references.push({
name: dataViewReferenceName,
type: DATA_VIEW_SAVED_OBJECT_TYPE,
id: workingState.dataViewId!,
});
delete workingState.dataViewId;
}
return { state: workingState as EmbeddableStateWithType, references };
};
};
19 changes: 19 additions & 0 deletions src/plugins/controls/common/control_types/range_slider/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { ControlInput } from '../../types';

export const RANGE_SLIDER_CONTROL = 'rangeSliderControl';

export type RangeValue = [string, string];

export interface RangeSliderEmbeddableInput extends ControlInput {
fieldName: string;
dataViewId: string;
value: RangeValue;
}
7 changes: 5 additions & 2 deletions src/plugins/controls/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
* Side Public License, v 1.
*/

export type { ControlWidth } from './types';
export type { ControlPanelState, ControlsPanels, ControlGroupInput } from './control_group/types';
export type { OptionsListEmbeddableInput } from './control_types/options_list/types';
export type { ControlWidth } from './types';
export type { RangeSliderEmbeddableInput } from './control_types/range_slider/types';

export { OPTIONS_LIST_CONTROL } from './control_types/options_list/types';
export { CONTROL_GROUP_TYPE } from './control_group/types';
export { OPTIONS_LIST_CONTROL } from './control_types/options_list/types';
export { RANGE_SLIDER_CONTROL } from './control_types/range_slider/types';

export { getDefaultControlGroupInput } from './control_group/control_group_constants';
61 changes: 61 additions & 0 deletions src/plugins/controls/public/__stories__/controls.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
import {
ControlGroupContainerFactory,
OptionsListEmbeddableInput,
RangeSliderEmbeddableInput,
OPTIONS_LIST_CONTROL,
RANGE_SLIDER_CONTROL,
} from '../';

import { ViewMode } from '../../../embeddable/public';
Expand Down Expand Up @@ -169,6 +171,65 @@ export const ConfiguredControlGroupStory = () => (
fieldName: 'Carrier',
} as OptionsListEmbeddableInput,
},
rangeSlider1: {
type: RANGE_SLIDER_CONTROL,
order: 4,
width: 'auto',
explicitInput: {
id: 'rangeSlider1',
title: 'Average ticket price',
dataViewId: 'demoDataFlights',
fieldName: 'AvgTicketPrice',
value: ['4', '12'],
step: 2,
} as RangeSliderEmbeddableInput,
},
}}
/>
);

export const RangeSliderControlGroupStory = () => (
<ControlGroupStoryComponent
panels={{
rangeSlider1: {
type: RANGE_SLIDER_CONTROL,
order: 1,
width: 'auto',
explicitInput: {
id: 'rangeSlider1',
title: 'Average ticket price',
dataViewId: 'demoDataFlights',
fieldName: 'AvgTicketPrice',
value: ['4', '12'],
step: 2,
} as RangeSliderEmbeddableInput,
},
rangeSlider2: {
type: RANGE_SLIDER_CONTROL,
order: 2,
width: 'auto',
explicitInput: {
id: 'rangeSlider2',
title: 'Total distance in miles',
dataViewId: 'demoDataFlights',
fieldName: 'DistanceMiles',
value: ['0', '100'],
step: 10,
} as RangeSliderEmbeddableInput,
},
rangeSlider3: {
type: RANGE_SLIDER_CONTROL,
order: 3,
width: 'auto',
explicitInput: {
id: 'rangeSlider3',
title: 'Flight duration in hour',
dataViewId: 'demoDataFlight',
fieldName: 'FlightTimeHour',
value: ['30', '600'],
step: 30,
} as RangeSliderEmbeddableInput,
},
}}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { OptionsListEmbeddableFactory } from '../control_types/options_list';
import { RangeSliderEmbeddableFactory } from '../control_types/range_slider';
import { ControlsService } from '../services/controls';
import { ControlFactory } from '..';

Expand All @@ -17,4 +18,11 @@ export const populateStorybookControlFactories = (controlsServiceStub: ControlsS
const optionsListControlFactory = optionsListFactoryStub as unknown as ControlFactory;
optionsListControlFactory.getDefaultInput = () => ({});
controlsServiceStub.registerControlType(optionsListControlFactory);

const rangeSliderFactoryStub = new RangeSliderEmbeddableFactory();

// cast to unknown because the stub cannot use the embeddable start contract to transform the EmbeddableFactoryDefinition into an EmbeddableFactory
const rangeSliderControlFactory = rangeSliderFactoryStub as unknown as ControlFactory;
rangeSliderControlFactory.getDefaultInput = () => ({});
controlsServiceStub.registerControlType(rangeSliderControlFactory);
};
1 change: 1 addition & 0 deletions src/plugins/controls/public/control_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*/

export * from './options_list';
export * from './range_slider';
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export const OptionsListStrings = {
}),
},
editor: {
getIndexPatternTitle: () =>
i18n.translate('controls.optionsList.editor.indexPatternTitle', {
defaultMessage: 'Index pattern',
}),
getDataViewTitle: () =>
i18n.translate('controls.optionsList.editor.dataViewTitle', {
defaultMessage: 'Data view',
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/controls/public/control_types/range_slider/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export { RANGE_SLIDER_CONTROL } from '../../../common/control_types/range_slider/types';
export { RangeSliderEmbeddableFactory } from './range_slider_embeddable_factory';

export type { RangeSliderEmbeddable } from './range_slider_embeddable';
export type { RangeSliderEmbeddableInput } from '../../../common/control_types/range_slider/types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React, { FC, useCallback, useState } from 'react';
import { BehaviorSubject } from 'rxjs';

import { DataViewField } from '../../../../data_views/public';
import { useReduxEmbeddableContext } from '../../../../presentation_util/public';
import { useStateObservable } from '../../hooks/use_state_observable';
import { RangeSliderPopover } from './range_slider_popover';
import { rangeSliderReducers } from './range_slider_reducers';
import { RangeSliderEmbeddableInput, RangeValue } from './types';

import './range_slider.scss';

interface Props {
componentStateSubject: BehaviorSubject<RangeSliderComponentState>;
}
// Availableoptions and loading state is controled by the embeddable, but is not considered embeddable input.
export interface RangeSliderComponentState {
field?: DataViewField;
fieldFormatter: (value: string) => string;
min: string;
max: string;
loading: boolean;
}

export const RangeSliderComponent: FC<Props> = ({ componentStateSubject }) => {
// Redux embeddable Context to get state from Embeddable input
const {
useEmbeddableDispatch,
useEmbeddableSelector,
actions: { selectRange },
} = useReduxEmbeddableContext<RangeSliderEmbeddableInput, typeof rangeSliderReducers>();
const dispatch = useEmbeddableDispatch();

// useStateObservable to get component state from Embeddable
const { loading, min, max, fieldFormatter } = useStateObservable<RangeSliderComponentState>(
componentStateSubject,
componentStateSubject.getValue()
);

const { value = ['', ''], id, title } = useEmbeddableSelector((state) => state);

const [selectedValue, setSelectedValue] = useState<RangeValue>(value || ['', '']);

const onChangeComplete = useCallback(
(range: RangeValue) => {
dispatch(selectRange(range));
setSelectedValue(range);
},
[selectRange, setSelectedValue, dispatch]
);

return (
<RangeSliderPopover
id={id}
isLoading={loading}
min={min}
max={max}
title={title}
value={selectedValue}
onChange={onChangeComplete}
fieldFormatter={fieldFormatter}
/>
);
};
Loading

0 comments on commit 233f300

Please sign in to comment.