Commit 1a0b6c87 authored by Justin Boyson's avatar Justin Boyson Committed by Paul Slaughter

Decouple file uploading from initBlob

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49601
parent 97f3ae0f
...@@ -38,9 +38,20 @@ const initPopovers = () => { ...@@ -38,9 +38,20 @@ const initPopovers = () => {
} }
}; };
export const initUploadForm = () => {
const uploadBlobForm = $('.js-upload-blob-form');
if (uploadBlobForm.length) {
const method = uploadBlobForm.data('method');
new BlobFileDropzone(uploadBlobForm, method);
new NewCommitForm(uploadBlobForm);
disableButtonIfEmptyField(uploadBlobForm.find('.js-commit-message'), '.btn-upload-file');
}
};
export default () => { export default () => {
const editBlobForm = $('.js-edit-blob-form'); const editBlobForm = $('.js-edit-blob-form');
const uploadBlobForm = $('.js-upload-blob-form');
const deleteBlobForm = $('.js-delete-blob-form'); const deleteBlobForm = $('.js-delete-blob-form');
if (editBlobForm.length) { if (editBlobForm.length) {
...@@ -80,14 +91,7 @@ export default () => { ...@@ -80,14 +91,7 @@ export default () => {
window.onbeforeunload = () => ''; window.onbeforeunload = () => '';
} }
if (uploadBlobForm.length) { initUploadForm();
const method = uploadBlobForm.data('method');
new BlobFileDropzone(uploadBlobForm, method);
new NewCommitForm(uploadBlobForm);
disableButtonIfEmptyField(uploadBlobForm.find('.js-commit-message'), '.btn-upload-file');
}
if (deleteBlobForm.length) { if (deleteBlobForm.length) {
new NewCommitForm(deleteBlobForm); new NewCommitForm(deleteBlobForm);
......
import initTree from 'ee_else_ce/repository'; import initTree from 'ee_else_ce/repository';
import initBlob from '~/blob_edit/blob_bundle'; import { initUploadForm } from '~/blob_edit/blob_bundle';
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import NotificationsForm from '~/notifications_form'; import NotificationsForm from '~/notifications_form';
import UserCallout from '~/user_callout'; import UserCallout from '~/user_callout';
...@@ -26,7 +26,7 @@ new UserCallout({ ...@@ -26,7 +26,7 @@ new UserCallout({
// Project show page loads different overview content based on user preferences // Project show page loads different overview content based on user preferences
const treeSlider = document.getElementById('js-tree-list'); const treeSlider = document.getElementById('js-tree-list');
if (treeSlider) { if (treeSlider) {
initBlob(); initUploadForm();
initTree(); initTree();
} }
......
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