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

[Fleet] Only show agent dashboard links if there is more than one non-server agent and if the dashboards exist #164469

Merged
merged 4 commits into from
Aug 23, 2023

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Aug 22, 2023

Summary

Closes #161827

These buttons were showing in cloud when there was only the cloud agent added:

Screenshot 2023-08-22 at 16 18 51

The ingest dashboard links will now only show if:

  • the user has one agent that is not part of a policy containing fleet server (I have re-used an existing hook we have to check this here)
  • the agent ingest metrics dashaboard exists in the current space

Test Scenarios

  1. Setup fleet with ONLY a fleet server connected, the dashboard links should not show
  2. Setup fleet with fleet server and another non-fleet server agent, the dashboard links should show
  3. With the same setup as test case 2, now create another space, visit fleet in the new space, the links should not show as the dashboards are not installed in the current space.

Checklist

Delete any items that are not applicable to this PR.

@hop-dev hop-dev added release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Aug 22, 2023
@hop-dev hop-dev self-assigned this Aug 22, 2023
@hop-dev hop-dev requested a review from a team as a code owner August 22, 2023 15:23
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@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.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

import { useDashboardLocator } from '../../../../hooks';
import { useDashboardLocator, useStartServices } from '../../../../hooks';

const useDashboardExists = (dashboardId: string) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as this hook is only used here I kept it in the same file, happy to move it to its own file?

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 it can stay in this file and can be moved if we need to reuse it elsewhere

@@ -94,6 +96,8 @@ export const SearchAndFilterBar: React.FunctionComponent<SearchAndFilterBarProps
}) => {
const { euiTheme } = useEuiTheme();
const { isFleetServerStandalone } = useFleetServerStandalone();
const { isFirstTimeAgentUser, isLoading: isFirstTimeAgentUserLoading } =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isFirstTimeAgentUser checks if the user has at least one non-fleet-server agent

Copy link
Contributor

@criamico criamico left a comment

Choose a reason for hiding this comment

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

LGTM 🚢

const fetchDashboard = async () => {
try {
const findDashboardsService = await dashboardPlugin.findDashboardsService();
const [dashboard] = await findDashboardsService.findByIds([dashboardId]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea to use the dashboard service!

import { useDashboardLocator } from '../../../../hooks';
import { useDashboardLocator, useStartServices } from '../../../../hooks';

const useDashboardExists = (dashboardId: string) => {
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 it can stay in this file and can be moved if we need to reuse it elsewhere

@hop-dev hop-dev enabled auto-merge (squash) August 22, 2023 20:31
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

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
fleet 1072 1073 +1

Async chunks

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

id before after diff
fleet 1.0MB 1.0MB +568.0B
Unknown metric groups

API count

id before after diff
fleet 1188 1189 +1

History

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

cc @hop-dev

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.10

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 23, 2023
…-server agent and if the dashboards exist (elastic#164469)

## Summary

Closes elastic#161827

These buttons were showing in cloud when there was only the cloud agent
added:

<img width="647" alt="Screenshot 2023-08-22 at 16 18 51"
src="https://github.com/elastic/kibana/assets/3315046/baaff9b9-17fc-49b5-bad9-980f91a5ae15">

The ingest dashboard links will now only show if:

- the user has one agent that is not part of a policy containing fleet
server (I have re-used an existing hook we have to check this here)
- the agent ingest metrics dashaboard exists in the current space

Test Scenarios

1. Setup fleet with ONLY a fleet server connected, the dashboard links
should not show
2. Setup fleet with fleet server and another non-fleet server agent, the
dashboard links should show
3. With the same setup as test case 2, now create another space, visit
fleet in the new space, the links should not show as the dashboards are
not installed in the current space.

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 805c974)
@hop-dev hop-dev deleted the 161827-fix-ingest-dashboard-links branch August 23, 2023 09:00
kibanamachine added a commit that referenced this pull request Aug 23, 2023
…one non-server agent and if the dashboards exist (#164469) (#164539)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Fleet] Only show agent dashboard links if there is more than one
non-server agent and if the dashboards exist
(#164469)](#164469)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Mark
Hopkin","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-23T08:53:49Z","message":"[Fleet]
Only show agent dashboard links if there is more than one non-server
agent and if the dashboards exist (#164469)\n\n## Summary\r\n\r\nCloses
#161827\r\n\r\nThese buttons were showing in cloud when there was only
the cloud agent\r\nadded:\r\n\r\n<img width=\"647\" alt=\"Screenshot
2023-08-22 at 16 18
51\"\r\nsrc=\"https://github.com/elastic/kibana/assets/3315046/baaff9b9-17fc-49b5-bad9-980f91a5ae15\">\r\n\r\nThe
ingest dashboard links will now only show if:\r\n\r\n- the user has one
agent that is not part of a policy containing fleet\r\nserver (I have
re-used an existing hook we have to check this here)\r\n- the agent
ingest metrics dashaboard exists in the current space\r\n\r\nTest
Scenarios\r\n\r\n1. Setup fleet with ONLY a fleet server connected, the
dashboard links\r\nshould not show\r\n2. Setup fleet with fleet server
and another non-fleet server agent, the\r\ndashboard links should
show\r\n3. With the same setup as test case 2, now create another space,
visit\r\nfleet in the new space, the links should not show as the
dashboards are\r\nnot installed in the current space.\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"805c974ed0c6f30be9153734859e0a28fa95eae1","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:prev-minor","v8.11.0"],"number":164469,"url":"https://github.com/elastic/kibana/pull/164469","mergeCommit":{"message":"[Fleet]
Only show agent dashboard links if there is more than one non-server
agent and if the dashboards exist (#164469)\n\n## Summary\r\n\r\nCloses
#161827\r\n\r\nThese buttons were showing in cloud when there was only
the cloud agent\r\nadded:\r\n\r\n<img width=\"647\" alt=\"Screenshot
2023-08-22 at 16 18
51\"\r\nsrc=\"https://github.com/elastic/kibana/assets/3315046/baaff9b9-17fc-49b5-bad9-980f91a5ae15\">\r\n\r\nThe
ingest dashboard links will now only show if:\r\n\r\n- the user has one
agent that is not part of a policy containing fleet\r\nserver (I have
re-used an existing hook we have to check this here)\r\n- the agent
ingest metrics dashaboard exists in the current space\r\n\r\nTest
Scenarios\r\n\r\n1. Setup fleet with ONLY a fleet server connected, the
dashboard links\r\nshould not show\r\n2. Setup fleet with fleet server
and another non-fleet server agent, the\r\ndashboard links should
show\r\n3. With the same setup as test case 2, now create another space,
visit\r\nfleet in the new space, the links should not show as the
dashboards are\r\nnot installed in the current space.\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"805c974ed0c6f30be9153734859e0a28fa95eae1"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164469","number":164469,"mergeCommit":{"message":"[Fleet]
Only show agent dashboard links if there is more than one non-server
agent and if the dashboards exist (#164469)\n\n## Summary\r\n\r\nCloses
#161827\r\n\r\nThese buttons were showing in cloud when there was only
the cloud agent\r\nadded:\r\n\r\n<img width=\"647\" alt=\"Screenshot
2023-08-22 at 16 18
51\"\r\nsrc=\"https://github.com/elastic/kibana/assets/3315046/baaff9b9-17fc-49b5-bad9-980f91a5ae15\">\r\n\r\nThe
ingest dashboard links will now only show if:\r\n\r\n- the user has one
agent that is not part of a policy containing fleet\r\nserver (I have
re-used an existing hook we have to check this here)\r\n- the agent
ingest metrics dashaboard exists in the current space\r\n\r\nTest
Scenarios\r\n\r\n1. Setup fleet with ONLY a fleet server connected, the
dashboard links\r\nshould not show\r\n2. Setup fleet with fleet server
and another non-fleet server agent, the\r\ndashboard links should
show\r\n3. With the same setup as test case 2, now create another space,
visit\r\nfleet in the new space, the links should not show as the
dashboards are\r\nnot installed in the current space.\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] Any UI touched in this PR is usable by keyboard only (learn
more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [x] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"805c974ed0c6f30be9153734859e0a28fa95eae1"}}]}]
BACKPORT-->

Co-authored-by: Mark Hopkin <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 23, 2023
* main: (150 commits)
  Fixes unnecessary autocompletes on HTTP methods (elastic#163233)
  [Defend Workflows] Convert filterQuery to kql  (elastic#161806)
  [Fleet] copy `inactivity_timeout` when duplicating agent policy (elastic#164544)
  Fix 7.17 forward compatibility with 8.2+ (elastic#164274)
  [ML] Fixes dark mode in flyouts and modals (elastic#164399)
  [Defend Workflows]Changes to policy settings are not persistent until a refresh (elastic#164403)
  [Security Solution][Endpoint] Fixes kibana crash when going back to policy details page (elastic#164329)
  Prepare the Security domain HTTP APIs for Serverless (elastic#162087)
  skip failing test suite (elastic#160986)
  [Security Solution] Fix flaky Event Filters test (elastic#164473)
  [EDR workflows] Osquery serverless tests (elastic#163795)
  [Fleet] Only show agent dashboard links if there is more than one non-server agent and if the dashboards exist (elastic#164469)
  [Chrome UI] Fix background color in serverless (elastic#164419)
  [DOCS] Saved objects - resolve import errors API (elastic#162825)
  Remove 'Create Rule' button from Rule Group page (elastic#164167)
  [Security Solution] expandable flyout - fix infinite loop in correlations (elastic#163450)
  [Remote Clusters] Update copy about port help text (elastic#164442)
  [api-docs] 2023-08-23 Daily api_docs build (elastic#164524)
  [data views] Disable scripted fields in serverless environment (elastic#163228)
  [Reporting] Fix - show diagnostic only when image reporting is enabled (elastic#164336)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.10.0 v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Dashboards links in agent list page are broken in cloud
7 participants