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
89c3c88e
Commit
89c3c88e
authored
7 years ago
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add confirm when navigating away from page with tests.
parent
50a64953
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+16
-0
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+33
-0
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
89c3c88e
...
@@ -152,6 +152,12 @@
...
@@ -152,6 +152,12 @@
hasUpdated
()
{
hasUpdated
()
{
return
!!
this
.
state
.
updatedAt
;
return
!!
this
.
state
.
updatedAt
;
},
},
issueChanged
()
{
return
this
.
initialDescriptionText
!==
this
.
store
.
formState
.
description
||
this
.
initialTitleText
!==
this
.
store
.
formState
.
title
;
},
},
},
created
()
{
created
()
{
this
.
service
=
new
Service
(
this
.
endpoint
);
this
.
service
=
new
Service
(
this
.
endpoint
);
...
@@ -176,6 +182,8 @@
...
@@ -176,6 +182,8 @@
}
}
});
});
window
.
addEventListener
(
'
beforeunload
'
,
this
.
handleBeforeUnloadEvent
);
eventHub
.
$on
(
'
delete.issuable
'
,
this
.
deleteIssuable
);
eventHub
.
$on
(
'
delete.issuable
'
,
this
.
deleteIssuable
);
eventHub
.
$on
(
'
update.issuable
'
,
this
.
updateIssuable
);
eventHub
.
$on
(
'
update.issuable
'
,
this
.
updateIssuable
);
eventHub
.
$on
(
'
close.form
'
,
this
.
closeForm
);
eventHub
.
$on
(
'
close.form
'
,
this
.
closeForm
);
...
@@ -188,6 +196,14 @@
...
@@ -188,6 +196,14 @@
eventHub
.
$off
(
'
open.form
'
,
this
.
openForm
);
eventHub
.
$off
(
'
open.form
'
,
this
.
openForm
);
},
},
methods
:
{
methods
:
{
handleBeforeUnloadEvent
(
e
)
{
const
event
=
e
;
if
(
this
.
showForm
&&
this
.
issueChanged
)
{
event
.
returnValue
=
'
Are you sure you want to lose your issue information?
'
;
}
return
undefined
;
},
openForm
()
{
openForm
()
{
if
(
!
this
.
showForm
)
{
if
(
!
this
.
showForm
)
{
this
.
showForm
=
true
;
this
.
showForm
=
true
;
...
...
This diff is collapsed.
Click to expand it.
spec/javascripts/issue_show/components/app_spec.js
View file @
89c3c88e
...
@@ -218,6 +218,39 @@ describe('Issuable output', () => {
...
@@ -218,6 +218,39 @@ describe('Issuable output', () => {
});
});
});
});
describe
(
'
shows dialog when issue has unsaved changed
'
,
()
=>
{
it
(
'
confirms on title change
'
,
(
done
)
=>
{
vm
.
showForm
=
true
;
vm
.
state
.
titleText
=
'
title has changed
'
;
const
e
=
{
returnValue
:
null
};
vm
.
handleBeforeUnloadEvent
(
e
);
Vue
.
nextTick
(()
=>
{
expect
(
e
.
returnValue
).
not
.
toBeNull
();
done
();
});
});
it
(
'
confirms on description change
'
,
(
done
)
=>
{
vm
.
showForm
=
true
;
vm
.
state
.
descriptionText
=
'
description has changed
'
;
const
e
=
{
returnValue
:
null
};
vm
.
handleBeforeUnloadEvent
(
e
);
Vue
.
nextTick
(()
=>
{
expect
(
e
.
returnValue
).
not
.
toBeNull
();
done
();
});
});
it
(
'
does nothing when nothing has changed
'
,
(
done
)
=>
{
const
e
=
{
returnValue
:
null
};
vm
.
handleBeforeUnloadEvent
(
e
);
Vue
.
nextTick
(()
=>
{
expect
(
e
.
returnValue
).
toBeNull
();
done
();
});
});
});
describe
(
'
error when updating
'
,
()
=>
{
describe
(
'
error when updating
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
...
...
This diff is collapsed.
Click to expand it.
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