-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:elastic/kibana into implement/plugi…
…n-discovery-package
- Loading branch information
Showing
181 changed files
with
10,818 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/kbn-securitysolution-rules/src/configuration_constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/plugins/controls/common/control_types/range_slider/range_slider_persistable_state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
src/plugins/controls/common/control_types/range_slider/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
*/ | ||
|
||
export * from './options_list'; | ||
export * from './range_slider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/plugins/controls/public/control_types/range_slider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
72 changes: 72 additions & 0 deletions
72
src/plugins/controls/public/control_types/range_slider/range_slider.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.