From ea090291bba6bb665b3631cc5a2659e6673a6959 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 31 May 2017 00:50:53 -0500 Subject: Rename "Slash commands" to "Quick actions" Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/27070 Deprecate "chat commands" in favor of "slash commands" We looked for things like: - `slash commmand` - `slash_command` - `slash-command` - `SlashCommand` --- app/assets/javascripts/notes.js | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'app/assets/javascripts/notes.js') diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 978be3b20c1..e2d96695e6d 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; @@ -280,7 +280,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) { @@ -1198,27 +1198,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); }); @@ -1276,7 +1276,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 = $( @@ -1325,7 +1325,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; @@ -1344,9 +1344,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 @@ -1363,10 +1363,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, })); } @@ -1388,7 +1388,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'); } @@ -1422,7 +1422,7 @@ const normalizeNewlines = function(str) { } if (note.commands_changes) { - this.handleSlashCommands(note); + this.handleQuickActions(note); } $form.trigger('ajax:success', [note]); @@ -1430,7 +1430,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(); } -- cgit v1.2.3