New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Controls] [Portable Dashboards] Add control group renderer example plugin #146189
[Controls] [Portable Dashboards] Add control group renderer example plugin #146189
Conversation
1f1d8dc
to
a3f800e
Compare
a3f800e
to
bbb2342
Compare
Pinging @elastic/kibana-presentation (Team:Presentation) |
0c7a4a3
to
bf5bfe4
Compare
馃挌 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @Heenawter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Code only review. The only comments I added are related to forward-looking future things and ideas, but all the code in this PR is exactly what I was hoping for. Nice work!
{ data }: ControlsExampleStartDeps, | ||
{ element }: AppMountParameters | ||
) => { | ||
const dataViews = await data.dataViews.find('kibana_sample_data_ecommerce'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required for this PR - as this one is mostly about upgrading the API, but food for thought - maybe for all of our examples, we should align behind the sample web logs data set, as it has more relevance to solution use cases.
Additionally, maybe we should show some sort of warning asking developers who want to use the examples to install this data set if it doesn't exist.
interface Props { | ||
dataView: DataView; | ||
} | ||
const ControlGroupRenderer = withSuspense(LazyControlGroupRenderer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not for right now, but I've been thinking about our usages of withSuspense
, and how we actually export the LazyControlGroupRenderer
. I'm thinking that maybe we should write our own version of withSuspense
that only works with the Control Group (with a better / centered loading indicator), and export that instead so that implementors don't need to also use presentation_util.
onEmbeddableLoad: (controlGroupContainer: ControlGroupContainer) => void; | ||
getCreationOptions: ( | ||
builder: typeof ControlGroupInputBuilder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃挴
const id = useMemo(() => uuid.v4(), []); | ||
|
||
/** | ||
* Use Lifecycles to load initial control group container | ||
*/ | ||
useLifecycles( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that while I was working on Portable Dashboard I ran into some problem with the useLifecycles
hook which made me replace it with a general useEffect
. Not sure exactly what the problem was anymore because it was a while ago, but I'd make sure that it gets called when you expect it to, and that the cleanup function works as / when expected.
import { getCompatibleControlType, getNextPanelOrder } from './embeddable/control_group_helpers'; | ||
import { controlGroupReducers } from './state/control_group_reducers'; | ||
|
||
const ControlGroupInputBuilder = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next step of this process will be to use an input builder like this one in the inline editor to serve the Control Creation use case. This is because the control editor in that case simply returns a partial input object for the Control type you're creating, so it would be cool to eventually use the same APIs for partial input creation inside or outside of the Controls plugin.
const ControlGroupInputBuilder = { | ||
addDataControlFromField: async ( | ||
initialInput: Partial<ControlGroupInput>, | ||
newPanelInput: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nreese, I'm appreciating your suggestion to expose API methods here for individual control types, but I think we should also keep this generic one for simplicity.
In the individual control type builders, we would be able to take selections
, in case a consumer wanted to build an Options List control for instance with some options pre-selected.
* main: (30 commits) [Cloud Posture] test latest findings table sort (elastic#144668) [api-docs] 2022-11-28 Daily api_docs build (elastic#146359) [api-docs] 2022-11-27 Daily api_docs build (elastic#146353) [api-docs] 2022-11-26 Daily api_docs build (elastic#146350) [DataViews] Fix form validation UX when the same data view name already exists (elastic#146126) [Discover] Prevent agg based visualizations of Discover saved objects with adhoc data views (elastic#145583) [Health Gateway] Update response aggregation (elastic#145761) [api-docs] 2022-11-25 Daily api_docs build (elastic#146341) [Metric threshold rule] Adds new context variable for group by keys (elastic#145654) [Controls] [Portable Dashboards] Add control group renderer example plugin (elastic#146189) Refactor Observability Overview Page (elastic#146182) Send complete test data to xMatters, so it can create an alert (elastic#145431) [Dashboard] [Controls] Allow options list suggestions to be sorted (elastic#144867) Add open API specification for list connector types (elastic#145951) skip flaky suite (elastic#146086) [ML] Removing duplicate tooltip text (elastic#146308) Refactor Rules Page (elastic#146193) [DOCS] Alert limit for cases (elastic#145950) Extend session index fields mapping with a session creation timestamp. (elastic#145997) [Files] Move <Image /> component to `@kbn/shared-ux` package (elastic#145995) ...
Closes #145429
Summary
This PR expands on the control group building block by
input
declarative API and replacing it with agetCreationOptions
callbackAs part of this, I created an example plugin to demonstrate some of the new functionality 馃憤
Also, to avoid some code duplication, I had to move some code to the generic
control_group_helpers.tsx
so that both the controls plugin and the new example plugin could use it.Checklist
For maintainers