BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
c34268c8
Commit
c34268c8
authored
Apr 17, 2018
by
Paul
Committed by
Phil Hughes
Apr 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the input confirmation validation for the delete branches modal
parent
dd557c46
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
0 deletions
+56
-0
branches_delete_modal.js
app/assets/javascripts/branches/branches_delete_modal.js
+11
-0
44985-fix-protected-branch-delete-modal.yml
...gs/unreleased/44985-fix-protected-branch-delete-modal.yml
+5
-0
branches_delete_modal_spec.js
spec/javascripts/branches/branches_delete_modal_spec.js
+40
-0
No files found.
app/assets/javascripts/branches/branches_delete_modal.js
View file @
c34268c8
...
...
@@ -16,6 +16,7 @@ class DeleteModal {
bindEvents
()
{
this
.
$toggleBtns
.
on
(
'click'
,
this
.
setModalData
.
bind
(
this
));
this
.
$confirmInput
.
on
(
'input'
,
this
.
setDeleteDisabled
.
bind
(
this
));
this
.
$deleteBtn
.
on
(
'click'
,
this
.
setDisableDeleteButton
.
bind
(
this
));
}
setModalData
(
e
)
{
...
...
@@ -30,6 +31,16 @@ class DeleteModal {
this
.
$deleteBtn
.
attr
(
'disabled'
,
e
.
currentTarget
.
value
!==
this
.
branchName
);
}
setDisableDeleteButton
(
e
)
{
if
(
this
.
$deleteBtn
.
is
(
'[disabled]'
))
{
e
.
preventDefault
();
e
.
stopPropagation
();
return
false
;
}
return
true
;
}
updateModal
()
{
this
.
$branchName
.
text
(
this
.
branchName
);
this
.
$confirmInput
.
val
(
''
);
...
...
changelogs/unreleased/44985-fix-protected-branch-delete-modal.yml
0 → 100644
View file @
c34268c8
---
title
:
Fix confirmation modal for deleting a protected branch
merge_request
:
18176
author
:
Paul Bonaud @PaulRbR
type
:
fixed
spec/javascripts/branches/branches_delete_modal_spec.js
0 → 100644
View file @
c34268c8
import
$
from
'jquery'
;
import
DeleteModal
from
'~/branches/branches_delete_modal'
;
describe
(
'branches delete modal'
,
()
=>
{
describe
(
'setDisableDeleteButton'
,
()
=>
{
let
submitSpy
;
let
$deleteButton
;
beforeEach
(()
=>
{
setFixtures
(
`
<div id="modal-delete-branch">
<form>
<button type="submit" class="js-delete-branch">Delete</button>
</form>
</div>
`
);
$deleteButton
=
$
(
'.js-delete-branch'
);
submitSpy
=
jasmine
.
createSpy
(
'submit'
).
and
.
callFake
(
event
=>
event
.
preventDefault
());
$
(
'#modal-delete-branch form'
).
on
(
'submit'
,
submitSpy
);
// eslint-disable-next-line no-new
new
DeleteModal
();
});
it
(
'does not submit if button is disabled'
,
()
=>
{
$deleteButton
.
attr
(
'disabled'
,
true
);
$deleteButton
.
click
();
expect
(
submitSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'submits if button is not disabled'
,
()
=>
{
$deleteButton
.
attr
(
'disabled'
,
false
);
$deleteButton
.
click
();
expect
(
submitSpy
).
toHaveBeenCalled
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment