forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Drilldowns] Trigger picker (elastic#74751)
Drilldowns now support trigger picker. It allows to create a drilldown and specify which trigger it should be attached to. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
8ea2bb3
commit 832b952
Showing
47 changed files
with
942 additions
and
150 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
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
1 change: 1 addition & 0 deletions
1
...ced_examples/public/dashboard_hello_world_only_range_select_drilldown/README.md
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 @@ | ||
This folder contains a one-file example of the most basic drilldown implementation which support only RANGE_SELECT_TRIGGER. |
62 changes: 62 additions & 0 deletions
62
...ions_enhanced_examples/public/dashboard_hello_world_only_range_select_drilldown/index.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,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFormRow, EuiFieldText } from '@elastic/eui'; | ||
import { reactToUiComponent } from '../../../../../src/plugins/kibana_react/public'; | ||
import { UiActionsEnhancedDrilldownDefinition as Drilldown } from '../../../../plugins/ui_actions_enhanced/public'; | ||
import { RangeSelectContext } from '../../../../../src/plugins/embeddable/public'; | ||
import { CollectConfigProps } from '../../../../../src/plugins/kibana_utils/public'; | ||
import { SELECT_RANGE_TRIGGER } from '../../../../../src/plugins/ui_actions/public'; | ||
|
||
export interface Config { | ||
name: string; | ||
} | ||
|
||
const SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT = | ||
'SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT'; | ||
|
||
export class DashboardHelloWorldOnlyRangeSelectDrilldown | ||
implements Drilldown<Config, typeof SELECT_RANGE_TRIGGER> { | ||
public readonly id = SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN_ONLY_RANGE_SELECT; | ||
|
||
public readonly order = 7; | ||
|
||
public readonly getDisplayName = () => 'Say hello only for range select'; | ||
|
||
public readonly euiIcon = 'cheer'; | ||
|
||
supportedTriggers(): Array<typeof SELECT_RANGE_TRIGGER> { | ||
return [SELECT_RANGE_TRIGGER]; | ||
} | ||
|
||
private readonly ReactCollectConfig: React.FC<CollectConfigProps<Config>> = ({ | ||
config, | ||
onConfig, | ||
}) => ( | ||
<EuiFormRow label="Enter your name" fullWidth> | ||
<EuiFieldText | ||
fullWidth | ||
value={config.name} | ||
onChange={(event) => onConfig({ ...config, name: event.target.value })} | ||
/> | ||
</EuiFormRow> | ||
); | ||
|
||
public readonly CollectConfig = reactToUiComponent(this.ReactCollectConfig); | ||
|
||
public readonly createConfig = () => ({ | ||
name: '', | ||
}); | ||
|
||
public readonly isConfigValid = (config: Config): config is Config => { | ||
return !!config.name; | ||
}; | ||
|
||
public readonly execute = async (config: Config, context: RangeSelectContext) => { | ||
alert(`Hello, ${config.name}, your selected range: ${JSON.stringify(context.data.range)}`); | ||
}; | ||
} |
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
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/drilldown_shared.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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
APPLY_FILTER_TRIGGER, | ||
SELECT_RANGE_TRIGGER, | ||
TriggerId, | ||
VALUE_CLICK_TRIGGER, | ||
} from '../../../../../../../src/plugins/ui_actions/public'; | ||
|
||
/** | ||
* We know that VALUE_CLICK_TRIGGER and SELECT_RANGE_TRIGGER are also triggering APPLY_FILTER_TRIGGER | ||
* This function appends APPLY_FILTER_TRIGGER to list of triggers if VALUE_CLICK_TRIGGER or SELECT_RANGE_TRIGGER | ||
* | ||
* TODO: this probably should be part of uiActions infrastructure, | ||
* but dynamic implementation of nested trigger doesn't allow to statically express such relations | ||
* | ||
* @param triggers | ||
*/ | ||
export function ensureNestedTriggers(triggers: TriggerId[]): TriggerId[] { | ||
if ( | ||
!triggers.includes(APPLY_FILTER_TRIGGER) && | ||
(triggers.includes(VALUE_CLICK_TRIGGER) || triggers.includes(SELECT_RANGE_TRIGGER)) | ||
) { | ||
return [...triggers, APPLY_FILTER_TRIGGER]; | ||
} | ||
|
||
return triggers; | ||
} |
Oops, something went wrong.