Add `active_when` helper
We have the following pattern all over the codebase in views:
%li{ class: (klass == Gitlab::GitLogger ? 'active' : '') }
It'd be awesome if we could just do this, for example:
%li{ class: active_when(klass == Gitlab::GitLogger) }
The implementation couldn't be simpler:
def active_when(condition)
'active' if condition
end
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
I'd love to take this up as a starter issue. Only thing I'd like to ask is how to best test this behavior?
- Author Owner
@pawandubey Great! https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/helpers/broadcast_messages_helper_spec.rb contains some really basic helper specs that should give you an idea of how to test a helper and our preferred style.
Also, as much as
ApplicationHelper
is a junk drawer already, I think this is a rare case of this helper actually belonging in that module. - Contributor
@rspeicher Hi i'm new here, i would love take care of this issue, i don't know if @pawandubey still working on this, if not could you please assignee me to this issue?
- username-removed-128633 Added ~307491 label
Added ~307491 label
- username-removed-128633 Milestone changed to %8.15
Milestone changed to %8.15
@lchavez Hey Luis, I am almost done with this issue and will be making a PR by tomorrow. Sorry for the delay!
- username-removed-128633 Reassigned to @pawandubey
Reassigned to @pawandubey
- username-removed-443319 Added Deliverable and removed ~307491 technical debt ~131895 labels
Added Deliverable and removed ~307491 technical debt ~131895 labels
- username-removed-443319 Added ~874211 ~889916 ~480950 technical debt ~131895 labels
Added ~874211 ~889916 ~480950 technical debt ~131895 labels
- Maintainer
I wonder if
active_when
should take a block instead of a value and becomeactive_if { something }
to resembleArray#delete_if
better. Would this work? - Author Owner
@grzesiek What's the benefit there? The point of the helper as I saw it was just to clean up the frontend code a bit, and I think the block form is slightly dirtier.
- Maintainer
@rspeicher Makes sense!
- Maintainer
@pawandubey Any progress on this? Do you need help?
@rymai I am sorry for vanishing off the face of the internet. I am stuck with exams at the university for the next few days. I just have to make the PR but I need to clean up my commits. Is it acceptable if I delay it by a few days? I will make time for this by Dec 2nd.
- Maintainer
@pawandubey That's ok, thanks for the heads up!
- username-removed-443319 changed milestone to %8.16
changed milestone to %8.16
- username-removed-419655 added ~123454 label
added ~123454 label
- Douwe Maan changed milestone to %8.17
changed milestone to %8.17
- Douwe Maan removed milestone
removed milestone
- Douwe Maan removed Deliverable label
removed Deliverable label
- username-removed-378947 removed ~131895 label
removed ~131895 label
- username-removed-48286 mentioned in merge request !9166 (merged)
mentioned in merge request !9166 (merged)
- Robert Speicher closed via merge request !9166 (merged)
closed via merge request !9166 (merged)
- Nikola Milojevic mentioned in merge request !14785
mentioned in merge request !14785