Commit 1f026738 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Fix promoting labels and milestones copy text

parent fe5f7390
...@@ -19,15 +19,19 @@ ...@@ -19,15 +19,19 @@
type: String, type: String,
required: true, required: true,
}, },
groupName: {
type: String,
required: true,
},
}, },
computed: { computed: {
title() { title() {
return sprintf(s__('Milestones|Promote %{milestoneTitle} to group milestone?'), { milestoneTitle: this.milestoneTitle }); return sprintf(s__('Milestones|Promote %{milestoneTitle} to group milestone?'), { milestoneTitle: this.milestoneTitle });
}, },
text() { text() {
return s__(`Milestones|Promoting this milestone will make it available for all projects inside the group. return sprintf(s__(`Milestones|Promoting %{milestoneTitle} will make it available for all projects inside %{groupName}.
Existing project milestones with the same title will be merged. Existing project milestones with the same title will be merged.
This action cannot be reversed.`); This action cannot be reversed.`), { milestoneTitle: this.milestoneTitle, groupName: this.groupName });
}, },
}, },
methods: { methods: {
......
...@@ -25,6 +25,7 @@ export default () => { ...@@ -25,6 +25,7 @@ export default () => {
const modalProps = { const modalProps = {
milestoneTitle: button.dataset.milestoneTitle, milestoneTitle: button.dataset.milestoneTitle,
url: button.dataset.url, url: button.dataset.url,
groupName: button.dataset.groupName,
}; };
eventHub.$once('promoteMilestoneModal.requestStarted', onRequestStarted); eventHub.$once('promoteMilestoneModal.requestStarted', onRequestStarted);
eventHub.$emit('promoteMilestoneModal.props', modalProps); eventHub.$emit('promoteMilestoneModal.props', modalProps);
...@@ -54,6 +55,7 @@ export default () => { ...@@ -54,6 +55,7 @@ export default () => {
return { return {
modalProps: { modalProps: {
milestoneTitle: '', milestoneTitle: '',
groupName: '',
url: '', url: '',
}, },
}; };
......
...@@ -27,11 +27,18 @@ ...@@ -27,11 +27,18 @@
type: String, type: String,
required: true, required: true,
}, },
groupName: {
type: String,
required: true,
},
}, },
computed: { computed: {
text() { text() {
return s__(`Milestones|Promoting this label will make it available for all projects inside the group. return sprintf(s__(`Labels|Promoting %{labelTitle} will make it available for all projects inside %{groupName}.
Existing project labels with the same title will be merged. This action cannot be reversed.`); Existing project labels with the same title will be merged. This action cannot be reversed.`), {
labelTitle: this.labelTitle,
groupName: this.groupName,
});
}, },
title() { title() {
const label = `<span const label = `<span
......
...@@ -30,6 +30,7 @@ const initLabelIndex = () => { ...@@ -30,6 +30,7 @@ const initLabelIndex = () => {
labelColor: button.dataset.labelColor, labelColor: button.dataset.labelColor,
labelTextColor: button.dataset.labelTextColor, labelTextColor: button.dataset.labelTextColor,
url: button.dataset.url, url: button.dataset.url,
groupName: button.dataset.groupName,
}; };
eventHub.$once('promoteLabelModal.requestStarted', onRequestStarted); eventHub.$once('promoteLabelModal.requestStarted', onRequestStarted);
eventHub.$emit('promoteLabelModal.props', modalProps); eventHub.$emit('promoteLabelModal.props', modalProps);
...@@ -62,6 +63,7 @@ const initLabelIndex = () => { ...@@ -62,6 +63,7 @@ const initLabelIndex = () => {
labelColor: '', labelColor: '',
labelTextColor: '', labelTextColor: '',
url: '', url: '',
groupName: '',
}, },
}; };
}, },
......
...@@ -112,7 +112,7 @@ class Projects::LabelsController < Projects::ApplicationController ...@@ -112,7 +112,7 @@ class Projects::LabelsController < Projects::ApplicationController
begin begin
return render_404 unless promote_service.execute(@label) return render_404 unless promote_service.execute(@label)
flash[:notice] = "#{@label.title} promoted to group label." flash[:notice] = "#{@label.title} promoted to <a href=#{group_labels_path(@project.group)}>group label.</a>".html_safe
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to(project_labels_path(@project), status: 303) redirect_to(project_labels_path(@project), status: 303)
......
...@@ -74,9 +74,9 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -74,9 +74,9 @@ class Projects::MilestonesController < Projects::ApplicationController
end end
def promote def promote
Milestones::PromoteService.new(project, current_user).execute(milestone) promoted_milestone = Milestones::PromoteService.new(project, current_user).execute(milestone)
flash[:notice] = "#{milestone.title} promoted to group milestone" flash[:notice] = "#{milestone.title} promoted to <a href=#{group_milestone_path(project.group, promoted_milestone.iid)}>group milestone.</a>".html_safe
respond_to do |format| respond_to do |format|
format.html do format.html do
redirect_to project_milestones_path(project) redirect_to project_milestones_path(project)
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
%button.js-promote-project-milestone-button.btn.btn-grouped{ data: { toggle: 'modal', %button.js-promote-project-milestone-button.btn.btn-grouped{ data: { toggle: 'modal',
target: '#promote-milestone-modal', target: '#promote-milestone-modal',
milestone_title: @milestone.title, milestone_title: @milestone.title,
group_name: @project.group.name,
url: promote_project_milestone_path(@milestone.project, @milestone), url: promote_project_milestone_path(@milestone.project, @milestone),
container: 'body' }, container: 'body' },
disabled: true, disabled: true,
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
label_title: label.title, label_title: label.title,
label_color: label.color, label_color: label.color,
label_text_color: label.text_color, label_text_color: label.text_color,
group_name: label.project.group.name,
target: '#promote-label-modal', target: '#promote-label-modal',
container: 'body', container: 'body',
toggle: 'modal' } } toggle: 'modal' } }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
type: 'button', type: 'button',
data: { url: promote_project_milestone_path(milestone.project, milestone), data: { url: promote_project_milestone_path(milestone.project, milestone),
milestone_title: milestone.title, milestone_title: milestone.title,
group_name: @project.group.name,
target: '#promote-milestone-modal', target: '#promote-milestone-modal',
container: 'body', container: 'body',
toggle: 'modal' } } toggle: 'modal' } }
......
...@@ -107,7 +107,7 @@ describe Projects::MilestonesController do ...@@ -107,7 +107,7 @@ describe Projects::MilestonesController do
it 'shows group milestone' do it 'shows group milestone' do
post :promote, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid post :promote, namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid
expect(flash[:notice]).to eq("#{milestone.title} promoted to group milestone") expect(flash[:notice]).to eq("#{milestone.title} promoted to <a href=#{group_milestone_path(project.group, milestone.iid)}>group milestone.</a>")
expect(response).to redirect_to(project_milestones_path(project)) expect(response).to redirect_to(project_milestones_path(project))
end end
end end
......
...@@ -12,6 +12,7 @@ describe('Promote label modal', () => { ...@@ -12,6 +12,7 @@ describe('Promote label modal', () => {
labelColor: '#5cb85c', labelColor: '#5cb85c',
labelTextColor: '#ffffff', labelTextColor: '#ffffff',
url: `${gl.TEST_HOST}/dummy/promote/labels`, url: `${gl.TEST_HOST}/dummy/promote/labels`,
groupName: 'group',
}; };
describe('Modal title and description', () => { describe('Modal title and description', () => {
...@@ -24,7 +25,7 @@ describe('Promote label modal', () => { ...@@ -24,7 +25,7 @@ describe('Promote label modal', () => {
}); });
it('contains the proper description', () => { it('contains the proper description', () => {
expect(vm.text).toContain('Promoting this label will make it available for all projects inside the group'); expect(vm.text).toContain(`Promoting ${labelMockData.labelTitle} will make it available for all projects inside ${labelMockData.groupName}`);
}); });
it('contains a label span with the color', () => { it('contains a label span with the color', () => {
......
...@@ -10,6 +10,7 @@ describe('Promote milestone modal', () => { ...@@ -10,6 +10,7 @@ describe('Promote milestone modal', () => {
const milestoneMockData = { const milestoneMockData = {
milestoneTitle: 'v1.0', milestoneTitle: 'v1.0',
url: `${gl.TEST_HOST}/dummy/promote/milestones`, url: `${gl.TEST_HOST}/dummy/promote/milestones`,
groupName: 'group',
}; };
describe('Modal title and description', () => { describe('Modal title and description', () => {
...@@ -22,7 +23,7 @@ describe('Promote milestone modal', () => { ...@@ -22,7 +23,7 @@ describe('Promote milestone modal', () => {
}); });
it('contains the proper description', () => { it('contains the proper description', () => {
expect(vm.text).toContain('Promoting this milestone will make it available for all projects inside the group.'); expect(vm.text).toContain(`Promoting ${milestoneMockData.milestoneTitle} will make it available for all projects inside ${milestoneMockData.groupName}.`);
}); });
it('contains the correct title', () => { it('contains the correct title', () => {
......
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