diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-04 15:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-04 15:09:14 +0300 |
commit | 8a9cbfa9c56792d8e338c289eb803fb0ebde2083 (patch) | |
tree | fa5ff83fa919ae9a1c37cd8146b78a4a04c9ab7c /app/assets/javascripts/registry | |
parent | fc7ce8aea5b2eca1aaf510667c79b3e7e72f2f3f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/registry')
6 files changed, 33 insertions, 0 deletions
diff --git a/app/assets/javascripts/registry/explorer/constants/details.js b/app/assets/javascripts/registry/explorer/constants/details.js index 1dc5882d415..306e6903a4f 100644 --- a/app/assets/javascripts/registry/explorer/constants/details.js +++ b/app/assets/javascripts/registry/explorer/constants/details.js @@ -15,6 +15,10 @@ export const DELETE_TAGS_SUCCESS_MESSAGE = s__( '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 DIGEST_LABEL = s__('ContainerRegistry|Digest: %{imageId}'); export const CREATED_AT_LABEL = s__('ContainerRegistry|Published %{timeInfo}'); diff --git a/app/assets/javascripts/registry/explorer/stores/actions.js b/app/assets/javascripts/registry/explorer/stores/actions.js index 9125f573aa4..b9b0e1704d8 100644 --- a/app/assets/javascripts/registry/explorer/stores/actions.js +++ b/app/assets/javascripts/registry/explorer/stores/actions.js @@ -1,11 +1,13 @@ import axios from '~/lib/utils/axios_utils'; import { deprecatedCreateFlash as createFlash } from '~/flash'; +import Api from '~/api'; import * as types from './mutation_types'; import { FETCH_IMAGES_LIST_ERROR_MESSAGE, DEFAULT_PAGE, DEFAULT_PAGE_SIZE, FETCH_TAGS_LIST_ERROR_MESSAGE, + FETCH_IMAGE_DETAILS_ERROR_MESSAGE, } from '../constants/index'; import { decodeAndParse } from '../utils'; @@ -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 }) => { commit(types.SET_MAIN_LOADING, true); return axios diff --git a/app/assets/javascripts/registry/explorer/stores/mutation_types.js b/app/assets/javascripts/registry/explorer/stores/mutation_types.js index f32cdf90783..5dd0cec52eb 100644 --- a/app/assets/javascripts/registry/explorer/stores/mutation_types.js +++ b/app/assets/javascripts/registry/explorer/stores/mutation_types.js @@ -7,3 +7,4 @@ export const SET_MAIN_LOADING = 'SET_MAIN_LOADING'; export const SET_TAGS_PAGINATION = 'SET_TAGS_PAGINATION'; 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_IMAGE_DETAILS = 'SET_IMAGE_DETAILS'; diff --git a/app/assets/javascripts/registry/explorer/stores/mutations.js b/app/assets/javascripts/registry/explorer/stores/mutations.js index 706f6489287..5bdb431ad2e 100644 --- a/app/assets/javascripts/registry/explorer/stores/mutations.js +++ b/app/assets/javascripts/registry/explorer/stores/mutations.js @@ -47,4 +47,8 @@ export default { const normalizedHeaders = normalizeHeaders(headers); state.tagsPagination = parseIntPagination(normalizedHeaders); }, + + [types.SET_IMAGE_DETAILS](state, details) { + state.imageDetails = details; + }, }; diff --git a/app/assets/javascripts/registry/explorer/stores/state.js b/app/assets/javascripts/registry/explorer/stores/state.js index 694006aac81..66ee56eb47b 100644 --- a/app/assets/javascripts/registry/explorer/stores/state.js +++ b/app/assets/javascripts/registry/explorer/stores/state.js @@ -3,6 +3,7 @@ export default () => ({ showGarbageCollectionTip: false, config: {}, images: [], + imageDetails: {}, tags: [], pagination: {}, tagsPagination: {}, diff --git a/app/assets/javascripts/registry/explorer/utils.js b/app/assets/javascripts/registry/explorer/utils.js index 44262a6cbb6..7c6348151c1 100644 --- a/app/assets/javascripts/registry/explorer/utils.js +++ b/app/assets/javascripts/registry/explorer/utils.js @@ -1 +1,9 @@ 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}`; +}; |