mvysny / karibu-dsl

Kotlin Vaadin extensions and DSL
http://www.vaadinonkotlin.eu
MIT License
126 stars 16 forks source link

+ navigateToView(routerLink: RouterLink) #31

Closed vlipovetskii closed 3 years ago

mvysny commented 3 years ago

@vlipovetskii Thanks for the contribution! Before we merge this, could you please describe your use-case, in order for me to understand the need for this function better (and so that I can document it)?

vlipovetskii commented 3 years ago

Programmatical switching between tabs (with RouterLink) in AppLayout.

So I have a @Route class SomeAppLayoutView : AppLayout(), ... containg some tabs with RouterLink in each of them. Also I have @Route(..., SomeAppLayoutView::class) SomeViewPage(...) presenting the content for a tab in the AppLayoutView. I leverage navigateTo(routerLink) to switch to the tab with RouterLink and SomeViewPage content.

mvysny commented 3 years ago

Sounds good! Could you please write a simple test for this functionality? E.g. create a RouterLink pointing to one of the test routes, then performing the navigation, then asserting that the navigation has been done?

Actually, instead of having navigateToView() I propose to have an extension function RouterLink.navigateTo():

  1. Extension function doesn't "pollute" the global space
  2. Much better naming since navigateToView() suggests a view while we're passing in RouterLink.
vlipovetskii commented 3 years ago

Sure, I will migrate to RouterLink.navigateTo() and do a test for it.

mvysny commented 3 years ago

Thank you so much. I've created the CONTRIBUTING.md file and added a documentation on writing+running tests, please check it out and let me know whether the docs are clear, or whether they need improving.

vlipovetskii commented 3 years ago

The docs are clear and I made the test following the manual in a couple of minutes.

mvysny commented 3 years ago

Perfect, thank you, merging.