Skip to content

Commit

Permalink
Differentiate request state badge icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed Apr 12, 2023
1 parent 7257571 commit 59b5deb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/api/app/assets/stylesheets/webui/colors.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.bg-gray-800 {
background-color: $gray-800;
}

.bg-dismissed {
background-color: $gray-500;
}
4 changes: 4 additions & 0 deletions src/api/app/assets/stylesheets/webui/requests.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
height: 400px;
}

.fa-stack-slash {
left: -2px;
}

@include media-breakpoint-up(sm) {
.order-sm-1 {
order: 1;
Expand Down
35 changes: 33 additions & 2 deletions src/api/app/components/bs_request_state_badge_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(bs_request:, css_class: nil)
def call
content_tag(
:span,
tag.i(class: 'fas fa-code-pull-request me-1').concat(@bs_request.state),
icon_state_tag.concat(@bs_request.state),
class: ['badge', "bg-#{decode_state_color(@bs_request.state)}", @css_class]
)
end
Expand All @@ -18,14 +18,45 @@ def decode_state_color(state)
case state
when :review, :new
'secondary'
when :declined, :revoke
when :declined
'danger'
when :superseded
'warning'
when :accepted
'success'
when :revoked
'dismissed'
else
'dark'
end
end

def decode_state_icon(state)
case state
when :new
'code-branch'
when :review, :declined, :revoked
'code-pull-request'
when :superseded
'code-compare'
when :accepted
'code-merge'
else
'code-fork'
end
end

def icon_state_tag
if [:declined, :revoked].include?(@bs_request.state)
content_tag(
:span,
tag.i(class: "fas fa-#{decode_state_icon(@bs_request.state)}").concat(
tag.i(class: 'fas fa-slash fa-stack-1x fa-stack-slash top-icon')
),
class: 'position-relative me-1'
)
else
tag.i(class: "fas fa-#{decode_state_icon(@bs_request.state)} me-1")
end
end
end

0 comments on commit 59b5deb

Please sign in to comment.