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.
[Embeddable rebuild] Add panel placement registry (elastic#182120)
Fixes elastic#182113 ## Summary Adds a registry for plugins to specify the width, height, and placement strategy for their embeddables. To test this: 1. Run `yarn start --run-examples` 2. Load the Kibana sample data logs dataset 3. Start editing the [Logs] Web Traffic dashboard 4. In the "Add panel" dropdown, select the "Field list" subitem under the "Embeddable examples" group This also adds some additional documentation to the "Embeddables" Developer examples.
- Loading branch information
Showing
19 changed files
with
295 additions
and
127 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
27 changes: 27 additions & 0 deletions
27
...embeddable_examples/public/react_embeddables/field_list/register_field_list_embeddable.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,27 @@ | ||
/* | ||
* 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 { | ||
registerDashboardPanelPlacementSetting, | ||
PanelPlacementStrategy, | ||
} from '@kbn/dashboard-plugin/public'; | ||
import { FIELD_LIST_ID } from './constants'; | ||
import { FieldListSerializedStateState } from './types'; | ||
|
||
const getPanelPlacementSetting = (serializedState?: FieldListSerializedStateState) => { | ||
// Consider using the serialized state to determine the width, height, and strategy | ||
return { | ||
width: 12, | ||
height: 36, | ||
strategy: PanelPlacementStrategy.placeAtTop, | ||
}; | ||
}; | ||
|
||
export function registerFieldListPanelPlacementSetting() { | ||
registerDashboardPanelPlacementSetting(FIELD_LIST_ID, getPanelPlacementSetting); | ||
} |
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
27 changes: 27 additions & 0 deletions
27
examples/embeddable_examples/public/react_embeddables/register_saved_object_example.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,27 @@ | ||
/* | ||
* 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 { registerReactEmbeddableSavedObject } from '@kbn/embeddable-plugin/public'; | ||
|
||
const MY_EMBEDDABLE_TYPE = 'myEmbeddableType'; | ||
const MY_SAVED_OBJECT_TYPE = 'mySavedObjectType'; | ||
const APP_ICON = 'logoKibana'; | ||
|
||
export const registerMyEmbeddableSavedObject = () => | ||
registerReactEmbeddableSavedObject({ | ||
onAdd: (container, savedObject) => { | ||
container.addNewPanel({ | ||
panelType: MY_EMBEDDABLE_TYPE, | ||
initialState: savedObject.attributes, | ||
}); | ||
}, | ||
embeddableType: MY_EMBEDDABLE_TYPE, | ||
savedObjectType: MY_SAVED_OBJECT_TYPE, | ||
savedObjectName: 'Some saved object', | ||
getIconForSavedObject: () => APP_ICON, | ||
}); |
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
Oops, something went wrong.