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
29be4dbd
Commit
29be4dbd
authored
Sep 08, 2020
by
Nicolò Maria Mezzopera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update log_tree to use immutables
- graphql config - log_tree update - test adjustments
parent
cc86d001
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
25 deletions
+33
-25
app/assets/javascripts/repository/graphql.js
app/assets/javascripts/repository/graphql.js
+1
-0
app/assets/javascripts/repository/log_tree.js
app/assets/javascripts/repository/log_tree.js
+8
-5
spec/frontend/repository/log_tree_spec.js
spec/frontend/repository/log_tree_spec.js
+24
-20
No files found.
app/assets/javascripts/repository/graphql.js
View file @
29be4dbd
...
@@ -58,6 +58,7 @@ const defaultClient = createDefaultClient(
...
@@ -58,6 +58,7 @@ const defaultClient = createDefaultClient(
/* eslint-enable @gitlab/require-i18n-strings */
/* eslint-enable @gitlab/require-i18n-strings */
},
},
},
},
assumeImmutableResults
:
true
,
},
},
);
);
...
...
app/assets/javascripts/repository/log_tree.js
View file @
29be4dbd
import
produce
from
'
immer
'
;
import
{
normalizeData
}
from
'
ee_else_ce/repository/utils/commit
'
;
import
{
normalizeData
}
from
'
ee_else_ce/repository/utils/commit
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
commitsQuery
from
'
./queries/commits.query.graphql
'
;
import
commitsQuery
from
'
./queries/commits.query.graphql
'
;
...
@@ -34,16 +35,18 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
...
@@ -34,16 +35,18 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
params
:
{
format
:
'
json
'
,
offset
},
params
:
{
format
:
'
json
'
,
offset
},
},
},
)
)
.
then
(({
data
,
headers
})
=>
{
.
then
(({
data
:
newData
,
headers
})
=>
{
const
headerLogsOffset
=
headers
[
'
more-logs-offset
'
];
const
headerLogsOffset
=
headers
[
'
more-logs-offset
'
];
const
{
commits
}
=
client
.
readQuery
({
query
:
commitsQuery
});
const
sourceData
=
client
.
readQuery
({
query
:
commitsQuery
});
const
newCommitData
=
[...
commits
,
...
normalizeData
(
data
,
path
)];
const
data
=
produce
(
sourceData
,
draftState
=>
{
draftState
.
commits
.
push
(...
normalizeData
(
newData
,
path
));
});
client
.
writeQuery
({
client
.
writeQuery
({
query
:
commitsQuery
,
query
:
commitsQuery
,
data
:
{
commits
:
newCommitData
}
,
data
,
});
});
resolvers
.
forEach
(
r
=>
resolveCommit
(
newCommitData
,
path
,
r
));
resolvers
.
forEach
(
r
=>
resolveCommit
(
data
.
commits
,
path
,
r
));
fetchpromise
=
null
;
fetchpromise
=
null
;
...
...
spec/frontend/repository/log_tree_spec.js
View file @
29be4dbd
...
@@ -100,11 +100,13 @@ describe('fetchLogsTree', () => {
...
@@ -100,11 +100,13 @@ describe('fetchLogsTree', () => {
);
);
}));
}));
it
(
'
writes query to client
'
,
()
=>
it
(
'
writes query to client
'
,
async
()
=>
{
fetchLogsTree
(
client
,
''
,
'
0
'
,
resolver
).
then
(()
=>
{
await
fetchLogsTree
(
client
,
''
,
'
0
'
,
resolver
);
expect
(
client
.
writeQuery
).
toHaveBeenCalledWith
({
expect
(
client
.
writeQuery
).
toHaveBeenCalledWith
({
query
:
expect
.
anything
(),
query
:
expect
.
anything
(),
data
:
{
data
:
{
projectPath
:
'
gitlab-org/gitlab-foss
'
,
escapedRef
:
'
master
'
,
commits
:
[
commits
:
[
expect
.
objectContaining
({
expect
.
objectContaining
({
__typename
:
'
LogTreeCommit
'
,
__typename
:
'
LogTreeCommit
'
,
...
@@ -112,12 +114,14 @@ describe('fetchLogsTree', () => {
...
@@ -112,12 +114,14 @@ describe('fetchLogsTree', () => {
committedDate
:
'
2019-01-01
'
,
committedDate
:
'
2019-01-01
'
,
fileName
:
'
index.js
'
,
fileName
:
'
index.js
'
,
filePath
:
'
/index.js
'
,
filePath
:
'
/index.js
'
,
lockLabel
:
false
,
message
:
'
testing message
'
,
message
:
'
testing message
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
titleHtml
:
undefined
,
type
:
'
blob
'
,
type
:
'
blob
'
,
}),
}),
],
],
},
},
});
});
})
);
}
);
});
});
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