text: // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  // See LICENSE.txt for license information.
  
  import {connect} from 'react-redux';
  import {bindActionCreators} from 'redux';
  import {getOutgoingHook, updateOutgoingHook} from 'mattermost-redux/actions/integrations';
  import {getConfig} from 'mattermost-redux/selectors/entities/general';
  
  import EditOutgoingWebhook from './edit_outgoing_webhook.jsx';
  
  function mapStateToProps(state, ownProps) {
      const config = getConfig(state);
      const hookId = (new URLSearchParams(ownProps.location.search)).get('id');
      const enableOutgoingWebhooks = config.EnableOutgoingWebhooks === 'true';
      const enablePostUsernameOverride = config.EnablePostUsernameOverride === 'true';
      const enablePostIconOverride = config.EnablePostIconOverride === 'true';
  
      return {
          hookId,
          hook: state.entities.integrations.outgoingHooks[hookId],
          updateOutgoingHookRequest: state.requests.integrations.createOutgoingHook,
          enableOutgoingWebhooks,
          enablePostUsernameOverride,
          enablePostIconOverride,
      };
  }
  
  function mapDispatchToProps(dispatch) {
      return {
          actions: bindActionCreators({
              updateOutgoingHook,
              getOutgoingHook,
          }, dispatch),
      };
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(EditOutgoingWebhook);
  