diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-16 19:32:53 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-16 19:32:53 +0300 |
commit | 352a9ed56213b6f83a679e72f9554638a0aed1ee (patch) | |
tree | 04ac45d05a67dfd71ff325ed45c8ffacaf9ec23b /app/assets/javascripts/notes.js | |
parent | c6701d45474acab6a2d687d2e2ffdaac5c0d5491 (diff) | |
parent | ea090291bba6bb665b3631cc5a2659e6673a6959 (diff) |
Merge branch '27070-rename-slash-commands-to-quick-actions' into 'master'
Rename "Slash commands" to "Quick actions"
Closes #27070
See merge request !11811
Diffstat (limited to 'app/assets/javascripts/notes.js')
-rw-r--r-- | app/assets/javascripts/notes.js | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index d56cf959486..f12a35f0485 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -32,7 +32,7 @@ const normalizeNewlines = function(str) { (function() { this.Notes = (function() { const MAX_VISIBLE_COMMIT_LIST_COUNT = 3; - const REGEX_SLASH_COMMANDS = /^\/\w+.*$/gm; + const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm; Notes.interval = null; @@ -284,7 +284,7 @@ const normalizeNewlines = function(str) { return this.initRefresh(); }; - Notes.prototype.handleSlashCommands = function(noteEntity) { + Notes.prototype.handleQuickActions = function(noteEntity) { var votesBlock; if (noteEntity.commands_changes) { if ('merge' in noteEntity.commands_changes) { @@ -1220,27 +1220,27 @@ const normalizeNewlines = function(str) { }; /** - * Identify if comment has any slash commands + * Identify if comment has any quick actions */ - Notes.prototype.hasSlashCommands = function(formContent) { - return REGEX_SLASH_COMMANDS.test(formContent); + Notes.prototype.hasQuickActions = function(formContent) { + return REGEX_QUICK_ACTIONS.test(formContent); }; /** - * Remove slash commands and leave comment with pure message + * Remove quick actions and leave comment with pure message */ - Notes.prototype.stripSlashCommands = function(formContent) { - return formContent.replace(REGEX_SLASH_COMMANDS, '').trim(); + Notes.prototype.stripQuickActions = function(formContent) { + return formContent.replace(REGEX_QUICK_ACTIONS, '').trim(); }; /** - * Gets appropriate description from slash commands found in provided `formContent` + * Gets appropriate description from quick actions found in provided `formContent` */ - Notes.prototype.getSlashCommandDescription = function (formContent, availableSlashCommands = []) { + Notes.prototype.getQuickActionDescription = function (formContent, availableQuickActions = []) { let tempFormContent; - // Identify executed slash commands from `formContent` - const executedCommands = availableSlashCommands.filter((command, index) => { + // Identify executed quick actions from `formContent` + const executedCommands = availableQuickActions.filter((command, index) => { const commandRegex = new RegExp(`/${command.name}`); return commandRegex.test(formContent); }); @@ -1298,7 +1298,7 @@ const normalizeNewlines = function(str) { }; /** - * Create Placeholder System Note DOM element populated with slash command description + * Create Placeholder System Note DOM element populated with quick action description */ Notes.prototype.createPlaceholderSystemNote = function ({ formContent, uniqueId }) { const $tempNote = $( @@ -1347,7 +1347,7 @@ const normalizeNewlines = function(str) { const { formData, formContent, formAction } = this.getFormData($form); let noteUniqueId; let systemNoteUniqueId; - let hasSlashCommands = false; + let hasQuickActions = false; let $notesContainer; let tempFormContent; @@ -1366,9 +1366,9 @@ const normalizeNewlines = function(str) { } tempFormContent = formContent; - if (this.hasSlashCommands(formContent)) { - tempFormContent = this.stripSlashCommands(formContent); - hasSlashCommands = true; + if (this.hasQuickActions(formContent)) { + tempFormContent = this.stripQuickActions(formContent); + hasQuickActions = true; } // Show placeholder note @@ -1385,10 +1385,10 @@ const normalizeNewlines = function(str) { } // Show placeholder system note - if (hasSlashCommands) { + if (hasQuickActions) { systemNoteUniqueId = _.uniqueId('tempSystemNote_'); $notesContainer.append(this.createPlaceholderSystemNote({ - formContent: this.getSlashCommandDescription(formContent, AjaxCache.get(gl.GfmAutoComplete.dataSources.commands)), + formContent: this.getQuickActionDescription(formContent, AjaxCache.get(gl.GfmAutoComplete.dataSources.commands)), uniqueId: systemNoteUniqueId, })); } @@ -1410,7 +1410,7 @@ const normalizeNewlines = function(str) { $notesContainer.find(`#${noteUniqueId}`).remove(); // Reset cached commands list when command is applied - if (hasSlashCommands) { + if (hasQuickActions) { $form.find('textarea.js-note-text').trigger('clear-commands-cache.atwho'); } @@ -1444,7 +1444,7 @@ const normalizeNewlines = function(str) { } if (note.commands_changes) { - this.handleSlashCommands(note); + this.handleQuickActions(note); } $form.trigger('ajax:success', [note]); @@ -1452,7 +1452,7 @@ const normalizeNewlines = function(str) { // Submission failed, remove placeholder note and show Flash error message $notesContainer.find(`#${noteUniqueId}`).remove(); - if (hasSlashCommands) { + if (hasQuickActions) { $notesContainer.find(`#${systemNoteUniqueId}`).remove(); } |