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
3c8b2098
Commit
3c8b2098
authored
Nov 04, 2020
by
Nicolò Maria Mezzopera
Committed by
David O'Regan
Nov 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add containerRegistryDetails to api.js
- source - tests
parent
de852bce
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
131 additions
and
1 deletion
+131
-1
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+6
-0
app/assets/javascripts/registry/explorer/constants/details.js
...assets/javascripts/registry/explorer/constants/details.js
+4
-0
app/assets/javascripts/registry/explorer/stores/actions.js
app/assets/javascripts/registry/explorer/stores/actions.js
+15
-0
app/assets/javascripts/registry/explorer/stores/mutation_types.js
...ts/javascripts/registry/explorer/stores/mutation_types.js
+1
-0
app/assets/javascripts/registry/explorer/stores/mutations.js
app/assets/javascripts/registry/explorer/stores/mutations.js
+4
-0
app/assets/javascripts/registry/explorer/stores/state.js
app/assets/javascripts/registry/explorer/stores/state.js
+1
-0
app/assets/javascripts/registry/explorer/utils.js
app/assets/javascripts/registry/explorer/utils.js
+8
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+18
-0
spec/frontend/registry/explorer/stores/actions_spec.js
spec/frontend/registry/explorer/stores/actions_spec.js
+43
-1
spec/frontend/registry/explorer/stores/mutations_spec.js
spec/frontend/registry/explorer/stores/mutations_spec.js
+9
-0
spec/frontend/registry/explorer/utils_spec.js
spec/frontend/registry/explorer/utils_spec.js
+19
-0
No files found.
app/assets/javascripts/api.js
View file @
3c8b2098
...
@@ -70,6 +70,7 @@ const Api = {
...
@@ -70,6 +70,7 @@ const Api = {
featureFlagUserLists
:
'
/api/:version/projects/:id/feature_flags_user_lists
'
,
featureFlagUserLists
:
'
/api/:version/projects/:id/feature_flags_user_lists
'
,
featureFlagUserList
:
'
/api/:version/projects/:id/feature_flags_user_lists/:list_iid
'
,
featureFlagUserList
:
'
/api/:version/projects/:id/feature_flags_user_lists/:list_iid
'
,
billableGroupMembersPath
:
'
/api/:version/groups/:id/billable_members
'
,
billableGroupMembersPath
:
'
/api/:version/groups/:id/billable_members
'
,
containerRegistryDetailsPath
:
'
/api/:version/registry/repositories/:id/
'
,
group
(
groupId
,
callback
=
()
=>
{})
{
group
(
groupId
,
callback
=
()
=>
{})
{
const
url
=
Api
.
buildUrl
(
Api
.
groupPath
).
replace
(
'
:id
'
,
groupId
);
const
url
=
Api
.
buildUrl
(
Api
.
groupPath
).
replace
(
'
:id
'
,
groupId
);
...
@@ -106,6 +107,11 @@ const Api = {
...
@@ -106,6 +107,11 @@ const Api = {
return
axios
.
delete
(
url
);
return
axios
.
delete
(
url
);
},
},
containerRegistryDetails
(
registryId
,
options
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
containerRegistryDetailsPath
).
replace
(
'
:id
'
,
registryId
);
return
axios
.
get
(
url
,
options
);
},
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
));
...
...
app/assets/javascripts/registry/explorer/constants/details.js
View file @
3c8b2098
...
@@ -15,6 +15,10 @@ export const DELETE_TAGS_SUCCESS_MESSAGE = s__(
...
@@ -15,6 +15,10 @@ export const DELETE_TAGS_SUCCESS_MESSAGE = s__(
'
ContainerRegistry|Tags successfully marked for deletion.
'
,
'
ContainerRegistry|Tags successfully marked for deletion.
'
,
);
);
export
const
FETCH_IMAGE_DETAILS_ERROR_MESSAGE
=
s__
(
'
ContainerRegistry|Something went wrong while fetching the image details.
'
,
);
export
const
TAGS_LIST_TITLE
=
s__
(
'
ContainerRegistry|Image tags
'
);
export
const
TAGS_LIST_TITLE
=
s__
(
'
ContainerRegistry|Image tags
'
);
export
const
DIGEST_LABEL
=
s__
(
'
ContainerRegistry|Digest: %{imageId}
'
);
export
const
DIGEST_LABEL
=
s__
(
'
ContainerRegistry|Digest: %{imageId}
'
);
export
const
CREATED_AT_LABEL
=
s__
(
'
ContainerRegistry|Published %{timeInfo}
'
);
export
const
CREATED_AT_LABEL
=
s__
(
'
ContainerRegistry|Published %{timeInfo}
'
);
...
...
app/assets/javascripts/registry/explorer/stores/actions.js
View file @
3c8b2098
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
Api
from
'
~/api
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
{
import
{
FETCH_IMAGES_LIST_ERROR_MESSAGE
,
FETCH_IMAGES_LIST_ERROR_MESSAGE
,
DEFAULT_PAGE
,
DEFAULT_PAGE
,
DEFAULT_PAGE_SIZE
,
DEFAULT_PAGE_SIZE
,
FETCH_TAGS_LIST_ERROR_MESSAGE
,
FETCH_TAGS_LIST_ERROR_MESSAGE
,
FETCH_IMAGE_DETAILS_ERROR_MESSAGE
,
}
from
'
../constants/index
'
;
}
from
'
../constants/index
'
;
import
{
decodeAndParse
}
from
'
../utils
'
;
import
{
decodeAndParse
}
from
'
../utils
'
;
...
@@ -61,6 +63,19 @@ export const requestTagsList = ({ commit, dispatch }, { pagination = {}, params
...
@@ -61,6 +63,19 @@ export const requestTagsList = ({ commit, dispatch }, { pagination = {}, params
});
});
};
};
export
const
requestImageDetailsAndTagsList
=
({
dispatch
,
commit
},
id
)
=>
{
commit
(
types
.
SET_MAIN_LOADING
,
true
);
return
Api
.
containerRegistryDetails
(
id
)
.
then
(({
data
})
=>
{
commit
(
types
.
SET_IMAGE_DETAILS
,
data
);
dispatch
(
'
requestTagsList
'
);
})
.
catch
(()
=>
{
createFlash
(
FETCH_IMAGE_DETAILS_ERROR_MESSAGE
);
commit
(
types
.
SET_MAIN_LOADING
,
false
);
});
};
export
const
requestDeleteTag
=
({
commit
,
dispatch
,
state
},
{
tag
,
params
})
=>
{
export
const
requestDeleteTag
=
({
commit
,
dispatch
,
state
},
{
tag
,
params
})
=>
{
commit
(
types
.
SET_MAIN_LOADING
,
true
);
commit
(
types
.
SET_MAIN_LOADING
,
true
);
return
axios
return
axios
...
...
app/assets/javascripts/registry/explorer/stores/mutation_types.js
View file @
3c8b2098
...
@@ -7,3 +7,4 @@ export const SET_MAIN_LOADING = 'SET_MAIN_LOADING';
...
@@ -7,3 +7,4 @@ export const SET_MAIN_LOADING = 'SET_MAIN_LOADING';
export
const
SET_TAGS_PAGINATION
=
'
SET_TAGS_PAGINATION
'
;
export
const
SET_TAGS_PAGINATION
=
'
SET_TAGS_PAGINATION
'
;
export
const
SET_TAGS_LIST_SUCCESS
=
'
SET_TAGS_LIST_SUCCESS
'
;
export
const
SET_TAGS_LIST_SUCCESS
=
'
SET_TAGS_LIST_SUCCESS
'
;
export
const
SET_SHOW_GARBAGE_COLLECTION_TIP
=
'
SET_SHOW_GARBAGE_COLLECTION_TIP
'
;
export
const
SET_SHOW_GARBAGE_COLLECTION_TIP
=
'
SET_SHOW_GARBAGE_COLLECTION_TIP
'
;
export
const
SET_IMAGE_DETAILS
=
'
SET_IMAGE_DETAILS
'
;
app/assets/javascripts/registry/explorer/stores/mutations.js
View file @
3c8b2098
...
@@ -47,4 +47,8 @@ export default {
...
@@ -47,4 +47,8 @@ export default {
const
normalizedHeaders
=
normalizeHeaders
(
headers
);
const
normalizedHeaders
=
normalizeHeaders
(
headers
);
state
.
tagsPagination
=
parseIntPagination
(
normalizedHeaders
);
state
.
tagsPagination
=
parseIntPagination
(
normalizedHeaders
);
},
},
[
types
.
SET_IMAGE_DETAILS
](
state
,
details
)
{
state
.
imageDetails
=
details
;
},
};
};
app/assets/javascripts/registry/explorer/stores/state.js
View file @
3c8b2098
...
@@ -3,6 +3,7 @@ export default () => ({
...
@@ -3,6 +3,7 @@ export default () => ({
showGarbageCollectionTip
:
false
,
showGarbageCollectionTip
:
false
,
config
:
{},
config
:
{},
images
:
[],
images
:
[],
imageDetails
:
{},
tags
:
[],
tags
:
[],
pagination
:
{},
pagination
:
{},
tagsPagination
:
{},
tagsPagination
:
{},
...
...
app/assets/javascripts/registry/explorer/utils.js
View file @
3c8b2098
export
const
decodeAndParse
=
param
=>
JSON
.
parse
(
window
.
atob
(
param
));
export
const
decodeAndParse
=
param
=>
JSON
.
parse
(
window
.
atob
(
param
));
// eslint-disable-next-line @gitlab/require-i18n-strings
export
const
pathGenerator
=
(
imageDetails
,
ending
=
'
tags?format=json
'
)
=>
{
// this method is a temporary workaround, to be removed with graphql implementation
// https://gitlab.com/gitlab-org/gitlab/-/issues/276432
const
basePath
=
imageDetails
.
path
.
replace
(
`/
${
imageDetails
.
name
}
`
,
''
);
return
`/
${
basePath
}
/registry/repository/
${
imageDetails
.
id
}
/
${
ending
}
`
;
};
locale/gitlab.pot
View file @
3c8b2098
...
@@ -7214,6 +7214,9 @@ msgstr ""
...
@@ -7214,6 +7214,9 @@ msgstr ""
msgid "ContainerRegistry|Something went wrong while fetching the cleanup policy."
msgid "ContainerRegistry|Something went wrong while fetching the cleanup policy."
msgstr ""
msgstr ""
msgid "ContainerRegistry|Something went wrong while fetching the image details."
msgstr ""
msgid "ContainerRegistry|Something went wrong while fetching the repository list."
msgid "ContainerRegistry|Something went wrong while fetching the repository list."
msgstr ""
msgstr ""
...
...
spec/frontend/api_spec.js
View file @
3c8b2098
...
@@ -118,6 +118,24 @@ describe('Api', () => {
...
@@ -118,6 +118,24 @@ describe('Api', () => {
});
});
});
});
describe
(
'
container registry
'
,
()
=>
{
describe
(
'
containerRegistryDetails
'
,
()
=>
{
it
(
'
fetch container registry details
'
,
async
()
=>
{
const
expectedUrl
=
`foo`
;
const
apiResponse
=
{};
jest
.
spyOn
(
axios
,
'
get
'
);
jest
.
spyOn
(
Api
,
'
buildUrl
'
).
mockReturnValueOnce
(
expectedUrl
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
httpStatus
.
OK
,
apiResponse
);
const
{
data
}
=
await
Api
.
containerRegistryDetails
(
1
);
expect
(
data
).
toEqual
(
apiResponse
);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{});
});
});
});
describe
(
'
group
'
,
()
=>
{
describe
(
'
group
'
,
()
=>
{
it
(
'
fetches a group
'
,
done
=>
{
it
(
'
fetches a group
'
,
done
=>
{
const
groupId
=
'
123456
'
;
const
groupId
=
'
123456
'
;
...
...
spec/frontend/registry/explorer/stores/actions_spec.js
View file @
3c8b2098
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
Api
from
'
~/api
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
*
as
actions
from
'
~/registry/explorer/stores/actions
'
;
import
*
as
actions
from
'
~/registry/explorer/stores/actions
'
;
import
*
as
types
from
'
~/registry/explorer/stores/mutation_types
'
;
import
*
as
types
from
'
~/registry/explorer/stores/mutation_types
'
;
import
{
deprecatedCreateFlash
as
createFlash
}
from
'
~/flash
'
;
import
{
reposServerResponse
,
registryServerResponse
}
from
'
../mock_data
'
;
import
{
reposServerResponse
,
registryServerResponse
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/flash.js
'
);
jest
.
mock
(
'
~/flash.js
'
);
...
@@ -227,6 +228,47 @@ describe('Actions RegistryExplorer Store', () => {
...
@@ -227,6 +228,47 @@ describe('Actions RegistryExplorer Store', () => {
});
});
});
});
describe
(
'
requestImageDetailsAndTagsList
'
,
()
=>
{
it
(
'
sets the imageDetails and dispatch requestTagsList
'
,
done
=>
{
const
resolvedValue
=
{
foo
:
'
bar
'
};
jest
.
spyOn
(
Api
,
'
containerRegistryDetails
'
).
mockResolvedValue
({
data
:
resolvedValue
});
testAction
(
actions
.
requestImageDetailsAndTagsList
,
1
,
{},
[
{
type
:
types
.
SET_MAIN_LOADING
,
payload
:
true
},
{
type
:
types
.
SET_IMAGE_DETAILS
,
payload
:
resolvedValue
},
],
[
{
type
:
'
requestTagsList
'
,
},
],
done
,
);
});
it
(
'
should create flash on error
'
,
done
=>
{
jest
.
spyOn
(
Api
,
'
containerRegistryDetails
'
).
mockRejectedValue
();
testAction
(
actions
.
requestImageDetailsAndTagsList
,
1
,
{},
[
{
type
:
types
.
SET_MAIN_LOADING
,
payload
:
true
},
{
type
:
types
.
SET_MAIN_LOADING
,
payload
:
false
},
],
[],
()
=>
{
expect
(
createFlash
).
toHaveBeenCalled
();
done
();
},
);
});
});
describe
(
'
request delete multiple tags
'
,
()
=>
{
describe
(
'
request delete multiple tags
'
,
()
=>
{
const
url
=
`project-path/registry/repository/foo/tags`
;
const
url
=
`project-path/registry/repository/foo/tags`
;
const
params
=
window
.
btoa
(
JSON
.
stringify
({
tags_path
:
`
${
url
}
?format=json`
}));
const
params
=
window
.
btoa
(
JSON
.
stringify
({
tags_path
:
`
${
url
}
?format=json`
}));
...
...
spec/frontend/registry/explorer/stores/mutations_spec.js
View file @
3c8b2098
...
@@ -121,4 +121,13 @@ describe('Mutations Registry Explorer Store', () => {
...
@@ -121,4 +121,13 @@ describe('Mutations Registry Explorer Store', () => {
expect
(
mockState
).
toEqual
(
expectedState
);
expect
(
mockState
).
toEqual
(
expectedState
);
});
});
});
});
describe
(
'
SET_IMAGE_DETAILS
'
,
()
=>
{
it
(
'
should set imageDetails
'
,
()
=>
{
const
expectedState
=
{
...
mockState
,
imageDetails
:
{
foo
:
'
bar
'
}
};
mutations
[
types
.
SET_IMAGE_DETAILS
](
mockState
,
{
foo
:
'
bar
'
});
expect
(
mockState
).
toEqual
(
expectedState
);
});
});
});
});
spec/frontend/registry/explorer/utils_spec.js
0 → 100644
View file @
3c8b2098
import
{
pathGenerator
}
from
'
~/registry/explorer/utils
'
;
describe
(
'
Utils
'
,
()
=>
{
describe
(
'
pathGenerator
'
,
()
=>
{
const
imageDetails
=
{
path
:
'
foo/bar/baz
'
,
name
:
'
baz
'
,
id
:
1
,
};
it
(
'
returns the fetch url when no ending is passed
'
,
()
=>
{
expect
(
pathGenerator
(
imageDetails
)).
toBe
(
'
/foo/bar/registry/repository/1/tags?format=json
'
);
});
it
(
'
returns the url with an ending when is passed
'
,
()
=>
{
expect
(
pathGenerator
(
imageDetails
,
'
foo
'
)).
toBe
(
'
/foo/bar/registry/repository/1/foo
'
);
});
});
});
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