function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import forEach from 'lodash/forEach';
import getTablePostData from "../../../utils/getTablePostData";
export default (function (formatMessage, PiplineStore, projectId, searchDS, envIdDS, triggerTypeDs) {
  return {
    autoQuery: true,
    selection: false,
    transport: {
      read: function read(_ref) {
        var data = _ref.data;
        var searchData = data && data.search;

        var postData = _objectSpread({}, data);

        if (searchData && searchData.length) {
          forEach(searchData, function (item) {
            postData[item] = true;
          });
        }

        return {
          url: "/devops/v1/projects/".concat(projectId, "/pipeline/page_by_options"),
          method: 'post',
          data: postData
        };
      }
    },
    fields: [{
      name: 'isEnabled',
      type: 'string',
      label: formatMessage({
        id: 'pipeline.head'
      })
    }, {
      name: 'action'
    }, {
      name: 'triggerType',
      type: 'string',
      label: formatMessage({
        id: 'pipeline.trigger'
      })
    }, {
      name: 'name',
      type: 'string',
      label: formatMessage({
        id: 'name'
      })
    }, {
      name: 'createUserRealName',
      type: 'string',
      label: formatMessage({
        id: 'creator'
      })
    }, {
      name: 'lastUpdateDate',
      type: 'string',
      label: formatMessage({
        id: 'updateDate'
      })
    }, {
      name: 'envName',
      type: 'string',
      label: formatMessage({
        id: 'pipeline.deploy.env'
      })
    }],
    queryFields: [{
      name: 'search',
      type: 'string',
      textField: 'text',
      valueField: 'value',
      label: formatMessage({
        id: 'pipeline.search'
      }),
      options: searchDS,
      multiple: true
    }, {
      name: 'envId',
      type: 'string',
      textField: 'name',
      valueField: 'id',
      label: formatMessage({
        id: 'pipeline.deploy.env'
      }),
      options: envIdDS
    }, {
      name: 'triggerType',
      type: 'string',
      textField: 'text',
      valueField: 'value',
      label: formatMessage({
        id: 'pipeline.trigger'
      }),
      options: triggerTypeDs
    }]
  };
});