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
Show 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 {
...
@@ -32,7 +32,7 @@ export default {
},
},
computed
:
{
computed
:
{
...
mapState
([
'
changedFiles
'
,
'
openFiles
'
,
'
viewer
'
]),
...
mapState
([
'
changedFiles
'
,
'
openFiles
'
,
'
viewer
'
]),
...
mapGetters
([
'
activeFile
'
,
'
hasChanges
'
,
'
tabs
'
]),
...
mapGetters
([
'
activeFile
'
,
'
hasChanges
'
]),
},
},
mounted
()
{
mounted
()
{
const
returnValue
=
'
Are you sure you want to lose unsaved changes?
'
;
const
returnValue
=
'
Are you sure you want to lose unsaved changes?
'
;
...
@@ -61,7 +61,7 @@ export default {
...
@@ -61,7 +61,7 @@ export default {
>
>
<repo-tabs
<repo-tabs
:active-file=
"activeFile"
:active-file=
"activeFile"
:files=
"
tab
s"
:files=
"
openFile
s"
:viewer=
"viewer"
:viewer=
"viewer"
:has-changes=
"hasChanges"
:has-changes=
"hasChanges"
/>
/>
...
...
app/assets/javascripts/ide/ide_router.js
View file @
a515b459
...
@@ -76,11 +76,17 @@ router.beforeEach((to, from, next) => {
...
@@ -76,11 +76,17 @@ router.beforeEach((to, from, next) => {
.
then
(()
=>
{
.
then
(()
=>
{
if
(
to
.
params
[
0
])
{
if
(
to
.
params
[
0
])
{
const
path
=
const
path
=
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
:
to
.
params
[
0
];
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
const
treeEntry
=
Object
.
keys
(
store
.
state
.
entries
).
reduce
((
acc
,
key
)
=>
{
:
to
.
params
[
0
];
const
file
=
store
.
state
.
entries
[
key
];
const
treeEntry
=
store
.
state
.
entries
[
path
];
if
(
key
===
path
&&
!
file
.
pending
)
{
if
(
treeEntry
)
{
return
file
;
}
return
acc
;
},
{});
if
(
Object
.
keys
(
treeEntry
).
length
)
{
store
.
dispatch
(
'
handleTreeEntryAction
'
,
treeEntry
);
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';
...
@@ -6,9 +6,9 @@ import * as types from '../mutation_types';
import
router
from
'
../../ide_router
'
;
import
router
from
'
../../ide_router
'
;
import
{
setPageTitle
}
from
'
../utils
'
;
import
{
setPageTitle
}
from
'
../utils
'
;
export
const
closeFile
=
({
commit
,
state
,
getters
,
dispatch
},
file
)
=>
{
export
const
closeFile
=
({
commit
,
state
,
dispatch
},
file
)
=>
{
const
path
=
file
.
path
;
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
;
const
fileWasActive
=
file
.
active
;
if
(
file
.
pending
)
{
if
(
file
.
pending
)
{
...
@@ -18,9 +18,9 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
...
@@ -18,9 +18,9 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
commit
(
types
.
SET_FILE_ACTIVE
,
{
path
,
active
:
false
});
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
nextIndexToOpen
=
indexOfClosedFile
===
0
?
0
:
indexOfClosedFile
-
1
;
const
nextFileToOpen
=
getters
.
tab
s
[
nextIndexToOpen
];
const
nextFileToOpen
=
state
.
openFile
s
[
nextIndexToOpen
];
if
(
nextFileToOpen
.
pending
)
{
if
(
nextFileToOpen
.
pending
)
{
dispatch
(
'
updateViewer
'
,
'
diff
'
);
dispatch
(
'
updateViewer
'
,
'
diff
'
);
...
@@ -29,7 +29,7 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
...
@@ -29,7 +29,7 @@ export const closeFile = ({ commit, state, getters, dispatch }, file) => {
dispatch
(
'
updateDelayViewerUpdated
'
,
true
);
dispatch
(
'
updateDelayViewerUpdated
'
,
true
);
router
.
push
(
`/project
${
nextFileToOpen
.
url
}
`
);
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
}
/`
);
router
.
push
(
`/project/
${
file
.
projectId
}
/tree/
${
file
.
branchId
}
/`
);
}
}
...
@@ -76,14 +76,7 @@ export const getFileData = ({ state, commit, dispatch }, file) => {
...
@@ -76,14 +76,7 @@ export const getFileData = ({ state, commit, dispatch }, file) => {
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
flash
(
flash
(
'
Error loading file data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
);
'
Error loading file data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
);
});
});
};
};
...
@@ -94,14 +87,7 @@ export const getRawFileData = ({ commit, dispatch }, file) =>
...
@@ -94,14 +87,7 @@ export const getRawFileData = ({ commit, dispatch }, file) =>
commit
(
types
.
SET_FILE_RAW_DATA
,
{
file
,
raw
});
commit
(
types
.
SET_FILE_RAW_DATA
,
{
file
,
raw
});
})
})
.
catch
(()
=>
.
catch
(()
=>
flash
(
flash
(
'
Error loading file content. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
),
'
Error loading file content. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
),
);
);
export
const
changeFileContent
=
({
state
,
commit
},
{
path
,
content
})
=>
{
export
const
changeFileContent
=
({
state
,
commit
},
{
path
,
content
})
=>
{
...
@@ -129,10 +115,7 @@ export const setFileEOL = ({ getters, commit }, { eol }) => {
...
@@ -129,10 +115,7 @@ export const setFileEOL = ({ getters, commit }, { eol }) => {
}
}
};
};
export
const
setEditorPosition
=
(
export
const
setEditorPosition
=
({
getters
,
commit
},
{
editorRow
,
editorColumn
})
=>
{
{
getters
,
commit
},
{
editorRow
,
editorColumn
},
)
=>
{
if
(
getters
.
activeFile
)
{
if
(
getters
.
activeFile
)
{
commit
(
types
.
SET_FILE_POSITION
,
{
commit
(
types
.
SET_FILE_POSITION
,
{
file
:
getters
.
activeFile
,
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
=>
state
.
openFiles
.
find
(
file
=>
file
.
active
)
||
null
;
export
const
activeFile
=
state
=>
tabs
(
state
).
find
(
file
=>
file
.
active
)
||
null
;
export
const
addedFiles
=
state
=>
state
.
changedFiles
.
filter
(
f
=>
f
.
tempFile
);
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 {
...
@@ -6,12 +6,15 @@ export default {
active
,
active
,
});
});
if
(
active
)
{
if
(
active
&&
!
state
.
entries
[
path
].
pending
)
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTabs
.
map
(
f
=>
({
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
...
f
,
if
(
f
.
pending
)
{
active
:
false
,
return
Object
.
assign
(
f
,
{
active
:
false
});
})),
}
return
f
;
}),
});
});
}
}
},
},
...
@@ -23,8 +26,10 @@ export default {
...
@@ -23,8 +26,10 @@ export default {
if
(
state
.
entries
[
path
].
opened
)
{
if
(
state
.
entries
[
path
].
opened
)
{
state
.
openFiles
.
push
(
state
.
entries
[
path
]);
state
.
openFiles
.
push
(
state
.
entries
[
path
]);
}
else
{
}
else
{
const
file
=
state
.
entries
[
path
];
Object
.
assign
(
state
,
{
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 {
...
@@ -90,26 +95,31 @@ export default {
});
});
},
},
[
types
.
ADD_PENDING_TAB
](
state
,
file
)
{
[
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
,
{
Object
.
assign
(
state
,
{
openFiles
:
state
.
openFiles
.
map
(
f
=>
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
Object
.
assign
(
f
,
{
if
(
!
f
.
pending
)
{
active
:
false
,
return
Object
.
assign
(
f
,
{
active
:
false
});
}
return
f
;
}),
}),
),
});
});
if
(
pendingTab
)
{
if
(
pendingTab
)
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTabs
.
map
(
tab
=>
({
openFiles
:
state
.
openFiles
.
map
(
f
=>
{
...
tab
,
if
(
f
.
pending
&&
f
.
path
===
file
.
path
)
{
active
:
!!
pendingTab
,
return
Object
.
assign
(
f
,
{
active
:
true
});
})),
}
return
f
;
}),
});
});
}
else
{
}
else
{
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
pendingTabs
:
state
.
pendingTab
s
.
concat
({
openFiles
:
state
.
openFile
s
.
concat
({
...
file
,
...
file
,
active
:
true
,
active
:
true
,
pending
:
true
,
pending
:
true
,
...
@@ -120,7 +130,7 @@ export default {
...
@@ -120,7 +130,7 @@ export default {
},
},
[
types
.
REMOVE_PENDING_TAB
](
state
,
file
)
{
[
types
.
REMOVE_PENDING_TAB
](
state
,
file
)
{
Object
.
assign
(
state
,
{
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 () => ({
...
@@ -16,5 +16,4 @@ export default () => ({
entries
:
{},
entries
:
{},
viewer
:
'
editor
'
,
viewer
:
'
editor
'
,
delayViewerUpdated
:
false
,
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