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
a515b459
Commit
a515b459
authored
Mar 27, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove extra state property
pending tabs now get added into openfiles & just filtered correctly
parent
89bb7b85
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
54 deletions
+50
-54
app/assets/javascripts/ide/components/ide.vue
app/assets/javascripts/ide/components/ide.vue
+2
-2
app/assets/javascripts/ide/ide_router.js
app/assets/javascripts/ide/ide_router.js
+11
-5
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+8
-25
app/assets/javascripts/ide/stores/getters.js
app/assets/javascripts/ide/stores/getters.js
+1
-3
app/assets/javascripts/ide/stores/mutations/file.js
app/assets/javascripts/ide/stores/mutations/file.js
+28
-18
app/assets/javascripts/ide/stores/state.js
app/assets/javascripts/ide/stores/state.js
+0
-1
No files found.
app/assets/javascripts/ide/components/ide.vue
View file @
a515b459
...
...
@@ -32,7 +32,7 @@ export default {
},
computed
:
{
...
mapState
([
'
changedFiles
'
,
'
openFiles
'
,
'
viewer
'
]),
...
mapGetters
([
'
activeFile
'
,
'
hasChanges
'
,
'
tabs
'
]),
...
mapGetters
([
'
activeFile
'
,
'
hasChanges
'
]),
},
mounted
()
{
const
returnValue
=
'
Are you sure you want to lose unsaved changes?
'
;
...
...
@@ -61,7 +61,7 @@ export default {
>
<repo-tabs
:active-file=
"activeFile"
:files=
"
tab
s"
:files=
"
openFile
s"
:viewer=
"viewer"
:has-changes=
"hasChanges"
/>
...
...
app/assets/javascripts/ide/ide_router.js
View file @
a515b459
...
...
@@ -76,11 +76,17 @@ router.beforeEach((to, from, next) => {
.
then
(()
=>
{
if
(
to
.
params
[
0
])
{
const
path
=
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
:
to
.
params
[
0
];
const
treeEntry
=
store
.
state
.
entries
[
path
];
if
(
treeEntry
)
{
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
:
to
.
params
[
0
];
const
treeEntry
=
Object
.
keys
(
store
.
state
.
entries
).
reduce
((
acc
,
key
)
=>
{
const
file
=
store
.
state
.
entries
[
key
];
if
(
key
===
path
&&
!
file
.
pending
)
{
return
file
;
}
return
acc
;
},
{});
if
(
Object
.
keys
(
treeEntry
).
length
)
{
store
.
dispatch
(
'
handleTreeEntryAction
'
,
treeEntry
);
}
}
...
...
app/assets/javascripts/ide/stores/actions/file.js
View file @
a515b459
...
...
@@ -6,9 +6,9 @@ import * as types from '../mutation_types';
import
router
from
'
../../ide_router
'
;
import
{
setPageTitle
}
from
'
../utils
'
;
export
const
closeFile
=
({
commit
,
state
,
getters
,
dispatch
},
file
)
=>
{
export
const
closeFile
=
({
commit
,
state
,
dispatch
},
file
)
=>
{
const
path
=
file
.
path
;
const
indexOfClosedFile
=
getters
.
tab
s
.
findIndex
(
f
=>
f
.
key
===
file
.
key
);
const
indexOfClosedFile
=
state
.
openFile
s
.
findIndex
(
f
=>
f
.
key
===
file
.
key
);
const
fileWasActive
=
file
.
active
;
if
(
file
.
pending
)
{
...
...
@@ -18,9 +18,9 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
commit
(
types
.
SET_FILE_ACTIVE
,
{
path
,
active
:
false
});
}
if
(
getters
.
tab
s
.
length
>
0
&&
fileWasActive
)
{
if
(
state
.
openFile
s
.
length
>
0
&&
fileWasActive
)
{
const
nextIndexToOpen
=
indexOfClosedFile
===
0
?
0
:
indexOfClosedFile
-
1
;
const
nextFileToOpen
=
getters
.
tab
s
[
nextIndexToOpen
];
const
nextFileToOpen
=
state
.
openFile
s
[
nextIndexToOpen
];
if
(
nextFileToOpen
.
pending
)
{
dispatch
(
'
updateViewer
'
,
'
diff
'
);
...
...
@@ -29,7 +29,7 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
dispatch
(
'
updateDelayViewerUpdated
'
,
true
);
router
.
push
(
`/project
${
nextFileToOpen
.
url
}
`
);
}
}
else
if
(
!
getters
.
tab
s
.
length
)
{
}
else
if
(
!
state
.
openFile
s
.
length
)
{
router
.
push
(
`/project/
${
file
.
projectId
}
/tree/
${
file
.
branchId
}
/`
);
}
...
...
@@ -76,14 +76,7 @@ export const getFileData = ({ state, commit, dispatch }, file) => {
})
.
catch
(()
=>
{
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
flash
(
'
Error loading file data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
);
flash
(
'
Error loading file data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
);
});
};
...
...
@@ -94,14 +87,7 @@ export const getRawFileData = ({ commit, dispatch }, file) =>
commit
(
types
.
SET_FILE_RAW_DATA
,
{
file
,
raw
});
})
.
catch
(()
=>
flash
(
'
Error loading file content. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
),
flash
(
'
Error loading file content. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
),
);
export
const
changeFileContent
=
({
state
,
commit
},
{
path
,
content
})
=>
{
...
...
@@ -129,10 +115,7 @@ export const setFileEOL = ({ getters, commit }, { eol }) => {
}
};
export
const
setEditorPosition
=
(
{
getters
,
commit
},
{
editorRow
,
editorColumn
},
)
=>
{
export
const
setEditorPosition
=
({
getters
,
commit
},
{
editorRow
,
editorColumn
})
=>
{
if
(
getters
.
activeFile
)
{
commit
(
types
.
SET_FILE_POSITION
,
{
file
:
getters
.
activeFile
,
...
...
app/assets/javascripts/ide/stores/getters.js
View file @
a515b459
export
const
tabs
=
state
=>
state
.
openFiles
.
concat
(
state
.
pendingTabs
);
export
const
activeFile
=
state
=>
tabs
(
state
).
find
(
file
=>
file
.
active
)
||
null
;
export
const
activeFile
=
state
=>
state
.
openFiles
.
find
(
file
=>
file
.
active
)
||
null
;
export
const
addedFiles
=
state
=>
state
.
changedFiles
.
filter
(
f
=>
f
.
tempFile
);
...
...
app/assets/javascripts/ide/stores/mutations/file.js
View file @
a515b459
...
...
@@ -6,12 +6,15 @@ export default {
active
,
});
if
(
active
)
{
if
(
active
&&
!
state
.
entries
[
path
].
pending
)
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTabs
.
map
(
f
=>
({
...
f
,
active
:
false
,
})),
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
if
(
f
.
pending
)
{
return
Object
.
assign
(
f
,
{
active
:
false
});
}
return
f
;
}),
});
}
},
...
...
@@ -23,8 +26,10 @@ export default {
if
(
state
.
entries
[
path
].
opened
)
{
state
.
openFiles
.
push
(
state
.
entries
[
path
]);
}
else
{
const
file
=
state
.
entries
[
path
];
Object
.
assign
(
state
,
{
openFiles
:
state
.
openFiles
.
filter
(
f
=>
f
.
path
!==
path
),
openFiles
:
state
.
openFiles
.
filter
(
f
=>
f
.
key
!==
file
.
key
),
});
}
},
...
...
@@ -90,26 +95,31 @@ export default {
});
},
[
types
.
ADD_PENDING_TAB
](
state
,
file
)
{
const
pendingTab
=
state
.
pendingTabs
.
find
(
f
=>
f
.
path
===
file
.
path
);
const
pendingTab
=
state
.
openFiles
.
find
(
f
=>
f
.
path
===
file
.
path
&&
f
.
pending
);
Object
.
assign
(
state
,
{
openFiles
:
state
.
openFiles
.
map
(
f
=>
Object
.
assign
(
f
,
{
active
:
false
,
}),
),
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
if
(
!
f
.
pending
)
{
return
Object
.
assign
(
f
,
{
active
:
false
});
}
return
f
;
}),
});
if
(
pendingTab
)
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTabs
.
map
(
tab
=>
({
...
tab
,
active
:
!!
pendingTab
,
})),
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
if
(
f
.
pending
&&
f
.
path
===
file
.
path
)
{
return
Object
.
assign
(
f
,
{
active
:
true
});
}
return
f
;
}),
});
}
else
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTab
s
.
concat
({
openFiles
:
state
.
openFile
s
.
concat
({
...
file
,
active
:
true
,
pending
:
true
,
...
...
@@ -120,7 +130,7 @@ export default {
},
[
types
.
REMOVE_PENDING_TAB
](
state
,
file
)
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTabs
.
filter
(
f
=>
f
.
path
!==
file
.
path
),
openFiles
:
state
.
openFiles
.
filter
(
f
=>
f
.
key
!==
file
.
key
),
});
},
};
app/assets/javascripts/ide/stores/state.js
View file @
a515b459
...
...
@@ -16,5 +16,4 @@ export default () => ({
entries
:
{},
viewer
:
'
editor
'
,
delayViewerUpdated
:
false
,
pendingTabs
:
[],
});
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