2018-06-16 13:20:30 +00:00
|
|
|
/* eslint-disable no-new */
|
2018-03-09 20:18:59 +00:00
|
|
|
|
|
|
|
import $ from 'jquery';
|
2017-11-20 20:28:29 +00:00
|
|
|
import NewCommitForm from '../new_commit_form';
|
2017-03-08 00:04:20 +00:00
|
|
|
import EditBlob from './edit_blob';
|
|
|
|
import BlobFileDropzone from '../blob/blob_file_dropzone';
|
|
|
|
|
2018-02-21 20:22:56 +00:00
|
|
|
export default () => {
|
2017-03-08 00:04:20 +00:00
|
|
|
const editBlobForm = $('.js-edit-blob-form');
|
|
|
|
const uploadBlobForm = $('.js-upload-blob-form');
|
2017-08-01 08:50:59 +00:00
|
|
|
const deleteBlobForm = $('.js-delete-blob-form');
|
2017-03-08 00:04:20 +00:00
|
|
|
|
|
|
|
if (editBlobForm.length) {
|
2018-02-20 22:20:48 +00:00
|
|
|
const urlRoot = editBlobForm.data('relativeUrlRoot');
|
|
|
|
const assetsPath = editBlobForm.data('assetsPrefix');
|
2018-10-30 20:28:31 +00:00
|
|
|
const filePath = editBlobForm.data('blobFilename');
|
2018-02-20 22:20:48 +00:00
|
|
|
const currentAction = $('.js-file-title').data('currentAction');
|
2018-10-02 23:00:38 +00:00
|
|
|
const projectId = editBlobForm.data('project-id');
|
2018-11-27 10:05:25 +00:00
|
|
|
const commitButton = $('.js-commit-button');
|
|
|
|
|
|
|
|
commitButton.on('click', () => {
|
|
|
|
window.onbeforeunload = null;
|
|
|
|
});
|
2017-03-08 00:04:20 +00:00
|
|
|
|
2018-08-03 13:24:26 +00:00
|
|
|
new EditBlob(`${urlRoot}${assetsPath}`, filePath, currentAction, projectId);
|
2017-03-08 00:04:20 +00:00
|
|
|
new NewCommitForm(editBlobForm);
|
2018-11-27 10:05:25 +00:00
|
|
|
|
|
|
|
// returning here blocks page navigation
|
|
|
|
window.onbeforeunload = () => '';
|
2017-03-08 00:04:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (uploadBlobForm.length) {
|
|
|
|
const method = uploadBlobForm.data('method');
|
|
|
|
|
|
|
|
new BlobFileDropzone(uploadBlobForm, method);
|
|
|
|
new NewCommitForm(uploadBlobForm);
|
|
|
|
|
|
|
|
window.gl.utils.disableButtonIfEmptyField(
|
|
|
|
uploadBlobForm.find('.js-commit-message'),
|
|
|
|
'.btn-upload-file',
|
|
|
|
);
|
|
|
|
}
|
2017-08-01 08:50:59 +00:00
|
|
|
|
|
|
|
if (deleteBlobForm.length) {
|
|
|
|
new NewCommitForm(deleteBlobForm);
|
|
|
|
}
|
2018-02-21 20:22:56 +00:00
|
|
|
};
|