Commit e336d8d2 authored by Rajat Jain's avatar Rajat Jain Committed by Eugenia Grieff

Allow health status to be reset

Send in 0 instead of null to reset the health status in the backend.
parent f1e3dba7
......@@ -65,7 +65,10 @@ export default class IssuableBulkUpdateSidebar {
new MilestoneSelect();
issueStatusSelect();
subscriptionSelect();
HealthStatusSelect();
if (HealthStatusSelect) {
HealthStatusSelect();
}
}
setupBulkUpdateActions() {
......
......@@ -16,12 +16,12 @@ module Issuable
ids = params.delete(:issuable_ids).split(",")
items = find_issuables(parent, model_class, ids)
update_params = filter_update_params(type)
filter_update_params(type)
items.each do |issuable|
next unless can?(current_user, :"update_#{type}", issuable)
update_class.new(issuable.issuing_parent, current_user, update_params).execute(issuable)
update_class.new(issuable.issuing_parent, current_user, params).execute(issuable)
end
{
......@@ -53,8 +53,6 @@ module Issuable
if params[:assignee_ids] == [IssuableFinder::Params::NONE.to_s]
params[:assignee_ids] = []
end
params
end
def find_issuables(parent, model_class, ids)
......
- type = local_assigns.fetch(:type)
- bulk_issue_health_status_flag = @project&.group&.feature_available?(:issuable_health_status) && Feature.enabled?(:bulk_update_health_status) && type == :issues
- bulk_issue_health_status_flag = Feature.enabled?(:bulk_update_health_status) && type == :issues && @project&.group&.feature_available?(:issuable_health_status)
%aside.issues-bulk-update.js-right-sidebar.right-sidebar{ "aria-live" => "polite", data: { 'signed-in': current_user.present? } }
.issuable-sidebar.hidden
......
<script>
import Tracking from '~/tracking';
import { GlButton, GlDropdownItem, GlDropdown, GlDropdownDivider } from '@gitlab/ui';
import { s__ } from '~/locale';
import { healthStatusTextMap } from '../../constants';
......@@ -11,7 +10,6 @@ export default {
GlDropdownItem,
GlDropdownDivider,
},
mixins: [Tracking.mixin()],
props: {
isEditable: {
type: Boolean,
......@@ -40,9 +38,6 @@ export default {
};
},
computed: {
canRemoveStatus() {
return this.isEditable && this.status;
},
statusText() {
return this.status ? healthStatusTextMap[this.status] : s__('Sidebar|None');
},
......@@ -72,28 +67,11 @@ export default {
handleDropdownClick(status) {
this.selectedStatus = status;
this.$emit('onDropdownClick', status);
this.track('change_health_status', { property: status });
this.hideDropdown();
},
hideDropdown() {
this.isDropdownShowing = false;
},
toggleFormDropdown() {
this.isDropdownShowing = !this.isDropdownShowing;
/**
* We need to programmatically open the dropdown to make the
* outside click on document close the dropdown.
*/
const { dropdown } = this.$refs.dropdown.$refs;
if (dropdown && this.isDropdownShowing) {
dropdown.show();
}
},
removeStatus() {
this.handleDropdownClick(null);
},
isSelected(status) {
return this.status === status;
},
......
......@@ -27,7 +27,7 @@ export default () => {
this.selectedStatus = selectedStatus;
healthStatusFormFieldEl.setAttribute(
'value',
selectedStatus ? healthStatusForRestApi[selectedStatus] : selectedStatus,
healthStatusForRestApi[selectedStatus || 'NO_STATUS'],
);
},
},
......
- group = local_assigns.fetch(:group)
- type = local_assigns.fetch(:type)
- bulk_issue_health_status_flag = @group&.feature_available?(:issuable_health_status) && Feature.enabled?(:bulk_update_health_status) && type == :issues
- bulk_issue_health_status_flag = Feature.enabled?(:bulk_update_health_status) && type == :issues && @project&.group&.feature_available?(:issuable_health_status)
%aside.issues-bulk-update.js-right-sidebar.right-sidebar{ 'aria-live' => 'polite', data: { 'signed-in': current_user.present? } }
.issuable-sidebar.hidden
......
......@@ -3,12 +3,11 @@
require 'spec_helper'
describe 'Issues > Health status bulk assignment' do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, group: group) }
let!(:issue1) { create(:issue, project: project, title: "Issue 1") }
let!(:issue2) { create(:issue, project: project, title: "Issue 2") }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:issue1) { create(:issue, project: project, title: "Issue 1") }
let_it_be(:issue2) { create(:issue, project: project, title: "Issue 2") }
context 'as an allowed user', :js do
before do
......@@ -22,16 +21,12 @@ describe 'Issues > Health status bulk assignment' do
end
context 'sidebar' do
before do
enable_bulk_update
end
it 'is present when bulk edit is enabled' do
enable_bulk_update
expect(page).to have_css('.issuable-sidebar')
end
it 'is not present when bulk edit is disabled' do
disable_bulk_update
expect(page).not_to have_css('.issuable-sidebar')
end
end
......@@ -49,7 +44,7 @@ describe 'Issues > Health status bulk assignment' do
update_issues
end
it do
it 'updates the health statuses' do
expect(issue1.reload.health_status).to eq 'on_track'
expect(issue2.reload.health_status).to eq 'on_track'
end
......@@ -62,7 +57,7 @@ describe 'Issues > Health status bulk assignment' do
update_issues
end
it do
it 'updates the checked issue\'s status' do
expect(issue1.reload.health_status).to eq 'at_risk'
expect(issue2.reload.health_status).to eq nil
end
......@@ -81,12 +76,10 @@ describe 'Issues > Health status bulk assignment' do
visit project_issues_path(project)
end
context 'cannot bulk assign health_status' do
it do
expect(page).not_to have_button 'Edit issues'
expect(page).not_to have_css '.check-all-issues'
expect(page).not_to have_css '.issue-check'
end
it 'cannot bulk assign health_status' do
expect(page).not_to have_button 'Edit issues'
expect(page).not_to have_css '.check-all-issues'
expect(page).not_to have_css '.issue-check'
end
end
......@@ -99,7 +92,7 @@ describe 'Issues > Health status bulk assignment' do
end
end
def check_issue(issue, uncheck = false)
def toggle_issue(issue, uncheck = false)
page.within('.issues-list') do
if uncheck
uncheck "selected_issue_#{issue.id}"
......@@ -110,7 +103,7 @@ describe 'Issues > Health status bulk assignment' do
end
def uncheck_issue(issue)
check_issue(issue, true)
toggle_issue(issue, uncheck: true)
end
def update_issues
......@@ -122,8 +115,4 @@ describe 'Issues > Health status bulk assignment' do
visit project_issues_path(project)
click_button 'Edit issues'
end
def disable_bulk_update
click_button 'Cancel'
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment