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