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
Hide 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(
/* 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
axios
from
'
~/lib/utils/axios_utils
'
;
import
commitsQuery
from
'
./queries/commits.query.graphql
'
;
...
...
@@ -34,16 +35,18 @@ export function fetchLogsTree(client, path, offset, resolver = null) {
params
:
{
format
:
'
json
'
,
offset
},
},
)
.
then
(({
data
,
headers
})
=>
{
.
then
(({
data
:
newData
,
headers
})
=>
{
const
headerLogsOffset
=
headers
[
'
more-logs-offset
'
];
const
{
commits
}
=
client
.
readQuery
({
query
:
commitsQuery
});
const
newCommitData
=
[...
commits
,
...
normalizeData
(
data
,
path
)];
const
sourceData
=
client
.
readQuery
({
query
:
commitsQuery
});
const
data
=
produce
(
sourceData
,
draftState
=>
{
draftState
.
commits
.
push
(...
normalizeData
(
newData
,
path
));
});
client
.
writeQuery
({
query
:
commitsQuery
,
data
:
{
commits
:
newCommitData
}
,
data
,
});
resolvers
.
forEach
(
r
=>
resolveCommit
(
newCommitData
,
path
,
r
));
resolvers
.
forEach
(
r
=>
resolveCommit
(
data
.
commits
,
path
,
r
));
fetchpromise
=
null
;
...
...
spec/frontend/repository/log_tree_spec.js
View file @
29be4dbd
...
...
@@ -100,24 +100,28 @@ describe('fetchLogsTree', () => {
);
}));
it
(
'
writes query to client
'
,
()
=>
fetchLogsTree
(
client
,
''
,
'
0
'
,
resolver
).
then
(()
=>
{
expect
(
client
.
writeQuery
).
toHaveBeenCalledWith
({
query
:
expect
.
anything
(),
data
:
{
commits
:
[
expect
.
objectContaining
({
__typename
:
'
LogTreeCommit
'
,
commitPath
:
'
https://test.com
'
,
committedDate
:
'
2019-01-01
'
,
fileName
:
'
index.js
'
,
filePath
:
'
/index.js
'
,
message
:
'
testing message
'
,
sha
:
'
123
'
,
type
:
'
blob
'
,
}),
],
},
});
}));
it
(
'
writes query to client
'
,
async
()
=>
{
await
fetchLogsTree
(
client
,
''
,
'
0
'
,
resolver
);
expect
(
client
.
writeQuery
).
toHaveBeenCalledWith
({
query
:
expect
.
anything
(),
data
:
{
projectPath
:
'
gitlab-org/gitlab-foss
'
,
escapedRef
:
'
master
'
,
commits
:
[
expect
.
objectContaining
({
__typename
:
'
LogTreeCommit
'
,
commitPath
:
'
https://test.com
'
,
committedDate
:
'
2019-01-01
'
,
fileName
:
'
index.js
'
,
filePath
:
'
/index.js
'
,
lockLabel
:
false
,
message
:
'
testing message
'
,
sha
:
'
123
'
,
titleHtml
:
undefined
,
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