-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: π€ add example of Discover drilldown to sample plugin * fix: π show drilldowns with higher "order" first * feat: πΈ add createStartServicesGetter() to /public kibana_util * feat: πΈ load index patterns in Discover drilldown * feat: πΈ add toggle for index pattern selection * feat: πΈ add spacer to separate unrelated config fields * fix: π correctly configre setup core * feat: πΈ navigate to correct index pattern * chore: π€ fix type check errors * fix: π make index pattern select full width * fix: π add getHref support * feat: πΈ add example plugin ability to X-Pack * refactor: π‘ move Discover drilldown example to X-Pack * feat: πΈ add dashboard-to-url drilldown example * feat: πΈ add new tab support for URL drilldown * feat: πΈ add "hello world" drilldown example * docs: βοΈ add README * feat: πΈ add getHref support * chore: π€ cleanup after moving examples to X-Pack * docs: βοΈ add to README.md info on how to find drilldowns
- Loading branch information
Showing
24 changed files
with
582 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
## Ui actions enhanced examples | ||
# Ui actions enhanced examples | ||
|
||
To run this example, use the command `yarn start --run-examples`. | ||
To run this example plugin, use the command `yarn start --run-examples`. | ||
|
||
|
||
## Drilldown examples | ||
|
||
This plugin holds few examples on how to add drilldown types to dashboard. | ||
|
||
To play with drilldowns, open any dashboard, click "Edit" to put it in *edit mode*. | ||
Now when opening context menu of dashboard panels you should see "Create drilldown" option. | ||
|
||
![image](https://user-images.githubusercontent.com/9773803/80460907-c2ef7880-8934-11ea-8400-533bb9d57e36.png) | ||
|
||
Once you click "Create drilldown" you should be able to see drilldowns added by | ||
this sample plugin. | ||
|
||
![image](https://user-images.githubusercontent.com/9773803/80460408-131a0b00-8934-11ea-81e4-137e9e33f34b.png) | ||
|
||
|
||
### `dashboard_hello_world_drilldown` | ||
|
||
`dashboard_hello_world_drilldown` is the most basic "hello world" example showing | ||
how a drilldown can be built, all in one file. | ||
|
||
### `dashboard_to_url_drilldown` | ||
|
||
`dashboard_to_url_drilldown` is a good starting point for build a drilldown | ||
that navigates somewhere externally. | ||
|
||
One can see how middle-click or Ctrl + click behavior could be supported using | ||
`getHref` field. | ||
|
||
### `dashboard_to_discover_drilldown` | ||
|
||
`dashboard_to_discover_drilldown` shows how a real-world drilldown could look like. |
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
...s/ui_actions_enhanced_examples/public/dashboard_hello_world_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. |
62 changes: 62 additions & 0 deletions
62
...ck/examples/ui_actions_enhanced_examples/public/dashboard_hello_world_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 { DrilldownDefinition as Drilldown } from '../../../../plugins/drilldowns/public'; | ||
import { | ||
EmbeddableContext, | ||
RangeSelectTriggerContext, | ||
ValueClickTriggerContext, | ||
} from '../../../../../src/plugins/embeddable/public'; | ||
import { UiActionsCollectConfigProps } from '../../../../../src/plugins/ui_actions/public'; | ||
|
||
export type ActionContext = RangeSelectTriggerContext | ValueClickTriggerContext; | ||
|
||
export interface Config { | ||
name: string; | ||
} | ||
|
||
const SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN = 'SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN'; | ||
|
||
export class DashboardHelloWorldDrilldown | ||
implements Drilldown<Config, EmbeddableContext, ActionContext> { | ||
public readonly id = SAMPLE_DASHBOARD_HELLO_WORLD_DRILLDOWN; | ||
|
||
public readonly order = 6; | ||
|
||
public readonly getDisplayName = () => 'Say hello drilldown'; | ||
|
||
public readonly euiIcon = 'cheer'; | ||
|
||
private readonly ReactCollectConfig: React.FC<UiActionsCollectConfigProps<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: ActionContext) => { | ||
alert(`Hello, ${config.name}`); | ||
}; | ||
} |
71 changes: 71 additions & 0 deletions
71
...ons_enhanced_examples/public/dashboard_to_discover_drilldown/collect_config_container.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,71 @@ | ||
/* | ||
* 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, { useState, useEffect } from 'react'; | ||
import useMountedState from 'react-use/lib/useMountedState'; | ||
import { CollectConfigProps } from './types'; | ||
import { DiscoverDrilldownConfig, IndexPatternItem } from './components/discover_drilldown_config'; | ||
import { Params } from './drilldown'; | ||
|
||
export interface CollectConfigContainerProps extends CollectConfigProps { | ||
params: Params; | ||
} | ||
|
||
export const CollectConfigContainer: React.FC<CollectConfigContainerProps> = ({ | ||
config, | ||
onConfig, | ||
params: { start }, | ||
}) => { | ||
const isMounted = useMountedState(); | ||
const [indexPatterns, setIndexPatterns] = useState<IndexPatternItem[]>([]); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const indexPatternSavedObjects = await start().plugins.data.indexPatterns.getCache(); | ||
if (!isMounted()) return; | ||
setIndexPatterns( | ||
indexPatternSavedObjects | ||
? indexPatternSavedObjects.map(indexPattern => ({ | ||
id: indexPattern.id, | ||
title: indexPattern.attributes.title, | ||
})) | ||
: [] | ||
); | ||
})(); | ||
}, [isMounted, start]); | ||
|
||
return ( | ||
<DiscoverDrilldownConfig | ||
activeIndexPatternId={config.indexPatternId} | ||
indexPatterns={indexPatterns} | ||
onIndexPatternSelect={indexPatternId => { | ||
onConfig({ ...config, indexPatternId }); | ||
}} | ||
customIndexPattern={config.customIndexPattern} | ||
onCustomIndexPatternToggle={() => | ||
onConfig({ | ||
...config, | ||
customIndexPattern: !config.customIndexPattern, | ||
indexPatternId: undefined, | ||
}) | ||
} | ||
carryFiltersAndQuery={config.carryFiltersAndQuery} | ||
onCarryFiltersAndQueryToggle={() => | ||
onConfig({ | ||
...config, | ||
carryFiltersAndQuery: !config.carryFiltersAndQuery, | ||
}) | ||
} | ||
carryTimeRange={config.carryTimeRange} | ||
onCarryTimeRangeToggle={() => | ||
onConfig({ | ||
...config, | ||
carryTimeRange: !config.carryTimeRange, | ||
}) | ||
} | ||
/> | ||
); | ||
}; |
92 changes: 92 additions & 0 deletions
92
..._to_discover_drilldown/components/discover_drilldown_config/discover_drilldown_config.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,92 @@ | ||
/* | ||
* 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, EuiSelect, EuiSwitch, EuiSpacer } from '@elastic/eui'; | ||
import { txtChooseDestinationIndexPattern } from './i18n'; | ||
|
||
export interface IndexPatternItem { | ||
id: string; | ||
title: string; | ||
} | ||
|
||
export interface DiscoverDrilldownConfigProps { | ||
activeIndexPatternId?: string; | ||
indexPatterns: IndexPatternItem[]; | ||
onIndexPatternSelect: (indexPatternId: string) => void; | ||
customIndexPattern?: boolean; | ||
onCustomIndexPatternToggle?: () => void; | ||
carryFiltersAndQuery?: boolean; | ||
onCarryFiltersAndQueryToggle?: () => void; | ||
carryTimeRange?: boolean; | ||
onCarryTimeRangeToggle?: () => void; | ||
} | ||
|
||
export const DiscoverDrilldownConfig: React.FC<DiscoverDrilldownConfigProps> = ({ | ||
activeIndexPatternId, | ||
indexPatterns, | ||
onIndexPatternSelect, | ||
customIndexPattern, | ||
onCustomIndexPatternToggle, | ||
carryFiltersAndQuery, | ||
onCarryFiltersAndQueryToggle, | ||
carryTimeRange, | ||
onCarryTimeRangeToggle, | ||
}) => { | ||
return ( | ||
<> | ||
{!!onCustomIndexPatternToggle && ( | ||
<> | ||
<EuiFormRow hasChildLabel={false}> | ||
<EuiSwitch | ||
name="customIndexPattern" | ||
label="Use custom index pattern" | ||
checked={!!customIndexPattern} | ||
onChange={onCustomIndexPatternToggle} | ||
/> | ||
</EuiFormRow> | ||
{!!customIndexPattern && ( | ||
<EuiFormRow fullWidth label={txtChooseDestinationIndexPattern}> | ||
<EuiSelect | ||
name="selectDashboard" | ||
hasNoInitialSelection={true} | ||
fullWidth | ||
options={[ | ||
{ id: '', text: 'Pick one...' }, | ||
...indexPatterns.map(({ id, title }) => ({ value: id, text: title })), | ||
]} | ||
value={activeIndexPatternId || ''} | ||
onChange={e => onIndexPatternSelect(e.target.value)} | ||
/> | ||
</EuiFormRow> | ||
)} | ||
<EuiSpacer size="xl" /> | ||
</> | ||
)} | ||
|
||
{!!onCarryFiltersAndQueryToggle && ( | ||
<EuiFormRow hasChildLabel={false}> | ||
<EuiSwitch | ||
name="carryFiltersAndQuery" | ||
label="Carry over filters and query" | ||
checked={!!carryFiltersAndQuery} | ||
onChange={onCarryFiltersAndQueryToggle} | ||
/> | ||
</EuiFormRow> | ||
)} | ||
{!!onCarryTimeRangeToggle && ( | ||
<EuiFormRow hasChildLabel={false}> | ||
<EuiSwitch | ||
name="carryTimeRange" | ||
label="Carry over time range" | ||
checked={!!carryTimeRange} | ||
onChange={onCarryTimeRangeToggle} | ||
/> | ||
</EuiFormRow> | ||
)} | ||
</> | ||
); | ||
}; |
14 changes: 14 additions & 0 deletions
14
...mples/public/dashboard_to_discover_drilldown/components/discover_drilldown_config/i18n.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,14 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const txtChooseDestinationIndexPattern = i18n.translate( | ||
'xpack.uiActionsEnhanced.components.DiscoverDrilldownConfig.chooseIndexPattern', | ||
{ | ||
defaultMessage: 'Choose destination index pattern', | ||
} | ||
); |
7 changes: 7 additions & 0 deletions
7
...ples/public/dashboard_to_discover_drilldown/components/discover_drilldown_config/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,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './discover_drilldown_config'; |
Oops, something went wrong.