Commit fbde5e33 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Renamed some messages and refactored the project_edit class to a function

parent 42604d4c
...@@ -40,7 +40,7 @@ import Group from './group'; ...@@ -40,7 +40,7 @@ import Group from './group';
import GroupName from './group_name'; import GroupName from './group_name';
import GroupsList from './groups_list'; import GroupsList from './groups_list';
import ProjectsList from './projects_list'; import ProjectsList from './projects_list';
import ProjectEdit from './project_edit'; import setupProjectEdit from './project_edit';
import MiniPipelineGraph from './mini_pipeline_graph_dropdown'; import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater'; import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
import Landing from './landing'; import Landing from './landing';
...@@ -266,7 +266,7 @@ import ShortcutsBlob from './shortcuts_blob'; ...@@ -266,7 +266,7 @@ import ShortcutsBlob from './shortcuts_blob';
} }
break; break;
case 'projects:edit': case 'projects:edit':
new ProjectEdit(); setupProjectEdit();
break; break;
case 'projects:pipelines:builds': case 'projects:pipelines:builds':
case 'projects:pipelines:failures': case 'projects:pipelines:failures':
......
export default class ProjectEdit { export default function setupProjectEdit() {
constructor() { const $transferForm = $('.js-project-transfer-form');
this.transferForm = $('.js-project-transfer-form'); const $selectNamespace = $transferForm.find('.select2');
this.selectNamespace = $('.js-project-transfer-form').find('.select2');
this.selectNamespaceChangedWrapper = this.selectNamespaceChanged.bind(this); $selectNamespace.on('change', () => {
this.selectNamespace.on('change', this.selectNamespaceChangedWrapper); $transferForm.find(':submit').prop('disabled', !$selectNamespace.val());
this.selectNamespaceChanged(); });
} $selectNamespace.trigger('change');
selectNamespaceChanged() {
const selectedNamespaceValue = this.selectNamespace.val();
this.transferForm.find(':submit').prop('disabled', !selectedNamespaceValue);
}
} }
...@@ -16,9 +16,9 @@ module Projects ...@@ -16,9 +16,9 @@ module Projects
transfer(project, new_namespace) transfer(project, new_namespace)
else else
error_message = if new_namespace.blank? error_message = if new_namespace.blank?
'Please select a namespace to transfer the project to' 'Please select a new namespace for your project.'
else else
'Transfer failed, please contact an admin' 'Transfer failed, please contact an admin.'
end end
project.errors.add(:new_namespace, error_message) project.errors.add(:new_namespace, error_message)
false false
......
...@@ -253,7 +253,7 @@ ...@@ -253,7 +253,7 @@
= form_for([@project.namespace.becomes(Namespace), @project], url: transfer_namespace_project_path(@project.namespace, @project), method: :put, remote: true, html: { class: 'js-project-transfer-form' } ) do |f| = form_for([@project.namespace.becomes(Namespace), @project], url: transfer_namespace_project_path(@project.namespace, @project), method: :put, remote: true, html: { class: 'js-project-transfer-form' } ) do |f|
.form-group .form-group
= label_tag :new_namespace_id, nil, class: 'label-light' do = label_tag :new_namespace_id, nil, class: 'label-light' do
%span Select namespace to transfer to %span Select a new namespace
.form-group .form-group
= select_tag :new_namespace_id, namespaces_options(nil), include_blank: true, class: 'select2' = select_tag :new_namespace_id, namespaces_options(nil), include_blank: true, class: 'select2'
%ul %ul
......
...@@ -266,7 +266,7 @@ describe ProjectsController do ...@@ -266,7 +266,7 @@ describe ProjectsController do
expect(project.namespace.id).to eq(old_namespace_id) expect(project.namespace.id).to eq(old_namespace_id)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(flash[:alert]).to eq 'Please select a namespace to transfer the project to' expect(flash[:alert]).to eq 'Please select a new namespace for your project.'
end end
end end
end end
......
...@@ -26,7 +26,7 @@ describe Projects::TransferService, services: true do ...@@ -26,7 +26,7 @@ describe Projects::TransferService, services: true do
it { expect(@result).to eq false } it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) } it { expect(project.namespace).to eq(user.namespace) }
it { expect(project.errors.messages[:new_namespace][0]).to eq 'Please select a namespace to transfer the project to' } it { expect(project.errors.messages[:new_namespace][0]).to eq 'Please select a new namespace for your project.' }
end end
context 'disallow transfering of project with tags' do context 'disallow transfering of project with tags' do
......
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