diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-05 06:08:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-05 06:08:20 +0300 |
commit | b2814abdec5fc79e34936d651e7e7fc68858237f (patch) | |
tree | 4b57ecd36c51ce564e8105b3938af7192e02fccc /app/assets/javascripts | |
parent | 92a2c36b8cbbe4a7c0991312c28aa088a15201e6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts')
4 files changed, 44 insertions, 14 deletions
diff --git a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue index 418a22af406..ee2c0a771cf 100644 --- a/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue +++ b/app/assets/javascripts/ci/ci_variable_list/components/ci_variable_shared.vue @@ -9,6 +9,7 @@ import { ENVIRONMENT_QUERY_LIMIT, SORT_DIRECTIONS, UPDATE_MUTATION_ACTION, + mapMutationActionToToast, environmentFetchErrorText, genericMutationErrorText, variableFetchErrorText, @@ -268,11 +269,15 @@ export default { if (data.ciVariableMutation?.errors?.length) { const { errors } = data.ciVariableMutation; createAlert({ message: errors[0] }); - } else if (this.refetchAfterMutation) { - // The writing to cache for admin variable is not working - // because there is no ID in the cache at the top level. - // We therefore need to manually refetch. - this.$apollo.queries.ciVariables.refetch(); + } else { + this.$toast.show(mapMutationActionToToast[mutationAction](variable.key)); + + if (this.refetchAfterMutation) { + // The writing to cache for admin variable is not working + // because there is no ID in the cache at the top level. + // We therefore need to manually refetch. + this.$apollo.queries.ciVariables.refetch(); + } } } catch (e) { createAlert({ message: genericMutationErrorText }); diff --git a/app/assets/javascripts/ci/ci_variable_list/constants.js b/app/assets/javascripts/ci/ci_variable_list/constants.js index 03374162b79..c8f67bd3436 100644 --- a/app/assets/javascripts/ci/ci_variable_list/constants.js +++ b/app/assets/javascripts/ci/ci_variable_list/constants.js @@ -1,4 +1,4 @@ -import { __, s__ } from '~/locale'; +import { __, s__, sprintf } from '~/locale'; export const ADD_CI_VARIABLE_MODAL_ID = 'add-ci-variable'; export const ENVIRONMENT_QUERY_LIMIT = 30; @@ -98,6 +98,19 @@ export const ADD_MUTATION_ACTION = 'add'; export const UPDATE_MUTATION_ACTION = 'update'; export const DELETE_MUTATION_ACTION = 'delete'; +export const ADD_VARIABLE_TOAST = (key) => + sprintf(s__('CiVariable|Variable %{key} has been successfully added.'), { key }); +export const UPDATE_VARIABLE_TOAST = (key) => + sprintf(s__('CiVariable|Variable %{key} has been updated.'), { key }); +export const DELETE_VARIABLE_TOAST = (key) => + sprintf(s__('CiVariable|Variable %{key} has been deleted.'), { key }); + +export const mapMutationActionToToast = { + [ADD_MUTATION_ACTION]: ADD_VARIABLE_TOAST, + [UPDATE_MUTATION_ACTION]: UPDATE_VARIABLE_TOAST, + [DELETE_MUTATION_ACTION]: DELETE_VARIABLE_TOAST, +}; + export const EXPANDED_VARIABLES_NOTE = __( '%{codeStart}$%{codeEnd} will be treated as the start of a reference to another variable.', ); diff --git a/app/assets/javascripts/projects/commits/index.js b/app/assets/javascripts/projects/commits/index.js index f56884f605f..3179fcb14fd 100644 --- a/app/assets/javascripts/projects/commits/index.js +++ b/app/assets/javascripts/projects/commits/index.js @@ -35,6 +35,10 @@ export const initCommitsRefSwitcher = () => { const { projectId, ref, commitsPath, refType } = el.dataset; const commitsPathPrefix = commitsPath.match(COMMITS_PATH_REGEX)?.[0]; + const generateRefDestinationUrl = (selectedRef, selectedRefType) => { + const commitsPathSuffix = selectedRefType ? `?ref_type=${selectedRefType}` : ''; + return `${commitsPathPrefix}/${encodeURIComponent(selectedRef)}${commitsPathSuffix}`; + }; const useSymbolicRefNames = Boolean(refType); return new Vue({ el, @@ -48,15 +52,11 @@ export const initCommitsRefSwitcher = () => { }, on: { input(selected) { - if (useSymbolicRefNames) { - const matches = selected.match(/refs\/(heads|tags)\/(.+)/); - if (matches) { - visitUrl(`${commitsPathPrefix}/${matches[2]}?ref_type=${matches[1]}`); - } else { - visitUrl(`${commitsPathPrefix}/${selected}`); - } + const matches = selected.match(/refs\/(heads|tags)\/(.+)/); + if (useSymbolicRefNames && matches) { + visitUrl(generateRefDestinationUrl(matches[2], matches[1])); } else { - visitUrl(`${commitsPathPrefix}/${selected}`); + visitUrl(generateRefDestinationUrl(selected)); } }, }, diff --git a/app/assets/javascripts/super_sidebar/components/user_bar.vue b/app/assets/javascripts/super_sidebar/components/user_bar.vue index 62161f2846a..750ec0aa0c6 100644 --- a/app/assets/javascripts/super_sidebar/components/user_bar.vue +++ b/app/assets/javascripts/super_sidebar/components/user_bar.vue @@ -70,6 +70,9 @@ export default { v-gl-tooltip:super-sidebar.hover.bottom="$options.i18n.homepage" :href="rootPath" :title="$options.i18n.homepage" + data-track-action="click_link" + data-track-label="gitlab_logo_link" + data-track-property="nav_core_menu" > <img v-if="sidebarData.logo_url" @@ -120,6 +123,9 @@ export default { :count="sidebarData.assigned_open_issues_count" :href="sidebarData.issues_dashboard_path" :label="$options.i18n.issues" + data-track-action="click_link" + data-track-label="issues_link" + data-track-property="nav_core_menu" /> <merge-request-menu class="gl-flex-basis-third gl-display-block!" @@ -131,6 +137,9 @@ export default { icon="merge-request-open" :count="sidebarData.total_merge_requests_count" :label="$options.i18n.mergeRequests" + data-track-action="click_dropdown" + data-track-label="merge_requests_menu" + data-track-property="nav_core_menu" /> </merge-request-menu> <counter @@ -141,6 +150,9 @@ export default { href="/dashboard/todos" :label="$options.i18n.todoList" data-qa-selector="todos_shortcut_button" + data-track-action="click_link" + data-track-label="todos_link" + data-track-property="nav_core_menu" /> </div> </div> |