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] Replace hash router by router with scoped history #106267

Merged
merged 16 commits into from
Jul 26, 2021

Conversation

nchaulet
Copy link
Member

@nchaulet nchaulet commented Jul 20, 2021

Summary

Resolve #96134

Remove the use of hash router in fleet and use scope history instead.
(Url will change for example /app/fleet#/agents => /app/fleet/agents )

We are going to redirect old urls to new one without hash.

Tasks done in this PR

Fleet

  • Replace hashrouter by router with history
  • Change getHref to do not include hash
  • fix breadcrumb
  • use RedirectAppLinks to handle intra app link

Integrations

  • Replace hashrouter by router with history
  • Change getHref to do not include hash
  • fix breadcrumb
  • use RedirectAppLinks to handle intra app link

Cross app

  • search provider
  • test endpoint

@nchaulet nchaulet added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team auto-backport Deprecated - use backport:version if exact versions are needed v7.15.0 labels Jul 20, 2021
@nchaulet nchaulet self-assigned this Jul 20, 2021
@nchaulet nchaulet force-pushed the feature-use-scoped-history branch from 9a13baf to 44a8f85 Compare July 20, 2021 21:28
@nchaulet nchaulet force-pushed the feature-use-scoped-history branch from 44a8f85 to f634deb Compare July 20, 2021 22:09
@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@nchaulet nchaulet marked this pull request as ready for review July 21, 2021 12:58
@nchaulet nchaulet requested review from a team as code owners July 21, 2021 12:58
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

All looks good to me. Awesome work.

On the topic of adding redirects, I'm not totally sure. We've updated routes a few times (e.g. moving /fleet/epm -> /integrations) and neglected to add backwards-compatible redirects, but perhaps that's something we should try to remedy in this PR. Would be interested to get further thoughts from the team.

@nchaulet nchaulet requested a review from paul-tavares July 21, 2021 14:56
@joshdover
Copy link
Contributor

👋 Hey all, I know I'm a little early here, but since I saw the notification come across, I thought I'd leave my 2c.

On the topic of adding redirects, I'm not totally sure. We've updated routes a few times (e.g. moving /fleet/epm -> /integrations) and neglected to add backwards-compatible redirects, but perhaps that's something we should try to remedy in this PR. Would be interested to get further thoughts from the team.

I'm +1 on adding redirects to avoid breaking bookmarks if it's easy enough to do. I've seen other Kibana applications do something like this to replace their default "catch all" route:

<Route render={({ location }) => (
    location.pathname === '/' && location.hash.length > 0
    ? <Redirect to={{ ...location, pathname: location.hash, hash: undefined }} />
    : <Redirect to={FLEET_ROUTING_PATHS.agents} />
  )}
/>

@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@nchaulet nchaulet requested a review from kevinlog July 21, 2021 20:31
Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

I'm going to check this out next and try it out manually using the Endpoint page links and expected behaviors when redirecting to fleet.

I left some comments, but also: there several places in Security Solution that need updating. I did these searches:

  • 'fleet'
  • #/fleet
  • pagePathGetters.

(yes, some of our links pre-date the existence of pagePathGetters 😞 ) and found several instances. Looks like these will still work, given that you have a <Redirect /> in place, so if you rather not make these change at this time, just let me know and I can open a Tech. Debt item in our side to update.

@paul-tavares
Copy link
Contributor

Checked it out locally and the redirects are not working. Example:

These links:

http://localhost:5601/app/fleet#/policies/915449f0-e95e-11eb-80bd-c9aa11d20dca

http://localhost:5601/app/fleet#/agents/93f587a8-a526-4bd0-b1d6-9f7a421e52ec


http://localhost:5601/app/fleet#/agents/93f587a8-a526-4bd0-b1d6-9f7a421e52ec/activity?openReassignFlyout=true

seem to all be riderecting to their respective lists instead of the details.

If you would like to get some data into your dev env. to be able to display the endpoint pages, run:

x-pack/plugins/security_solution/scripts/endpoint/resolver_generator.js --auth elastic:changeme --delete --numHosts=15 --numDocs=2 --fleet

This will also create "fake" agents in fleet along with agent policies.

@nchaulet
Copy link
Member Author

@paul-tavares for the redirect the correct url in fleet with hash was http://localhost:5601/app/fleet#/fleet/policies/915449f0-e95e-11eb-80bd-c9aa11d20dca notice the #/fleet

@paul-tavares
Copy link
Contributor

Ohhhh. this is a bug then on our side - I have a feeling there is a discrepancy between the onClick handler and the route it uses and the href is being set incorrectly on the anchor. Thanks for pointing that out - going to open an issue on our side to track.

@nchaulet
Copy link
Member Author

nchaulet commented Jul 22, 2021

@paul-tavares My bad routes are not starting by #/fleet I am going to fix the redirect (only the agents routes are prefixed by #/fleet/agents)

@paul-tavares
Copy link
Contributor

@nchaulet - Yeah, I just checked and the links i posted above are correct in 8.0.0 - meaning that they send the user to the expected location. Even the one to the Agent details seems to work and does not have the #/fleet/* prefix in the hash.
you can check them out here in our nightly build server - click the actions for a row and select an option: https://kibana.endpoint.elastic.dev/app/security/administration/endpoints

@nchaulet nchaulet requested a review from a team as a code owner July 22, 2021 19:44
@nchaulet
Copy link
Member Author

@paul-tavares just pushed a fix to the redirect and also fixed a bunch of hash urls in security_solution thanks for the meticulous review here.

@nchaulet nchaulet requested a review from paul-tavares July 22, 2021 19:45
Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

Checked it out again and ran it, and it all works as expected. Thank you for the changes in the Security Solution code 🙏

🚢 🚢 🚢

@nchaulet
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 514 508 -6

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
actions 117 - -117
advancedSettings 22 - -22
alerting 234 - -234
apm 39 - -39
apmOss 4 - -4
banners 9 - -9
bfetch 62 - -62
canvas 5 - -5
cases 407 - -407
charts 159 - -159
cloud 21 - -21
core 1080 - -1080
dashboard 137 - -137
dashboardEnhanced 50 - -50
dashboardMode 11 - -11
data 3162 - -3162
dataEnhanced 16 - -16
dataVisualizer 104 - -104
devTools 8 - -8
discover 55 - -55
discoverEnhanced 37 - -37
embeddable 384 - -384
embeddableEnhanced 14 - -14
encryptedSavedObjects 28 - -28
enterpriseSearch 2 - -2
esUiShared 90 - -90
eventLog 70 - -70
expressionError 12 - -12
expressionRepeatImage 28 - -28
expressionRevealImage 4 - -4
expressions 1567 - -1567
expressionShape 90 - -90
features 97 - -97
fileUpload 128 - -128
fleet 1033 - -1033
globalSearch 14 - -14
home 70 - -70
indexLifecycleManagement 4 - -4
indexManagement 157 - -157
indexPatternFieldEditor 29 - -29
infra 22 - -22
inspector 78 - -78
kibanaLegacy 62 - -62
kibanaReact 230 - -230
kibanaUtils 359 - -359
lens 169 - -169
licenseApiGuard 8 - -8
licenseManagement 3 - -3
licensing 42 - -42
lists 143 - -143
management 40 - -40
maps 203 - -203
mapsEms 75 - -75
metricsEntities 6 - -6
ml 274 - -274
monitoring 10 - -10
navigation 31 - -31
newsfeed 17 - -17
observability 219 - -219
osquery 11 - -11
presentationUtil 136 - -136
remoteClusters 4 - -4
reporting 132 - -132
rollup 20 - -20
ruleRegistry 60 - -60
runtimeFields 19 - -19
savedObjects 199 - -199
savedObjectsManagement 85 - -85
savedObjectsTagging 50 - -50
savedObjectsTaggingOss 50 - -50
screenshotMode 17 - -17
security 51 - -51
securityOss 9 - -9
securitySolution 1245 - -1245
share 83 - -83
snapshotRestore 22 - -22
spacesOss 5 - -5
stackAlerts 4 - -4
taskManager 25 - -25
telemetryCollectionManager 29 - -29
telemetryCollectionXpack 1 - -1
telemetryManagementSection 13 - -13
timelines 763 - -763
triggersActionsUi 228 - -228
uiActions 88 - -88
uiActionsEnhanced 147 - -147
urlForwarding 15 - -15
usageCollection 16 - -16
visTypeTimeseries 10 - -10
visualizations 229 - -229
total -15317

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
bfetch 1 - -1
charts 2 - -2
core 148 - -148
dashboard 1 - -1
data 98 - -98
dataVisualizer 3 - -3
embeddable 4 - -4
esUiShared 4 - -4
expressions 58 - -58
fileUpload 4 - -4
fleet 15 - -15
indexManagement 12 - -12
indexPatternFieldEditor 1 - -1
inspector 6 - -6
kibanaLegacy 3 - -3
kibanaReact 5 - -5
kibanaUtils 3 - -3
maps 2 - -2
mapsEms 1 - -1
ml 10 - -10
presentationUtil 3 - -3
reporting 1 - -1
savedObjects 3 - -3
savedObjectsTaggingOss 3 - -3
securitySolution 8 - -8
share 1 - -1
snapshotRestore 1 - -1
timelines 6 - -6
triggersActionsUi 1 - -1
uiActionsEnhanced 2 - -2
visTypeTimeseries 1 - -1
visualizations 13 - -13
total -424

Async chunks

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

id before after diff
fleet 734.8KB 722.7KB -12.1KB
securitySolution 6.4MB 6.4MB -29.0B
total -12.2KB

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
actions 7 - -7
advancedSettings 1 - -1
alerting 16 - -16
apm 30 - -30
bfetch 2 - -2
canvas 3 - -3
cases 14 - -14
charts 1 - -1
core 31 - -31
dashboard 9 - -9
data 64 - -64
dataEnhanced 2 - -2
devTools 2 - -2
discover 6 - -6
discoverEnhanced 2 - -2
embeddable 3 - -3
encryptedSavedObjects 3 - -3
esUiShared 1 - -1
eventLog 4 - -4
expressionError 2 - -2
expressionRevealImage 1 - -1
expressions 5 - -5
features 2 - -2
fileUpload 1 - -1
fleet 8 - -8
globalSearch 5 - -5
home 5 - -5
indexManagement 3 - -3
indexPatternFieldEditor 4 - -4
infra 3 - -3
inspector 4 - -4
kibanaLegacy 1 - -1
kibanaReact 4 - -4
kibanaUtils 8 - -8
lens 14 - -14
licensing 8 - -8
lists 38 - -38
management 5 - -5
maps 11 - -11
metricsEntities 1 - -1
ml 33 - -33
monitoring 2 - -2
navigation 2 - -2
observability 10 - -10
presentationUtil 5 - -5
reporting 14 - -14
ruleRegistry 9 - -9
runtimeFields 2 - -2
savedObjects 5 - -5
screenshotMode 1 - -1
security 6 - -6
securityOss 3 - -3
securitySolution 28 - -28
share 8 - -8
snapshotRestore 1 - -1
taskManager 8 - -8
telemetryCollectionManager 4 - -4
timelines 25 - -25
triggersActionsUi 19 - -19
uiActions 11 - -11
uiActionsEnhanced 10 - -10
usageCollection 2 - -2
visTypeTimeseries 3 - -3
visualizations 12 - -12
total -557

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 447.6KB 446.5KB -1.1KB
Unknown metric groups

API count

id before after diff
actions 117 - -117
advancedSettings 23 - -23
alerting 242 - -242
apm 39 - -39
apmOss 4 - -4
banners 9 - -9
bfetch 73 - -73
canvas 6 - -6
cases 445 - -445
charts 190 - -190
cloud 21 - -21
core 2359 - -2359
dashboard 160 - -160
dashboardEnhanced 51 - -51
dashboardMode 11 - -11
data 3716 - -3716
dataEnhanced 16 - -16
dataVisualizer 104 - -104
devTools 10 - -10
discover 81 - -81
discoverEnhanced 39 - -39
embeddable 456 - -456
embeddableEnhanced 14 - -14
encryptedSavedObjects 30 - -30
enterpriseSearch 2 - -2
esUiShared 92 - -92
eventLog 70 - -70
expressionError 12 - -12
expressionRepeatImage 28 - -28
expressionRevealImage 4 - -4
expressions 2003 - -2003
expressionShape 90 - -90
features 215 - -215
fileUpload 128 - -128
fleet 1128 - -1128
globalSearch 68 - -68
home 94 - -94
indexLifecycleManagement 4 - -4
indexManagement 162 - -162
indexPatternFieldEditor 31 - -31
infra 25 - -25
inspector 101 - -101
kibanaLegacy 66 - -66
kibanaReact 260 - -260
kibanaUtils 551 - -551
lens 185 - -185
licenseApiGuard 8 - -8
licenseManagement 3 - -3
licensing 117 - -117
lists 150 - -150
management 40 - -40
maps 204 - -204
mapsEms 75 - -75
metricsEntities 9 - -9
ml 278 - -278
monitoring 10 - -10
navigation 31 - -31
newsfeed 17 - -17
observability 219 - -219
osquery 11 - -11
presentationUtil 163 - -163
remoteClusters 4 - -4
reporting 133 - -133
rollup 20 - -20
ruleRegistry 60 - -60
runtimeFields 24 - -24
savedObjects 213 - -213
savedObjectsManagement 96 - -96
savedObjectsTagging 54 - -54
savedObjectsTaggingOss 89 - -89
screenshotMode 22 - -22
security 112 - -112
securityOss 12 - -12
securitySolution 1296 - -1296
share 123 - -123
snapshotRestore 23 - -23
spaces 106 - -106
spacesOss 72 - -72
stackAlerts 4 - -4
taskManager 52 - -52
telemetry 42 - -42
telemetryCollectionManager 29 - -29
telemetryCollectionXpack 1 - -1
telemetryManagementSection 14 - -14
timelines 882 - -882
triggersActionsUi 237 - -237
uiActions 127 - -127
uiActionsEnhanced 205 - -205
urlForwarding 15 - -15
usageCollection 57 - -57
visTypeTimeseries 10 - -10
visualizations 247 - -247
total -19251

References to deprecated APIs

id before after diff
actions 8 - -8
alerting 32 - -32
apm 7 - -7
canvas 53 - -53
cases 151 - -151
crossClusterReplication 2 - -2
dashboard 128 - -128
dashboardEnhanced 10 - -10
dataEnhanced 53 - -53
dataVisualizer 16 - -16
discover 102 - -102
discoverEnhanced 19 - -19
embeddable 2 - -2
encryptedSavedObjects 2 - -2
fleet 89 - -89
globalSearch 4 - -4
graph 2 - -2
indexLifecycleManagement 2 - -2
indexManagement 12 - -12
infra 292 - -292
lens 168 - -168
lists 103 - -103
maps 592 - -592
ml 140 - -140
observability 34 - -34
presentationUtil 2 - -2
savedObjects 6 - -6
savedObjectsManagement 18 - -18
savedObjectsTaggingOss 5 - -5
security 2 - -2
securitySolution 881 - -881
stackAlerts 104 - -104
timelines 76 - -76
transform 16 - -16
uptime 11 - -11
urlDrilldown 18 - -18
visTypeTimeseries 10 - -10
visualizations 32 - -32
total -3204

History

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

cc @nchaulet

@nchaulet nchaulet merged commit 8924ff3 into elastic:master Jul 26, 2021
@nchaulet nchaulet deleted the feature-use-scoped-history branch July 26, 2021 11:50
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 26, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Migrate to ScopedHistory router
6 participants