Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5b7b4822
Commit
5b7b4822
authored
Nov 27, 2018
by
Sam Bigelow
Committed by
Phil Hughes
Nov 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Warn in Web Editor when user navigates away"
parent
1fae9f36
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
app/assets/javascripts/blob_edit/blob_bundle.js
app/assets/javascripts/blob_edit/blob_bundle.js
+8
-0
changelogs/unreleased/53728-warn-in-web-editor-when-user-navigates-away.yml
...sed/53728-warn-in-web-editor-when-user-navigates-away.yml
+5
-0
spec/javascripts/blob_edit/blob_bundle_spec.js
spec/javascripts/blob_edit/blob_bundle_spec.js
+30
-0
No files found.
app/assets/javascripts/blob_edit/blob_bundle.js
View file @
5b7b4822
...
@@ -16,9 +16,17 @@ export default () => {
...
@@ -16,9 +16,17 @@ export default () => {
const
filePath
=
editBlobForm
.
data
(
'
blobFilename
'
);
const
filePath
=
editBlobForm
.
data
(
'
blobFilename
'
);
const
currentAction
=
$
(
'
.js-file-title
'
).
data
(
'
currentAction
'
);
const
currentAction
=
$
(
'
.js-file-title
'
).
data
(
'
currentAction
'
);
const
projectId
=
editBlobForm
.
data
(
'
project-id
'
);
const
projectId
=
editBlobForm
.
data
(
'
project-id
'
);
const
commitButton
=
$
(
'
.js-commit-button
'
);
commitButton
.
on
(
'
click
'
,
()
=>
{
window
.
onbeforeunload
=
null
;
});
new
EditBlob
(
`
${
urlRoot
}${
assetsPath
}
`
,
filePath
,
currentAction
,
projectId
);
new
EditBlob
(
`
${
urlRoot
}${
assetsPath
}
`
,
filePath
,
currentAction
,
projectId
);
new
NewCommitForm
(
editBlobForm
);
new
NewCommitForm
(
editBlobForm
);
// returning here blocks page navigation
window
.
onbeforeunload
=
()
=>
''
;
}
}
if
(
uploadBlobForm
.
length
)
{
if
(
uploadBlobForm
.
length
)
{
...
...
changelogs/unreleased/53728-warn-in-web-editor-when-user-navigates-away.yml
0 → 100644
View file @
5b7b4822
---
title
:
Prevent user from navigating away from file edit without commit
merge_request
:
author
:
type
:
fixed
spec/javascripts/blob_edit/blob_bundle_spec.js
0 → 100644
View file @
5b7b4822
import
blobBundle
from
'
~/blob_edit/blob_bundle
'
;
import
$
from
'
jquery
'
;
window
.
ace
=
{
config
:
{
set
:
()
=>
{},
loadModule
:
()
=>
{},
},
edit
:
()
=>
({
focus
:
()
=>
{}
}),
};
describe
(
'
EditBlob
'
,
()
=>
{
beforeEach
(()
=>
{
setFixtures
(
`
<div class="js-edit-blob-form">
<button class="js-commit-button"></button>
</div>`
);
blobBundle
();
});
it
(
'
sets the window beforeunload listener to a function returning a string
'
,
()
=>
{
expect
(
window
.
onbeforeunload
()).
toBe
(
''
);
});
it
(
'
removes beforeunload listener if commit button is clicked
'
,
()
=>
{
$
(
'
.js-commit-button
'
).
click
();
expect
(
window
.
onbeforeunload
).
toBeNull
();
});
});
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