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
7dc2a7aa
Commit
7dc2a7aa
authored
Apr 23, 2019
by
Natalia Tepluhina
Committed by
Phil Hughes
Apr 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Increased page size to 100"
This reverts commit 2869a61f3b7aeb8b6d79c74332c93e32cec20caa.
parent
712a63a7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
64 deletions
+64
-64
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
.../javascripts/ide/stores/modules/file_templates/actions.js
+15
-10
app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
...avascripts/ide/stores/modules/file_templates/mutations.js
+2
-1
changelogs/unreleased/58252-web-ide-dropdown-duplicates.yml
changelogs/unreleased/58252-web-ide-dropdown-duplicates.yml
+5
-0
spec/frontend/ide/stores/modules/file_templates/mutations_spec.js
...ntend/ide/stores/modules/file_templates/mutations_spec.js
+30
-11
spec/javascripts/ide/stores/modules/file_templates/actions_spec.js
...scripts/ide/stores/modules/file_templates/actions_spec.js
+12
-42
No files found.
app/assets/javascripts/ide/stores/modules/file_templates/actions.js
View file @
7dc2a7aa
...
@@ -23,22 +23,27 @@ export const receiveTemplateTypesError = ({ commit, dispatch }) => {
...
@@ -23,22 +23,27 @@ export const receiveTemplateTypesError = ({ commit, dispatch }) => {
export
const
receiveTemplateTypesSuccess
=
({
commit
},
templates
)
=>
export
const
receiveTemplateTypesSuccess
=
({
commit
},
templates
)
=>
commit
(
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
,
templates
);
commit
(
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
,
templates
);
export
const
fetchTemplateTypes
=
({
dispatch
,
state
,
rootState
}
,
page
=
1
)
=>
{
export
const
fetchTemplateTypes
=
({
dispatch
,
state
,
rootState
})
=>
{
if
(
!
Object
.
keys
(
state
.
selectedTemplateType
).
length
)
return
Promise
.
reject
();
if
(
!
Object
.
keys
(
state
.
selectedTemplateType
).
length
)
return
Promise
.
reject
();
dispatch
(
'
requestTemplateTypes
'
);
dispatch
(
'
requestTemplateTypes
'
);
return
Api
.
projectTemplates
(
rootState
.
currentProjectId
,
state
.
selectedTemplateType
.
key
,
{
page
})
const
fetchPages
=
(
page
=
1
,
prev
=
[])
=>
Api
.
projectTemplates
(
rootState
.
currentProjectId
,
state
.
selectedTemplateType
.
key
,
{
page
,
per_page
:
100
,
})
.
then
(({
data
,
headers
})
=>
{
.
then
(({
data
,
headers
})
=>
{
const
nextPage
=
parseInt
(
normalizeHeaders
(
headers
)[
'
X-NEXT-PAGE
'
],
10
);
const
nextPage
=
parseInt
(
normalizeHeaders
(
headers
)[
'
X-NEXT-PAGE
'
],
10
);
const
nextData
=
prev
.
concat
(
data
);
dispatch
(
'
receiveTemplateTypesSuccess
'
,
d
ata
);
dispatch
(
'
receiveTemplateTypesSuccess
'
,
nextD
ata
);
if
(
nextPage
)
{
return
nextPage
?
fetchPages
(
nextPage
,
nextData
)
:
nextData
;
dispatch
(
'
fetchTemplateTypes
'
,
nextPage
);
}
})
})
.
catch
(()
=>
dispatch
(
'
receiveTemplateTypesError
'
));
.
catch
(()
=>
dispatch
(
'
receiveTemplateTypesError
'
));
return
fetchPages
();
};
};
export
const
setSelectedTemplateType
=
({
commit
,
dispatch
,
rootGetters
},
type
)
=>
{
export
const
setSelectedTemplateType
=
({
commit
,
dispatch
,
rootGetters
},
type
)
=>
{
...
...
app/assets/javascripts/ide/stores/modules/file_templates/mutations.js
View file @
7dc2a7aa
...
@@ -3,13 +3,14 @@ import * as types from './mutation_types';
...
@@ -3,13 +3,14 @@ import * as types from './mutation_types';
export
default
{
export
default
{
[
types
.
REQUEST_TEMPLATE_TYPES
](
state
)
{
[
types
.
REQUEST_TEMPLATE_TYPES
](
state
)
{
state
.
isLoading
=
true
;
state
.
isLoading
=
true
;
state
.
templates
=
[];
},
},
[
types
.
RECEIVE_TEMPLATE_TYPES_ERROR
](
state
)
{
[
types
.
RECEIVE_TEMPLATE_TYPES_ERROR
](
state
)
{
state
.
isLoading
=
false
;
state
.
isLoading
=
false
;
},
},
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
templates
)
{
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
templates
)
{
state
.
isLoading
=
false
;
state
.
isLoading
=
false
;
state
.
templates
=
state
.
templates
.
concat
(
templates
)
;
state
.
templates
=
templates
;
},
},
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
type
)
{
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
type
)
{
state
.
selectedTemplateType
=
type
;
state
.
selectedTemplateType
=
type
;
...
...
changelogs/unreleased/58252-web-ide-dropdown-duplicates.yml
0 → 100644
View file @
7dc2a7aa
---
title
:
Resolve Web IDE template dropdown showing duplicates
merge_request
:
27237
author
:
type
:
fixed
spec/frontend/ide/stores/modules/file_templates/mutations_spec.js
View file @
7dc2a7aa
...
@@ -2,6 +2,9 @@ import createState from '~/ide/stores/modules/file_templates/state';
...
@@ -2,6 +2,9 @@ import createState from '~/ide/stores/modules/file_templates/state';
import
*
as
types
from
'
~/ide/stores/modules/file_templates/mutation_types
'
;
import
*
as
types
from
'
~/ide/stores/modules/file_templates/mutation_types
'
;
import
mutations
from
'
~/ide/stores/modules/file_templates/mutations
'
;
import
mutations
from
'
~/ide/stores/modules/file_templates/mutations
'
;
const
mockFileTemplates
=
[[
'
MIT
'
],
[
'
CC
'
]];
const
mockTemplateType
=
'
test
'
;
describe
(
'
IDE file templates mutations
'
,
()
=>
{
describe
(
'
IDE file templates mutations
'
,
()
=>
{
let
state
;
let
state
;
...
@@ -10,11 +13,21 @@ describe('IDE file templates mutations', () => {
...
@@ -10,11 +13,21 @@ describe('IDE file templates mutations', () => {
});
});
describe
(
`
${
types
.
REQUEST_TEMPLATE_TYPES
}
`
,
()
=>
{
describe
(
`
${
types
.
REQUEST_TEMPLATE_TYPES
}
`
,
()
=>
{
it
(
'
sets isLoading
'
,
()
=>
{
it
(
'
sets loading to true
'
,
()
=>
{
state
.
isLoading
=
false
;
mutations
[
types
.
REQUEST_TEMPLATE_TYPES
](
state
);
mutations
[
types
.
REQUEST_TEMPLATE_TYPES
](
state
);
expect
(
state
.
isLoading
).
toBe
(
true
);
expect
(
state
.
isLoading
).
toBe
(
true
);
});
});
it
(
'
sets templates to an empty array
'
,
()
=>
{
state
.
templates
=
mockFileTemplates
;
mutations
[
types
.
REQUEST_TEMPLATE_TYPES
](
state
);
expect
(
state
.
templates
).
toEqual
([]);
});
});
});
describe
(
`
${
types
.
RECEIVE_TEMPLATE_TYPES_ERROR
}
`
,
()
=>
{
describe
(
`
${
types
.
RECEIVE_TEMPLATE_TYPES_ERROR
}
`
,
()
=>
{
...
@@ -31,29 +44,33 @@ describe('IDE file templates mutations', () => {
...
@@ -31,29 +44,33 @@ describe('IDE file templates mutations', () => {
it
(
'
sets isLoading to false
'
,
()
=>
{
it
(
'
sets isLoading to false
'
,
()
=>
{
state
.
isLoading
=
true
;
state
.
isLoading
=
true
;
mutations
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
[]
);
mutations
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
mockFileTemplates
);
expect
(
state
.
isLoading
).
toBe
(
false
);
expect
(
state
.
isLoading
).
toBe
(
false
);
});
});
it
(
'
sets templates
'
,
()
=>
{
it
(
'
sets templates to payload
'
,
()
=>
{
mutations
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
[
'
test
'
]);
state
.
templates
=
[
'
test
'
];
mutations
[
types
.
RECEIVE_TEMPLATE_TYPES_SUCCESS
](
state
,
mockFileTemplates
);
expect
(
state
.
templates
).
toEqual
(
[
'
test
'
]
);
expect
(
state
.
templates
).
toEqual
(
mockFileTemplates
);
});
});
});
});
describe
(
`
${
types
.
SET_SELECTED_TEMPLATE_TYPE
}
`
,
()
=>
{
describe
(
`
${
types
.
SET_SELECTED_TEMPLATE_TYPE
}
`
,
()
=>
{
it
(
'
sets
selectedTemplateT
ype
'
,
()
=>
{
it
(
'
sets
templates type to selected t
ype
'
,
()
=>
{
mutations
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
'
type
'
)
;
state
.
selectedTemplateType
=
''
;
expect
(
state
.
selectedTemplateType
).
toBe
(
'
type
'
);
mutations
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
mockTemplateType
);
expect
(
state
.
selectedTemplateType
).
toBe
(
mockTemplateType
);
});
});
it
(
'
clears templates
'
,
()
=>
{
it
(
'
sets templates to empty array
'
,
()
=>
{
state
.
templates
=
[
'
test
'
]
;
state
.
templates
=
mockFileTemplates
;
mutations
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
'
type
'
);
mutations
[
types
.
SET_SELECTED_TEMPLATE_TYPE
](
state
,
mockTemplateType
);
expect
(
state
.
templates
).
toEqual
([]);
expect
(
state
.
templates
).
toEqual
([]);
});
});
...
@@ -61,6 +78,8 @@ describe('IDE file templates mutations', () => {
...
@@ -61,6 +78,8 @@ describe('IDE file templates mutations', () => {
describe
(
`
${
types
.
SET_UPDATE_SUCCESS
}
`
,
()
=>
{
describe
(
`
${
types
.
SET_UPDATE_SUCCESS
}
`
,
()
=>
{
it
(
'
sets updateSuccess
'
,
()
=>
{
it
(
'
sets updateSuccess
'
,
()
=>
{
state
.
updateSuccess
=
false
;
mutations
[
types
.
SET_UPDATE_SUCCESS
](
state
,
true
);
mutations
[
types
.
SET_UPDATE_SUCCESS
](
state
,
true
);
expect
(
state
.
updateSuccess
).
toBe
(
true
);
expect
(
state
.
updateSuccess
).
toBe
(
true
);
...
...
spec/javascripts/ide/stores/modules/file_templates/actions_spec.js
View file @
7dc2a7aa
...
@@ -69,18 +69,16 @@ describe('IDE file templates actions', () => {
...
@@ -69,18 +69,16 @@ describe('IDE file templates actions', () => {
describe
(
'
fetchTemplateTypes
'
,
()
=>
{
describe
(
'
fetchTemplateTypes
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
let
nextPage
;
const
pages
=
[[{
name
:
'
MIT
'
}],
[{
name
:
'
Apache
'
}],
[{
name
:
'
CC
'
}]]
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/api
\/(
.*
)\/
templates
\/
licenses/
).
replyOnce
(()
=>
[
mock
.
onGet
(
/api
\/(
.*
)\/
templates
\/
licenses/
).
reply
(({
params
})
=>
{
200
,
const
pageNum
=
params
.
page
;
[
const
page
=
pages
[
pageNum
-
1
];
{
const
hasNextPage
=
pageNum
<
pages
.
length
;
name
:
'
MIT
'
,
},
return
[
200
,
page
,
hasNextPage
?
{
'
X-NEXT-PAGE
'
:
pageNum
+
1
}
:
{}];
],
});
{
'
X-NEXT-PAGE
'
:
nextPage
},
]);
});
});
it
(
'
rejects if selectedTemplateType is empty
'
,
done
=>
{
it
(
'
rejects if selectedTemplateType is empty
'
,
done
=>
{
...
@@ -112,43 +110,15 @@ describe('IDE file templates actions', () => {
...
@@ -112,43 +110,15 @@ describe('IDE file templates actions', () => {
},
},
{
{
type
:
'
receiveTemplateTypesSuccess
'
,
type
:
'
receiveTemplateTypesSuccess
'
,
payload
:
[
payload
:
pages
[
0
],
{
name
:
'
MIT
'
,
},
],
},
],
done
,
);
});
it
(
'
dispatches actions for next page
'
,
done
=>
{
nextPage
=
'
2
'
;
state
.
selectedTemplateType
=
{
key
:
'
licenses
'
,
};
testAction
(
actions
.
fetchTemplateTypes
,
null
,
state
,
[],
[
{
type
:
'
requestTemplateTypes
'
,
},
},
{
{
type
:
'
receiveTemplateTypesSuccess
'
,
type
:
'
receiveTemplateTypesSuccess
'
,
payload
:
[
payload
:
pages
[
0
].
concat
(
pages
[
1
]),
{
name
:
'
MIT
'
,
},
],
},
},
{
{
type
:
'
fetchTemplateType
s
'
,
type
:
'
receiveTemplateTypesSucces
s
'
,
payload
:
2
,
payload
:
pages
[
0
].
concat
(
pages
[
1
]).
concat
(
pages
[
2
])
,
},
},
],
],
done
,
done
,
...
...
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