jenkins-timeline-plugin
jenkins-timeline-plugin copied to clipboard
Update build url when navigating between build views
Is your feature request related to a problem? Please describe. Spawned from a discussion in https://github.com/tophat/jenkins-timeline-plugin/pull/120#pullrequestreview-605802987 where a feature to navigate between adjacent build is added
Currently navigating to new url does not update the url or the buildUrl state. This also applies to when using the Back button, it would also go back to the original build since we do not update the buildUrl.
The better way forward is likely to show on the url which build we have navigated to, and when backing to regular jenkins view, see the build that it's presently on inside jenkins-timeline
Describe the solution you'd like A clear and concise description of what you want to happen.
- no longer have buildUrl passed into Dashboard component, have it as a state inside Dashboard instead
- each time new build is navigated to, set state along with all other states inside fetchBuildData(), as well as push to history using react-router to update the url.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
- this was done using window.location.assign, but as discussed it breaks the single page app experience, also feel clunkier as a user
Additional context Add any other context or screenshots about the feature request here.
Something I envision for this would be along the lines of the regular Jenkins URLS, something like /job/<job_id>/build/<build_id>
instead of the current queryparam that contains that information. We don't necessarily have to throw in proper app state right away, but having this information neatly encoded in the URL and updated as we go would be neat.
What do you think?
I see what you mean now! I think I misunderstood initially.
Yeah, I think one way to do this is on the Java MenuItem end, instead of "/plugin/pipeline-timeline/index.html?build_url="+this.buildUrl;" do parse buildUrl to strip the https://jenkins.**.com out "/plugin/pipeline-timeline/strippedBuildUrl/index.html";
so it'd be /plugin/pipline-timeline/job/yourjob/build/3/index.html
A more UX question is, if Back button is clicked, should it go to the original build, or the build that it currently navigated to?
IMO the Back Button as in "Back to Jenkins" should lead back to the Jenkins build page corresponding to the timeline you are viewing. If we know the build and job ids, composing the URL we need to jump to should be pretty straightforward.
I do think you're on the right track re:the URL, there's a change on the Java side to communicate where you want to go to the webapp, and some routing logic in React.
Agreed on the Back Button behaviour, and yeah the change is pretty trivial regardless of the way URL is passed.
I found where the Java side of things is URL wise, I think i'm ready to pick this up and see where it goes.
Neat! Let me know if you want eyes on your PR along the way!