Skip to content

Commit

Permalink
Limit shown statuses to the project
Browse files Browse the repository at this point in the history
Only issue statuses allowed in workflows of active trackers are shown.

Fixes #121
Fixes #127
Fixes #130
  • Loading branch information
jgraichen committed Jul 17, 2021
1 parent 1bcab0f commit 8e3b877
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch

### New

- Limit shown statuses to the one available in the project (#121, #127, #130)
- Store dashboard settings in user preferences (#39)

### Changes
Expand Down
11 changes: 11 additions & 0 deletions app/models/rdb_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def issues
.includes(:assigned_to, :time_entries, :tracker, :status, :priority, :fixed_version)
end

def statuses
ids = WorkflowTransition
.where(tracker: trackers)
.distinct
.pluck(:old_status_id, :new_status_id)
.flatten
.uniq

IssueStatus.where(id: ids).sorted
end

def versions
@versions ||= Version.where(project_id: project_ids).distinct
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/rdb_taskboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def build
# Init columns
options[:hide_columns] ||= []

done_statuses = IssueStatus.sorted.select do |status|
done_statuses = statuses.select do |status|
next true if status.is_closed?

add_column RdbColumn.new(
Expand Down
34 changes: 34 additions & 0 deletions spec/models/rdb_dashboard/statuses_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require File.expand_path('../../spec_helper', __dir__)

describe RdbDashboard do
fixtures %i[
enabled_modules
issue_statuses
projects
projects_trackers
trackers
workflows
]

subject(:dashboard) { RdbDashboard.new(project, options, params) }

let(:project) { Project.find(1) }
let(:options) { {} }
let(:params) { {} }

describe '#statuses' do
subject(:statuses) { dashboard.statuses }

before do
# Delete all workflow rules related to status 6 (Rejected). We will test,
# that this now unused issue status does not appear on the board.
WorkflowTransition.where('new_status_id = :id OR old_status_id = :id', id: 6).delete_all
end

it 'returns the project' do
expect(statuses.map(&:id)).to eq [1, 2, 3, 4, 5]
end
end
end

0 comments on commit 8e3b877

Please sign in to comment.