Skip to content

Commit

Permalink
Notification filters: from links to checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ncounter committed May 30, 2024
1 parent fc8828b commit 0c9260b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 43 deletions.
4 changes: 4 additions & 0 deletions src/api/app/assets/stylesheets/webui/notifications.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ ul.avatars{
.collapse {
&.show { border-top: 1px solid $gray-300;}
}

.form-check-input:checked {
@extend .text-bg-info;
}
}
#notification-action-bar {
&.sticky-top { top: $top-navigation-height; }
Expand Down
140 changes: 98 additions & 42 deletions src/api/app/components/notification_filter_component.html.haml
Original file line number Diff line number Diff line change
@@ -1,43 +1,99 @@
.list-group.list-group-flush.my-2
= render NotificationFilterLinkComponent.new(text: 'Unread', amount: @count['unread'],
filter_item: { state: 'unread' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Read', filter_item: { state: 'read' },
selected_filter: @selected_filter)
.list-group.list-group-flush.mt-5.mb-2
%h5.ms-3 Filter
= render NotificationFilterLinkComponent.new(text: 'Comments', amount: @count['Comment'], icon: 'fas fa-comments',
filter_item: { kind: 'comments' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Requests', amount: @count['BsRequest'], icon: 'fas fa-code-pull-request',
filter_item: { kind: 'requests' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Incoming Requests', amount: @count['incoming_requests'], icon: 'fas fa-code-pull-request',
filter_item: { kind: 'incoming_requests' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Outgoing Requests', amount: @count['outgoing_requests'], icon: 'fas fa-code-pull-request',
filter_item: { kind: 'outgoing_requests' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Roles Granted', amount: @count['relationships_created'], icon: 'fas fa-user-tag',
filter_item: { kind: 'relationships_created' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Roles Revoked', amount: @count['relationships_deleted'], icon: 'fas fa-user-tag',
filter_item: { kind: 'relationships_deleted' }, selected_filter: @selected_filter)
= render NotificationFilterLinkComponent.new(text: 'Build Failures', amount: @count['build_failures'], icon: "fas fa-xmark text-danger",
filter_item: { kind: 'build_failures' }, selected_filter: @selected_filter)
- if ReportPolicy.new(@user, Report).notify?
= render NotificationFilterLinkComponent.new(text: 'Reports', amount: @count['reports'], icon: 'fas fa-flag',
filter_item: { kind: 'reports' }, selected_filter: @selected_filter,
)
= render NotificationFilterLinkComponent.new(text: 'Workflow Runs', amount: @count['workflow_runs'], icon: 'fas fa-book-open',
filter_item: { kind: 'workflow_runs' }, selected_filter: @selected_filter)
- if Flipper.enabled?(:content_moderation, @user)
= render NotificationFilterLinkComponent.new(text: 'Appealed Decisions', amount: @count['appealed_decisions'], icon: 'fas fa-hand',
filter_item: { kind: 'appealed_decisions' }, selected_filter: @selected_filter)
= form_for(:notification, url: my_notifications_path, method: :get) do |form|
.list-group.list-group-flush.mt-3.mb-2
%h6.px-3.py-2
%b State
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Unread', amount: @count['unread'] || 0,
key: 'state[unread]', checked: @selected_filter[:state] == 'unread' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Read', amount: @count['read'] || 0,
key: 'state[read]', checked: @selected_filter[:state] == 'read' }
.list-group.list-group-flush.mt-4.mb-4
%h6.px-3.py-2
%b Type
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Comments',
amount: @count['comments'] || 0,
key: 'kind[comments]',
label_icon: 'fas fa-comments',
checked: @selected_filter[:kind] == 'comments' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Requests',
amount: @count['requests'] || 0,
key: 'kind[requests]',
label_icon: 'fas fa-code-pull-request',
checked: @selected_filter[:kind] == 'requests' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Incoming Requests',
amount: @count['incoming_requests'] || 0,
key: 'kind[incoming_requests]',
label_icon: 'fas fa-code-pull-request',
checked: @selected_filter[:kind] == 'incoming_requests' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Outgoing Requests',
amount: @count['outgoing_requests'] || 0,
key: 'kind[outgoing_requests]',
label_icon: 'fas fa-code-pull-request',
checked: @selected_filter[:kind] == 'outgoing_requests' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Roles Granted',
amount: @count['relationships_created'] || 0,
key: 'kind[relationships_created]',
label_icon: 'fas fa-user-tag',
checked: @selected_filter[:kind] == 'relationships_created' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Roles Revoked',
amount: @count['relationships_deleted'] || 0,
key: 'kind[relationships_deleted]',
label_icon: 'fas fa-user-tag',
checked: @selected_filter[:kind] == 'relationships_deleted' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Build Failures',
amount: @count['build_failures'] || 0,
key: 'kind[build_failures]',
label_icon: 'fas fa-xmark text-danger',
checked: @selected_filter[:kind] == 'build_failures' }
- if ReportPolicy.new(@user, Report).notify?
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Reports',
amount: @count['reports'] || 0,
key: 'kind[reports]',
label_icon: 'fas fa-flag',
checked: @selected_filter[:kind] == 'reports' }
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Workflow Runs',
amount: @count['workflow_runs'] || 0,
key: 'kind[workflow_runs]',
label_icon: 'fas fa-book-open',
checked: @selected_filter[:kind] == 'workflow_runs' }
- if Flipper.enabled?(:content_moderation, @user)
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: 'Appealed Decisions',
amount: @count['appealed_decisions'] || 0,
key: 'kind[appealed_decisions]',
label_icon: 'fas fa-hand',
checked: @selected_filter[:kind] == 'appealed_decisions' }

- unless @projects_for_filter.empty?
.list-group.list-group-flush.mt-5.mb-2
%h5.ms-3 Projects
- @projects_for_filter.each_pair do |project_name, amount|
= render NotificationFilterLinkComponent.new(text: project_name, amount: amount, filter_item: { project: project_name },
selected_filter: @selected_filter)
- unless @groups_for_filter.empty?
.list-group.list-group-flush.mt-5.mb-2
%h5.ms-3 Groups
- @groups_for_filter.each_pair do |group_title, amount|
= render NotificationFilterLinkComponent.new(text: group_title, amount: amount, filter_item: { group: group_title },
selected_filter: @selected_filter)
- unless @projects_for_filter.empty?
.list-group.list-group-flush.mt-4.mb-4
%h6.px-3.py-2
%b Projects
- @projects_for_filter.each_pair do |project_name, amount|
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: project_name, amount: amount || 0,
key: "project[#{project_name}]",
checked: @selected_filter.dig(:project, project_name) }
- unless @groups_for_filter.empty?
.list-group.list-group-flush.mt-4.mb-4
%h6.px-3.py-2
%b Groups
- @groups_for_filter.each_pair do |group_title, amount|
.px-4.py-1
= render partial: 'webui/shared/check_box', locals: { label: group_title, amount: amount || 0,
key: "group[#{group_title}]",
checked: @selected_filter.dig(:group, group_title) }

.text-center.mt-4.mb-4
= link_to('Clear', my_notifications_path, class: 'btn btn-light border')
%button.btn.btn-info#filter-button{ type: :submit }
Apply
2 changes: 1 addition & 1 deletion src/api/app/views/webui/shared/_check_box.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%label.form-check-label.form-group.d-flex.justify-content-between{ for: key }
.form-check
= check_box_tag key, 1, checked = checked, class: 'form-check-input me-2'
= check_box_tag key, 1, checked = checked, class: 'form-check-input me-2', id: key
%span
- if defined?(label_icon)
%i.me-1{ class: label_icon }
Expand Down

0 comments on commit 0c9260b

Please sign in to comment.