Renamed some messages and refactored the project_edit class to a function
This commit is contained in:
parent
42604d4c33
commit
fbde5e3313
|
@ -40,7 +40,7 @@ import Group from './group';
|
|||
import GroupName from './group_name';
|
||||
import GroupsList from './groups_list';
|
||||
import ProjectsList from './projects_list';
|
||||
import ProjectEdit from './project_edit';
|
||||
import setupProjectEdit from './project_edit';
|
||||
import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
|
||||
import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
|
||||
import Landing from './landing';
|
||||
|
@ -266,7 +266,7 @@ import ShortcutsBlob from './shortcuts_blob';
|
|||
}
|
||||
break;
|
||||
case 'projects:edit':
|
||||
new ProjectEdit();
|
||||
setupProjectEdit();
|
||||
break;
|
||||
case 'projects:pipelines:builds':
|
||||
case 'projects:pipelines:failures':
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
export default class ProjectEdit {
|
||||
constructor() {
|
||||
this.transferForm = $('.js-project-transfer-form');
|
||||
this.selectNamespace = $('.js-project-transfer-form').find('.select2');
|
||||
export default function setupProjectEdit() {
|
||||
const $transferForm = $('.js-project-transfer-form');
|
||||
const $selectNamespace = $transferForm.find('.select2');
|
||||
|
||||
this.selectNamespaceChangedWrapper = this.selectNamespaceChanged.bind(this);
|
||||
this.selectNamespace.on('change', this.selectNamespaceChangedWrapper);
|
||||
this.selectNamespaceChanged();
|
||||
}
|
||||
|
||||
selectNamespaceChanged() {
|
||||
const selectedNamespaceValue = this.selectNamespace.val();
|
||||
|
||||
this.transferForm.find(':submit').prop('disabled', !selectedNamespaceValue);
|
||||
}
|
||||
$selectNamespace.on('change', () => {
|
||||
$transferForm.find(':submit').prop('disabled', !$selectNamespace.val());
|
||||
});
|
||||
$selectNamespace.trigger('change');
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ module Projects
|
|||
transfer(project, new_namespace)
|
||||
else
|
||||
error_message = if new_namespace.blank?
|
||||
'Please select a namespace to transfer the project to'
|
||||
'Please select a new namespace for your project.'
|
||||
else
|
||||
'Transfer failed, please contact an admin'
|
||||
'Transfer failed, please contact an admin.'
|
||||
end
|
||||
project.errors.add(:new_namespace, error_message)
|
||||
false
|
||||
|
|
|
@ -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-group
|
||||
= label_tag :new_namespace_id, nil, class: 'label-light' do
|
||||
%span Select namespace to transfer to
|
||||
%span Select a new namespace
|
||||
.form-group
|
||||
= select_tag :new_namespace_id, namespaces_options(nil), include_blank: true, class: 'select2'
|
||||
%ul
|
||||
|
|
|
@ -266,7 +266,7 @@ describe ProjectsController do
|
|||
|
||||
expect(project.namespace.id).to eq(old_namespace_id)
|
||||
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
|
||||
|
|
|
@ -26,7 +26,7 @@ describe Projects::TransferService, services: true do
|
|||
|
||||
it { expect(@result).to eq false }
|
||||
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
|
||||
|
||||
context 'disallow transfering of project with tags' do
|
||||
|
|
Loading…
Reference in New Issue