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
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
Hide 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 {
...
@@ -79,7 +79,12 @@ export default {
</span>
</span>
</a>
</a>
</li>
</li>
<li
v-if=
"hasMergeRequest"
role=
"separator"
class=
"divider"
></li>
<li
v-if=
"hasMergeRequest"
role=
"separator"
class=
"divider"
>
</li>
<li>
<li>
<a
<a
href=
"#"
href=
"#"
...
...
app/assets/javascripts/ide/ide_router.js
View file @
f00a971a
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
...
@@ -2,7 +2,6 @@ import Vue from 'vue';
import
VueRouter
from
'
vue-router
'
;
import
VueRouter
from
'
vue-router
'
;
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
store
from
'
./stores
'
;
import
store
from
'
./stores
'
;
import
{
getTreeEntry
}
from
'
./stores/utils
'
;
Vue
.
use
(
VueRouter
);
Vue
.
use
(
VueRouter
);
...
@@ -77,9 +76,7 @@ router.beforeEach((to, from, next) => {
...
@@ -77,9 +76,7 @@ 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
)
:
to
.
params
[
0
];
const
treeEntry
=
store
.
state
.
entries
[
path
];
const
treeEntry
=
store
.
state
.
entries
[
path
];
if
(
treeEntry
)
{
if
(
treeEntry
)
{
store
.
dispatch
(
'
handleTreeEntryAction
'
,
treeEntry
);
store
.
dispatch
(
'
handleTreeEntryAction
'
,
treeEntry
);
...
@@ -130,8 +127,7 @@ router.beforeEach((to, from, next) => {
...
@@ -130,8 +127,7 @@ router.beforeEach((to, from, next) => {
})
})
.
then
(()
=>
{
.
then
(()
=>
{
mrChanges
.
changes
.
forEach
((
change
,
ind
)
=>
{
mrChanges
.
changes
.
forEach
((
change
,
ind
)
=>
{
const
changeTreeEntry
=
const
changeTreeEntry
=
store
.
state
.
entries
[
change
.
new_path
];
store
.
state
.
entries
[
change
.
new_path
];
if
(
changeTreeEntry
)
{
if
(
changeTreeEntry
)
{
store
.
dispatch
(
'
setFileMrChange
'
,
{
store
.
dispatch
(
'
setFileMrChange
'
,
{
...
@@ -156,16 +152,12 @@ router.beforeEach((to, from, next) => {
...
@@ -156,16 +152,12 @@ router.beforeEach((to, from, next) => {
});
});
})
})
.
catch
(
e
=>
{
.
catch
(
e
=>
{
flash
(
flash
(
'
Error while loading the merge request changes. Please try again.
'
);
'
Error while loading the merge request changes. Please try again.
'
,
);
throw
e
;
throw
e
;
});
});
})
})
.
catch
(
e
=>
{
.
catch
(
e
=>
{
flash
(
flash
(
'
Error while loading the branch files. Please try again.
'
);
'
Error while loading the branch files. Please try again.
'
,
);
throw
e
;
throw
e
;
});
});
})
})
...
...
app/assets/javascripts/ide/services/index.js
View file @
f00a971a
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
import
VueResource
from
'
vue-resource
'
;
import
Api
from
'
~/api
'
;
import
Api
from
'
~/api
'
;
import
{
version
}
from
'
punycode
'
;
Vue
.
use
(
VueResource
);
Vue
.
use
(
VueResource
);
...
@@ -21,9 +20,7 @@ export default {
...
@@ -21,9 +20,7 @@ export default {
return
Promise
.
resolve
(
file
.
raw
);
return
Promise
.
resolve
(
file
.
raw
);
}
}
return
Vue
.
http
return
Vue
.
http
.
get
(
file
.
rawPath
,
{
params
:
{
format
:
'
json
'
}
}).
then
(
res
=>
res
.
text
());
.
get
(
file
.
rawPath
,
{
params
:
{
format
:
'
json
'
}
})
.
then
(
res
=>
res
.
text
());
},
},
getBaseRawFileData
(
file
,
sha
)
{
getBaseRawFileData
(
file
,
sha
)
{
if
(
file
.
tempFile
)
{
if
(
file
.
tempFile
)
{
...
...
app/assets/javascripts/ide/stores/actions/file.js
View file @
f00a971a
import
{
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
{
parsePatch
,
applyPatches
}
from
'
diff
'
;
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
eventHub
from
'
../../eventhub
'
;
import
eventHub
from
'
../../eventhub
'
;
import
service
from
'
../../services
'
;
import
service
from
'
../../services
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
router
from
'
../../ide_router
'
;
import
router
from
'
../../ide_router
'
;
import
{
setPageTitle
,
createTemp
,
findIndexOfFile
}
from
'
../utils
'
;
import
{
setPageTitle
}
from
'
../utils
'
;
export
const
closeFile
=
({
commit
,
state
,
getters
,
dispatch
},
path
)
=>
{
export
const
closeFile
=
({
commit
,
state
,
getters
,
dispatch
},
path
)
=>
{
const
indexOfClosedFile
=
state
.
openFiles
.
findIndex
(
f
=>
f
.
path
===
path
);
const
indexOfClosedFile
=
state
.
openFiles
.
findIndex
(
f
=>
f
.
path
===
path
);
...
@@ -47,19 +46,14 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
...
@@ -47,19 +46,14 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
commit
(
types
.
SET_CURRENT_BRANCH
,
file
.
branchId
);
commit
(
types
.
SET_CURRENT_BRANCH
,
file
.
branchId
);
};
};
export
const
getFileData
=
(
export
const
getFileData
=
({
state
,
commit
,
dispatch
},
{
path
,
makeFileActive
=
true
})
=>
{
{
state
,
commit
,
dispatch
},
{
path
,
makeFileActive
=
true
},
)
=>
{
const
file
=
state
.
entries
[
path
];
const
file
=
state
.
entries
[
path
];
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
service
service
.
getFileData
(
file
.
url
)
.
getFileData
(
file
.
url
)
.
then
(
res
=>
{
.
then
(
res
=>
{
const
pageTitle
=
decodeURI
(
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
]);
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
],
);
setPageTitle
(
pageTitle
);
setPageTitle
(
pageTitle
);
...
@@ -72,16 +66,8 @@ export const getFileData = (
...
@@ -72,16 +66,8 @@ export const getFileData = (
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
commit
(
types
.
TOGGLE_LOADING
,
{
entry
:
file
});
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
console
.
log
(
'
Error :
'
,
err
);
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
,
);
reject
(
err
);
reject
(
err
);
});
});
});
});
...
@@ -91,10 +77,7 @@ export const setFileMrChange = ({ state, commit }, { file, mrChange }) => {
...
@@ -91,10 +77,7 @@ export const setFileMrChange = ({ state, commit }, { file, mrChange }) => {
commit
(
types
.
SET_FILE_MR_CHANGE
,
{
file
,
mrChange
});
commit
(
types
.
SET_FILE_MR_CHANGE
,
{
file
,
mrChange
});
};
};
export
const
getRawFileData
=
(
export
const
getRawFileData
=
({
state
,
commit
,
dispatch
},
{
path
,
baseSha
})
=>
{
{
state
,
commit
,
dispatch
},
{
path
,
baseSha
},
)
=>
{
const
file
=
state
.
entries
[
path
];
const
file
=
state
.
entries
[
path
];
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
service
service
...
@@ -150,10 +133,7 @@ export const setFileEOL = ({ getters, commit }, { eol }) => {
...
@@ -150,10 +133,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 @
f00a971a
export
const
activeFile
=
state
=>
export
const
activeFile
=
state
=>
state
.
openFiles
.
find
(
file
=>
file
.
active
)
||
null
;
state
.
openFiles
.
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
);
export
const
modifiedFiles
=
state
=>
export
const
modifiedFiles
=
state
=>
state
.
changedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
state
.
changedFiles
.
filter
(
f
=>
!
f
.
tempFile
);
export
const
projectsWithTrees
=
state
=>
export
const
projectsWithTrees
=
state
=>
Object
.
keys
(
state
.
projects
).
map
(
projectId
=>
{
Object
.
keys
(
state
.
projects
).
map
(
projectId
=>
{
...
@@ -23,10 +21,12 @@ export const projectsWithTrees = state =>
...
@@ -23,10 +21,12 @@ export const projectsWithTrees = state =>
};
};
});
});
export
const
currentMergeRequest
=
state
=>
export
const
currentMergeRequest
=
state
=>
{
state
.
projects
[
state
.
currentProjectId
].
mergeRequests
[
if
(
state
.
projects
[
state
.
currentProjectId
])
{
state
.
currentMergeRequestId
return
state
.
projects
[
state
.
currentProjectId
].
mergeRequests
[
state
.
currentMergeRequestId
];
];
}
return
null
;
};
// eslint-disable-next-line no-confusing-arrow
// eslint-disable-next-line no-confusing-arrow
export
const
currentIcon
=
state
=>
export
const
currentIcon
=
state
=>
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
f00a971a
...
@@ -82,40 +82,10 @@ export const decorateData = entity => {
...
@@ -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
'
)
=>
export
const
findEntry
=
(
tree
,
type
,
name
,
prop
=
'
name
'
)
=>
tree
.
find
(
f
=>
f
.
type
===
type
&&
f
[
prop
]
===
name
);
tree
.
find
(
f
=>
f
.
type
===
type
&&
f
[
prop
]
===
name
);
export
const
findIndexOfFile
=
(
state
,
file
)
=>
export
const
findIndexOfFile
=
(
state
,
file
)
=>
state
.
findIndex
(
f
=>
f
.
path
===
file
.
path
);
state
.
findIndex
(
f
=>
f
.
path
===
file
.
path
);
export
const
setPageTitle
=
title
=>
{
export
const
setPageTitle
=
title
=>
{
document
.
title
=
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', () => {
...
@@ -11,6 +11,7 @@ describe('IDE changed file icon', () => {
vm
=
createComponent
(
component
,
{
vm
=
createComponent
(
component
,
{
file
:
{
file
:
{
tempFile
:
false
,
tempFile
:
false
,
changed
:
true
,
},
},
});
});
});
});
...
@@ -20,10 +21,16 @@ describe('IDE changed file icon', () => {
...
@@ -20,10 +21,16 @@ describe('IDE changed file icon', () => {
});
});
describe
(
'
changedIcon
'
,
()
=>
{
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
'
);
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
'
,
()
=>
{
it
(
'
equals file-addition when a temp file
'
,
()
=>
{
vm
.
file
.
tempFile
=
true
;
vm
.
file
.
tempFile
=
true
;
...
@@ -36,6 +43,12 @@ describe('IDE changed file icon', () => {
...
@@ -36,6 +43,12 @@ describe('IDE changed file icon', () => {
expect
(
vm
.
changedIconClass
).
toContain
(
'
multi-file-modified
'
);
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
'
,
()
=>
{
it
(
'
includes multi-file-addition when a temp file
'
,
()
=>
{
vm
.
file
.
tempFile
=
true
;
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