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

[Papercut][Dashboard][Data Discovery] Add description to saved object finder table if applicable #198816

Merged
merged 21 commits into from
Nov 27, 2024

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Nov 4, 2024

Summary

Closes #79754

This PR adds a description under the titles to the saved object finder table that is used in Dashboard's Add to Library Panel.

Screenshot 2024-11-07 at 7 55 14 AM

@rshen91 rshen91 changed the title [Papercut] Add description to saved object finder table if applicable [Papercut][Dashboard] Add description to saved object finder table if applicable Nov 4, 2024
@rshen91 rshen91 self-assigned this Nov 4, 2024
@rshen91 rshen91 added the papercut Small "burr" in the product that we should fix. label Nov 4, 2024
@rshen91 rshen91 marked this pull request as ready for review November 6, 2024 15:17
@rshen91 rshen91 requested a review from a team as a code owner November 6, 2024 15:17
@rshen91 rshen91 changed the title [Papercut][Dashboard] Add description to saved object finder table if applicable [Papercut][Dashboard][Data Discovery] Add description to saved object finder table if applicable Nov 6, 2024
@rshen91 rshen91 added backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development release_note:enhancement labels Nov 6, 2024
@jughosta
Copy link
Contributor

jughosta commented Nov 6, 2024

QQ: what if we show descriptions under the title as on Dashboard page for example:

Screenshot 2024-11-06 at 17 18 40

This would help to reduce the number of columns and give more space for a longer text or a larger number of tags. Wdyt?

@rshen91 rshen91 marked this pull request as draft November 6, 2024 16:29
@rshen91 rshen91 marked this pull request as ready for review November 6, 2024 18:36
@rshen91 rshen91 requested a review from a team as a code owner November 6, 2024 20:48
Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

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

Overall looks good, I left a comment on where to check if there is or not a description for the row item.

@@ -212,6 +213,12 @@ export class SavedObjectFinderUi extends React.Component<

public render() {
const { onChoose, savedObjectMetaData } = this.props;
const descriptionsDefined =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make this check separately for each row item. So I would remove it here and change L317 (see comment)

@@ -307,13 +314,23 @@ export class SavedObjectFinderUi extends React.Component<
);

const tooltipText = this.props.getTooltipText?.(item);

const description = descriptionsDefined && (
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be

const description = !!item.simple.attributes.description && (
  <EuiText size="xs" color="subdued" className="eui-textTruncate">
    {item.simple.attributes.description}
  </EuiText>
)

Copy link
Contributor Author

@rshen91 rshen91 Nov 7, 2024

Choose a reason for hiding this comment

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

ooooo TIL boolean !! thanks!

@rshen91 rshen91 requested a review from sebelga November 7, 2024 14:37
Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

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

@rshen91 I should have said ask for it in my previous comment: can we update the jest test for the saved object finder to test that description are rendered (if one is provided)? thanks!

@rshen91 rshen91 requested a review from jughosta November 7, 2024 21:40
Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

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

Thanks for adding the test! I added a comment about avoiding testing implementation details. I'll approve the PR to unblock you but it would be nice to update the test 👍

@@ -217,6 +219,29 @@ describe('SavedObjectsFinder', () => {
</React.Fragment>
`);
});

it('render description if provided', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

In this test you are testing implementation details which is not ideal. Changing the implementation (underlying component, props to those component) will break this test.

Concretely you assume that the EuiInMemoryTable is present and that it takes items prop.

Now I know that you basically copied what other tests are doing 😊 but let's take this opportunity to improve the test.

In https://github.com/elastic/kibana/blob/main/packages/kbn-test-jest-helpers/src/testbed/testbed.ts I wrote a helper function to parse an EUI table and read its content for testing purpose. Let's copy it over in this file.

So on L37 (below the imports), add the helper func

...
import { coreMock } from '@kbn/core/public/mocks';

// Copied from packages/kbn-test-jest-helpers/src/testbed/testbed.ts
const getTableMetadata = (subject: string, reactWrapper: ReactWrapper) => {
  const table = findTestSubject(reactWrapper, subject);

  if (!table.length) {
    throw new Error(`Eui Table "${subject}" not found.`);
  }

  const rows = table
    .find('tr')
    .slice(1) // we remove the first row as it is the table header
    .map((row) => ({
      reactWrapper: row,
      columns: row.find('div.euiTableCellContent').map((col) => ({
        reactWrapper: col,
        // We can't access the td value with col.text() because
        // eui adds an extra div in td on mobile => (.euiTableRowCell__mobileHeader)
        value: col.find('div.euiTableCellContent').text(),
      })),
    }));

  // Also output the raw cell values, in the following format: [[td0, td1, td2], [td0, td1, td2]]
  const tableCellsValues = rows.map(({ columns }) => columns.map((col) => col.value));
  return { rows, tableCellsValues };
};

Now this test can become

it('render description if provided', async () => {
  (contentClient.mSearch as any as jest.SpyInstance).mockImplementation(() =>
    Promise.resolve({ hits: [doc, doc2, doc4] })
  );

  const wrapper = mount(
    <SavedObjectFinder
      services={{ uiSettings, contentClient, savedObjectsTagging }}
      savedObjectMetaData={searchMetaData}
    />
  );

  await nextTick();
  wrapper.update();

  const table = getTableMetadata('savedObjectsFinderTable', wrapper);
  expect(table.tableCellsValues).toEqual([
    ['Another titleanother description', 'tag-2'],
    ['Example titleexample description', 'tag-1'],
    ['Search', 'tag-4'],
  ]);
});

See how we don't test the underlying implementation. We test that the table renders the correct text.

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Nice improvement for the users! LGTM 👍

@jughosta
Copy link
Contributor

Let's update the branch and merge? 🙂

@rshen91 rshen91 enabled auto-merge (squash) November 20, 2024 17:41
@jughosta
Copy link
Contributor

/ci

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

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
savedObjectsFinder 25 26 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
savedObjectsFinder 7.4KB 7.6KB +232.0B
Unknown metric groups

API count

id before after diff
savedObjectsFinder 25 26 +1

History

cc @rshen91

@jughosta
Copy link
Contributor

@elasticmachine run docs-build

@rshen91 rshen91 merged commit 23c4306 into elastic:main Nov 27, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.15, 8.16, 8.17, 8.x

https://github.com/elastic/kibana/actions/runs/12054630713

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
… finder table if applicable (elastic#198816)

## Summary

Closes elastic#79754

This PR adds a description under the titles to the saved object finder
table that is used in Dashboard's Add to Library Panel.

<img width="736" alt="Screenshot 2024-11-07 at 7 55 14 AM"
src="https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d">

---------

Co-authored-by: Davis McPhee <[email protected]>
(cherry picked from commit 23c4306)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
… finder table if applicable (elastic#198816)

## Summary

Closes elastic#79754

This PR adds a description under the titles to the saved object finder
table that is used in Dashboard's Add to Library Panel.

<img width="736" alt="Screenshot 2024-11-07 at 7 55 14 AM"
src="https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d">

---------

Co-authored-by: Davis McPhee <[email protected]>
(cherry picked from commit 23c4306)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
… finder table if applicable (elastic#198816)

## Summary

Closes elastic#79754

This PR adds a description under the titles to the saved object finder
table that is used in Dashboard's Add to Library Panel.

<img width="736" alt="Screenshot 2024-11-07 at 7 55 14 AM"
src="https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d">

---------

Co-authored-by: Davis McPhee <[email protected]>
(cherry picked from commit 23c4306)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
… finder table if applicable (elastic#198816)

## Summary

Closes elastic#79754

This PR adds a description under the titles to the saved object finder
table that is used in Dashboard's Add to Library Panel.

<img width="736" alt="Screenshot 2024-11-07 at 7 55 14 AM"
src="https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d">

---------

Co-authored-by: Davis McPhee <[email protected]>
(cherry picked from commit 23c4306)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15
8.16
8.17
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 27, 2024
…object finder table if applicable (#198816) (#202031)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Papercut][Dashboard][Data Discovery] Add description to saved object
finder table if applicable
(#198816)](#198816)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Rachel
Shen","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-27T16:38:39Z","message":"[Papercut][Dashboard][Data
Discovery] Add description to saved object finder table if applicable
(#198816)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/79754\r\n\r\nThis PR adds a
description under the titles to the saved object finder\r\ntable that is
used in Dashboard's Add to Library Panel.\r\n\r\n<img width=\"736\"
alt=\"Screenshot 2024-11-07 at 7 55
14 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Davis McPhee
<[email protected]>","sha":"23c4306387725cdafc1c6c6d3aec5049a6f82858","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","v9.0.0","backport:prev-major","papercut"],"title":"[Papercut][Dashboard][Data
Discovery] Add description to saved object finder table if
applicable","number":198816,"url":"https://github.com/elastic/kibana/pull/198816","mergeCommit":{"message":"[Papercut][Dashboard][Data
Discovery] Add description to saved object finder table if applicable
(#198816)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/79754\r\n\r\nThis PR adds a
description under the titles to the saved object finder\r\ntable that is
used in Dashboard's Add to Library Panel.\r\n\r\n<img width=\"736\"
alt=\"Screenshot 2024-11-07 at 7 55
14 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Davis McPhee
<[email protected]>","sha":"23c4306387725cdafc1c6c6d3aec5049a6f82858"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198816","number":198816,"mergeCommit":{"message":"[Papercut][Dashboard][Data
Discovery] Add description to saved object finder table if applicable
(#198816)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/79754\r\n\r\nThis PR adds a
description under the titles to the saved object finder\r\ntable that is
used in Dashboard's Add to Library Panel.\r\n\r\n<img width=\"736\"
alt=\"Screenshot 2024-11-07 at 7 55
14 AM\"\r\nsrc=\"https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d\">\r\n\r\n---------\r\n\r\nCo-authored-by:
Davis McPhee
<[email protected]>","sha":"23c4306387725cdafc1c6c6d3aec5049a6f82858"}}]}]
BACKPORT-->

Co-authored-by: Rachel Shen <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
… finder table if applicable (elastic#198816)

## Summary

Closes elastic#79754

This PR adds a description under the titles to the saved object finder
table that is used in Dashboard's Add to Library Panel.

<img width="736" alt="Screenshot 2024-11-07 at 7 55 14 AM"
src="https://github.com/user-attachments/assets/6a2029cb-1958-4ae3-932b-f7fcb584870d">

---------

Co-authored-by: Davis McPhee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development papercut Small "burr" in the product that we should fix. release_note:enhancement v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dashboard] View Descriptions in Add Panel Flyout of SavedObjectFinder
6 participants