From 35320efe1afad87419992275ba555ddcbfcdf46b Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Fri, 18 Mar 2016 13:16:51 -0400
Subject: Revert "PLT-2183 Slash command auto-complete"

---
 .../user_settings/manage_command_hooks.jsx         | 313 ++++++++-------------
 1 file changed, 120 insertions(+), 193 deletions(-)

(limited to 'webapp/components/user_settings/manage_command_hooks.jsx')

diff --git a/webapp/components/user_settings/manage_command_hooks.jsx b/webapp/components/user_settings/manage_command_hooks.jsx
index 9703664cc..ce353ad64 100644
--- a/webapp/components/user_settings/manage_command_hooks.jsx
+++ b/webapp/components/user_settings/manage_command_hooks.jsx
@@ -4,13 +4,9 @@
 import LoadingScreen from '../loading_screen.jsx';
 
 import * as Client from 'utils/client.jsx';
-import * as Utils from 'utils/utils.jsx';
-import Constants from 'utils/constants.jsx';
 
 import {intlShape, injectIntl, defineMessages, FormattedMessage, FormattedHTMLMessage} from 'react-intl';
 
-const PreReleaseFeatures = Constants.PRE_RELEASE_FEATURES;
-
 const holders = defineMessages({
     requestTypePost: {
         id: 'user.settings.cmds.request_type_post',
@@ -63,7 +59,6 @@ export default class ManageCommandCmds extends React.Component {
         this.getCmds = this.getCmds.bind(this);
         this.addNewCmd = this.addNewCmd.bind(this);
         this.emptyCmd = this.emptyCmd.bind(this);
-        this.updateExternalManagement = this.updateExternalManagement.bind(this);
         this.updateTrigger = this.updateTrigger.bind(this);
         this.updateURL = this.updateURL.bind(this);
         this.updateMethod = this.updateMethod.bind(this);
@@ -104,7 +99,7 @@ export default class ManageCommandCmds extends React.Component {
     addNewCmd(e) {
         e.preventDefault();
 
-        if (this.state.cmd.url === '' || (this.state.cmd.trigger === '' && !this.state.external_management)) {
+        if (this.state.cmd.trigger === '' || this.state.cmd.url === '') {
             return;
         }
 
@@ -194,12 +189,6 @@ export default class ManageCommandCmds extends React.Component {
         );
     }
 
-    updateExternalManagement(e) {
-        var cmd = this.state.cmd;
-        cmd.external_management = e.target.checked;
-        this.setState(cmd);
-    }
-
     updateTrigger(e) {
         var cmd = this.state.cmd;
         cmd.trigger = e.target.value;
@@ -281,26 +270,11 @@ export default class ManageCommandCmds extends React.Component {
                 );
             }
 
-            let slashCommandAutocompleteDiv;
-            if (Utils.isFeatureEnabled(PreReleaseFeatures.SLASHCMD_AUTOCMP)) {
-                slashCommandAutocompleteDiv = (
-                    <div className='padding-top x2'>
-                        <strong>
-                            <FormattedMessage
-                                id='user.settings.cmds.external_management'
-                                defaultMessage='External management: '
-                            />
-                        </strong><span className='word-break--all'>{cmd.external_management ? this.props.intl.formatMessage(holders.autocompleteYes) : this.props.intl.formatMessage(holders.autocompleteNo)}</span>
-                    </div>
-                );
-            }
-
             cmds.push(
                 <div
                     key={cmd.id}
                     className='webhook__item webcmd__item'
                 >
-                    {slashCommandAutocompleteDiv}
                     {triggerDiv}
                     <div className='padding-top x2 webcmd__url'>
                         <strong>
@@ -442,188 +416,46 @@ export default class ManageCommandCmds extends React.Component {
             </div>
         );
 
-        const disableButton = this.state.cmd.url === '' || (this.state.cmd.trigger === '' && !this.state.external_management);
-
-        let triggerInput;
-        if (!this.state.cmd.external_management) {
-            triggerInput = (
-                <div className='padding-top x2'>
-                    <label className='control-label'>
-                        <FormattedMessage
-                            id='user.settings.cmds.trigger'
-                            defaultMessage='Command Trigger Word: '
-                        />
-                    </label>
-                    <div className='padding-top'>
-                        <input
-                            ref='trigger'
-                            className='form-control'
-                            value={this.state.cmd.trigger}
-                            onChange={this.updateTrigger}
-                            placeholder={this.props.intl.formatMessage(holders.addTriggerPlaceholder)}
-                        />
-                    </div>
-                    <div className='padding-top'>
-                        <FormattedMessage
-                            id='user.settings.cmds.trigger_desc'
-                            defaultMessage='Examples: /patient, /client, /employee Reserved: /echo, /join, /logout, /me, /shrug'
-                        />
-                    </div>
-                </div>
-            );
-        }
-
-        let slashCommandAutocompleteCheckbox;
-        if (Utils.isFeatureEnabled(PreReleaseFeatures.SLASHCMD_AUTOCMP)) {
-            slashCommandAutocompleteCheckbox = (
-                <div className='padding-top x2'>
-                    <label className='control-label'>
-                        <FormattedMessage
-                            id='user.settings.cmds.external_management'
-                            defaultMessage='External management: '
-                        />
-                    </label>
-                    <div className='padding-top'>
-                        <div className='checkbox'>
-                            <label>
-                                <input
-                                    type='checkbox'
-                                    checked={this.state.cmd.external_management}
-                                    onChange={this.updateExternalManagement}
-                                />
-                                <FormattedMessage
-                                    id='user.settings.cmds.slashCmd_autocmp'
-                                    defaultMessage='Enable external application to offer autocomplete'
-                                />
-                            </label>
-                        </div>
-                    </div>
-                </div>
-
-            );
-        }
-
-        let autoCompleteSettings;
-        if (!this.state.cmd.external_management) {
-            autoCompleteSettings = (
-                <div>
-                    <div className='padding-top x2'>
-                        <label className='control-label'>
-                            <FormattedMessage
-                                id='user.settings.cmds.auto_complete'
-                                defaultMessage='Autocomplete: '
-                            />
-                        </label>
-                        <div className='padding-top'>
-                            <div className='checkbox'>
-                                <label>
-                                    <input
-                                        type='checkbox'
-                                        checked={this.state.cmd.auto_complete}
-                                        onChange={this.updateAutoComplete}
-                                    />
-                                    <FormattedMessage
-                                        id='user.settings.cmds.auto_complete_help'
-                                        defaultMessage=' Show this command in the autocomplete list.'
-                                    />
-                                </label>
-                            </div>
-                        </div>
-                    </div>
-
-                    <div className='padding-top x2'>
-                        <label className='control-label'>
-                            <FormattedMessage
-                                id='user.settings.cmds.auto_complete_hint'
-                                defaultMessage='Autocomplete Hint: '
-                            />
-                        </label>
-                        <div className='padding-top'>
-                            <input
-                                ref='autoCompleteHint'
-                                className='form-control'
-                                value={this.state.cmd.auto_complete_hint}
-                                onChange={this.updateAutoCompleteHint}
-                                placeholder={this.props.intl.formatMessage(holders.addAutoCompleteHintPlaceholder)}
-                            />
-                        </div>
-                        <div className='padding-top'>
-                            <FormattedMessage
-                                id='user.settings.cmds.auto_complete_hint_desc'
-                                defaultMessage='Optional hint in the autocomplete list about parameters needed for command.'
-                            />
-                        </div>
-                    </div>
+        const disableButton = this.state.cmd.trigger === '' || this.state.cmd.url === '';
 
-                    <div className='padding-top x2'>
-                        <label className='control-label'>
-                            <FormattedMessage
-                                id='user.settings.cmds.auto_complete_desc'
-                                defaultMessage='Autocomplete Description: '
-                            />
-                        </label>
-                        <div className='padding-top'>
-                            <input
-                                ref='autoCompleteDesc'
-                                className='form-control'
-                                value={this.state.cmd.auto_complete_desc}
-                                onChange={this.updateAutoCompleteDesc}
-                                placeholder={this.props.intl.formatMessage(holders.addAutoCompleteDescPlaceholder)}
-                            />
-                        </div>
-                        <div className='padding-top'>
-                            <FormattedMessage
-                                id='user.settings.cmds.auto_complete_desc_desc'
-                                defaultMessage='Optional short description of slash command for the autocomplete list.'
-                            />
-                        </div>
-                    </div>
+        return (
+            <div key='addCommandCmd'>
+                <FormattedHTMLMessage
+                    id='user.settings.cmds.add_desc'
+                    defaultMessage='Create slash commands to send events to external integrations and receive a response. For example typing `/patient Joe Smith` could bring back search results from your internal health records management system for the name “Joe Smith”.  Please see <a href="http://docs.mattermost.com/developer/slash-commands.html">Slash commands documentation</a>  for detailed instructions. View all slash commands configured on this team below.'
+                />
+                <div><label className='control-label padding-top x2'>
+                    <FormattedMessage
+                        id='user.settings.cmds.add_new'
+                        defaultMessage='Add a new command'
+                    />
+                </label></div>
+                <div className='padding-top divider-light'></div>
+                <div className='padding-top'>
 
                     <div className='padding-top x2'>
                         <label className='control-label'>
                             <FormattedMessage
-                                id='user.settings.cmds.display_name'
-                                defaultMessage='Descriptive Label: '
+                                id='user.settings.cmds.trigger'
+                                defaultMessage='Command Trigger Word: '
                             />
                         </label>
                         <div className='padding-top'>
                             <input
-                                ref='displayName'
+                                ref='trigger'
                                 className='form-control'
-                                value={this.state.cmd.display_name}
-                                onChange={this.updateDisplayName}
-                                placeholder={this.props.intl.formatMessage(holders.addDisplayNamePlaceholder)}
+                                value={this.state.cmd.trigger}
+                                onChange={this.updateTrigger}
+                                placeholder={this.props.intl.formatMessage(holders.addTriggerPlaceholder)}
                             />
                         </div>
                         <div className='padding-top'>
                             <FormattedMessage
-                                id='user.settings.cmds.cmd_display_name'
-                                defaultMessage='Brief description of slash command to show in listings.'
+                                id='user.settings.cmds.trigger_desc'
+                                defaultMessage='Examples: /patient, /client, /employee Reserved: /echo, /join, /logout, /me, /shrug'
                             />
                         </div>
-                        {addError}
                     </div>
-                </div>
-            );
-        }
-
-        return (
-            <div key='addCommandCmd'>
-                <FormattedHTMLMessage
-                    id='user.settings.cmds.add_desc'
-                    defaultMessage='Create slash commands to send events to external integrations and receive a response. For example typing `/patient Joe Smith` could bring back search results from your internal health records management system for the name “Joe Smith”.  Please see <a href="http://docs.mattermost.com/developer/slash-commands.html">Slash commands documentation</a>  for detailed instructions. View all slash commands configured on this team below.'
-                />
-                <div><label className='control-label padding-top x2'>
-                    <FormattedMessage
-                        id='user.settings.cmds.add_new'
-                        defaultMessage='Add a new command'
-                    />
-                </label></div>
-                <div className='padding-top divider-light'></div>
-                <div className='padding-top'>
-
-                    {slashCommandAutocompleteCheckbox}
-                    {triggerInput}
 
                     <div className='padding-top x2'>
                         <label className='control-label'>
@@ -728,7 +560,102 @@ export default class ManageCommandCmds extends React.Component {
                         </div>
                     </div>
 
-                    {autoCompleteSettings}
+                    <div className='padding-top x2'>
+                        <label className='control-label'>
+                            <FormattedMessage
+                                id='user.settings.cmds.auto_complete'
+                                defaultMessage='Autocomplete: '
+                            />
+                        </label>
+                        <div className='padding-top'>
+                            <div className='checkbox'>
+                                <label>
+                                    <input
+                                        type='checkbox'
+                                        checked={this.state.cmd.auto_complete}
+                                        onChange={this.updateAutoComplete}
+                                    />
+                                    <FormattedMessage
+                                        id='user.settings.cmds.auto_complete_help'
+                                        defaultMessage=' Show this command in the autocomplete list.'
+                                    />
+                                </label>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div className='padding-top x2'>
+                        <label className='control-label'>
+                            <FormattedMessage
+                                id='user.settings.cmds.auto_complete_hint'
+                                defaultMessage='Autocomplete Hint: '
+                            />
+                        </label>
+                        <div className='padding-top'>
+                            <input
+                                ref='autoCompleteHint'
+                                className='form-control'
+                                value={this.state.cmd.auto_complete_hint}
+                                onChange={this.updateAutoCompleteHint}
+                                placeholder={this.props.intl.formatMessage(holders.addAutoCompleteHintPlaceholder)}
+                            />
+                        </div>
+                        <div className='padding-top'>
+                            <FormattedMessage
+                                id='user.settings.cmds.auto_complete_hint_desc'
+                                defaultMessage='Optional hint in the autocomplete list about parameters needed for command.'
+                            />
+                        </div>
+                    </div>
+
+                    <div className='padding-top x2'>
+                        <label className='control-label'>
+                            <FormattedMessage
+                                id='user.settings.cmds.auto_complete_desc'
+                                defaultMessage='Autocomplete Description: '
+                            />
+                        </label>
+                        <div className='padding-top'>
+                            <input
+                                ref='autoCompleteDesc'
+                                className='form-control'
+                                value={this.state.cmd.auto_complete_desc}
+                                onChange={this.updateAutoCompleteDesc}
+                                placeholder={this.props.intl.formatMessage(holders.addAutoCompleteDescPlaceholder)}
+                            />
+                        </div>
+                        <div className='padding-top'>
+                            <FormattedMessage
+                                id='user.settings.cmds.auto_complete_desc_desc'
+                                defaultMessage='Optional short description of slash command for the autocomplete list.'
+                            />
+                        </div>
+                    </div>
+
+                    <div className='padding-top x2'>
+                        <label className='control-label'>
+                            <FormattedMessage
+                                id='user.settings.cmds.display_name'
+                                defaultMessage='Descriptive Label: '
+                            />
+                        </label>
+                        <div className='padding-top'>
+                            <input
+                                ref='displayName'
+                                className='form-control'
+                                value={this.state.cmd.display_name}
+                                onChange={this.updateDisplayName}
+                                placeholder={this.props.intl.formatMessage(holders.addDisplayNamePlaceholder)}
+                            />
+                        </div>
+                        <div className='padding-top'>
+                            <FormattedMessage
+                                id='user.settings.cmds.cmd_display_name'
+                                defaultMessage='Brief description of slash command to show in listings.'
+                            />
+                        </div>
+                        {addError}
+                    </div>
 
                     <div className='padding-top x2 padding-bottom'>
                         <a
-- 
cgit v1.2.3-1-g7c22

