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

[Infrastructure UI] Asset Details: Add pins to the metadata table #161074

Conversation

jennypavlova
Copy link
Member

@jennypavlova jennypavlova commented Jul 3, 2023

Closes #155190

Summary

This PR adds the possibility to pin different rows inside the metadata table in asset details embeddable. The pins are persisted in the local storage and should be available after refreshing/reopening the host flyout. The order and sorting are explained in this comment, so basically we keep the original sorting order of the table (host, cloud, agent) also for the pins.

Testing

  • Go to hosts view and open a single host flyout (metadata tab)
  • Try to add / remove pins
  • Check if the pins are persisted after a page refresh
pins.mov

@jennypavlova jennypavlova self-assigned this Jul 3, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@jennypavlova jennypavlova added Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes labels Jul 3, 2023
@jennypavlova jennypavlova marked this pull request as ready for review July 3, 2023 12:27
@jennypavlova jennypavlova requested a review from a team as a code owner July 3, 2023 12:27
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

@crespocarlos crespocarlos self-requested a review July 5, 2023 16:44
Copy link
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

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

Good job, Jenny 👏 ! This is very useful. Just left a few minor comments.

Comment on lines 28 to 36
const handleAddPin = (pin: Field['name']) => {
setPinnedItems([...pinnedItems, pin]);
};

const handleRemovePin = (pin: Field['name']) => {
if (pinnedItems && pinnedItems.includes(pin)) {
setPinnedItems((pinnedItems ?? []).filter((pinName: string) => pin !== pinName));
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

These handlers are receiving pin as parameter. When they are called, we basically pass fieldName. I think we could do this instead

Suggested change
const handleAddPin = (pin: Field['name']) => {
setPinnedItems([...pinnedItems, pin]);
};
const handleRemovePin = (pin: Field['name']) => {
if (pinnedItems && pinnedItems.includes(pin)) {
setPinnedItems((pinnedItems ?? []).filter((pinName: string) => pin !== pinName));
}
};
const handleAddPin = () => {
setPinnedItems([...pinnedItems, fieldName]);
};
const handleRemovePin = () => {
if (pinnedItems && pinnedItems.includes(fieldName)) {
setPinnedItems((pinnedItems ?? []).filter((pinName: string) => fieldName !== pinName));
}
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, thanks! I change those 👍

export const AddMetadataPinToRow = ({
fieldName,
pinnedItems,
setPinnedItems,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is an event handler, I'd name it onPinned or something along those lines. Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm this is basically setting the the pinned items to the locale storage here but in this component I can rename it 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed ✅

Comment on lines 248 to 249
// FLAKY: https://github.com/elastic/kibana/issues/159368
// FLAKY: https://github.com/elastic/kibana/issues/159369
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're removing this in another PR, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I removed them here as well :)

@jennypavlova jennypavlova requested a review from crespocarlos July 6, 2023 10:51
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
infra 1380 1381 +1

Async chunks

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

id before after diff
infra 1.9MB 1.9MB +1.5KB
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 410 414 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 489 493 +4
total +6

History

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

cc @jennypavlova

Copy link
Contributor

@crespocarlos crespocarlos left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for making the changes.

@jennypavlova jennypavlova merged commit b641a22 into elastic:main Jul 6, 2023
@jennypavlova jennypavlova deleted the 155190-asset-details-add-pins-to-the-metadata-table branch July 6, 2023 15:10
@kibanamachine kibanamachine added v8.10.0 backport:skip This commit does not require backporting labels Jul 6, 2023
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 release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Infrastructure UI] Asset Details: Add pins to the metadata table
6 participants