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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
cb197ceb
Commit
cb197ceb
authored
Apr 11, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correctly dispose cached models
parent
49d8a62e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+10
-1
spec/javascripts/ide/stores/actions/file_spec.js
spec/javascripts/ide/stores/actions/file_spec.js
+26
-0
No files found.
app/assets/javascripts/ide/stores/actions/file.js
View file @
cb197ceb
...
...
@@ -156,7 +156,7 @@ export const setFileViewMode = ({ state, commit }, { file, viewMode }) => {
commit
(
types
.
SET_FILE_VIEWMODE
,
{
file
,
viewMode
});
};
export
const
discardFileChanges
=
({
state
,
commit
},
path
)
=>
{
export
const
discardFileChanges
=
({
dispatch
,
state
,
commit
,
getters
},
path
)
=>
{
const
file
=
state
.
entries
[
path
];
commit
(
types
.
DISCARD_FILE_CHANGES
,
path
);
...
...
@@ -164,9 +164,18 @@ export const discardFileChanges = ({ state, commit }, path) => {
if
(
file
.
tempFile
&&
file
.
opened
)
{
commit
(
types
.
TOGGLE_FILE_OPEN
,
path
);
}
else
if
(
getters
.
activeFile
&&
file
.
path
===
getters
.
activeFile
.
path
)
{
dispatch
(
'
updateDelayViewerUpdated
'
,
true
)
.
then
(()
=>
{
router
.
push
(
`/project
${
file
.
url
}
`
);
})
.
catch
(
e
=>
{
throw
e
;
});
}
eventHub
.
$emit
(
`editor.update.model.new.content.
${
file
.
key
}
`
,
file
.
content
);
eventHub
.
$emit
(
`editor.update.model.dispose.unstaged-
${
file
.
key
}
`
,
file
.
content
);
};
export
const
stageChange
=
({
commit
,
state
},
path
)
=>
{
...
...
spec/javascripts/ide/stores/actions/file_spec.js
View file @
cb197ceb
...
...
@@ -405,6 +405,7 @@ describe('IDE store file actions', () => {
beforeEach
(()
=>
{
spyOn
(
eventHub
,
'
$on
'
);
spyOn
(
eventHub
,
'
$emit
'
);
tmpFile
=
file
();
tmpFile
.
content
=
'
testing
'
;
...
...
@@ -463,6 +464,31 @@ describe('IDE store file actions', () => {
})
.
catch
(
done
.
fail
);
});
it
(
'
pushes route for active file
'
,
done
=>
{
tmpFile
.
active
=
true
;
store
.
state
.
openFiles
.
push
(
tmpFile
);
store
.
dispatch
(
'
discardFileChanges
'
,
tmpFile
.
path
)
.
then
(()
=>
{
expect
(
router
.
push
).
toHaveBeenCalledWith
(
`/project
${
tmpFile
.
url
}
`
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
emits eventHub event to dispose cached model
'
,
done
=>
{
store
.
dispatch
(
'
discardFileChanges
'
,
tmpFile
.
path
)
.
then
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalled
();
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
stageChange
'
,
()
=>
{
...
...
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