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

Update breadcrumb #6514

Closed
wants to merge 2 commits into from
Closed

Update breadcrumb #6514

wants to merge 2 commits into from

Conversation

bgeuken
Copy link
Member

@bgeuken bgeuken commented Dec 7, 2018

Evaluate the label for the active breadcrumb in a helper to reduce
repetitive view code.

Advantages

  • No more overhead by using Rails path helpers
  • One place where we set the label for the active breadcrumb
  • More generic code, which means we only have to explicitly set the
    breadcrumb label for some edge cases.

@bgeuken bgeuken added the Frontend Things related to the OBS RoR app label Dec 7, 2018
@bgeuken
Copy link
Member Author

bgeuken commented Dec 7, 2018

I think there is still more to do. But I want to get some feedback first.

Evaluate the label for the active breadcrumb in a helper to reduce
repetitive view code.

Advantages

  * No more overhead by using Rails path helpers
  * One place where we set the label for the active breadcrumb
  * More generic code, which means we only have to explicitly set the
    breadcrumb label for some edge cases.
This replace the usage of path helpers in our breadcrumbs with
checks for action and / or controller name.
This means that we don't have to worry anymore whether a @project
or @Package variable, that was needed by one of the helpers, was
set.
In addition we stop having to looking up the rooting table only
to check if we are on a show or index page.
@dmarcoux
Copy link
Contributor

dmarcoux commented Dec 7, 2018

I agree that the duplication should be avoided, but I also like that everything about the breadcrumbs is in partials. I find that this approach adds another layer (in the helper) and it's not really making it simpler.

@coolo
Copy link
Member

coolo commented Dec 8, 2018

simple code isn't really a design goal, de-duplication always wins IMO.

@ChrisBr
Copy link
Member

ChrisBr commented Dec 10, 2018

I agree that the duplication should be avoided, but I also like that everything about the breadcrumbs is in partials. I find that this approach adds another layer (in the helper) and it's not really making it simpler.

I agree.

@@ -1,6 +1,6 @@
= render partial: "webui/#{@container.model_name.singular}/breadcrumb_items"

- if current_page?(index_attribs_path)
Copy link
Member

@ChrisBr ChrisBr Dec 10, 2018

Choose a reason for hiding this comment

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

What is wrong with this approach? I don't see a benefit in using action_name == ... over current_page...

Copy link
Member Author

Choose a reason for hiding this comment

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

We just want to know where we are. There is no need to generate a path. Especially if this can fail, e.g. when the object needed by the generated route does not exist. We had issues like this and alike a couple of times.

The only disadvantage of using action_name / controller_name that I see is that we have to adjust them manually whenever the routes change. But that doesn't happen often.

@dmarcoux
Copy link
Contributor

I prefer to follow the KISS principle.

@bgeuken
Copy link
Member Author

bgeuken commented Dec 10, 2018

I don't see what is simple in having breadcrumb partials all over the place. And having so many breadcrumb related patches / PRs doesn't really speak for it's simplicity.

That said, I agree that this approach isn't perfect either. IMO we should have a simple way to generate them. Without having to define individual partials everywhere.

@hennevogel
Copy link
Member

simple code isn't really a design goal

Au contraire, mon ami!

@coolo
Copy link
Member

coolo commented Dec 11, 2018

Perhaps my statement was too simplified to be generic - which was my point to begin with, so I think I created a recursion.

If 'simple code' was a design goal, we wouldn't spend all this effort with models and functions and whatnot.

maintable code is the design goal - and I very much agree with @bgeuken here, that the current breadcrumb partials aren't KISS. They are horrible copy&paste code.

But I prefer #6532 (comment) over fighting this

@bgeuken
Copy link
Member Author

bgeuken commented Jan 20, 2019

Closing for now, since this requires some more polishing

@bgeuken bgeuken closed this Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Things related to the OBS RoR app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants