Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Embeddables Rebuild] Data table example #181768

Merged

Conversation

ThomThomson
Copy link
Contributor

Summary

Closes #176180

Discoverboard2

Communication with siblings

This PR uses the method listenForCompatibleApi, to listen to

  • a data view from the closest API that publishes data views
  • Selected fields from the closest API that publishes selected fields.

This works alongside the field list Embeddable example to create the behaviour above.

@ThomThomson ThomThomson added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Feature:Embeddables Relating to the Embeddable system project:embeddableRebuild labels Apr 25, 2024
@ThomThomson
Copy link
Contributor Author

/ci

@ThomThomson
Copy link
Contributor Author

/ci

@ThomThomson ThomThomson marked this pull request as ready for review April 25, 2024 20:50
@ThomThomson ThomThomson requested a review from a team as a code owner April 25, 2024 20:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@ThomThomson ThomThomson added the release_note:skip Skip the PR/issue when compiling release notes label Apr 25, 2024
@nreese nreese self-requested a review April 25, 2024 20:57
true
);
},
getDisplayName: () =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove i18n translations from examples.

  1. Examples target developers and all development is done in English
  2. Creating translations cost money
  3. Translations bloat bundle size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like keeping the i18n in examples because I'd like it to show our best practices and I'd like the code to look / work as close as possible to the real world code.

I agree that all development on Kibana is done in English, but I'm pretty sure usages in examples don't get translated - as they shouldn't:
There are 0 instances of embeddableExamples in the translation files, and some i18n usages have been around for over 4 years. embeddableExamples.searchableListContainer.displayName and embeddableExamples.searchableListContainer.displayName are roughly that old.

As for the bundle sizes, this only applies when user is running Kibana with --run-examples - which only developers should be doing.

import { initializeDataTableQueries } from './data_table_queries';
import { DataTableApi, DataTableProvider, DataTableSerializedState } from './types';

export const isDataTableProvider = (api: unknown): api is DataTableProvider => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like isDataTableProvider is not used any where and can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, removed in e19133b

<>
<EuiScreenReaderOnly>
<span id="dataTableReactEmbeddableAria">
{i18n.translate('embeddableExamples.dataTable.ariaLabel', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove i18n

]);
if (!defaultDataView) {
throw new Error(
i18n.translate('embeddableExamples.dataTable.noDataViewError', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove i18n

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this message does not align with if statement check for !defaultDataView

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated message in e19133b


// run query whenever the unified search state changes
const runQuery = async (unifiedSearchState: DataTableQueryState) => {
const { filters, query, timeRange, dataView } = unifiedSearchState;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also consume timeslice so example response to timeslider control

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added time slice in e19133b

const { rawResponse: resp } = await lastValueFrom(
searchSource.fetch$({
abortSignal: abortController.signal,
sessionId: v4(), // todo, search sessions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use search session from fetch$

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed in e19133b


export type DataTableApi = DefaultEmbeddableApi<DataTableSerializedState> & PublishesDataLoading;

export type DataTableProvider = PublishesDataViews & PublishesSelectedFields;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataTableProvider type can be removed. Its not used any where

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - missed this. Removed in 2b6cf98

@nreese
Copy link
Contributor

nreese commented Apr 26, 2024

Not sure if this is worth fixing since this is an example, but changing the data view does not clear out the selected fields. In the screen shot, the field list was changed from logs and now the table is displaying fields that do not make sense for the field list
Screenshot 2024-04-26 at 9 47 46 AM

Steps

  1. add fields from logs sample data set
  2. change field list to another data view
  3. notice how data table did not clear fieldlist

@ThomThomson
Copy link
Contributor Author

ThomThomson commented Apr 26, 2024

I went back and forth on fixing this or not fixing this back when I implemented the field list. Clearing the fields on data view change felt like we were wiping user-selections as part of an unrelated action - but it looks like Discover clears the fields when the data view is changed, so these should probably do the same.

At the end of the day though it is just an example, so we really shouldn't be trying to make the UX perfect. I think I can update it to do that really quickly though...

Edit - changed this behaviour in f4dcafd

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - nice example to show how sibling embeddables can interact
code review, tested in chrome

@nreese
Copy link
Contributor

nreese commented Apr 26, 2024

#181761 is merged now. Would you mind adding grouping: [addPanelGrouping], to add panel action?

@ThomThomson
Copy link
Contributor Author

On it!

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #70 / visualize app visual builder Time Series basics Dark mode viz should have light class when background color is white

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/presentation-publishing 153 155 +2

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/presentation-publishing 6 5 -1
Unknown metric groups

API count

id before after diff
@kbn/presentation-publishing 182 184 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ThomThomson ThomThomson merged commit 98d2ab2 into elastic:main Apr 26, 2024
17 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Apr 26, 2024
yuliacech pushed a commit to yuliacech/kibana that referenced this pull request May 3, 2024
Adds a new data table example that shows how embeddables can interact with their siblings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Embeddables Relating to the Embeddable system impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Embeddables Rebuild] New Embeddable Examples
5 participants