Skip to content

Commit

Permalink
Activity page fixes (#811)
Browse files Browse the repository at this point in the history
* Fixed incorrect breadcrumbs for project and group activity page, fixed issue with settings menu not remaining open when an item was selected on the group activity page, updated project details page to show the number of members without automation bots

* Updated view_history? policy methods to allow members of shared groups with the access level maintainer or higher to view history items
  • Loading branch information
deepsidhu85 authored Oct 17, 2024
1 parent 13fdbc0 commit 52d12ff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<%= viral_tooltip(title: t(:"components.project_dashboard.information.number_of_members")) do %>
<span class="flex items-center">
<%= viral_icon(name: :users, color: :subdued, classes: "h-5 w-5 m-0 mr-2") %>
<%= @project.namespace.project_members.count %>
<%= @project.namespace.project_members.without_automation_bots.count %>
</span>
<% end %>
</span>
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def context_crumbs
case action_name
when 'new', 'create', 'show'
@context_crumbs
when 'activity'
@context_crumbs += [{
name: I18n.t('groups.activity.title'),
path: group_activity_path
}]
else
@context_crumbs += [{
name: I18n.t('groups.edit.title'),
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def context_crumbs
name: I18n.t('projects.edit.title'),
path: namespace_project_edit_path
}]
when 'activity'
@context_crumbs += [{
name: I18n.t('projects.activity.title'),
path: namespace_project_activity_path
}]
end
end

Expand Down
6 changes: 6 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class Member < ApplicationRecord # rubocop:disable Metrics/ClassLength

scope :not_expired, -> { where('expires_at IS NULL OR expires_at > ?', Time.zone.now.beginning_of_day) }

scope :without_automation_bots, lambda {
joins(:user).where.not(
user: { user_type: User.user_types[:project_automation_bot] }
)
}

class << self
DEFAULT_CAN_OPTIONS = {
include_group_links: true
Expand Down
2 changes: 1 addition & 1 deletion app/policies/group_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_subgroup?
end

def view_history?
return true if Member.can_view?(user, record, include_group_links: false) == true
return true if Member.can_view?(user, record) == true

details[:name] = record.name
false
Expand Down
2 changes: 1 addition & 1 deletion app/policies/project_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def activity?

def view_history?
return true if record.namespace.parent.user_namespace? && record.namespace.parent.owner == user
return true if Member.can_view?(user, record.namespace, include_group_links: false) == true
return true if Member.can_view?(user, record.namespace) == true

details[:name] = record.name
false
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/groups.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
selectable_pages: [
t(:"groups.sidebar.general"),
t(:"groups.sidebar.bot_accounts"),
t(:"groups.sidebar.history"),
],
current_page: @current_page
) do |multi_level_menu| %>
Expand Down

0 comments on commit 52d12ff

Please sign in to comment.