(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["index"],{

/***/ "./admin/App.js":
/*!**********************!*\
  !*** ./admin/App.js ***!
  \**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _connectedReactRouter = __webpack_require__(/*! connected-react-router */ "./node_modules/connected-react-router/lib/index.js");

__webpack_require__(/*! ./App.css */ "./admin/App.css");

var _routes = __webpack_require__(/*! ./routes */ "./admin/routes/index.js");

var _routes2 = _interopRequireDefault(_routes);

var _Menu = __webpack_require__(/*! ./components/molecules/Menu */ "./admin/components/molecules/Menu/index.js");

var _Menu2 = _interopRequireDefault(_Menu);

var _metadata = __webpack_require__(/*! ./ducks/metadata */ "./admin/ducks/metadata.js");

var _metadata2 = __webpack_require__(/*! ./selectors/metadata */ "./admin/selectors/metadata.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  fetchMetadata: _propTypes2.default.func.isRequired,
  history: _propTypes2.default.object.isRequired,
  url: _propTypes2.default.string
};

var App = function (_Component) {
  (0, _inherits3.default)(App, _Component);

  function App() {
    (0, _classCallCheck3.default)(this, App);
    return (0, _possibleConstructorReturn3.default)(this, (App.__proto__ || (0, _getPrototypeOf2.default)(App)).apply(this, arguments));
  }

  (0, _createClass3.default)(App, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.props.fetchMetadata();
    }
  }, {
    key: "render",
    value: function render() {
      var _props = this.props,
          url = _props.url,
          history = _props.history;


      return _react2.default.createElement(
        _connectedReactRouter.ConnectedRouter,
        { history: history },
        _react2.default.createElement(
          "div",
          { className: "App" },
          _react2.default.createElement(_Menu2.default, null),
          _react2.default.createElement(
            _semanticUiReact.Container,
            { style: { marginTop: "80px" } },
            _react2.default.createElement(_routes2.default, { url: url })
          )
        )
      );
    }
  }]);
  return App;
}(_react.Component);

App.propTypes = propTypes;

var mapStateToProps = function mapStateToProps(state) {
  return {
    url: (0, _metadata2.selectMetadataAdmin)(state)
  };
};

var mapDispatchToProps = {
  fetchMetadata: _metadata.fetchMetadataRequest
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(App);

/***/ }),

/***/ "./admin/api.js":
/*!**********************!*\
  !*** ./admin/api.js ***!
  \**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _superagent = __webpack_require__(/*! superagent */ "./node_modules/superagent/lib/client.js");

var _superagent2 = _interopRequireDefault(_superagent);

var _swaggerClient = __webpack_require__(/*! swagger-client */ "./node_modules/swagger-client/dist/index.js");

var _swaggerClient2 = _interopRequireDefault(_swaggerClient);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var urls = {
  metadata: "/_crud/metadata/"
};

var Api = function () {
  function Api() {
    (0, _classCallCheck3.default)(this, Api);
  }

  (0, _createClass3.default)(Api, null, [{
    key: "getOperation",
    value: function getOperation(client, resource, verb) {
      var collection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

      var path = collection ? "/" + resource + "/" : "/" + resource + "/{element_id}/";
      var operationId = client.spec.paths[path][verb].operationId;

      return client.apis[resource][operationId];
    }
  }, {
    key: "fetchMetadata",
    value: function fetchMetadata() {
      return _superagent2.default.get(urls.metadata).then(function (response) {
        return response.body;
      });
    }
  }, {
    key: "fetchResourceCollection",
    value: function fetchResourceCollection(_ref, client) {
      var resourceName = _ref.resourceName,
          query = _ref.query;

      var operation = Api.getOperation(client, resourceName, "get");

      return operation(query).then(function (response) {
        return response.body;
      });
    }
  }, {
    key: "fetchResourceElement",
    value: function fetchResourceElement(_ref2, client) {
      var resourceName = _ref2.resourceName,
          resourceId = _ref2.resourceId;

      var operation = Api.getOperation(client, resourceName, "get", false);

      return operation({ element_id: resourceId }).then(function (response) {
        return response.body;
      });
    }
  }, {
    key: "fetchSwaggerSchema",
    value: function fetchSwaggerSchema(schemaUrl) {
      return (0, _swaggerClient2.default)(schemaUrl).then(function (client) {
        return client;
      });
    }
  }, {
    key: "submitResource",
    value: function submitResource(_ref3, client) {
      var resourceName = _ref3.resourceName,
          resourceData = _ref3.resourceData;

      var operation = Api.getOperation(client, resourceName, "post");

      return operation({}, { requestBody: resourceData }).then(function (response) {
        return response.body;
      });
    }
  }, {
    key: "updateResourceElement",
    value: function updateResourceElement(_ref4, client) {
      var resourceName = _ref4.resourceName,
          resourceId = _ref4.resourceId,
          resourceData = _ref4.resourceData;

      var operation = Api.getOperation(client, resourceName, "put", false);

      return operation({ element_id: resourceId }, { requestBody: resourceData }).then(function (response) {
        return response.body;
      });
    }
  }, {
    key: "deleteResourceElement",
    value: function deleteResourceElement(_ref5, client) {
      var resourceName = _ref5.resourceName,
          resourceId = _ref5.resourceId;

      var operation = Api.getOperation(client, resourceName, "delete", false);

      return operation({ element_id: resourceId }).then(function (response) {
        return response.body;
      });
    }
  }]);
  return Api;
}();

exports.default = Api;

/***/ }),

/***/ "./admin/components/atoms/MenuResources/MenuResources.jsx":
/*!****************************************************************!*\
  !*** ./admin/components/atoms/MenuResources/MenuResources.jsx ***!
  \****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _assign = __webpack_require__(/*! babel-runtime/core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");

var _assign2 = _interopRequireDefault(_assign);

var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _lang = __webpack_require__(/*! lodash/lang */ "./node_modules/lodash/lang.js");

var _object = __webpack_require__(/*! lodash/object */ "./node_modules/lodash/object.js");

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _metadata = __webpack_require__(/*! ../../../selectors/metadata */ "./admin/selectors/metadata.js");

var _resource = __webpack_require__(/*! ../../../selectors/resource */ "./admin/selectors/resource.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  url: _propTypes2.default.string,
  resources: _propTypes2.default.object,
  resourceName: _propTypes2.default.string,
  verboseName: _propTypes2.default.string
};

var defaultProps = {};

var MenuResources = function (_React$Component) {
  (0, _inherits3.default)(MenuResources, _React$Component);

  function MenuResources(props) {
    (0, _classCallCheck3.default)(this, MenuResources);

    var _this = (0, _possibleConstructorReturn3.default)(this, (MenuResources.__proto__ || (0, _getPrototypeOf2.default)(MenuResources)).call(this, props));

    _this.state = { resourceFilter: "" };
    _this.renderResources = _this.renderResources.bind(_this);
    return _this;
  }

  (0, _createClass3.default)(MenuResources, [{
    key: "renderResources",
    value: function renderResources() {
      var url = this.props.url;

      return (0, _entries2.default)(this.filteredResources).map(function (_ref) {
        var _ref2 = (0, _slicedToArray3.default)(_ref, 2),
            name = _ref2[0],
            resource = _ref2[1];

        return _react2.default.createElement(
          _semanticUiReact.Dropdown.Item,
          { key: name, as: _reactRouterDom.Link, to: "" + url + name + "/" },
          resource.verbose_name
        );
      });
    }
  }, {
    key: "renderNoResults",
    value: function renderNoResults() {
      return _react2.default.createElement(
        _semanticUiReact.Dropdown.Item,
        { disabled: true },
        "No resources found"
      );
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var verboseName = this.props.verboseName;


      return _react2.default.createElement(
        _semanticUiReact.Dropdown,
        { item: true, text: verboseName },
        _react2.default.createElement(
          _semanticUiReact.Dropdown.Menu,
          null,
          _react2.default.createElement(_semanticUiReact.Input, {
            onChange: function onChange(e) {
              return _this2.setState({ resourceFilter: e.target.value });
            },
            icon: "search",
            iconPosition: "left",
            placeholder: "Resource"
          }),
          _react2.default.createElement(_semanticUiReact.Dropdown.Divider, null),
          (0, _lang.isEmpty)(this.filteredResources) ? this.renderNoResults() : this.renderResources()
        )
      );
    }
  }, {
    key: "filteredResources",
    get: function get() {
      var resources = this.props.resources;
      var resourceFilter = this.state.resourceFilter;


      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)((0, _entries2.default)(resources).filter(function (_ref3) {
        var _ref4 = (0, _slicedToArray3.default)(_ref3, 2),
            key = _ref4[0],
            value = _ref4[1];

        return value.verbose_name.toLowerCase().includes(resourceFilter.toLowerCase());
      })));
    }
  }]);
  return MenuResources;
}(_react2.default.Component);

MenuResources.propTypes = propTypes;
MenuResources.defaultProps = defaultProps;

var mapStateToProps = function mapStateToProps(state) {
  return {
    url: (0, _metadata.selectMetadataAdmin)(state),
    resources: (0, _metadata.selectMetadataResources)(state),
    resourceName: (0, _resource.selectResourceName)(state),
    verboseName: (0, _resource.selectResourceVerboseName)(state)
  };
};

exports.default = (0, _reactRedux.connect)(mapStateToProps)(MenuResources);

/***/ }),

/***/ "./admin/components/atoms/MenuResources/index.js":
/*!*******************************************************!*\
  !*** ./admin/components/atoms/MenuResources/index.js ***!
  \*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _MenuResources = __webpack_require__(/*! ./MenuResources */ "./admin/components/atoms/MenuResources/MenuResources.jsx");

var _MenuResources2 = _interopRequireDefault(_MenuResources);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _MenuResources2.default;

/***/ }),

/***/ "./admin/components/atoms/PolymorphicInput/PolymorphicInput.jsx":
/*!**********************************************************************!*\
  !*** ./admin/components/atoms/PolymorphicInput/PolymorphicInput.jsx ***!
  \**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = __webpack_require__(/*! babel-runtime/helpers/objectWithoutProperties */ "./node_modules/babel-runtime/helpers/objectWithoutProperties.js");

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _defineProperty2 = __webpack_require__(/*! babel-runtime/helpers/defineProperty */ "./node_modules/babel-runtime/helpers/defineProperty.js");

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _assign = __webpack_require__(/*! babel-runtime/core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");

var _assign2 = _interopRequireDefault(_assign);

var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _freeze = __webpack_require__(/*! babel-runtime/core-js/object/freeze */ "./node_modules/babel-runtime/core-js/object/freeze.js");

var _freeze2 = _interopRequireDefault(_freeze);

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var types = (0, _freeze2.default)(_assign2.default.apply(Object, (0, _toConsumableArray3.default)(["string", "integer", "boolean", "float", "time", "date", "datetime", "unknown"].map(function (item) {
  return (0, _defineProperty3.default)({}, item, item);
}))));

var propTypes = {
  type: _propTypes2.default.string.isRequired,
  format: _propTypes2.default.string
};

var defaultProps = {
  format: null
};

var PolymorphicInput = function (_React$PureComponent) {
  (0, _inherits3.default)(PolymorphicInput, _React$PureComponent);

  function PolymorphicInput() {
    (0, _classCallCheck3.default)(this, PolymorphicInput);
    return (0, _possibleConstructorReturn3.default)(this, (PolymorphicInput.__proto__ || (0, _getPrototypeOf2.default)(PolymorphicInput)).apply(this, arguments));
  }

  (0, _createClass3.default)(PolymorphicInput, [{
    key: "renderInput",
    value: function renderInput(inputProps) {
      var _props = this.props,
          type = _props.type,
          format = _props.format,
          remainingProps = (0, _objectWithoutProperties3.default)(_props, ["type", "format"]);

      return _react2.default.createElement(_semanticUiReact.Form.Field, (0, _extends3.default)({ control: _semanticUiReact.Input }, inputProps, remainingProps));
    }
  }, {
    key: "renderTimePicker",
    value: function renderTimePicker() {
      var _props2 = this.props,
          type = _props2.type,
          format = _props2.format,
          placeholder = _props2.placeholder,
          remainingProps = (0, _objectWithoutProperties3.default)(_props2, ["type", "format", "placeholder"]);

      return _react2.default.createElement(_semanticUiReact.Form.Field, (0, _extends3.default)({ control: _semanticUiReact.Input, placeholder: "HH:MM:SS" }, remainingProps));
    }
  }, {
    key: "renderDatePicker",
    value: function renderDatePicker() {
      var _props3 = this.props,
          type = _props3.type,
          format = _props3.format,
          placeholder = _props3.placeholder,
          remainingProps = (0, _objectWithoutProperties3.default)(_props3, ["type", "format", "placeholder"]);

      return _react2.default.createElement(_semanticUiReact.Form.Field, (0, _extends3.default)({ control: _semanticUiReact.Input, placeholder: "YYYY/MM/DD" }, remainingProps));
    }
  }, {
    key: "renderDateTimePicker",
    value: function renderDateTimePicker() {
      var _props4 = this.props,
          type = _props4.type,
          format = _props4.format,
          placeholder = _props4.placeholder,
          remainingProps = (0, _objectWithoutProperties3.default)(_props4, ["type", "format", "placeholder"]);

      return _react2.default.createElement(_semanticUiReact.Form.Field, (0, _extends3.default)({ control: _semanticUiReact.Input, placeholder: "YYYY/MM/DD HH:MM:SS" }, remainingProps));
    }
  }, {
    key: "renderCheckbox",
    value: function renderCheckbox() {
      var _props5 = this.props,
          type = _props5.type,
          format = _props5.format,
          placeholder = _props5.placeholder,
          value = _props5.value,
          remainingProps = (0, _objectWithoutProperties3.default)(_props5, ["type", "format", "placeholder", "value"]);

      return _react2.default.createElement(_semanticUiReact.Form.Checkbox, (0, _extends3.default)({ checked: value === true }, remainingProps));
    }
  }, {
    key: "renderTextArea",
    value: function renderTextArea() {
      var _props6 = this.props,
          type = _props6.type,
          format = _props6.format,
          remainingProps = (0, _objectWithoutProperties3.default)(_props6, ["type", "format"]);

      return _react2.default.createElement(_semanticUiReact.Form.TextArea, remainingProps);
    }
  }, {
    key: "render",
    value: function render() {
      var _props7 = this.props,
          type = _props7.type,
          format = _props7.format;


      switch (PolymorphicInput.getType(type, format)) {
        case types.integer:
          return this.renderInput({ type: "number", step: 1 });
        case types.float:
          return this.renderInput({ type: "number", step: "any" });
        case types.string:
          return this.renderInput();
        case types.time:
          return this.renderTimePicker();
        case types.date:
          return this.renderDatePicker();
        case types.datetime:
          return this.renderDateTimePicker();
        case types.boolean:
          return this.renderCheckbox();
        default:
          return this.renderTextArea();
      }
    }
  }], [{
    key: "getType",
    value: function getType(type, format) {
      switch (type) {
        case "integer":
          return types.integer;
        case "number":
          return types.float;
        case "string":
          switch (format) {
            case "time":
              return types.time;
            case "date":
              return types.date;
            case "datetime":
              return types.datetime;
            default:
              return types.string;
          }
        case "boolean":
          return types.boolean;
        default:
          return types.unknown;
      }
    }
  }]);
  return PolymorphicInput;
}(_react2.default.PureComponent);

PolymorphicInput.propTypes = propTypes;
PolymorphicInput.defaultProps = defaultProps;

exports.default = PolymorphicInput;

/***/ }),

/***/ "./admin/components/atoms/SegmentLoader/SegmentLoader.jsx":
/*!****************************************************************!*\
  !*** ./admin/components/atoms/SegmentLoader/SegmentLoader.jsx ***!
  \****************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var SegmentLoader = function (_React$PureComponent) {
  (0, _inherits3.default)(SegmentLoader, _React$PureComponent);

  function SegmentLoader() {
    (0, _classCallCheck3.default)(this, SegmentLoader);
    return (0, _possibleConstructorReturn3.default)(this, (SegmentLoader.__proto__ || (0, _getPrototypeOf2.default)(SegmentLoader)).apply(this, arguments));
  }

  (0, _createClass3.default)(SegmentLoader, [{
    key: "render",
    value: function render() {
      return _react2.default.createElement(
        _semanticUiReact.Segment,
        (0, _extends3.default)({ style: { minHeight: "200px" } }, this.props),
        _react2.default.createElement(
          _semanticUiReact.Dimmer,
          { active: true, inverted: true },
          _react2.default.createElement(
            _semanticUiReact.Loader,
            { inverted: true },
            "Loading"
          )
        )
      );
    }
  }]);
  return SegmentLoader;
}(_react2.default.PureComponent);

exports.default = SegmentLoader;

/***/ }),

/***/ "./admin/components/atoms/SegmentLoader/index.js":
/*!*******************************************************!*\
  !*** ./admin/components/atoms/SegmentLoader/index.js ***!
  \*******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _SegmentLoader = __webpack_require__(/*! ./SegmentLoader */ "./admin/components/atoms/SegmentLoader/SegmentLoader.jsx");

var _SegmentLoader2 = _interopRequireDefault(_SegmentLoader);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _SegmentLoader2.default;

/***/ }),

/***/ "./admin/components/molecules/Menu/Menu.jsx":
/*!**************************************************!*\
  !*** ./admin/components/molecules/Menu/Menu.jsx ***!
  \**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _lang = __webpack_require__(/*! lodash/lang */ "./node_modules/lodash/lang.js");

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _metadata = __webpack_require__(/*! ../../../selectors/metadata */ "./admin/selectors/metadata.js");

var _resource = __webpack_require__(/*! ../../../selectors/resource */ "./admin/selectors/resource.js");

var _MenuResources = __webpack_require__(/*! ../../atoms/MenuResources */ "./admin/components/atoms/MenuResources/index.js");

var _MenuResources2 = _interopRequireDefault(_MenuResources);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  url: _propTypes2.default.string,
  schema: _propTypes2.default.object,
  resourceName: _propTypes2.default.string,
  currentEntity: _propTypes2.default.object
};

var defaultProps = {};

var Menu = function (_React$Component) {
  (0, _inherits3.default)(Menu, _React$Component);

  function Menu() {
    (0, _classCallCheck3.default)(this, Menu);
    return (0, _possibleConstructorReturn3.default)(this, (Menu.__proto__ || (0, _getPrototypeOf2.default)(Menu)).apply(this, arguments));
  }

  (0, _createClass3.default)(Menu, [{
    key: "render",
    value: function render() {
      var _props = this.props,
          schema = _props.schema,
          resourceName = _props.resourceName,
          currentEntity = _props.currentEntity,
          url = _props.url;

      var title = schema && schema.spec.info.title || "API Star CRUD";

      return _react2.default.createElement(
        _semanticUiReact.Menu,
        { fixed: "top", inverted: true },
        _react2.default.createElement(
          _semanticUiReact.Menu.Item,
          { as: "a", href: "/", header: true },
          title
        ),
        _react2.default.createElement(
          _semanticUiReact.Menu.Item,
          { as: _reactRouterDom.Link, to: "" + url },
          "Admin"
        ),
        resourceName && _react2.default.createElement(_MenuResources2.default, null),
        !(0, _lang.isEmpty)(currentEntity) && _react2.default.createElement(
          _semanticUiReact.Menu.Item,
          { as: "a" },
          currentEntity.id
        )
      );
    }
  }]);
  return Menu;
}(_react2.default.Component);

Menu.propTypes = propTypes;
Menu.defaultProps = defaultProps;

var mapStateToProps = function mapStateToProps(state) {
  return {
    url: (0, _metadata.selectMetadataAdmin)(state),
    schema: (0, _metadata.selectMetadataClient)(state),
    resourceName: (0, _resource.selectResourceName)(state),
    currentEntity: (0, _resource.selectResourceCurrentEntity)(state)
  };
};

exports.default = (0, _reactRedux.connect)(mapStateToProps)(Menu);

/***/ }),

/***/ "./admin/components/molecules/Menu/index.js":
/*!**************************************************!*\
  !*** ./admin/components/molecules/Menu/index.js ***!
  \**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Menu = __webpack_require__(/*! ./Menu */ "./admin/components/molecules/Menu/Menu.jsx");

var _Menu2 = _interopRequireDefault(_Menu);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _Menu2.default;

/***/ }),

/***/ "./admin/components/molecules/ResourceForm/ResourceForm.jsx":
/*!******************************************************************!*\
  !*** ./admin/components/molecules/ResourceForm/ResourceForm.jsx ***!
  \******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends3 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends4 = _interopRequireDefault(_extends3);

var _defineProperty2 = __webpack_require__(/*! babel-runtime/helpers/defineProperty */ "./node_modules/babel-runtime/helpers/defineProperty.js");

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _assign = __webpack_require__(/*! babel-runtime/core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");

var _assign2 = _interopRequireDefault(_assign);

var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _keys = __webpack_require__(/*! babel-runtime/core-js/object/keys */ "./node_modules/babel-runtime/core-js/object/keys.js");

var _keys2 = _interopRequireDefault(_keys);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _resource = __webpack_require__(/*! ../../../ducks/resource */ "./admin/ducks/resource.js");

var _metadata = __webpack_require__(/*! ../../../selectors/metadata */ "./admin/selectors/metadata.js");

var _resource2 = __webpack_require__(/*! ../../../selectors/resource */ "./admin/selectors/resource.js");

var _PolymorphicInput = __webpack_require__(/*! ../../atoms/PolymorphicInput/PolymorphicInput */ "./admin/components/atoms/PolymorphicInput/PolymorphicInput.jsx");

var _PolymorphicInput2 = _interopRequireDefault(_PolymorphicInput);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  schema: _propTypes2.default.object,
  fetchResource: _propTypes2.default.func,
  updateResourceElement: _propTypes2.default.func,
  submitResource: _propTypes2.default.func,
  verboseName: _propTypes2.default.string,
  currentEntity: _propTypes2.default.object,
  resourceId: _propTypes2.default.string,
  resourceName: _propTypes2.default.string.isRequired
};
var defaultProps = {};

var ResourceForm = function (_React$Component) {
  (0, _inherits3.default)(ResourceForm, _React$Component);

  function ResourceForm(props) {
    (0, _classCallCheck3.default)(this, ResourceForm);

    var _this = (0, _possibleConstructorReturn3.default)(this, (ResourceForm.__proto__ || (0, _getPrototypeOf2.default)(ResourceForm)).call(this, props));

    _this.getValue = _this.getValue.bind(_this);
    _this.handleChange = _this.handleChange.bind(_this);
    _this.handleSubmit = _this.handleSubmit.bind(_this);

    _this.state = {};
    return _this;
  }

  (0, _createClass3.default)(ResourceForm, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _props = this.props,
          resourceId = _props.resourceId,
          resourceName = _props.resourceName;


      if (resourceId) {
        this.props.fetchResource({ resourceName: resourceName, resourceId: resourceId });
      }
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate(prevProps) {
      if (prevProps.currentEntity === null && this.props.currentEntity !== null) {
        var currentEntity = this.props.currentEntity;

        var writableFields = (0, _keys2.default)(this.writableFields);

        var data = (0, _entries2.default)(currentEntity).filter(function (_ref) {
          var _ref2 = (0, _slicedToArray3.default)(_ref, 2),
              key = _ref2[0],
              value = _ref2[1];

          return writableFields.includes(key);
        });
        data = _assign2.default.apply(Object, (0, _toConsumableArray3.default)(data.map(function (_ref3) {
          var _ref4 = (0, _slicedToArray3.default)(_ref3, 2),
              key = _ref4[0],
              value = _ref4[1];

          return (0, _defineProperty3.default)({}, key, value);
        })));
        this.setState((0, _extends4.default)({}, this.state, data));
      }
    }
  }, {
    key: "getValue",
    value: function getValue(name) {
      var currentEntity = this.props.currentEntity;


      var value = null;

      if (name in this.state) {
        value = this.state[name];
      } else if (currentEntity) {
        value = currentEntity[name];
      }

      return value || "";
    }
  }, {
    key: "handleChange",
    value: function handleChange(e, _ref6) {
      var name = _ref6.name,
          value = _ref6.value;

      this.setState((0, _extends4.default)({}, this.state, (0, _defineProperty3.default)({}, name, value)));
    }
  }, {
    key: "handleSubmit",
    value: function handleSubmit(evt) {
      evt.preventDefault();

      var _props2 = this.props,
          resourceId = _props2.resourceId,
          resourceName = _props2.resourceName,
          updateResourceElement = _props2.updateResourceElement,
          submitResource = _props2.submitResource;


      if (resourceId) {
        updateResourceElement({ resourceName: resourceName, resourceId: resourceId, resourceData: this.state });
      } else {
        submitResource({ resourceName: resourceName, resourceData: this.state });
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var resourceId = this.props.resourceId;


      var fields = resourceId === null ? this.writableFields : this.fields;

      return _react2.default.createElement(
        _semanticUiReact.Form,
        { onSubmit: this.handleSubmit },
        (0, _entries2.default)(fields).map(function (_ref7) {
          var _ref8 = (0, _slicedToArray3.default)(_ref7, 2),
              name = _ref8[0],
              field = _ref8[1];

          return _react2.default.createElement(_PolymorphicInput2.default, {
            key: name,
            name: name,
            type: field.type,
            format: field.format,
            label: field.description || field.title || name,
            placeholder: field.default,
            value: _this2.getValue(name),
            required: !field.readOnly && field.required,
            readOnly: field.readOnly,
            onChange: _this2.handleChange
          });
        }),
        _react2.default.createElement(_semanticUiReact.Form.Button, { content: "Save", positive: true })
      );
    }
  }, {
    key: "resourceSchema",
    get: function get() {
      var _props3 = this.props,
          resourceName = _props3.resourceName,
          schema = _props3.schema;


      return schema && schema.spec.paths["/" + resourceName + "/"];
    }
  }, {
    key: "fields",
    get: function get() {
      var _resourceSchema$get$r = this.resourceSchema.get.responses["200"].content["application/json"].schema.items,
          getProps = _resourceSchema$get$r.properties,
          getRequired = _resourceSchema$get$r.required;
      var _resourceSchema$post$ = this.resourceSchema.post.requestBody.content["application/json"].schema,
          postProps = _resourceSchema$post$.properties,
          postRequired = _resourceSchema$post$.required;


      var getFields = (0, _entries2.default)(getProps).map(function (_ref9) {
        var _ref10 = (0, _slicedToArray3.default)(_ref9, 2),
            key = _ref10[0],
            value = _ref10[1];

        var field = value;
        field.readOnly = true;
        field.required = getRequired.includes(key);
        return [key, field];
      });

      var postFields = (0, _entries2.default)(postProps).map(function (_ref11) {
        var _ref12 = (0, _slicedToArray3.default)(_ref11, 2),
            key = _ref12[0],
            value = _ref12[1];

        var field = value;
        field.readOnly = false;
        field.required = postRequired.includes(key);
        return [key, field];
      });

      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)(getFields.map(function (_ref13) {
        var _ref14 = (0, _slicedToArray3.default)(_ref13, 2),
            key = _ref14[0],
            value = _ref14[1];

        return (0, _defineProperty3.default)({}, key, value);
      })).concat((0, _toConsumableArray3.default)(postFields.map(function (_ref16) {
        var _ref17 = (0, _slicedToArray3.default)(_ref16, 2),
            key = _ref17[0],
            value = _ref17[1];

        return (0, _defineProperty3.default)({}, key, value);
      }))));
    }
  }, {
    key: "readOnlyFields",
    get: function get() {
      var fields = (0, _entries2.default)(this.fields).filter(function (_ref19) {
        var _ref20 = (0, _slicedToArray3.default)(_ref19, 2),
            key = _ref20[0],
            value = _ref20[1];

        return value.readOnly;
      });
      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)(fields.map(function (_ref21) {
        var _ref22 = (0, _slicedToArray3.default)(_ref21, 2),
            key = _ref22[0],
            value = _ref22[1];

        return (0, _defineProperty3.default)({}, key, value);
      })));
    }
  }, {
    key: "writableFields",
    get: function get() {
      var fields = (0, _entries2.default)(this.fields).filter(function (_ref24) {
        var _ref25 = (0, _slicedToArray3.default)(_ref24, 2),
            key = _ref25[0],
            value = _ref25[1];

        return !value.readOnly;
      });
      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)(fields.map(function (_ref26) {
        var _ref27 = (0, _slicedToArray3.default)(_ref26, 2),
            key = _ref27[0],
            value = _ref27[1];

        return (0, _defineProperty3.default)({}, key, value);
      })));
    }
  }]);
  return ResourceForm;
}(_react2.default.Component);

ResourceForm.propTypes = propTypes;
ResourceForm.defaultProps = defaultProps;

var mapStateToProps = function mapStateToProps(state) {
  return {
    schema: (0, _metadata.selectMetadataClient)(state),
    verboseName: (0, _resource2.selectResourceVerboseName)(state),
    currentEntity: (0, _resource2.selectResourceCurrentEntity)(state),
    errors: (0, _resource2.selectResourceErrors)(state)
  };
};

var mapDispatchToProps = {
  fetchResource: _resource.fetchCurrentResourceRequest,
  submitResource: _resource.submitResourceRequest,
  updateResourceElement: _resource.updateResourceElementRequest
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(ResourceForm);

/***/ }),

/***/ "./admin/components/molecules/ResourceList/ResourceList.jsx":
/*!******************************************************************!*\
  !*** ./admin/components/molecules/ResourceList/ResourceList.jsx ***!
  \******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _keys = __webpack_require__(/*! babel-runtime/core-js/object/keys */ "./node_modules/babel-runtime/core-js/object/keys.js");

var _keys2 = _interopRequireDefault(_keys);

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _collection = __webpack_require__(/*! lodash/collection */ "./node_modules/lodash/collection.js");

var _lang = __webpack_require__(/*! lodash/lang */ "./node_modules/lodash/lang.js");

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _resource = __webpack_require__(/*! ../../../ducks/resource */ "./admin/ducks/resource.js");

var _metadata = __webpack_require__(/*! ../../../selectors/metadata */ "./admin/selectors/metadata.js");

var _resource2 = __webpack_require__(/*! ../../../selectors/resource */ "./admin/selectors/resource.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  columns: _propTypes2.default.object.isRequired,
  url: _propTypes2.default.string,
  resourceName: _propTypes2.default.string.isRequired,
  fetchResources: _propTypes2.default.func.isRequired,
  resources: _propTypes2.default.arrayOf(_propTypes2.default.object),
  rowsPerPage: _propTypes2.default.number,
  currentPage: _propTypes2.default.number,
  totalCount: _propTypes2.default.number
};

var ResourceList = function (_React$Component) {
  (0, _inherits3.default)(ResourceList, _React$Component);

  function ResourceList(props) {
    (0, _classCallCheck3.default)(this, ResourceList);

    var _this = (0, _possibleConstructorReturn3.default)(this, (ResourceList.__proto__ || (0, _getPrototypeOf2.default)(ResourceList)).call(this, props));

    _this.handlePageChange = _this.handlePageChange.bind(_this);
    return _this;
  }

  (0, _createClass3.default)(ResourceList, [{
    key: "handlePageChange",
    value: function handlePageChange(event, _ref) {
      var activePage = _ref.activePage;

      if (event && activePage !== this.props.currentPage && activePage > 0 && activePage < this.props.totalCount / this.props.rowsPerPage) {
        var _props = this.props,
            resourceName = _props.resourceName,
            rowsPerPage = _props.rowsPerPage;

        this.props.fetchResources({
          resourceName: resourceName,
          query: {
            page: activePage,
            page_size: rowsPerPage
          }
        });
      }
    }
  }, {
    key: "renderEmpty",
    value: function renderEmpty() {
      return _react2.default.createElement(
        _semanticUiReact.Segment,
        { attached: true },
        "No results found."
      );
    }
  }, {
    key: "renderResources",
    value: function renderResources() {
      var _props2 = this.props,
          columns = _props2.columns,
          currentPage = _props2.currentPage,
          totalCount = _props2.totalCount,
          rowsPerPage = _props2.rowsPerPage,
          resourceName = _props2.resourceName,
          resources = _props2.resources,
          url = _props2.url;

      var sortedResources = (0, _collection.orderBy)(resources, ["id"], ["desc"]);

      return _react2.default.createElement(
        _semanticUiReact.Table,
        { attached: true, compact: "very", striped: true, singleLine: true },
        _react2.default.createElement(
          _semanticUiReact.Table.Header,
          null,
          _react2.default.createElement(
            _semanticUiReact.Table.Row,
            null,
            _react2.default.createElement(
              _semanticUiReact.Table.HeaderCell,
              null,
              "ID"
            ),
            (0, _entries2.default)(columns).map(function (_ref2) {
              var _ref3 = (0, _slicedToArray3.default)(_ref2, 2),
                  k = _ref3[0],
                  v = _ref3[1];

              return _react2.default.createElement(
                _semanticUiReact.Table.HeaderCell,
                { key: k },
                v.description || v.title || k
              );
            })
          )
        ),
        _react2.default.createElement(
          _semanticUiReact.Table.Body,
          null,
          sortedResources.map(function (item) {
            return _react2.default.createElement(
              _semanticUiReact.Table.Row,
              { key: item.id },
              _react2.default.createElement(
                _semanticUiReact.Table.Cell,
                null,
                _react2.default.createElement(
                  _reactRouterDom.Link,
                  { to: "" + url + resourceName + "/" + item.id + "/" },
                  item.id
                )
              ),
              (0, _keys2.default)(columns).map(function (field) {
                return _react2.default.createElement(
                  _semanticUiReact.Table.Cell,
                  { key: field },
                  item[field]
                );
              })
            );
          })
        ),
        _react2.default.createElement(
          _semanticUiReact.Table.Footer,
          null,
          _react2.default.createElement(
            _semanticUiReact.Table.Row,
            null,
            _react2.default.createElement(
              _semanticUiReact.Table.HeaderCell,
              { colSpan: (0, _keys2.default)(columns).length + 1, textAlign: "center" },
              _react2.default.createElement(_semanticUiReact.Pagination, {
                activePage: currentPage,
                totalPages: totalCount / rowsPerPage,
                onPageChange: this.handlePageChange
              })
            )
          )
        )
      );
    }
  }, {
    key: "render",
    value: function render() {
      return this.isEmpty ? this.renderEmpty() : this.renderResources();
    }
  }, {
    key: "isEmpty",
    get: function get() {
      var resources = this.props.resources;

      return (0, _lang.isEmpty)(resources);
    }
  }]);
  return ResourceList;
}(_react2.default.Component);

ResourceList.propTypes = propTypes;

var mapStateToProps = function mapStateToProps(state) {
  return {
    url: (0, _metadata.selectMetadataAdmin)(state),
    rowsPerPage: (0, _resource2.selectResourceRowsPerPage)(state),
    currentPage: (0, _resource2.selectResourceCurrentPage)(state),
    totalCount: (0, _resource2.selectResourceTotalCount)(state),
    resources: (0, _resource2.selectResourceEntities)(state)
  };
};

var mapDispatchToProps = {
  fetchResources: _resource.fetchResourceEntitiesRequest
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(ResourceList);

/***/ }),

/***/ "./admin/components/molecules/ResourceList/index.js":
/*!**********************************************************!*\
  !*** ./admin/components/molecules/ResourceList/index.js ***!
  \**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _ResourceList = __webpack_require__(/*! ./ResourceList */ "./admin/components/molecules/ResourceList/ResourceList.jsx");

var _ResourceList2 = _interopRequireDefault(_ResourceList);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _ResourceList2.default;

/***/ }),

/***/ "./admin/components/pages/DetailPage.jsx":
/*!***********************************************!*\
  !*** ./admin/components/pages/DetailPage.jsx ***!
  \***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _resource = __webpack_require__(/*! ../../ducks/resource */ "./admin/ducks/resource.js");

var _metadata = __webpack_require__(/*! ../../selectors/metadata */ "./admin/selectors/metadata.js");

var _ResourceForm = __webpack_require__(/*! ../molecules/ResourceForm/ResourceForm */ "./admin/components/molecules/ResourceForm/ResourceForm.jsx");

var _ResourceForm2 = _interopRequireDefault(_ResourceForm);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  match: _propTypes2.default.object,
  resources: _propTypes2.default.object,
  deleteResourceElement: _propTypes2.default.func
};

var DetailPage = function (_React$Component) {
  (0, _inherits3.default)(DetailPage, _React$Component);

  function DetailPage(props) {
    (0, _classCallCheck3.default)(this, DetailPage);

    var _this = (0, _possibleConstructorReturn3.default)(this, (DetailPage.__proto__ || (0, _getPrototypeOf2.default)(DetailPage)).call(this, props));

    _this.showDelete = _this.showDelete.bind(_this);
    _this.handleDeleteConfirm = _this.handleDeleteConfirm.bind(_this);
    _this.handleDeleteCancel = _this.handleDeleteCancel.bind(_this);

    _this.state = { isDeleteOpen: false };
    return _this;
  }

  (0, _createClass3.default)(DetailPage, [{
    key: "showDelete",
    value: function showDelete() {
      this.setState((0, _extends3.default)({}, this.state, { isDeleteOpen: true }));
    }
  }, {
    key: "handleDeleteConfirm",
    value: function handleDeleteConfirm() {
      var _props = this.props,
          deleteResourceElement = _props.deleteResourceElement,
          match = _props.match;
      var _match$params = match.params,
          resource = _match$params.resource,
          id = _match$params.id;


      deleteResourceElement({ resourceName: resource, resourceId: id });

      this.setState((0, _extends3.default)({}, this.state, { isDeleteOpen: false }));
    }
  }, {
    key: "handleDeleteCancel",
    value: function handleDeleteCancel() {
      this.setState((0, _extends3.default)({}, this.state, { isDeleteOpen: false }));
    }
  }, {
    key: "render",
    value: function render() {
      var isDeleteOpen = this.state.isDeleteOpen;
      var match = this.props.match;
      var _match$params2 = match.params,
          resource = _match$params2.resource,
          id = _match$params2.id;


      var resourceId = id === "new" ? null : id;

      return _react2.default.createElement(
        _react2.default.Fragment,
        null,
        _react2.default.createElement(
          _semanticUiReact.Menu,
          { attached: "top" },
          _react2.default.createElement(
            _semanticUiReact.Menu.Item,
            { header: true },
            this.verboseName
          ),
          resourceId && _react2.default.createElement(
            _semanticUiReact.Menu.Item,
            null,
            resourceId
          ),
          resourceId && _react2.default.createElement(
            _semanticUiReact.Menu.Menu,
            { position: "right" },
            _react2.default.createElement(
              _semanticUiReact.Menu.Item,
              null,
              _react2.default.createElement(
                _semanticUiReact.Button,
                { name: "delete", onClick: this.showDelete, onKeyPress: this.showDelete, negative: true },
                _react2.default.createElement(_semanticUiReact.Icon, { name: "delete" }),
                "Delete"
              )
            )
          )
        ),
        _react2.default.createElement(
          _semanticUiReact.Segment,
          { attached: true },
          _react2.default.createElement(_ResourceForm2.default, { resourceName: resource, resourceId: resourceId, attached: true })
        ),
        resourceId && _react2.default.createElement(_semanticUiReact.Confirm, {
          open: isDeleteOpen,
          header: "Delete " + this.verboseName,
          content: "Are you sure you want to delete " + this.verboseName + " (" + resourceId + ")?",
          onCancel: this.handleDeleteCancel,
          onConfirm: this.handleDeleteConfirm
        })
      );
    }
  }, {
    key: "verboseName",
    get: function get() {
      var _props2 = this.props,
          resources = _props2.resources,
          match = _props2.match;

      return resources[match.params.resource].verbose_name;
    }
  }]);
  return DetailPage;
}(_react2.default.Component);

DetailPage.propTypes = propTypes;

var mapStateToProps = function mapStateToProps(state) {
  return {
    resources: (0, _metadata.selectMetadataResources)(state)
  };
};

var mapDispatchToProps = {
  deleteResourceElement: _resource.deleteResourceElementRequest
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(DetailPage);

/***/ }),

/***/ "./admin/components/pages/ErrorInternalServerPage.jsx":
/*!************************************************************!*\
  !*** ./admin/components/pages/ErrorInternalServerPage.jsx ***!
  \************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {};
var defaultProps = {};

var ErrorInternalServerPage = function ErrorInternalServerPage(props) {
  return _react2.default.createElement(_semanticUiReact.Message, { header: "Internal Server Error" });
};

ErrorInternalServerPage.propTypes = propTypes;
ErrorInternalServerPage.defaultProps = defaultProps;

exports.default = ErrorInternalServerPage;

/***/ }),

/***/ "./admin/components/pages/ErrorNotFoundPage.jsx":
/*!******************************************************!*\
  !*** ./admin/components/pages/ErrorNotFoundPage.jsx ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {};
var defaultProps = {};

var ErrorNotFoundPage = function ErrorNotFoundPage(props) {
  return _react2.default.createElement(_semanticUiReact.Message, { header: "Not Found" });
};

ErrorNotFoundPage.propTypes = propTypes;
ErrorNotFoundPage.defaultProps = defaultProps;

exports.default = ErrorNotFoundPage;

/***/ }),

/***/ "./admin/components/pages/HomePage.jsx":
/*!*********************************************!*\
  !*** ./admin/components/pages/HomePage.jsx ***!
  \*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _metadata = __webpack_require__(/*! ../../selectors/metadata */ "./admin/selectors/metadata.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  url: _propTypes2.default.string,
  resources: _propTypes2.default.object
};

var defaultProps = {
  resources: null
};

var HomePage = function (_React$Component) {
  (0, _inherits3.default)(HomePage, _React$Component);

  function HomePage() {
    (0, _classCallCheck3.default)(this, HomePage);
    return (0, _possibleConstructorReturn3.default)(this, (HomePage.__proto__ || (0, _getPrototypeOf2.default)(HomePage)).apply(this, arguments));
  }

  (0, _createClass3.default)(HomePage, [{
    key: "render",
    value: function render() {
      var resources = this.props.resources;


      return resources && _react2.default.createElement(
        "div",
        null,
        _react2.default.createElement(
          _semanticUiReact.Menu,
          { vertical: true, fluid: true },
          _react2.default.createElement(
            _semanticUiReact.Menu.Item,
            { color: "red", header: true },
            "Resources"
          ),
          (0, _entries2.default)(resources).map(function (_ref) {
            var _ref2 = (0, _slicedToArray3.default)(_ref, 2),
                k = _ref2[0],
                v = _ref2[1];

            return _react2.default.createElement(
              _semanticUiReact.Menu.Item,
              { key: k, as: _reactRouterDom.Link, to: k + "/", name: k },
              v.verbose_name
            );
          })
        )
      );
    }
  }]);
  return HomePage;
}(_react2.default.Component);

HomePage.propTypes = propTypes;
HomePage.defaultProps = defaultProps;

var mapStateToProps = function mapStateToProps(state) {
  return {
    resources: (0, _metadata.selectMetadataResources)(state),
    url: (0, _metadata.selectMetadataAdmin)(state)
  };
};

exports.default = (0, _reactRedux.connect)(mapStateToProps)(HomePage);

/***/ }),

/***/ "./admin/components/pages/ListPage.jsx":
/*!*********************************************!*\
  !*** ./admin/components/pages/ListPage.jsx ***!
  \*********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _assign = __webpack_require__(/*! babel-runtime/core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");

var _assign2 = _interopRequireDefault(_assign);

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _defineProperty2 = __webpack_require__(/*! babel-runtime/helpers/defineProperty */ "./node_modules/babel-runtime/helpers/defineProperty.js");

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _extends3 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends4 = _interopRequireDefault(_extends3);

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _collection = __webpack_require__(/*! lodash/collection */ "./node_modules/lodash/collection.js");

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _semanticUiReact = __webpack_require__(/*! semantic-ui-react */ "./node_modules/semantic-ui-react/dist/es/index.js");

var _resource = __webpack_require__(/*! ../../ducks/resource */ "./admin/ducks/resource.js");

var _metadata = __webpack_require__(/*! ../../selectors/metadata */ "./admin/selectors/metadata.js");

var _resource2 = __webpack_require__(/*! ../../selectors/resource */ "./admin/selectors/resource.js");

var _SegmentLoader = __webpack_require__(/*! ../atoms/SegmentLoader */ "./admin/components/atoms/SegmentLoader/index.js");

var _SegmentLoader2 = _interopRequireDefault(_SegmentLoader);

var _ResourceList = __webpack_require__(/*! ../molecules/ResourceList */ "./admin/components/molecules/ResourceList/index.js");

var _ResourceList2 = _interopRequireDefault(_ResourceList);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var INVALID_PARAMS = ["page", "page_size"];
var PARAM_TYPE = "query";

var propTypes = {
  match: _propTypes2.default.object,
  schema: _propTypes2.default.object,
  resources: _propTypes2.default.object,
  url: _propTypes2.default.string,
  fetchResources: _propTypes2.default.func.isRequired,
  rowsPerPage: _propTypes2.default.number,
  currentPage: _propTypes2.default.number,
  isFetching: _propTypes2.default.bool
};

var ListPage = function (_React$Component) {
  (0, _inherits3.default)(ListPage, _React$Component);

  function ListPage(props) {
    (0, _classCallCheck3.default)(this, ListPage);

    var _this = (0, _possibleConstructorReturn3.default)(this, (ListPage.__proto__ || (0, _getPrototypeOf2.default)(ListPage)).call(this, props));

    _this.handleChange = _this.handleChange.bind(_this);
    _this.handleSelect = _this.handleSelect.bind(_this);

    _this.state = { filter: null, value: null, columnsOpen: false, columns: null };
    return _this;
  }

  (0, _createClass3.default)(ListPage, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _props = this.props,
          currentPage = _props.currentPage,
          rowsPerPage = _props.rowsPerPage;


      this.props.fetchResources({
        resourceName: this.resourceName,
        query: {
          page_size: rowsPerPage,
          page: currentPage
        }
      });
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate(prevProps) {
      if (this.props.schema !== null && (prevProps.schema === null || this.state.columns === null)) {
        var resources = this.props.resources;


        this.setState((0, _extends4.default)({}, this.state, { columns: [].concat((0, _toConsumableArray3.default)(resources[this.resourceName].columns)) }));
      }
    }
  }, {
    key: "handleChange",
    value: function handleChange(e, _ref) {
      var _this2 = this;

      var name = _ref.name,
          value = _ref.value;

      this.setState((0, _extends4.default)({}, this.state, (0, _defineProperty3.default)({}, name, value)), function () {
        var _state = _this2.state,
            filter = _state.filter,
            filterValue = _state.value;
        var _props2 = _this2.props,
            currentPage = _props2.currentPage,
            rowsPerPage = _props2.rowsPerPage;


        if (filter !== null && filterValue !== null) {
          _this2.props.fetchResources({
            resourceName: _this2.resourceName,
            query: (0, _defineProperty3.default)({
              page_size: rowsPerPage,
              page: currentPage
            }, filter, filterValue)
          });
        }
      });
    }
  }, {
    key: "handleSelect",
    value: function handleSelect(e, _ref2) {
      var value = _ref2.value;
      var columns = this.state.columns;

      columns = columns || [];

      if (columns.includes(value)) {
        columns = columns.filter(function (item) {
          return item !== value;
        });
      } else {
        columns.push(value);
      }

      this.setState((0, _extends4.default)({}, this.state, { columns: [].concat((0, _toConsumableArray3.default)(columns)) }));
    }
  }, {
    key: "renderMenu",
    value: function renderMenu() {
      var _this3 = this;

      var url = this.props.url;


      var filterOptions = this.filterParameters.map(function (item) {
        return { key: item.name, text: item.name, value: item.name };
      });
      var columnsOptions = (0, _entries2.default)(this.fields).map(function (_ref3) {
        var _ref4 = (0, _slicedToArray3.default)(_ref3, 2),
            k = _ref4[0],
            v = _ref4[1];

        return {
          key: k,
          text: v.description || v.title || k,
          value: k
        };
      });

      var columns = this.columns;

      return _react2.default.createElement(
        _semanticUiReact.Menu,
        { size: "large", attached: "top" },
        _react2.default.createElement(
          _semanticUiReact.Menu.Item,
          { header: true },
          this.verboseName
        ),
        _react2.default.createElement(
          _semanticUiReact.Menu.Menu,
          { position: "right" },
          _react2.default.createElement(
            _semanticUiReact.Menu.Item,
            null,
            _react2.default.createElement(_semanticUiReact.Input, {
              name: "value",
              onChange: this.handleChange,
              icon: "filter",
              iconPosition: "left",
              placeholder: "Filter...",
              action: _react2.default.createElement(_semanticUiReact.Dropdown, {
                onChange: this.handleChange,
                name: "filter",
                placeholder: "Filter",
                compact: true,
                selection: true,
                search: true,
                options: filterOptions
              })
            })
          ),
          _react2.default.createElement(
            _semanticUiReact.Dropdown,
            {
              item: true,
              name: "columns",
              text: "Columns",
              open: this.state.columnsOpen,
              onFocus: function onFocus() {
                _this3.setState((0, _extends4.default)({}, _this3.state, { columnsOpen: true }));
              },
              onBlur: function onBlur() {
                _this3.setState((0, _extends4.default)({}, _this3.state, { columnsOpen: false }));
              }
            },
            _react2.default.createElement(
              _semanticUiReact.Dropdown.Menu,
              null,
              _react2.default.createElement(_semanticUiReact.Dropdown.Header, { icon: "columns", content: "Columns" }),
              _react2.default.createElement(
                _semanticUiReact.Dropdown.Menu,
                { scrolling: true },
                columnsOptions.map(function (option) {
                  return _react2.default.createElement(_semanticUiReact.Dropdown.Item, (0, _extends4.default)({
                    selected: option.value in columns,
                    onClick: _this3.handleSelect,
                    key: option.value
                  }, option));
                })
              )
            )
          ),
          _react2.default.createElement(
            _semanticUiReact.Menu.Item,
            null,
            _react2.default.createElement(
              _semanticUiReact.Button,
              { primary: true, as: _reactRouterDom.Link, to: "" + url + this.resourceName + "/new/" },
              "Create"
            )
          )
        )
      );
    }
  }, {
    key: "render",
    value: function render() {
      var _props3 = this.props,
          isFetching = _props3.isFetching,
          schema = _props3.schema;


      return _react2.default.createElement(
        _react2.default.Fragment,
        null,
        schema && this.renderMenu(),
        isFetching ? _react2.default.createElement(_SegmentLoader2.default, { attached: true }) : _react2.default.createElement(_ResourceList2.default, { resourceName: this.resourceName, columns: this.columns })
      );
    }
  }, {
    key: "resourceName",
    get: function get() {
      var match = this.props.match;

      return match.params.resource;
    }
  }, {
    key: "verboseName",
    get: function get() {
      var resources = this.props.resources;

      return resources[this.resourceName].verbose_name;
    }
  }, {
    key: "filterParameters",
    get: function get() {
      var schema = this.props.schema;

      return schema.spec.paths["/" + this.resourceName + "/"].get.parameters.filter(function (item) {
        return item.in === PARAM_TYPE && !INVALID_PARAMS.includes(item.name);
      });
    }
  }, {
    key: "resourceSchema",
    get: function get() {
      var schema = this.props.schema;

      return schema && schema.spec.paths["/" + this.resourceName + "/"].get;
    }
  }, {
    key: "fields",
    get: function get() {
      var fields = (0, _entries2.default)(this.resourceSchema.responses["200"].content["application/json"].schema.items.properties);

      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)((0, _collection.orderBy)(fields.filter(function (_ref5) {
        var _ref6 = (0, _slicedToArray3.default)(_ref5, 2),
            k = _ref6[0],
            v = _ref6[1];

        return k !== "id";
      }), ["description"], ["asc"]).map(function (_ref7) {
        var _ref8 = (0, _slicedToArray3.default)(_ref7, 2),
            k = _ref8[0],
            v = _ref8[1];

        return (0, _defineProperty3.default)({}, k, v);
      })));
    }
  }, {
    key: "columns",
    get: function get() {
      var columns = this.state.columns;

      columns = columns || [];

      return _assign2.default.apply(Object, (0, _toConsumableArray3.default)((0, _entries2.default)(this.fields).map(function (_ref10) {
        var _ref11 = (0, _slicedToArray3.default)(_ref10, 2),
            k = _ref11[0],
            v = _ref11[1];

        return columns.includes(k) ? (0, _defineProperty3.default)({}, k, v) : {};
      })));
    }
  }]);
  return ListPage;
}(_react2.default.Component);

ListPage.propTypes = propTypes;

var mapStateToProps = function mapStateToProps(state) {
  return {
    schema: (0, _metadata.selectMetadataClient)(state),
    resources: (0, _metadata.selectMetadataResources)(state),
    url: (0, _metadata.selectMetadataAdmin)(state),
    rowsPerPage: (0, _resource2.selectResourceRowsPerPage)(state),
    currentPage: (0, _resource2.selectResourceCurrentPage)(state),
    isFetching: (0, _resource2.selectResourceIsFetching)(state)
  };
};

var mapDispatchToProps = {
  fetchResources: _resource.fetchResourceEntitiesRequest
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(ListPage);

/***/ }),

/***/ "./admin/ducks/index.js":
/*!******************************!*\
  !*** ./admin/ducks/index.js ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/index.js");

var _metadata = __webpack_require__(/*! ./metadata */ "./admin/ducks/metadata.js");

var _metadata2 = _interopRequireDefault(_metadata);

var _resource = __webpack_require__(/*! ./resource */ "./admin/ducks/resource.js");

var _resource2 = _interopRequireDefault(_resource);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = (0, _redux.combineReducers)({
  metadata: _metadata2.default,
  resource: _resource2.default
});

/***/ }),

/***/ "./admin/ducks/metadata.js":
/*!*********************************!*\
  !*** ./admin/ducks/metadata.js ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.fetchMetadataFailure = exports.fetchMetadataSuccess = exports.fetchMetadataRequest = exports.FETCH_METADATA_FAILURE = exports.FETCH_METADATA_SUCCESS = exports.FETCH_METADATA_REQUEST = undefined;

var _defineProperty2 = __webpack_require__(/*! babel-runtime/helpers/defineProperty */ "./node_modules/babel-runtime/helpers/defineProperty.js");

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

var _handleActions;

var _reduxActions = __webpack_require__(/*! redux-actions */ "./node_modules/redux-actions/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// -TYPES
var FETCH_METADATA_REQUEST = exports.FETCH_METADATA_REQUEST = "metadata/fetch/REQUEST";
var FETCH_METADATA_SUCCESS = exports.FETCH_METADATA_SUCCESS = "metadata/fetch/SUCCESS";
var FETCH_METADATA_FAILURE = exports.FETCH_METADATA_FAILURE = "metadata/fetch/FAILURE";

// -ACTIONS
var fetchMetadataRequest = exports.fetchMetadataRequest = (0, _reduxActions.createAction)(FETCH_METADATA_REQUEST);
var fetchMetadataSuccess = exports.fetchMetadataSuccess = (0, _reduxActions.createAction)(FETCH_METADATA_SUCCESS);
var fetchMetadataFailure = exports.fetchMetadataFailure = (0, _reduxActions.createAction)(FETCH_METADATA_FAILURE);

// -STATE
var initialState = {
  resources: null,
  schema: null,
  client: null,
  admin: null
};

// -REDUCERS
exports.default = (0, _reduxActions.handleActions)((_handleActions = {}, (0, _defineProperty3.default)(_handleActions, FETCH_METADATA_SUCCESS, function (state, _ref) {
  var payload = _ref.payload;
  return (0, _extends3.default)({}, state, payload);
}), (0, _defineProperty3.default)(_handleActions, FETCH_METADATA_FAILURE, function (state, _ref2) {
  var payload = _ref2.payload;
  return (0, _extends3.default)({}, state, { error: payload });
}), _handleActions), initialState);

/***/ }),

/***/ "./admin/ducks/resource.js":
/*!*********************************!*\
  !*** ./admin/ducks/resource.js ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.deleteResourceElementFailure = exports.deleteResourceElementSuccess = exports.deleteResourceElementRequest = exports.updateResourceElementFailure = exports.updateResourceElementSuccess = exports.updateResourceElementRequest = exports.submitResourceFailure = exports.submitResourceSuccess = exports.submitResourceRequest = exports.fetchCurrentResourceFailure = exports.fetchCurrentResourceSuccess = exports.fetchCurrentResourceRequest = exports.fetchResourceEntitiesFailure = exports.fetchResourceEntitiesSuccess = exports.fetchResourceEntitiesRequest = exports.DELETE_RESOURCE_ELEMENT_FAILURE = exports.DELETE_RESOURCE_ELEMENT_SUCCESS = exports.DELETE_RESOURCE_ELEMENT_REQUEST = exports.UPDATE_RESOURCE_ELEMENT_FAILURE = exports.UPDATE_RESOURCE_ELEMENT_SUCCESS = exports.UPDATE_RESOURCE_ELEMENT_REQUEST = exports.SUBMIT_RESOURCE_FAILURE = exports.SUBMIT_RESOURCE_SUCCESS = exports.SUBMIT_RESOURCE_REQUEST = exports.FETCH_CURRENT_RESOURCE_FAILURE = exports.FETCH_CURRENT_RESOURCE_SUCCESS = exports.FETCH_CURRENT_RESOURCE_REQUEST = exports.FETCH_RESOURCE_ENTITIES_FAILURE = exports.FETCH_RESOURCE_ENTITIES_SUCCESS = exports.FETCH_RESOURCE_ENTITIES_REQUEST = undefined;

var _defineProperty2 = __webpack_require__(/*! babel-runtime/helpers/defineProperty */ "./node_modules/babel-runtime/helpers/defineProperty.js");

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _slicedToArray2 = __webpack_require__(/*! babel-runtime/helpers/slicedToArray */ "./node_modules/babel-runtime/helpers/slicedToArray.js");

var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);

var _entries = __webpack_require__(/*! babel-runtime/core-js/object/entries */ "./node_modules/babel-runtime/core-js/object/entries.js");

var _entries2 = _interopRequireDefault(_entries);

var _assign = __webpack_require__(/*! babel-runtime/core-js/object/assign */ "./node_modules/babel-runtime/core-js/object/assign.js");

var _assign2 = _interopRequireDefault(_assign);

var _set = __webpack_require__(/*! babel-runtime/core-js/set */ "./node_modules/babel-runtime/core-js/set.js");

var _set2 = _interopRequireDefault(_set);

var _toConsumableArray2 = __webpack_require__(/*! babel-runtime/helpers/toConsumableArray */ "./node_modules/babel-runtime/helpers/toConsumableArray.js");

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

var _handleActions;

var _reduxActions = __webpack_require__(/*! redux-actions */ "./node_modules/redux-actions/es/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// -TYPES
var FETCH_RESOURCE_ENTITIES_REQUEST = exports.FETCH_RESOURCE_ENTITIES_REQUEST = "resource/entities/fetch/REQUEST";
var FETCH_RESOURCE_ENTITIES_SUCCESS = exports.FETCH_RESOURCE_ENTITIES_SUCCESS = "resource/entities/fetch/SUCCESS";
var FETCH_RESOURCE_ENTITIES_FAILURE = exports.FETCH_RESOURCE_ENTITIES_FAILURE = "resource/entities/fetch/FAILURE";

var FETCH_CURRENT_RESOURCE_REQUEST = exports.FETCH_CURRENT_RESOURCE_REQUEST = "resource/current-resource/REQUEST";
var FETCH_CURRENT_RESOURCE_SUCCESS = exports.FETCH_CURRENT_RESOURCE_SUCCESS = "resource/current-resource/SUCCESS";
var FETCH_CURRENT_RESOURCE_FAILURE = exports.FETCH_CURRENT_RESOURCE_FAILURE = "resource/current-resource/FAILURE";

var SUBMIT_RESOURCE_REQUEST = exports.SUBMIT_RESOURCE_REQUEST = "resource/submit/REQUEST";
var SUBMIT_RESOURCE_SUCCESS = exports.SUBMIT_RESOURCE_SUCCESS = "resource/submit/SUCCESS";
var SUBMIT_RESOURCE_FAILURE = exports.SUBMIT_RESOURCE_FAILURE = "resource/submit/FAILURE";

var UPDATE_RESOURCE_ELEMENT_REQUEST = exports.UPDATE_RESOURCE_ELEMENT_REQUEST = "resource/update/REQUEST";
var UPDATE_RESOURCE_ELEMENT_SUCCESS = exports.UPDATE_RESOURCE_ELEMENT_SUCCESS = "resource/update/SUCCESS";
var UPDATE_RESOURCE_ELEMENT_FAILURE = exports.UPDATE_RESOURCE_ELEMENT_FAILURE = "resource/update/FAILURE";

var DELETE_RESOURCE_ELEMENT_REQUEST = exports.DELETE_RESOURCE_ELEMENT_REQUEST = "resource/delete/REQUEST";
var DELETE_RESOURCE_ELEMENT_SUCCESS = exports.DELETE_RESOURCE_ELEMENT_SUCCESS = "resource/delete/SUCCESS";
var DELETE_RESOURCE_ELEMENT_FAILURE = exports.DELETE_RESOURCE_ELEMENT_FAILURE = "resource/delete/FAILURE";

// -ACTIONS
var fetchResourceEntitiesRequest = exports.fetchResourceEntitiesRequest = (0, _reduxActions.createAction)(FETCH_RESOURCE_ENTITIES_REQUEST);
var fetchResourceEntitiesSuccess = exports.fetchResourceEntitiesSuccess = (0, _reduxActions.createAction)(FETCH_RESOURCE_ENTITIES_SUCCESS);
var fetchResourceEntitiesFailure = exports.fetchResourceEntitiesFailure = (0, _reduxActions.createAction)(FETCH_RESOURCE_ENTITIES_FAILURE);

var fetchCurrentResourceRequest = exports.fetchCurrentResourceRequest = (0, _reduxActions.createAction)(FETCH_CURRENT_RESOURCE_REQUEST);
var fetchCurrentResourceSuccess = exports.fetchCurrentResourceSuccess = (0, _reduxActions.createAction)(FETCH_CURRENT_RESOURCE_SUCCESS);
var fetchCurrentResourceFailure = exports.fetchCurrentResourceFailure = (0, _reduxActions.createAction)(FETCH_CURRENT_RESOURCE_FAILURE);

var submitResourceRequest = exports.submitResourceRequest = (0, _reduxActions.createAction)(SUBMIT_RESOURCE_REQUEST);
var submitResourceSuccess = exports.submitResourceSuccess = (0, _reduxActions.createAction)(SUBMIT_RESOURCE_SUCCESS);
var submitResourceFailure = exports.submitResourceFailure = (0, _reduxActions.createAction)(SUBMIT_RESOURCE_FAILURE);

var updateResourceElementRequest = exports.updateResourceElementRequest = (0, _reduxActions.createAction)(UPDATE_RESOURCE_ELEMENT_REQUEST);
var updateResourceElementSuccess = exports.updateResourceElementSuccess = (0, _reduxActions.createAction)(UPDATE_RESOURCE_ELEMENT_SUCCESS);
var updateResourceElementFailure = exports.updateResourceElementFailure = (0, _reduxActions.createAction)(UPDATE_RESOURCE_ELEMENT_FAILURE);

var deleteResourceElementRequest = exports.deleteResourceElementRequest = (0, _reduxActions.createAction)(DELETE_RESOURCE_ELEMENT_REQUEST);
var deleteResourceElementSuccess = exports.deleteResourceElementSuccess = (0, _reduxActions.createAction)(DELETE_RESOURCE_ELEMENT_SUCCESS);
var deleteResourceElementFailure = exports.deleteResourceElementFailure = (0, _reduxActions.createAction)(DELETE_RESOURCE_ELEMENT_FAILURE);

// -STATE
var initialState = {
  ids: [],
  entities: {},
  name: null,
  verboseName: null,
  currentEntity: null,
  rowsPerPage: 10,
  totalCount: 0,
  currentPage: 1,
  errors: null,
  isFetching: false
};

// -REDUCERS
exports.default = (0, _reduxActions.handleActions)((_handleActions = {}, (0, _defineProperty3.default)(_handleActions, FETCH_RESOURCE_ENTITIES_REQUEST, function (state) {
  return (0, _extends3.default)({}, state, { isFetching: true });
}), (0, _defineProperty3.default)(_handleActions, FETCH_RESOURCE_ENTITIES_SUCCESS, function (state, _ref) {
  var _ref$payload = _ref.payload,
      ids = _ref$payload.ids,
      entities = _ref$payload.entities,
      name = _ref$payload.name,
      verboseName = _ref$payload.verboseName,
      rowsPerPage = _ref$payload.rowsPerPage,
      totalCount = _ref$payload.totalCount,
      currentPage = _ref$payload.currentPage;
  return (0, _extends3.default)({}, state, {
    currentEntity: null,
    ids: [].concat((0, _toConsumableArray3.default)(new _set2.default([].concat((0, _toConsumableArray3.default)(ids))))),
    entities: (0, _extends3.default)({}, entities),
    name: name,
    verboseName: verboseName,
    rowsPerPage: rowsPerPage,
    totalCount: totalCount,
    currentPage: currentPage,
    isFetching: false
  });
}), (0, _defineProperty3.default)(_handleActions, FETCH_CURRENT_RESOURCE_REQUEST, function (state) {
  return (0, _extends3.default)({}, state, { isFetching: false });
}), (0, _defineProperty3.default)(_handleActions, FETCH_CURRENT_RESOURCE_SUCCESS, function (state, _ref2) {
  var _ref2$payload = _ref2.payload,
      name = _ref2$payload.name,
      verboseName = _ref2$payload.verboseName,
      currentEntity = _ref2$payload.currentEntity,
      entities = _ref2$payload.entities;
  return (0, _extends3.default)({}, state, {
    name: name,
    verboseName: verboseName,
    currentEntity: currentEntity,
    ids: [].concat((0, _toConsumableArray3.default)(new _set2.default([].concat((0, _toConsumableArray3.default)(state.entities), [currentEntity])))),
    entities: (0, _extends3.default)({}, state.entities, entities),
    isFetching: false
  });
}), (0, _defineProperty3.default)(_handleActions, (0, _reduxActions.combineActions)(SUBMIT_RESOURCE_SUCCESS, UPDATE_RESOURCE_ELEMENT_SUCCESS), function (state, _ref3) {
  var entities = _ref3.payload.entities;
  return (0, _extends3.default)({}, state, {
    entities: (0, _extends3.default)({}, state.entities, entities)
  });
}), (0, _defineProperty3.default)(_handleActions, DELETE_RESOURCE_ELEMENT_SUCCESS, function (state, _ref4) {
  var resourceId = _ref4.payload.resourceId;
  return (0, _extends3.default)({}, state, {
    entities: _assign2.default.apply(Object, (0, _toConsumableArray3.default)((0, _entries2.default)(state.entities).filter(function (_ref5) {
      var _ref6 = (0, _slicedToArray3.default)(_ref5, 1),
          k = _ref6[0];

      return k != resourceId;
    }).map(function (_ref7) {
      var _ref8 = (0, _slicedToArray3.default)(_ref7, 2),
          k = _ref8[0],
          v = _ref8[1];

      return (0, _defineProperty3.default)({}, k, v);
    }))),
    ids: state.ids.filter(function (item) {
      return item != resourceId;
    })
  });
}), (0, _defineProperty3.default)(_handleActions, (0, _reduxActions.combineActions)(FETCH_RESOURCE_ENTITIES_FAILURE, FETCH_CURRENT_RESOURCE_FAILURE, SUBMIT_RESOURCE_FAILURE, UPDATE_RESOURCE_ELEMENT_FAILURE, DELETE_RESOURCE_ELEMENT_FAILURE), function (state, _ref10) {
  var payload = _ref10.payload;
  return (0, _extends3.default)({}, state, {
    errors: payload,
    isFetching: false
  });
}), _handleActions), initialState);

/***/ }),

/***/ "./admin/index.js":
/*!************************!*\
  !*** ./admin/index.js ***!
  \************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _reactDom = __webpack_require__(/*! react-dom */ "./node_modules/react-dom/index.js");

var _reactDom2 = _interopRequireDefault(_reactDom);

var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js");

var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/index.js");

var _createBrowserHistory = __webpack_require__(/*! history/createBrowserHistory */ "./node_modules/history/createBrowserHistory.js");

var _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory);

var _connectedReactRouter = __webpack_require__(/*! connected-react-router */ "./node_modules/connected-react-router/lib/index.js");

var _reduxSaga = __webpack_require__(/*! redux-saga */ "./node_modules/redux-saga/es/index.js");

var _reduxSaga2 = _interopRequireDefault(_reduxSaga);

var _reactTapEventPlugin = __webpack_require__(/*! react-tap-event-plugin */ "./node_modules/react-tap-event-plugin/src/injectTapEventPlugin.js");

var _reactTapEventPlugin2 = _interopRequireDefault(_reactTapEventPlugin);

var _App = __webpack_require__(/*! ./App */ "./admin/App.js");

var _App2 = _interopRequireDefault(_App);

__webpack_require__(/*! semantic-ui-css/semantic.min.css */ "./node_modules/semantic-ui-css/semantic.min.css");

__webpack_require__(/*! ./index.css */ "./admin/index.css");

var _ducks = __webpack_require__(/*! ./ducks */ "./admin/ducks/index.js");

var _ducks2 = _interopRequireDefault(_ducks);

var _sagas = __webpack_require__(/*! ./sagas */ "./admin/sagas/index.js");

var _sagas2 = _interopRequireDefault(_sagas);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var history = (0, _createBrowserHistory2.default)();
var sagaMiddleware = (0, _reduxSaga2.default)();

var composeEnhancers = _redux.compose;

if (true) {
  var composeWithDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
  if (typeof composeWithDevToolsExtension === "function") {
    composeEnhancers = composeWithDevToolsExtension;
  }
}

var store = (0, _redux.createStore)((0, _connectedReactRouter.connectRouter)(history)(_ducks2.default), composeEnhancers((0, _redux.applyMiddleware)((0, _connectedReactRouter.routerMiddleware)(history), sagaMiddleware)));

sagaMiddleware.run(_sagas2.default);

(0, _reactTapEventPlugin2.default)();

_reactDom2.default.render(_react2.default.createElement(
  _reactRedux.Provider,
  { store: store },
  _react2.default.createElement(_App2.default, { history: history })
), document.getElementById("root"));

/***/ }),

/***/ "./admin/routes/Routes.jsx":
/*!*********************************!*\
  !*** ./admin/routes/Routes.jsx ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ "./node_modules/babel-runtime/core-js/object/get-prototype-of.js");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ "./node_modules/babel-runtime/helpers/classCallCheck.js");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ "./node_modules/babel-runtime/helpers/createClass.js");

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ "./node_modules/babel-runtime/helpers/possibleConstructorReturn.js");

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ "./node_modules/babel-runtime/helpers/inherits.js");

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = __webpack_require__(/*! react */ "./node_modules/react/index.js");

var _react2 = _interopRequireDefault(_react);

var _propTypes = __webpack_require__(/*! prop-types */ "./node_modules/prop-types/index.js");

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js");

var _HomePage = __webpack_require__(/*! ../components/pages/HomePage */ "./admin/components/pages/HomePage.jsx");

var _HomePage2 = _interopRequireDefault(_HomePage);

var _ListPage = __webpack_require__(/*! ../components/pages/ListPage */ "./admin/components/pages/ListPage.jsx");

var _ListPage2 = _interopRequireDefault(_ListPage);

var _DetailPage = __webpack_require__(/*! ../components/pages/DetailPage */ "./admin/components/pages/DetailPage.jsx");

var _DetailPage2 = _interopRequireDefault(_DetailPage);

var _ErrorInternalServerPage = __webpack_require__(/*! ../components/pages/ErrorInternalServerPage */ "./admin/components/pages/ErrorInternalServerPage.jsx");

var _ErrorInternalServerPage2 = _interopRequireDefault(_ErrorInternalServerPage);

var _ErrorNotFoundPage = __webpack_require__(/*! ../components/pages/ErrorNotFoundPage */ "./admin/components/pages/ErrorNotFoundPage.jsx");

var _ErrorNotFoundPage2 = _interopRequireDefault(_ErrorNotFoundPage);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var propTypes = {
  url: _propTypes2.default.string
};

var Routes = function (_Component) {
  (0, _inherits3.default)(Routes, _Component);

  function Routes() {
    (0, _classCallCheck3.default)(this, Routes);
    return (0, _possibleConstructorReturn3.default)(this, (Routes.__proto__ || (0, _getPrototypeOf2.default)(Routes)).apply(this, arguments));
  }

  (0, _createClass3.default)(Routes, [{
    key: "render",
    value: function render() {
      var url = this.props.url;


      if (url) {
        return _react2.default.createElement(
          _reactRouterDom.Switch,
          null,
          _react2.default.createElement(_reactRouterDom.Route, { exact: true, path: url, component: _HomePage2.default }),
          _react2.default.createElement(_reactRouterDom.Route, { exact: true, path: url + ":resource/", component: _ListPage2.default }),
          _react2.default.createElement(_reactRouterDom.Route, { exact: true, path: url + ":resource/:id/", component: _DetailPage2.default }),
          _react2.default.createElement(_reactRouterDom.Route, { path: "/404/", component: _ErrorNotFoundPage2.default }),
          _react2.default.createElement(_reactRouterDom.Route, { path: "/500/", component: _ErrorInternalServerPage2.default })
        );
      }

      return null;
    }
  }]);
  return Routes;
}(_react.Component);

exports.default = Routes;


Routes.propTypes = propTypes;

/***/ }),

/***/ "./admin/routes/index.js":
/*!*******************************!*\
  !*** ./admin/routes/index.js ***!
  \*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Routes = __webpack_require__(/*! ./Routes */ "./admin/routes/Routes.jsx");

var _Routes2 = _interopRequireDefault(_Routes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _Routes2.default;

/***/ }),

/***/ "./admin/sagas/index.js":
/*!******************************!*\
  !*** ./admin/sagas/index.js ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator = __webpack_require__(/*! babel-runtime/regenerator */ "./node_modules/babel-runtime/regenerator/index.js");

var _regenerator2 = _interopRequireDefault(_regenerator);

exports.default = root;

var _effects = __webpack_require__(/*! redux-saga/effects */ "./node_modules/redux-saga/es/effects.js");

var _metadata = __webpack_require__(/*! ./metadata */ "./admin/sagas/metadata.js");

var _metadata2 = _interopRequireDefault(_metadata);

var _resource = __webpack_require__(/*! ./resource */ "./admin/sagas/resource.js");

var _resource2 = _interopRequireDefault(_resource);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/_regenerator2.default.mark(root);

function root() {
  return _regenerator2.default.wrap(function root$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return (0, _effects.all)([(0, _metadata2.default)(), (0, _resource2.default)()]);

        case 2:
        case 'end':
          return _context.stop();
      }
    }
  }, _marked, this);
}

/***/ }),

/***/ "./admin/sagas/metadata.js":
/*!*********************************!*\
  !*** ./admin/sagas/metadata.js ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator = __webpack_require__(/*! babel-runtime/regenerator */ "./node_modules/babel-runtime/regenerator/index.js");

var _regenerator2 = _interopRequireDefault(_regenerator);

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

exports.default = watchMetadata;

var _effects = __webpack_require__(/*! redux-saga/effects */ "./node_modules/redux-saga/es/effects.js");

var _metadata = __webpack_require__(/*! ../ducks/metadata */ "./admin/ducks/metadata.js");

var _api = __webpack_require__(/*! ../api */ "./admin/api.js");

var _api2 = _interopRequireDefault(_api);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/_regenerator2.default.mark(fetchMetadata),
    _marked2 = /*#__PURE__*/_regenerator2.default.mark(watchMetadata);

function fetchMetadata() {
  var metadata, client;
  return _regenerator2.default.wrap(function fetchMetadata$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return (0, _effects.call)(_api2.default.fetchMetadata);

        case 2:
          metadata = _context.sent;
          _context.next = 5;
          return (0, _effects.call)(_api2.default.fetchSwaggerSchema, metadata.schema);

        case 5:
          client = _context.sent;
          _context.next = 8;
          return (0, _effects.put)((0, _metadata.fetchMetadataSuccess)((0, _extends3.default)({}, metadata, {
            client: client
          })));

        case 8:
        case "end":
          return _context.stop();
      }
    }
  }, _marked, this);
}

function watchMetadata() {
  return _regenerator2.default.wrap(function watchMetadata$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
          _context2.next = 2;
          return (0, _effects.takeLatest)(_metadata.FETCH_METADATA_REQUEST, fetchMetadata);

        case 2:
        case "end":
          return _context2.stop();
      }
    }
  }, _marked2, this);
}

/***/ }),

/***/ "./admin/sagas/resource.js":
/*!*********************************!*\
  !*** ./admin/sagas/resource.js ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator = __webpack_require__(/*! babel-runtime/regenerator */ "./node_modules/babel-runtime/regenerator/index.js");

var _regenerator2 = _interopRequireDefault(_regenerator);

var _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ "./node_modules/babel-runtime/helpers/extends.js");

var _extends3 = _interopRequireDefault(_extends2);

exports.default = watchResource;

var _connectedReactRouter = __webpack_require__(/*! connected-react-router */ "./node_modules/connected-react-router/lib/index.js");

var _normalizr = __webpack_require__(/*! normalizr */ "./node_modules/normalizr/dist/src/index.js");

var _reduxSaga = __webpack_require__(/*! redux-saga */ "./node_modules/redux-saga/es/index.js");

var _effects = __webpack_require__(/*! redux-saga/effects */ "./node_modules/redux-saga/es/effects.js");

var _api = __webpack_require__(/*! ../api */ "./admin/api.js");

var _api2 = _interopRequireDefault(_api);

var _metadata = __webpack_require__(/*! ../ducks/metadata */ "./admin/ducks/metadata.js");

var _resource = __webpack_require__(/*! ../ducks/resource */ "./admin/ducks/resource.js");

var _schema = __webpack_require__(/*! ../schema */ "./admin/schema.js");

var _schema2 = _interopRequireDefault(_schema);

var _metadata2 = __webpack_require__(/*! ../selectors/metadata */ "./admin/selectors/metadata.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _marked = /*#__PURE__*/_regenerator2.default.mark(getSchema),
    _marked2 = /*#__PURE__*/_regenerator2.default.mark(fetchResourceCollection),
    _marked3 = /*#__PURE__*/_regenerator2.default.mark(submitResourceElement),
    _marked4 = /*#__PURE__*/_regenerator2.default.mark(updateResourceElement),
    _marked5 = /*#__PURE__*/_regenerator2.default.mark(fetchResourceElement),
    _marked6 = /*#__PURE__*/_regenerator2.default.mark(deleteResourceElement),
    _marked7 = /*#__PURE__*/_regenerator2.default.mark(watchResource);

function getSchema() {
  var client, metadata, schema;
  return _regenerator2.default.wrap(function getSchema$(_context) {
    while (1) {
      switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return (0, _effects.select)(_metadata2.selectMetadataClient);

        case 2:
          client = _context.sent;

          if (client) {
            _context.next = 13;
            break;
          }

          _context.next = 6;
          return (0, _effects.call)(_api2.default.fetchMetadata);

        case 6:
          metadata = _context.sent;
          schema = metadata.schema;
          _context.next = 10;
          return (0, _effects.call)(_api2.default.fetchSwaggerSchema, schema);

        case 10:
          client = _context.sent;
          _context.next = 13;
          return (0, _effects.put)((0, _metadata.fetchMetadataSuccess)((0, _extends3.default)({}, metadata, {
            client: client
          })));

        case 13:
          return _context.abrupt("return", client);

        case 14:
        case "end":
          return _context.stop();
      }
    }
  }, _marked, this);
}

function fetchResourceCollection(_ref) {
  var payload = _ref.payload;
  var client, resources, entities, metadataResources, name, verboseName;
  return _regenerator2.default.wrap(function fetchResourceCollection$(_context2) {
    while (1) {
      switch (_context2.prev = _context2.next) {
        case 0:
          _context2.prev = 0;
          _context2.next = 3;
          return (0, _effects.call)(_reduxSaga.delay, 500);

        case 3:
          _context2.next = 5;
          return (0, _effects.call)(getSchema);

        case 5:
          client = _context2.sent;
          _context2.next = 8;
          return (0, _effects.call)(_api2.default.fetchResourceCollection, payload, client);

        case 8:
          resources = _context2.sent;
          entities = (0, _normalizr.normalize)(resources, { data: _schema2.default.resourceCollection });
          _context2.next = 12;
          return (0, _effects.select)(_metadata2.selectMetadataResources);

        case 12:
          metadataResources = _context2.sent;
          name = payload.resourceName;
          verboseName = metadataResources[name].verbose_name;
          _context2.next = 17;
          return (0, _effects.put)((0, _resource.fetchResourceEntitiesSuccess)({
            ids: entities.result.data,
            entities: entities.entities,
            name: name,
            verboseName: verboseName,
            rowsPerPage: entities.result.meta.page_size,
            currentPage: entities.result.meta.page,
            totalCount: entities.result.meta.count
          }));

        case 17:
          _context2.next = 37;
          break;

        case 19:
          _context2.prev = 19;
          _context2.t0 = _context2["catch"](0);
          _context2.next = 23;
          return (0, _effects.put)((0, _resource.fetchResourceEntitiesFailure)(_context2.t0.message));

        case 23:
          if (!("status" in _context2.t0)) {
            _context2.next = 34;
            break;
          }

          if (!(_context2.t0.status === 404)) {
            _context2.next = 29;
            break;
          }

          _context2.next = 27;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 27:
          _context2.next = 32;
          break;

        case 29:
          if (!(_context2.t0.status >= 500)) {
            _context2.next = 32;
            break;
          }

          _context2.next = 32;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/500"));

        case 32:
          _context2.next = 37;
          break;

        case 34:
          console.error(_context2.t0);
          _context2.next = 37;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 37:
        case "end":
          return _context2.stop();
      }
    }
  }, _marked2, this, [[0, 19]]);
}

function submitResourceElement(_ref2) {
  var payload = _ref2.payload;
  var client, resource, entities, url;
  return _regenerator2.default.wrap(function submitResourceElement$(_context3) {
    while (1) {
      switch (_context3.prev = _context3.next) {
        case 0:
          _context3.prev = 0;
          _context3.next = 3;
          return getSchema();

        case 3:
          client = _context3.sent;
          _context3.next = 6;
          return (0, _effects.call)(_api2.default.submitResource, payload, client);

        case 6:
          resource = _context3.sent;
          entities = (0, _normalizr.normalize)(resource, _schema2.default.resource);
          _context3.next = 10;
          return (0, _effects.put)((0, _resource.submitResourceSuccess)({
            currentEntity: entities.result,
            entities: entities.entities
          }));

        case 10:
          _context3.next = 12;
          return (0, _effects.select)(_metadata2.selectMetadataAdmin);

        case 12:
          url = _context3.sent;
          _context3.next = 15;
          return (0, _effects.put)((0, _connectedReactRouter.push)("" + url + payload.resourceName + "/"));

        case 15:
          _context3.next = 30;
          break;

        case 17:
          _context3.prev = 17;
          _context3.t0 = _context3["catch"](0);
          _context3.next = 21;
          return (0, _effects.put)((0, _resource.submitResourceFailure)(_context3.t0));

        case 21:
          if (!("status" in _context3.t0)) {
            _context3.next = 30;
            break;
          }

          if (!(_context3.t0.status === 404)) {
            _context3.next = 27;
            break;
          }

          _context3.next = 25;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 25:
          _context3.next = 30;
          break;

        case 27:
          if (!(_context3.t0.status >= 500)) {
            _context3.next = 30;
            break;
          }

          _context3.next = 30;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/500"));

        case 30:
        case "end":
          return _context3.stop();
      }
    }
  }, _marked3, this, [[0, 17]]);
}

function updateResourceElement(_ref3) {
  var payload = _ref3.payload;
  var client, resource, entities, url;
  return _regenerator2.default.wrap(function updateResourceElement$(_context4) {
    while (1) {
      switch (_context4.prev = _context4.next) {
        case 0:
          _context4.prev = 0;
          _context4.next = 3;
          return (0, _effects.select)(_metadata2.selectMetadataClient);

        case 3:
          client = _context4.sent;
          _context4.next = 6;
          return (0, _effects.call)(_api2.default.updateResourceElement, payload, client);

        case 6:
          resource = _context4.sent;
          entities = (0, _normalizr.normalize)(resource, _schema2.default.resource);
          _context4.next = 10;
          return (0, _effects.put)((0, _resource.fetchCurrentResourceSuccess)({
            currentEntity: entities.result,
            entities: entities.entities
          }));

        case 10:
          _context4.next = 12;
          return (0, _effects.select)(_metadata2.selectMetadataAdmin);

        case 12:
          url = _context4.sent;
          _context4.next = 15;
          return (0, _effects.put)((0, _connectedReactRouter.push)("" + url + payload.resourceName + "/"));

        case 15:
          _context4.next = 30;
          break;

        case 17:
          _context4.prev = 17;
          _context4.t0 = _context4["catch"](0);
          _context4.next = 21;
          return (0, _effects.put)((0, _resource.updateResourceElementFailure)(_context4.t0));

        case 21:
          if (!("status" in _context4.t0)) {
            _context4.next = 30;
            break;
          }

          if (!(_context4.t0.status === 404)) {
            _context4.next = 27;
            break;
          }

          _context4.next = 25;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 25:
          _context4.next = 30;
          break;

        case 27:
          if (!(_context4.t0.status >= 500)) {
            _context4.next = 30;
            break;
          }

          _context4.next = 30;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/500"));

        case 30:
        case "end":
          return _context4.stop();
      }
    }
  }, _marked4, this, [[0, 17]]);
}

function fetchResourceElement(_ref4) {
  var payload = _ref4.payload;
  var client, resource, entities, metadataResources, name, verboseName;
  return _regenerator2.default.wrap(function fetchResourceElement$(_context5) {
    while (1) {
      switch (_context5.prev = _context5.next) {
        case 0:
          _context5.prev = 0;
          _context5.next = 3;
          return getSchema();

        case 3:
          client = _context5.sent;
          _context5.next = 6;
          return (0, _effects.call)(_api2.default.fetchResourceElement, payload, client);

        case 6:
          resource = _context5.sent;
          entities = (0, _normalizr.normalize)(resource, _schema2.default.resource);
          _context5.next = 10;
          return (0, _effects.select)(_metadata2.selectMetadataResources);

        case 10:
          metadataResources = _context5.sent;
          name = payload.resourceName;
          verboseName = metadataResources[name].verbose_name;
          _context5.next = 15;
          return (0, _effects.put)((0, _resource.fetchCurrentResourceSuccess)({
            name: name,
            verboseName: verboseName,
            currentEntity: entities.result,
            entities: entities.entities
          }));

        case 15:
          _context5.next = 30;
          break;

        case 17:
          _context5.prev = 17;
          _context5.t0 = _context5["catch"](0);
          _context5.next = 21;
          return (0, _effects.put)((0, _resource.fetchCurrentResourceFailure)(_context5.t0));

        case 21:
          if (!("status" in _context5.t0)) {
            _context5.next = 30;
            break;
          }

          if (!(_context5.t0.status === 404)) {
            _context5.next = 27;
            break;
          }

          _context5.next = 25;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 25:
          _context5.next = 30;
          break;

        case 27:
          if (!(_context5.t0.status >= 500)) {
            _context5.next = 30;
            break;
          }

          _context5.next = 30;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/500"));

        case 30:
        case "end":
          return _context5.stop();
      }
    }
  }, _marked5, this, [[0, 17]]);
}

function deleteResourceElement(_ref5) {
  var payload = _ref5.payload;
  var client, response, url;
  return _regenerator2.default.wrap(function deleteResourceElement$(_context6) {
    while (1) {
      switch (_context6.prev = _context6.next) {
        case 0:
          _context6.prev = 0;
          _context6.next = 3;
          return getSchema();

        case 3:
          client = _context6.sent;
          _context6.next = 6;
          return (0, _effects.call)(_api2.default.deleteResourceElement, payload, client);

        case 6:
          response = _context6.sent;
          _context6.next = 9;
          return (0, _effects.put)((0, _resource.deleteResourceElementSuccess)(payload));

        case 9:
          _context6.next = 11;
          return (0, _effects.select)(_metadata2.selectMetadataAdmin);

        case 11:
          url = _context6.sent;
          _context6.next = 14;
          return (0, _effects.put)((0, _connectedReactRouter.push)("" + url + payload.resourceName + "/"));

        case 14:
          _context6.next = 29;
          break;

        case 16:
          _context6.prev = 16;
          _context6.t0 = _context6["catch"](0);
          _context6.next = 20;
          return (0, _effects.put)((0, _resource.deleteResourceElementFailure)(_context6.t0));

        case 20:
          if (!("status" in _context6.t0)) {
            _context6.next = 29;
            break;
          }

          if (!(_context6.t0.status === 404)) {
            _context6.next = 26;
            break;
          }

          _context6.next = 24;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/404"));

        case 24:
          _context6.next = 29;
          break;

        case 26:
          if (!(_context6.t0.status >= 500)) {
            _context6.next = 29;
            break;
          }

          _context6.next = 29;
          return (0, _effects.put)((0, _connectedReactRouter.push)("/500"));

        case 29:
        case "end":
          return _context6.stop();
      }
    }
  }, _marked6, this, [[0, 16]]);
}

function watchResource() {
  return _regenerator2.default.wrap(function watchResource$(_context7) {
    while (1) {
      switch (_context7.prev = _context7.next) {
        case 0:
          _context7.next = 2;
          return (0, _effects.takeLatest)(_resource.FETCH_RESOURCE_ENTITIES_REQUEST, fetchResourceCollection);

        case 2:
          _context7.next = 4;
          return (0, _effects.takeLatest)(_resource.SUBMIT_RESOURCE_REQUEST, submitResourceElement);

        case 4:
          _context7.next = 6;
          return (0, _effects.takeLatest)(_resource.FETCH_CURRENT_RESOURCE_REQUEST, fetchResourceElement);

        case 6:
          _context7.next = 8;
          return (0, _effects.takeLatest)(_resource.UPDATE_RESOURCE_ELEMENT_REQUEST, updateResourceElement);

        case 8:
          _context7.next = 10;
          return (0, _effects.takeLatest)(_resource.DELETE_RESOURCE_ELEMENT_REQUEST, deleteResourceElement);

        case 10:
        case "end":
          return _context7.stop();
      }
    }
  }, _marked7, this);
}

/***/ }),

/***/ "./admin/schema.js":
/*!*************************!*\
  !*** ./admin/schema.js ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _normalizr = __webpack_require__(/*! normalizr */ "./node_modules/normalizr/dist/src/index.js");

exports.default = {
  resource: new _normalizr.schema.Entity("resource"),
  resourceCollection: new _normalizr.schema.Array(new _normalizr.schema.Entity("resource"))
};

/***/ }),

/***/ "./admin/selectors/metadata.js":
/*!*************************************!*\
  !*** ./admin/selectors/metadata.js ***!
  \*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.selectMetadataResources = exports.selectMetadataClient = exports.selectMetadataSchema = exports.selectMetadataAdmin = exports.selectMetadata = undefined;

var _reselect = __webpack_require__(/*! reselect */ "./node_modules/reselect/lib/index.js");

var selectMetadata = exports.selectMetadata = function selectMetadata(state) {
  return state.metadata;
};
var selectMetadataAdmin = exports.selectMetadataAdmin = (0, _reselect.createSelector)(selectMetadata, function (state) {
  return state.admin;
});
var selectMetadataSchema = exports.selectMetadataSchema = (0, _reselect.createSelector)(selectMetadata, function (state) {
  return state.schema;
});
var selectMetadataClient = exports.selectMetadataClient = (0, _reselect.createSelector)(selectMetadata, function (state) {
  return state.client;
});
var selectMetadataResources = exports.selectMetadataResources = (0, _reselect.createSelector)(selectMetadata, function (state) {
  return state.resources;
});

/***/ }),

/***/ "./admin/selectors/resource.js":
/*!*************************************!*\
  !*** ./admin/selectors/resource.js ***!
  \*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.selectResourceIsFetching = exports.selectResourceErrors = exports.selectResourceCurrentPage = exports.selectResourceTotalCount = exports.selectResourceRowsPerPage = exports.selectResourceCurrentEntity = exports.selectResourceVerboseName = exports.selectResourceName = exports.selectResourceEntities = exports.selectResourceIds = exports.selectResource = undefined;

var _normalizr = __webpack_require__(/*! normalizr */ "./node_modules/normalizr/dist/src/index.js");

var _reselect = __webpack_require__(/*! reselect */ "./node_modules/reselect/lib/index.js");

var _schema = __webpack_require__(/*! ../schema */ "./admin/schema.js");

var _schema2 = _interopRequireDefault(_schema);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var selectResource = exports.selectResource = function selectResource(state) {
  return state.resource;
};
var selectResourceIds = exports.selectResourceIds = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.ids;
});
var selectResourceEntities = exports.selectResourceEntities = (0, _reselect.createSelector)(selectResource, function (state) {
  return (0, _normalizr.denormalize)(state.ids, _schema2.default.resourceCollection, state.entities);
});
var selectResourceName = exports.selectResourceName = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.name;
});
var selectResourceVerboseName = exports.selectResourceVerboseName = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.verboseName;
});
var selectResourceCurrentEntity = exports.selectResourceCurrentEntity = (0, _reselect.createSelector)(selectResource, function (state) {
  return (0, _normalizr.denormalize)(state.currentEntity, _schema2.default.resource, state.entities);
});
var selectResourceRowsPerPage = exports.selectResourceRowsPerPage = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.rowsPerPage;
});
var selectResourceTotalCount = exports.selectResourceTotalCount = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.totalCount;
});
var selectResourceCurrentPage = exports.selectResourceCurrentPage = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.currentPage;
});
var selectResourceErrors = exports.selectResourceErrors = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.errors;
});
var selectResourceIsFetching = exports.selectResourceIsFetching = (0, _reselect.createSelector)(selectResource, function (state) {
  return state.isFetching;
});

/***/ })

},[["./admin/index.js","runtime~index","styles.react","vendors~index"]]]);
//# sourceMappingURL=data:application/json;charset=utf-8;base64, 