webpackJsonp([21],{2148:function(e,t,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var a=t.location.query.id;return(0,i.default)({},t,{commandId:a,commands:(0,l.getCommands)(e)})}function o(e){return{actions:(0,m.bindActionCreators)({getCustomTeamCommands:u.getCustomTeamCommands,editCommand:u.editCommand},e)}}Object.defineProperty(t,"__esModule",{value:!0});var d=a(19),i=n(d),s=a(29),m=a(20),u=a(743),l=a(2099),f=a(2391),c=n(f);t.default=(0,s.connect)(r,o)(c.default)},2391:function(e,t,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=a(313),o=n(r),d=a(76),i=n(d),s=a(77),m=n(s),u=a(6),l=n(u),f=a(4),c=n(f),C=a(5),p=n(C),g=a(7),h=n(g),M=a(8),v=n(M),w=a(2),E=n(w),_=a(1),b=n(_),x=a(17),y=a(41),k=a(237),q=n(k),S=a(312),T=n(S),R=a(2108),j=n(R),D={id:"integrations.edit",defaultMessage:"Edit"},F={id:"edit_command.save",defaultMessage:"Update"},I=function(e){function t(e){var a=this;(0,c.default)(this,t);var n=(0,h.default)(this,(t.__proto__||(0,l.default)(t)).call(this,e));return n.editCommand=function(){var e=(0,m.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n.newCommand=t,n.state.originalCommand.id&&(t.id=n.state.originalCommand.id),n.state.originalCommand.url===n.newCommand.url&&n.state.originalCommand.trigger===n.newCommand.trigger&&n.state.originalCommand.method===n.newCommand.method){e.next=6;break}n.handleConfirmModal(),e.next=8;break;case 6:return e.next=8,n.submitCommand();case 8:case"end":return e.stop()}},e,a)}));return function(t){return e.apply(this,arguments)}}(),n.handleConfirmModal=function(){n.setState({showConfirmModal:!0})},n.confirmModalDismissed=function(){n.setState({showConfirmModal:!1})},n.submitCommand=(0,m.default)(i.default.mark(function e(){var t,r,o;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.setState({serverError:""}),e.next=3,n.props.actions.editCommand(n.newCommand);case 3:if(t=e.sent,r=t.data,o=t.error,!r){e.next=9;break}return y.browserHistory.push("/"+n.props.team.name+"/integrations/commands"),e.abrupt("return");case 9:n.setState({showConfirmModal:!1}),o&&n.setState({serverError:o.message});case 11:case"end":return e.stop()}},e,a)})),n.renderExtra=function(){var e=b.default.createElement(x.FormattedMessage,{id:"update_command.update",defaultMessage:"Update"}),t=b.default.createElement(x.FormattedMessage,{id:"update_command.confirm",defaultMessage:"Edit Slash Command"}),a=b.default.createElement(x.FormattedMessage,{id:"update_command.question",defaultMessage:"Your changes may break the existing slash command. Are you sure you would like to update it?"});return b.default.createElement(T.default,{title:t,message:a,confirmButtonText:e,show:n.state.showConfirmModal,onConfirm:n.submitCommand,onCancel:n.confirmModalDismissed})},n.state={originalCommand:null,showConfirmModal:!1,serverError:""},n}return(0,v.default)(t,e),(0,p.default)(t,[{key:"componentDidMount",value:function(){var e=this;"true"===window.mm_config.EnableCommands&&this.props.actions.getCustomTeamCommands(this.props.team.id).then(function(){e.setState({originalCommand:(0,o.default)(e.props.commands).filter(function(t){return t.id===e.props.commandId})[0]})})}},{key:"render",value:function(){return this.state.originalCommand?b.default.createElement(j.default,{team:this.props.team,header:D,footer:F,renderExtra:this.renderExtra(),action:this.editCommand,serverError:this.state.serverError,initialCommand:this.state.originalCommand}):b.default.createElement(q.default,null)}}]),t}(b.default.PureComponent);I.propTypes={team:E.default.object.isRequired,commandId:E.default.string.isRequired,commands:E.default.object,actions:E.default.shape({getCustomTeamCommands:E.default.func.isRequired,editCommand:E.default.func.isRequired}).isRequired},t.default=I}});
//# sourceMappingURL=21.6ef56bbd58317f0de7b3.js.map