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
Léo-Paul Géneau
gitlab-ce
Commits
17735dc8
Commit
17735dc8
authored
Sep 28, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed file templates not being fully fetched in Web IDE
Closes #51912
parent
ba66e0cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
8 deletions
+60
-8
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
.../javascripts/ide/stores/modules/file_templates/actions.js
+12
-3
app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
...avascripts/ide/stores/modules/file_templates/mutations.js
+1
-1
changelogs/unreleased/ide-fetch-templates-pages.yml
changelogs/unreleased/ide-fetch-templates-pages.yml
+5
-0
spec/javascripts/ide/stores/modules/file_templates/actions_spec.js
...scripts/ide/stores/modules/file_templates/actions_spec.js
+42
-4
No files found.
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
View file @
17735dc8
import
Api
from
'
~/api
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
normalizeHeaders
}
from
'
~/lib/utils/common_utils
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
eventHub
from
'
../../../eventhub
'
;
...
...
@@ -22,13 +23,21 @@ export const receiveTemplateTypesError = ({ commit, dispatch }) => {
export
const
receiveTemplateTypesSuccess
=
({
commit
},
templates
)
=>
commit
(
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
,
templates
);
export
const
fetchTemplateTypes
=
({
dispatch
,
state
})
=>
{
export
const
fetchTemplateTypes
=
({
dispatch
,
state
}
,
page
=
1
)
=>
{
if
(
!
Object
.
keys
(
state
.
selectedTemplateType
).
length
)
return
Promise
.
reject
();
dispatch
(
'
requestTemplateTypes
'
);
return
Api
.
templates
(
state
.
selectedTemplateType
.
key
)
.
then
(({
data
})
=>
dispatch
(
'
receiveTemplateTypesSuccess
'
,
data
))
return
Api
.
templates
(
state
.
selectedTemplateType
.
key
,
{
page
})
.
then
(({
data
,
headers
})
=>
{
const
nextPage
=
parseInt
(
normalizeHeaders
(
headers
)[
'
X-NEXT-PAGE
'
],
10
);
dispatch
(
'
receiveTemplateTypesSuccess
'
,
data
);
if
(
nextPage
)
{
dispatch
(
'
fetchTemplateTypes
'
,
nextPage
);
}
})
.
catch
(()
=>
dispatch
(
'
receiveTemplateTypesError
'
));
};
...
...
app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
View file @
17735dc8
...
...
@@ -9,7 +9,7 @@ export default {
},
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
templates
)
{
state
.
isLoading
=
false
;
state
.
templates
=
templates
;
state
.
templates
=
state
.
templates
.
concat
(
templates
)
;
},
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
type
)
{
state
.
selectedTemplateType
=
type
;
...
...
changelogs/unreleased/ide-fetch-templates-pages.yml
0 → 100644
View file @
17735dc8
---
title
:
Fixed file templates not fully being fetched in Web IDE
merge_request
:
author
:
type
:
fixed
spec/javascripts/ide/stores/modules/file_templates/actions_spec.js
View file @
17735dc8
...
...
@@ -69,11 +69,17 @@ describe('IDE file templates actions', () => {
describe
(
'
fetchTemplateTypes
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
let
nextPage
;
beforeEach
(()
=>
{
mock
.
onGet
(
/api
\/(
.*
)\/
templates
\/
licenses/
).
replyOnce
(
200
,
[
{
name
:
'
MIT
'
,
},
mock
.
onGet
(
/api
\/(
.*
)\/
templates
\/
licenses/
).
replyOnce
(()
=>
[
200
,
[
{
name
:
'
MIT
'
,
},
],
{
'
X-NEXT-PAGE
'
:
nextPage
},
]);
});
...
...
@@ -116,6 +122,38 @@ describe('IDE file templates actions', () => {
done
,
);
});
it
(
'
dispatches actions for next page
'
,
done
=>
{
nextPage
=
'
2
'
;
state
.
selectedTemplateType
=
{
key
:
'
licenses
'
,
};
testAction
(
actions
.
fetchTemplateTypes
,
null
,
state
,
[],
[
{
type
:
'
requestTemplateTypes
'
,
},
{
type
:
'
receiveTemplateTypesSuccess
'
,
payload
:
[
{
name
:
'
MIT
'
,
},
],
},
{
type
:
'
fetchTemplateTypes
'
,
payload
:
2
,
},
],
done
,
);
});
});
describe
(
'
error
'
,
()
=>
{
...
...
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