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
Boxiang Sun
gitlab-ce
Commits
f00a971a
Commit
f00a971a
authored
Mar 25, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ESLint + Karma fixes
parent
fa3b0241
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
83 deletions
+40
-83
app/assets/javascripts/ide/components/editor_mode_dropdown.vue
...ssets/javascripts/ide/components/editor_mode_dropdown.vue
+6
-1
app/assets/javascripts/ide/ide_router.js
app/assets/javascripts/ide/ide_router.js
+4
-12
app/assets/javascripts/ide/services/index.js
app/assets/javascripts/ide/services/index.js
+1
-4
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+6
-26
app/assets/javascripts/ide/stores/getters.js
app/assets/javascripts/ide/stores/getters.js
+8
-8
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+1
-31
spec/javascripts/ide/components/changed_file_icon_spec.js
spec/javascripts/ide/components/changed_file_icon_spec.js
+14
-1
No files found.
app/assets/javascripts/ide/components/editor_mode_dropdown.vue
View file @
f00a971a
...
...
@@ -79,7 +79,12 @@ export default {
</span>
</a>
</li>
<li
v-if=
"hasMergeRequest"
role=
"separator"
class=
"divider"
></li>
<li
v-if=
"hasMergeRequest"
role=
"separator"
class=
"divider"
>
</li>
<li>
<a
href=
"#"
...
...
app/assets/javascripts/ide/ide_router.js
View file @
f00a971a
...
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
VueRouter
from
'
vue-router
'
;
import
flash
from
'
~/flash
'
;
import
store
from
'
./stores
'
;
import
{
getTreeEntry
}
from
'
./stores/utils
'
;
Vue
.
use
(
VueRouter
);
...
...
@@ -77,9 +76,7 @@ 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
];
to
.
params
[
0
].
slice
(
-
1
)
===
'
/
'
?
to
.
params
[
0
].
slice
(
0
,
-
1
)
:
to
.
params
[
0
];
const
treeEntry
=
store
.
state
.
entries
[
path
];
if
(
treeEntry
)
{
store
.
dispatch
(
'
handleTreeEntryAction
'
,
treeEntry
);
...
...
@@ -130,8 +127,7 @@ router.beforeEach((to, from, next) => {
})
.
then
(()
=>
{
mrChanges
.
changes
.
forEach
((
change
,
ind
)
=>
{
const
changeTreeEntry
=
store
.
state
.
entries
[
change
.
new_path
];
const
changeTreeEntry
=
store
.
state
.
entries
[
change
.
new_path
];
if
(
changeTreeEntry
)
{
store
.
dispatch
(
'
setFileMrChange
'
,
{
...
...
@@ -156,16 +152,12 @@ router.beforeEach((to, from, next) => {
});
})
.
catch
(
e
=>
{
flash
(
'
Error while loading the merge request changes. Please try again.
'
,
);
flash
(
'
Error while loading the merge request changes. Please try again.
'
);
throw
e
;
});
})
.
catch
(
e
=>
{
flash
(
'
Error while loading the branch files. Please try again.
'
,
);
flash
(
'
Error while loading the branch files. Please try again.
'
);
throw
e
;
});
})
...
...
app/assets/javascripts/ide/services/index.js
View file @
f00a971a
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
import
Api
from
'
~/api
'
;
import
{
version
}
from
'
punycode
'
;
Vue
.
use
(
VueResource
);
...
...
@@ -21,9 +20,7 @@ export default {
return
Promise
.
resolve
(
file
.
raw
);
}
return
Vue
.
http
.
get
(
file
.
rawPath
,
{
params
:
{
format
:
'
json
'
}
})
.
then
(
res
=>
res
.
text
());
return
Vue
.
http
.
get
(
file
.
rawPath
,
{
params
:
{
format
:
'
json
'
}
}).
then
(
res
=>
res
.
text
());
},
getBaseRawFileData
(
file
,
sha
)
{
if
(
file
.
tempFile
)
{
...
...
app/assets/javascripts/ide/stores/actions/file.js
View file @
f00a971a
import
{
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
parsePatch
,
applyPatches
}
from
'
diff
'
;
import
flash
from
'
~/flash
'
;
import
eventHub
from
'
../../eventhub
'
;
import
service
from
'
../../services
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
router
from
'
../../ide_router
'
;
import
{
setPageTitle
,
createTemp
,
findIndexOfFile
}
from
'
../utils
'
;
import
{
setPageTitle
}
from
'
../utils
'
;
export
const
closeFile
=
({
commit
,
state
,
getters
,
dispatch
},
path
)
=>
{
const
indexOfClosedFile
=
state
.
openFiles
.
findIndex
(
f
=>
f
.
path
===
path
);
...
...
@@ -47,19 +46,14 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
commit
(
types
.
SET_CURRENT_BRANCH
,
file
.
branchId
);
};
export
const
getFileData
=
(
{
state
,
commit
,
dispatch
},
{
path
,
makeFileActive
=
true
},
)
=>
{
export
const
getFileData
=
({
state
,
commit
,
dispatch
},
{
path
,
makeFileActive
=
true
})
=>
{
const
file
=
state
.
entries
[
path
];
return
new
Promise
((
resolve
,
reject
)
=>
{
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
service
.
getFileData
(
file
.
url
)
.
then
(
res
=>
{
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
],
);
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
]);
setPageTitle
(
pageTitle
);
...
...
@@ -72,16 +66,8 @@ export const getFileData = (
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
})
.
catch
(
err
=>
{
console
.
log
(
'
Error :
'
,
err
);
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
);
reject
(
err
);
});
});
...
...
@@ -91,10 +77,7 @@ export const setFileMrChange = ({ state, commit }, { file, mrChange }) => {
commit
(
types
.
SET_FILE_MR_CHANGE
,
{
file
,
mrChange
});
};
export
const
getRawFileData
=
(
{
state
,
commit
,
dispatch
},
{
path
,
baseSha
},
)
=>
{
export
const
getRawFileData
=
({
state
,
commit
,
dispatch
},
{
path
,
baseSha
})
=>
{
const
file
=
state
.
entries
[
path
];
return
new
Promise
((
resolve
,
reject
)
=>
{
service
...
...
@@ -150,10 +133,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 @
f00a971a
export
const
activeFile
=
state
=>
state
.
openFiles
.
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
);
export
const
modifiedFiles
=
state
=>
state
.
changedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
export
const
modifiedFiles
=
state
=>
state
.
changedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
export
const
projectsWithTrees
=
state
=>
Object
.
keys
(
state
.
projects
).
map
(
projectId
=>
{
...
...
@@ -23,10 +21,12 @@ export const projectsWithTrees = state =>
};
});
export
const
currentMergeRequest
=
state
=>
state
.
projects
[
state
.
currentProjectId
].
mergeRequests
[
state
.
currentMergeRequestId
];
export
const
currentMergeRequest
=
state
=>
{
if
(
state
.
projects
[
state
.
currentProjectId
])
{
return
state
.
projects
[
state
.
currentProjectId
].
mergeRequests
[
state
.
currentMergeRequestId
];
}
return
null
;
};
// eslint-disable-next-line no-confusing-arrow
export
const
currentIcon
=
state
=>
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
f00a971a
...
...
@@ -82,40 +82,10 @@ export const decorateData = entity => {
};
};
/*
Takes the multi-dimensional tree and returns a flattened array.
This allows for the table to recursively render the table rows but keeps the data
structure nested to make it easier to add new files/directories.
*/
export
const
treeList
=
(
state
,
treeId
)
=>
{
const
baseTree
=
state
.
trees
[
treeId
];
if
(
baseTree
)
{
const
mapTree
=
arr
=>
!
arr
.
tree
||
!
arr
.
tree
.
length
?
[]
:
_
.
map
(
arr
.
tree
,
a
=>
[
a
,
mapTree
(
a
)]);
return
_
.
chain
(
baseTree
.
tree
)
.
map
(
arr
=>
[
arr
,
mapTree
(
arr
)])
.
flatten
()
.
value
();
}
return
[];
};
export
const
getTree
=
state
=>
(
namespace
,
projectId
,
branch
)
=>
state
.
trees
[
`
${
namespace
}
/
${
projectId
}
/
${
branch
}
`
];
export
const
getTreeEntry
=
(
store
,
treeId
,
path
)
=>
{
const
fileList
=
treeList
(
store
.
state
,
treeId
);
return
fileList
?
fileList
.
find
(
file
=>
file
.
path
===
path
)
:
null
;
};
export
const
findEntry
=
(
tree
,
type
,
name
,
prop
=
'
name
'
)
=>
tree
.
find
(
f
=>
f
.
type
===
type
&&
f
[
prop
]
===
name
);
export
const
findIndexOfFile
=
(
state
,
file
)
=>
state
.
findIndex
(
f
=>
f
.
path
===
file
.
path
);
export
const
findIndexOfFile
=
(
state
,
file
)
=>
state
.
findIndex
(
f
=>
f
.
path
===
file
.
path
);
export
const
setPageTitle
=
title
=>
{
document
.
title
=
title
;
...
...
spec/javascripts/ide/components/changed_file_icon_spec.js
View file @
f00a971a
...
...
@@ -11,6 +11,7 @@ describe('IDE changed file icon', () => {
vm
=
createComponent
(
component
,
{
file
:
{
tempFile
:
false
,
changed
:
true
,
},
});
});
...
...
@@ -20,10 +21,16 @@ describe('IDE changed file icon', () => {
});
describe
(
'
changedIcon
'
,
()
=>
{
it
(
'
equals file-modified when not a temp file
'
,
()
=>
{
it
(
'
equals file-modified when not a temp file
and has changes
'
,
()
=>
{
expect
(
vm
.
changedIcon
).
toBe
(
'
file-modified
'
);
});
it
(
'
equals git-merge when not a temp file and has no changes
'
,
()
=>
{
vm
.
file
.
changed
=
false
;
expect
(
vm
.
changedIcon
).
toBe
(
'
git-merge
'
);
});
it
(
'
equals file-addition when a temp file
'
,
()
=>
{
vm
.
file
.
tempFile
=
true
;
...
...
@@ -36,6 +43,12 @@ describe('IDE changed file icon', () => {
expect
(
vm
.
changedIconClass
).
toContain
(
'
multi-file-modified
'
);
});
it
(
'
includes multi-git-merge when a mr changed file
'
,
()
=>
{
vm
.
file
.
changed
=
false
;
expect
(
vm
.
changedIconClass
).
toContain
(
'
multi-git-merge
'
);
});
it
(
'
includes multi-file-addition when a temp file
'
,
()
=>
{
vm
.
file
.
tempFile
=
true
;
...
...
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