diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-04 21:14:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-04 21:14:20 +0300 |
commit | a1a863274074b217f018553efe4854a009b6ed7b (patch) | |
tree | 88c18509d0b6104d845a3839101f80119f02c38e /app/assets/javascripts/project_select_combo_button.js | |
parent | d19a19ce85fe06bef4cea7c0f4415979086b4305 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/project_select_combo_button.js')
-rw-r--r-- | app/assets/javascripts/project_select_combo_button.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/app/assets/javascripts/project_select_combo_button.js b/app/assets/javascripts/project_select_combo_button.js index fd45d643ecc..09dbf2cee04 100644 --- a/app/assets/javascripts/project_select_combo_button.js +++ b/app/assets/javascripts/project_select_combo_button.js @@ -1,11 +1,12 @@ import $ from 'jquery'; +import { sprintf, __ } from '~/locale'; import AccessorUtilities from './lib/utils/accessor'; import { loadCSSFile } from './lib/utils/css_utils'; export default class ProjectSelectComboButton { constructor(select) { this.projectSelectInput = $(select); - this.newItemBtn = $('.new-project-item-link'); + this.newItemBtn = $('.js-new-project-item-link'); this.resourceType = this.newItemBtn.data('type'); this.resourceLabel = this.newItemBtn.data('label'); this.formattedText = this.deriveTextVariants(); @@ -80,9 +81,18 @@ export default class ProjectSelectComboButton { setNewItemBtnAttributes(project) { if (project) { this.newItemBtn.attr('href', project.url); - this.newItemBtn.text(`${this.formattedText.defaultTextPrefix} in ${project.name}`); + this.newItemBtn.text( + sprintf(__('New %{type} in %{project}'), { + type: this.resourceLabel, + project: project.name, + }), + ); } else { - this.newItemBtn.text(`Select project to create ${this.formattedText.presetTextSuffix}`); + this.newItemBtn.text( + sprintf(__('Select project to create %{type}'), { + type: this.formattedText.presetTextSuffix, + }), + ); } } @@ -99,15 +109,12 @@ export default class ProjectSelectComboButton { } deriveTextVariants() { - const defaultTextPrefix = this.resourceLabel; - // the trailing slice call depluralizes each of these strings (e.g. new-issues -> new-issue) const localStorageItemType = `new-${this.resourceType.split('_').join('-').slice(0, -1)}`; const presetTextSuffix = this.resourceType.split('_').join(' ').slice(0, -1); return { localStorageItemType, // new-issue / new-merge-request - defaultTextPrefix, // New issue / New merge request presetTextSuffix, // issue / merge request }; } |