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
05420006
Commit
05420006
authored
Nov 01, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multi-file editor fetch log data from a different endpoint
Closes #38360
parent
d4ceec9d
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
104 additions
and
26 deletions
+104
-26
app/assets/javascripts/repo/components/repo_file.vue
app/assets/javascripts/repo/components/repo_file.vue
+32
-3
app/assets/javascripts/repo/components/repo_loading_file.vue
app/assets/javascripts/repo/components/repo_loading_file.vue
+1
-1
app/assets/javascripts/repo/services/index.js
app/assets/javascripts/repo/services/index.js
+7
-0
app/assets/javascripts/repo/stores/actions/tree.js
app/assets/javascripts/repo/stores/actions/tree.js
+28
-1
app/assets/javascripts/repo/stores/mutation_types.js
app/assets/javascripts/repo/stores/mutation_types.js
+2
-0
app/assets/javascripts/repo/stores/mutations.js
app/assets/javascripts/repo/stores/mutations.js
+7
-0
app/assets/javascripts/repo/stores/mutations/tree.js
app/assets/javascripts/repo/stores/mutations/tree.js
+8
-3
app/assets/javascripts/repo/stores/state.js
app/assets/javascripts/repo/stores/state.js
+1
-0
app/assets/javascripts/repo/stores/utils.js
app/assets/javascripts/repo/stores/utils.js
+7
-9
app/controllers/projects/refs_controller.rb
app/controllers/projects/refs_controller.rb
+7
-1
app/serializers/blob_entity.rb
app/serializers/blob_entity.rb
+0
-4
app/serializers/tree_entity.rb
app/serializers/tree_entity.rb
+0
-4
app/serializers/tree_root_entity.rb
app/serializers/tree_root_entity.rb
+4
-0
No files found.
app/assets/javascripts/repo/components/repo_file.vue
View file @
05420006
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
...
mapGetters
([
...
mapGetters
([
'
isCollapsed
'
,
'
isCollapsed
'
,
]),
]),
isSubmodule
()
{
return
this
.
file
.
type
===
'
submodule
'
;
},
fileIcon
()
{
fileIcon
()
{
return
{
return
{
'
fa-spinner fa-spin
'
:
this
.
file
.
loading
,
'
fa-spinner fa-spin
'
:
this
.
file
.
loading
,
...
@@ -31,6 +34,9 @@
...
@@ -31,6 +34,9 @@
shortId
()
{
shortId
()
{
return
this
.
file
.
id
.
substr
(
0
,
8
);
return
this
.
file
.
id
.
substr
(
0
,
8
);
},
},
submoduleColSpan
()
{
return
!
this
.
isCollapsed
&&
this
.
isSubmodule
?
3
:
undefined
;
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
...
mapActions
([
...
@@ -44,7 +50,7 @@
...
@@ -44,7 +50,7 @@
<tr
<tr
class=
"file"
class=
"file"
@
click.prevent=
"clickedTreeRow(file)"
>
@
click.prevent=
"clickedTreeRow(file)"
>
<td>
<td
:colspan=
"submoduleColSpan"
>
<i
<i
class=
"fa fa-fw file-icon"
class=
"fa fa-fw file-icon"
:class=
"fileIcon"
:class=
"fileIcon"
...
@@ -58,7 +64,7 @@
...
@@ -58,7 +64,7 @@
>
>
{{
file
.
name
}}
{{
file
.
name
}}
</a>
</a>
<template
v-if=
"
file.type === 'submodule'
&& file.id"
>
<template
v-if=
"
isSubmodule
&& file.id"
>
@
@
<span
class=
"commit-sha"
>
<span
class=
"commit-sha"
>
<a
<a
...
@@ -71,15 +77,27 @@
...
@@ -71,15 +77,27 @@
</
template
>
</
template
>
</td>
</td>
<
template
v-if=
"!isCollapsed"
>
<
template
v-if=
"!isCollapsed
&& !isSubmodule
"
>
<td
class=
"hidden-sm hidden-xs"
>
<td
class=
"hidden-sm hidden-xs"
>
<a
<a
v-if=
"file.lastCommit.message"
@
click
.
stop
@
click
.
stop
:href=
"file.lastCommit.url"
:href=
"file.lastCommit.url"
class=
"commit-message"
class=
"commit-message"
>
>
{{
file
.
lastCommit
.
message
}}
{{
file
.
lastCommit
.
message
}}
</a>
</a>
<div
v-else
class=
"animation-container animation-container-small"
>
<div
v-for=
"n in 6"
:key=
"n"
:class=
"'skeleton-line-' + n"
>
</div>
</div>
</td>
</td>
<td
class=
"commit-update hidden-xs text-right"
>
<td
class=
"commit-update hidden-xs text-right"
>
...
@@ -89,6 +107,17 @@
...
@@ -89,6 +107,17 @@
>
>
{{
timeFormated
(
file
.
lastCommit
.
updatedAt
)
}}
{{
timeFormated
(
file
.
lastCommit
.
updatedAt
)
}}
</span>
</span>
<div
v-else
class=
"animation-container animation-container-small animation-container-right"
>
<div
v-for=
"n in 6"
:key=
"n"
:class=
"'skeleton-line-' + n"
>
</div>
</div>
</td>
</td>
</
template
>
</
template
>
</tr>
</tr>
...
...
app/assets/javascripts/repo/components/repo_loading_file.vue
View file @
05420006
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
<template
v-if=
"!isCollapsed"
>
<template
v-if=
"!isCollapsed"
>
<td
<td
class=
"hidden-sm hidden-xs"
>
class=
"hidden-sm hidden-xs"
>
<div
class=
"animation-container"
>
<div
class=
"animation-container
animation-container-small
"
>
<div
<div
v-for=
"n in 6"
v-for=
"n in 6"
:key=
"n"
:key=
"n"
...
...
app/assets/javascripts/repo/services/index.js
View file @
05420006
...
@@ -30,4 +30,11 @@ export default {
...
@@ -30,4 +30,11 @@ export default {
commit
(
projectId
,
payload
)
{
commit
(
projectId
,
payload
)
{
return
Api
.
commitMultiple
(
projectId
,
payload
);
return
Api
.
commitMultiple
(
projectId
,
payload
);
},
},
getTreeLastCommit
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
,
{
params
:
{
format
:
'
json
'
,
},
});
},
};
};
app/assets/javascripts/repo/stores/actions/tree.js
View file @
05420006
...
@@ -10,7 +10,7 @@ import {
...
@@ -10,7 +10,7 @@ import {
}
from
'
../utils
'
;
}
from
'
../utils
'
;
export
const
getTreeData
=
(
export
const
getTreeData
=
(
{
commit
,
state
},
{
commit
,
state
,
dispatch
},
{
endpoint
=
state
.
endpoints
.
rootEndpoint
,
tree
=
state
}
=
{},
{
endpoint
=
state
.
endpoints
.
rootEndpoint
,
tree
=
state
}
=
{},
)
=>
{
)
=>
{
commit
(
types
.
TOGGLE_LOADING
,
tree
);
commit
(
types
.
TOGGLE_LOADING
,
tree
);
...
@@ -30,7 +30,9 @@ export const getTreeData = (
...
@@ -30,7 +30,9 @@ export const getTreeData = (
commit
(
types
.
SET_DIRECTORY_DATA
,
{
data
,
tree
});
commit
(
types
.
SET_DIRECTORY_DATA
,
{
data
,
tree
});
commit
(
types
.
SET_PARENT_TREE_URL
,
data
.
parent_tree_url
);
commit
(
types
.
SET_PARENT_TREE_URL
,
data
.
parent_tree_url
);
commit
(
types
.
SET_LAST_COMMIT_URL
,
{
tree
,
url
:
data
.
last_commit_path
});
commit
(
types
.
TOGGLE_LOADING
,
tree
);
commit
(
types
.
TOGGLE_LOADING
,
tree
);
dispatch
(
'
getLastCommitData
'
,
tree
);
pushState
(
endpoint
);
pushState
(
endpoint
);
})
})
...
@@ -108,3 +110,28 @@ export const createTempTree = ({ state, commit, dispatch }, name) => {
...
@@ -108,3 +110,28 @@ export const createTempTree = ({ state, commit, dispatch }, name) => {
});
});
}
}
};
};
export
const
getLastCommitData
=
({
state
,
commit
,
dispatch
},
tree
=
state
)
=>
{
if
(
tree
.
lastCommitPath
===
''
)
return
;
service
.
getTreeLastCommit
(
tree
.
lastCommitPath
)
.
then
((
res
)
=>
{
const
lastCommitPath
=
normalizeHeaders
(
res
.
headers
)[
'
LOG-URL
'
];
commit
(
types
.
SET_LAST_COMMIT_URL
,
{
tree
,
url
:
lastCommitPath
});
return
res
.
json
();
})
.
then
((
data
)
=>
{
data
.
forEach
((
lastCommit
)
=>
{
const
entry
=
findEntry
(
tree
,
lastCommit
.
type
,
lastCommit
.
file_name
);
if
(
entry
)
{
commit
(
types
.
SET_LAST_COMMIT_DATA
,
{
entry
,
lastCommit
});
}
});
dispatch
(
'
getLastCommitData
'
,
tree
);
})
.
catch
(()
=>
flash
(
'
Error fetching log data.
'
));
};
app/assets/javascripts/repo/stores/mutation_types.js
View file @
05420006
...
@@ -4,11 +4,13 @@ export const SET_COMMIT_REF = 'SET_COMMIT_REF';
...
@@ -4,11 +4,13 @@ export const SET_COMMIT_REF = 'SET_COMMIT_REF';
export
const
SET_PARENT_TREE_URL
=
'
SET_PARENT_TREE_URL
'
;
export
const
SET_PARENT_TREE_URL
=
'
SET_PARENT_TREE_URL
'
;
export
const
SET_ROOT
=
'
SET_ROOT
'
;
export
const
SET_ROOT
=
'
SET_ROOT
'
;
export
const
SET_PREVIOUS_URL
=
'
SET_PREVIOUS_URL
'
;
export
const
SET_PREVIOUS_URL
=
'
SET_PREVIOUS_URL
'
;
export
const
SET_LAST_COMMIT_DATA
=
'
SET_LAST_COMMIT_DATA
'
;
// Tree mutation types
// Tree mutation types
export
const
SET_DIRECTORY_DATA
=
'
SET_DIRECTORY_DATA
'
;
export
const
SET_DIRECTORY_DATA
=
'
SET_DIRECTORY_DATA
'
;
export
const
TOGGLE_TREE_OPEN
=
'
TOGGLE_TREE_OPEN
'
;
export
const
TOGGLE_TREE_OPEN
=
'
TOGGLE_TREE_OPEN
'
;
export
const
CREATE_TMP_TREE
=
'
CREATE_TMP_TREE
'
;
export
const
CREATE_TMP_TREE
=
'
CREATE_TMP_TREE
'
;
export
const
SET_LAST_COMMIT_URL
=
'
SET_LAST_COMMIT_URL
'
;
// File mutation types
// File mutation types
export
const
SET_FILE_DATA
=
'
SET_FILE_DATA
'
;
export
const
SET_FILE_DATA
=
'
SET_FILE_DATA
'
;
...
...
app/assets/javascripts/repo/stores/mutations.js
View file @
05420006
...
@@ -48,6 +48,13 @@ export default {
...
@@ -48,6 +48,13 @@ export default {
previousUrl
,
previousUrl
,
});
});
},
},
[
types
.
SET_LAST_COMMIT_DATA
](
state
,
{
entry
,
lastCommit
})
{
Object
.
assign
(
entry
.
lastCommit
,
{
url
:
`
${
state
.
project
.
url
}
/commit/
${
lastCommit
.
commit
.
id
}
`
,
message
:
lastCommit
.
commit
.
message
,
updatedAt
:
lastCommit
.
commit
.
authored_date
,
});
},
...
fileMutations
,
...
fileMutations
,
...
treeMutations
,
...
treeMutations
,
...
branchMutations
,
...
branchMutations
,
...
...
app/assets/javascripts/repo/stores/mutations/tree.js
View file @
05420006
...
@@ -18,19 +18,19 @@ export default {
...
@@ -18,19 +18,19 @@ export default {
type
:
'
tree
'
,
type
:
'
tree
'
,
parentTreeUrl
,
parentTreeUrl
,
level
,
level
,
}
,
state
.
project
.
url
)),
})),
...
data
.
submodules
.
map
(
m
=>
utils
.
decorateData
({
...
data
.
submodules
.
map
(
m
=>
utils
.
decorateData
({
...
m
,
...
m
,
type
:
'
submodule
'
,
type
:
'
submodule
'
,
parentTreeUrl
,
parentTreeUrl
,
level
,
level
,
}
,
state
.
project
.
url
)),
})),
...
data
.
blobs
.
map
(
b
=>
utils
.
decorateData
({
...
data
.
blobs
.
map
(
b
=>
utils
.
decorateData
({
...
b
,
...
b
,
type
:
'
blob
'
,
type
:
'
blob
'
,
parentTreeUrl
,
parentTreeUrl
,
level
,
level
,
}
,
state
.
project
.
url
)),
})),
],
],
});
});
},
},
...
@@ -39,6 +39,11 @@ export default {
...
@@ -39,6 +39,11 @@ export default {
parentTreeUrl
:
url
,
parentTreeUrl
:
url
,
});
});
},
},
[
types
.
SET_LAST_COMMIT_URL
](
state
,
{
tree
=
state
,
url
})
{
Object
.
assign
(
tree
,
{
lastCommitPath
:
url
,
});
},
[
types
.
CREATE_TMP_TREE
](
state
,
{
parent
,
tmpEntry
})
{
[
types
.
CREATE_TMP_TREE
](
state
,
{
parent
,
tmpEntry
})
{
parent
.
tree
.
push
(
tmpEntry
);
parent
.
tree
.
push
(
tmpEntry
);
},
},
...
...
app/assets/javascripts/repo/stores/state.js
View file @
05420006
...
@@ -8,6 +8,7 @@ export default () => ({
...
@@ -8,6 +8,7 @@ export default () => ({
endpoints
:
{},
endpoints
:
{},
isRoot
:
false
,
isRoot
:
false
,
isInitialRoot
:
false
,
isInitialRoot
:
false
,
lastCommitPath
:
''
,
loading
:
false
,
loading
:
false
,
onTopOfBranch
:
false
,
onTopOfBranch
:
false
,
openFiles
:
[],
openFiles
:
[],
...
...
app/assets/javascripts/repo/stores/utils.js
View file @
05420006
...
@@ -12,7 +12,12 @@ export const dataStructure = () => ({
...
@@ -12,7 +12,12 @@ export const dataStructure = () => ({
opened
:
false
,
opened
:
false
,
active
:
false
,
active
:
false
,
changed
:
false
,
changed
:
false
,
lastCommit
:
{},
lastCommitPath
:
''
,
lastCommit
:
{
url
:
''
,
message
:
''
,
updatedAt
:
''
,
},
tree_url
:
''
,
tree_url
:
''
,
blamePath
:
''
,
blamePath
:
''
,
commitsPath
:
''
,
commitsPath
:
''
,
...
@@ -27,14 +32,13 @@ export const dataStructure = () => ({
...
@@ -27,14 +32,13 @@ export const dataStructure = () => ({
base64
:
false
,
base64
:
false
,
});
});
export
const
decorateData
=
(
entity
,
projectUrl
=
''
)
=>
{
export
const
decorateData
=
(
entity
)
=>
{
const
{
const
{
id
,
id
,
type
,
type
,
url
,
url
,
name
,
name
,
icon
,
icon
,
last_commit
,
tree_url
,
tree_url
,
path
,
path
,
renderError
,
renderError
,
...
@@ -66,12 +70,6 @@ export const decorateData = (entity, projectUrl = '') => {
...
@@ -66,12 +70,6 @@ export const decorateData = (entity, projectUrl = '') => {
renderError
,
renderError
,
content
,
content
,
base64
,
base64
,
// eslint-disable-next-line camelcase
lastCommit
:
last_commit
?
{
url
:
`
${
projectUrl
}
/commit/
${
last_commit
.
id
}
`
,
message
:
last_commit
.
message
,
updatedAt
:
last_commit
.
committed_date
,
}
:
{},
};
};
};
};
...
...
app/controllers/projects/refs_controller.rb
View file @
05420006
...
@@ -58,7 +58,8 @@ class Projects::RefsController < Projects::ApplicationController
...
@@ -58,7 +58,8 @@ class Projects::RefsController < Projects::ApplicationController
last_commit
=
@repo
.
last_commit_for_path
(
@commit
.
id
,
file
)
last_commit
=
@repo
.
last_commit_for_path
(
@commit
.
id
,
file
)
{
{
file_name:
content
.
name
,
file_name:
content
.
name
,
commit:
last_commit
commit:
last_commit
,
type:
content
.
type
}
}
end
end
end
end
...
@@ -70,6 +71,11 @@ class Projects::RefsController < Projects::ApplicationController
...
@@ -70,6 +71,11 @@ class Projects::RefsController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
render_404
}
format
.
html
{
render_404
}
format
.
json
do
response
.
headers
[
"Log-Url"
]
=
@more_log_url
render
json:
@logs
end
format
.
js
format
.
js
end
end
end
end
...
...
app/serializers/blob_entity.rb
View file @
05420006
...
@@ -3,10 +3,6 @@ class BlobEntity < Grape::Entity
...
@@ -3,10 +3,6 @@ class BlobEntity < Grape::Entity
expose
:id
,
:path
,
:name
,
:mode
expose
:id
,
:path
,
:name
,
:mode
expose
:last_commit
do
|
blob
|
request
.
project
.
repository
.
last_commit_for_path
(
blob
.
commit_id
,
blob
.
path
)
end
expose
:icon
do
|
blob
|
expose
:icon
do
|
blob
|
IconsHelper
.
file_type_icon_class
(
'file'
,
blob
.
mode
,
blob
.
name
)
IconsHelper
.
file_type_icon_class
(
'file'
,
blob
.
mode
,
blob
.
name
)
end
end
...
...
app/serializers/tree_entity.rb
View file @
05420006
...
@@ -3,10 +3,6 @@ class TreeEntity < Grape::Entity
...
@@ -3,10 +3,6 @@ class TreeEntity < Grape::Entity
expose
:id
,
:path
,
:name
,
:mode
expose
:id
,
:path
,
:name
,
:mode
expose
:last_commit
do
|
tree
|
request
.
project
.
repository
.
last_commit_for_path
(
tree
.
commit_id
,
tree
.
path
)
end
expose
:icon
do
|
tree
|
expose
:icon
do
|
tree
|
IconsHelper
.
file_type_icon_class
(
'folder'
,
tree
.
mode
,
tree
.
name
)
IconsHelper
.
file_type_icon_class
(
'folder'
,
tree
.
mode
,
tree
.
name
)
end
end
...
...
app/serializers/tree_root_entity.rb
View file @
05420006
...
@@ -18,4 +18,8 @@ class TreeRootEntity < Grape::Entity
...
@@ -18,4 +18,8 @@ class TreeRootEntity < Grape::Entity
project_tree_path
(
request
.
project
,
File
.
join
(
request
.
ref
,
parent_tree_path
))
project_tree_path
(
request
.
project
,
File
.
join
(
request
.
ref
,
parent_tree_path
))
end
end
expose
:last_commit_path
do
|
tree
|
logs_file_project_ref_path
(
request
.
project
,
request
.
ref
,
tree
.
path
)
end
end
end
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