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
695b95d0
Commit
695b95d0
authored
Jul 11, 2020
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move package api js routes to core
Move routes in api.js to core in preparation for moving packages to core.
parent
f86de634
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
100 deletions
+100
-100
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+29
-0
ee/app/assets/javascripts/api.js
ee/app/assets/javascripts/api.js
+0
-29
ee/spec/frontend/api_spec.js
ee/spec/frontend/api_spec.js
+0
-71
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+71
-0
No files found.
app/assets/javascripts/api.js
View file @
695b95d0
...
@@ -11,6 +11,9 @@ const Api = {
...
@@ -11,6 +11,9 @@ const Api = {
groupMembersPath
:
'
/api/:version/groups/:id/members
'
,
groupMembersPath
:
'
/api/:version/groups/:id/members
'
,
subgroupsPath
:
'
/api/:version/groups/:id/subgroups
'
,
subgroupsPath
:
'
/api/:version/groups/:id/subgroups
'
,
namespacesPath
:
'
/api/:version/namespaces.json
'
,
namespacesPath
:
'
/api/:version/namespaces.json
'
,
groupPackagesPath
:
'
/api/:version/groups/:id/packages
'
,
projectPackagesPath
:
'
/api/:version/projects/:id/packages
'
,
projectPackagePath
:
'
/api/:version/projects/:id/packages/:package_id
'
,
groupProjectsPath
:
'
/api/:version/groups/:id/projects.json
'
,
groupProjectsPath
:
'
/api/:version/groups/:id/projects.json
'
,
projectsPath
:
'
/api/:version/projects.json
'
,
projectsPath
:
'
/api/:version/projects.json
'
,
projectPath
:
'
/api/:version/projects/:id
'
,
projectPath
:
'
/api/:version/projects/:id
'
,
...
@@ -66,6 +69,32 @@ const Api = {
...
@@ -66,6 +69,32 @@ const Api = {
});
});
},
},
groupPackages
(
id
,
options
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
groupPackagesPath
).
replace
(
'
:id
'
,
id
);
return
axios
.
get
(
url
,
options
);
},
projectPackages
(
id
,
options
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
projectPackagesPath
).
replace
(
'
:id
'
,
id
);
return
axios
.
get
(
url
,
options
);
},
buildProjectPackageUrl
(
projectId
,
packageId
)
{
return
Api
.
buildUrl
(
this
.
projectPackagePath
)
.
replace
(
'
:id
'
,
projectId
)
.
replace
(
'
:package_id
'
,
packageId
);
},
projectPackage
(
projectId
,
packageId
)
{
const
url
=
this
.
buildProjectPackageUrl
(
projectId
,
packageId
);
return
axios
.
get
(
url
);
},
deleteProjectPackage
(
projectId
,
packageId
)
{
const
url
=
this
.
buildProjectPackageUrl
(
projectId
,
packageId
);
return
axios
.
delete
(
url
);
},
groupMembers
(
id
,
options
)
{
groupMembers
(
id
,
options
)
{
const
url
=
Api
.
buildUrl
(
this
.
groupMembersPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
id
));
const
url
=
Api
.
buildUrl
(
this
.
groupMembersPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
id
));
...
...
ee/app/assets/javascripts/api.js
View file @
695b95d0
...
@@ -10,9 +10,6 @@ export default {
...
@@ -10,9 +10,6 @@ export default {
childEpicPath
:
'
/api/:version/groups/:id/epics/:epic_iid/epics
'
,
childEpicPath
:
'
/api/:version/groups/:id/epics/:epic_iid/epics
'
,
groupEpicsPath
:
'
/api/:version/groups/:id/epics
'
,
groupEpicsPath
:
'
/api/:version/groups/:id/epics
'
,
epicIssuePath
:
'
/api/:version/groups/:id/epics/:epic_iid/issues/:issue_id
'
,
epicIssuePath
:
'
/api/:version/groups/:id/epics/:epic_iid/issues/:issue_id
'
,
groupPackagesPath
:
'
/api/:version/groups/:id/packages
'
,
projectPackagesPath
:
'
/api/:version/projects/:id/packages
'
,
projectPackagePath
:
'
/api/:version/projects/:id/packages/:package_id
'
,
cycleAnalyticsTasksByTypePath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type
'
,
cycleAnalyticsTasksByTypePath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type
'
,
cycleAnalyticsTopLabelsPath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type/top_labels
'
,
cycleAnalyticsTopLabelsPath
:
'
/groups/:id/-/analytics/type_of_work/tasks_by_type/top_labels
'
,
cycleAnalyticsSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/summary
'
,
cycleAnalyticsSummaryDataPath
:
'
/groups/:id/-/analytics/value_stream_analytics/summary
'
,
...
@@ -113,32 +110,6 @@ export default {
...
@@ -113,32 +110,6 @@ export default {
return
axios
.
delete
(
url
);
return
axios
.
delete
(
url
);
},
},
groupPackages
(
id
,
options
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
groupPackagesPath
).
replace
(
'
:id
'
,
id
);
return
axios
.
get
(
url
,
options
);
},
projectPackages
(
id
,
options
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
projectPackagesPath
).
replace
(
'
:id
'
,
id
);
return
axios
.
get
(
url
,
options
);
},
buildProjectPackageUrl
(
projectId
,
packageId
)
{
return
Api
.
buildUrl
(
this
.
projectPackagePath
)
.
replace
(
'
:id
'
,
projectId
)
.
replace
(
'
:package_id
'
,
packageId
);
},
projectPackage
(
projectId
,
packageId
)
{
const
url
=
this
.
buildProjectPackageUrl
(
projectId
,
packageId
);
return
axios
.
get
(
url
);
},
deleteProjectPackage
(
projectId
,
packageId
)
{
const
url
=
this
.
buildProjectPackageUrl
(
projectId
,
packageId
);
return
axios
.
delete
(
url
);
},
cycleAnalyticsTasksByType
(
groupId
,
params
=
{})
{
cycleAnalyticsTasksByType
(
groupId
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsTasksByTypePath
).
replace
(
'
:id
'
,
groupId
);
const
url
=
Api
.
buildUrl
(
this
.
cycleAnalyticsTasksByTypePath
).
replace
(
'
:id
'
,
groupId
);
...
...
ee/spec/frontend/api_spec.js
View file @
695b95d0
...
@@ -200,77 +200,6 @@ describe('Api', () => {
...
@@ -200,77 +200,6 @@ describe('Api', () => {
});
});
});
});
describe
(
'
packages
'
,
()
=>
{
const
projectId
=
'
project_a
'
;
const
packageId
=
'
package_b
'
;
const
apiResponse
=
[{
id
:
1
,
name
:
'
foo
'
}];
describe
(
'
groupPackages
'
,
()
=>
{
const
groupId
=
'
group_a
'
;
it
(
'
fetch all group packages
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/groups/
${
groupId
}
/packages`
;
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
groupPackages
(
groupId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{});
});
});
});
describe
(
'
projectPackages
'
,
()
=>
{
it
(
'
fetch all project packages
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
projectId
}
/packages`
;
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
projectPackages
(
projectId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{});
});
});
});
describe
(
'
buildProjectPackageUrl
'
,
()
=>
{
it
(
'
returns the right url
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
projectId
}
/packages/
${
packageId
}
`
;
const
url
=
Api
.
buildProjectPackageUrl
(
projectId
,
packageId
);
expect
(
url
).
toEqual
(
expectedUrl
);
});
});
describe
(
'
projectPackage
'
,
()
=>
{
it
(
'
fetch package details
'
,
()
=>
{
const
expectedUrl
=
`foo`
;
jest
.
spyOn
(
Api
,
'
buildProjectPackageUrl
'
).
mockReturnValue
(
expectedUrl
);
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
projectPackage
(
projectId
,
packageId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
);
});
});
});
describe
(
'
deleteProjectPackage
'
,
()
=>
{
it
(
'
delete a package
'
,
()
=>
{
const
expectedUrl
=
`foo`
;
jest
.
spyOn
(
Api
,
'
buildProjectPackageUrl
'
).
mockReturnValue
(
expectedUrl
);
jest
.
spyOn
(
axios
,
'
delete
'
);
mock
.
onDelete
(
expectedUrl
).
replyOnce
(
200
,
true
);
return
Api
.
deleteProjectPackage
(
projectId
,
packageId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
true
);
expect
(
axios
.
delete
).
toHaveBeenCalledWith
(
expectedUrl
);
});
});
});
});
describe
(
'
Cycle analytics
'
,
()
=>
{
describe
(
'
Cycle analytics
'
,
()
=>
{
const
groupId
=
'
counting-54321
'
;
const
groupId
=
'
counting-54321
'
;
const
createdBefore
=
'
2019-11-18
'
;
const
createdBefore
=
'
2019-11-18
'
;
...
...
spec/frontend/api_spec.js
View file @
695b95d0
...
@@ -46,6 +46,77 @@ describe('Api', () => {
...
@@ -46,6 +46,77 @@ describe('Api', () => {
});
});
});
});
describe
(
'
packages
'
,
()
=>
{
const
projectId
=
'
project_a
'
;
const
packageId
=
'
package_b
'
;
const
apiResponse
=
[{
id
:
1
,
name
:
'
foo
'
}];
describe
(
'
groupPackages
'
,
()
=>
{
const
groupId
=
'
group_a
'
;
it
(
'
fetch all group packages
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/groups/
${
groupId
}
/packages`
;
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
groupPackages
(
groupId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{});
});
});
});
describe
(
'
projectPackages
'
,
()
=>
{
it
(
'
fetch all project packages
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
projectId
}
/packages`
;
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
projectPackages
(
projectId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{});
});
});
});
describe
(
'
buildProjectPackageUrl
'
,
()
=>
{
it
(
'
returns the right url
'
,
()
=>
{
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
projectId
}
/packages/
${
packageId
}
`
;
const
url
=
Api
.
buildProjectPackageUrl
(
projectId
,
packageId
);
expect
(
url
).
toEqual
(
expectedUrl
);
});
});
describe
(
'
projectPackage
'
,
()
=>
{
it
(
'
fetch package details
'
,
()
=>
{
const
expectedUrl
=
`foo`
;
jest
.
spyOn
(
Api
,
'
buildProjectPackageUrl
'
).
mockReturnValue
(
expectedUrl
);
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
apiResponse
);
return
Api
.
projectPackage
(
projectId
,
packageId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
);
});
});
});
describe
(
'
deleteProjectPackage
'
,
()
=>
{
it
(
'
delete a package
'
,
()
=>
{
const
expectedUrl
=
`foo`
;
jest
.
spyOn
(
Api
,
'
buildProjectPackageUrl
'
).
mockReturnValue
(
expectedUrl
);
jest
.
spyOn
(
axios
,
'
delete
'
);
mock
.
onDelete
(
expectedUrl
).
replyOnce
(
200
,
true
);
return
Api
.
deleteProjectPackage
(
projectId
,
packageId
).
then
(({
data
})
=>
{
expect
(
data
).
toEqual
(
true
);
expect
(
axios
.
delete
).
toHaveBeenCalledWith
(
expectedUrl
);
});
});
});
});
describe
(
'
group
'
,
()
=>
{
describe
(
'
group
'
,
()
=>
{
it
(
'
fetches a group
'
,
done
=>
{
it
(
'
fetches a group
'
,
done
=>
{
const
groupId
=
'
123456
'
;
const
groupId
=
'
123456
'
;
...
...
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