summaryrefslogtreecommitdiff
path: root/public/bundle.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-02 14:43:46 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-02 14:43:46 +0200
commit4765d46df24561f306ce63693db01565aa4980b8 (patch)
treea1962cbea7560f33dbce7959ec10b9ddc3914d0a /public/bundle.js
parent878844a79544e23ad8cec8e342cb341d46fe605f (diff)
refactor file list
Diffstat (limited to 'public/bundle.js')
-rw-r--r--public/bundle.js245
1 files changed, 108 insertions, 137 deletions
diff --git a/public/bundle.js b/public/bundle.js
index 9a2bb86..c39637a 100644
--- a/public/bundle.js
+++ b/public/bundle.js
@@ -946,8 +946,7 @@ exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(
Object.defineProperty(exports, "__esModule", {
value: true
});
-
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+exports.FileRow = exports.FileList = undefined;
var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js");
@@ -969,148 +968,120 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
var defaultFields = new Set(['date', 'size']);
-var FileList = function (_Component) {
- _inherits(FileList, _Component);
-
- function FileList(props) {
- _classCallCheck(this, FileList);
-
- return _possibleConstructorReturn(this, (FileList.__proto__ || Object.getPrototypeOf(FileList)).call(this));
- }
+var FileList = exports.FileList = function FileList(props) {
+ var files = props.files,
+ fields = props.fields,
+ linkFiles = props.linkFiles,
+ title = props.title,
+ onClick = props.onClick,
+ _props$className = props.className,
+ className = _props$className === undefined ? "" : _props$className;
- _createClass(FileList, [{
- key: 'render',
- value: function render() {
- var _this2 = this;
-
- var _props = this.props,
- files = _props.files,
- linkFiles = _props.linkFiles,
- title = _props.title,
- _onClick = _props.onClick,
- _props$className = _props.className,
- className = _props$className === undefined ? "" : _props$className;
-
- if (!files || !files.length) return null;
- var fields = this.props.fields || defaultFields;
- if (typeof fields === 'string') {
- fields = new Set(fields.split(' '));
- } else if (!(fields instanceof Set)) {
- fields = new Set(fields);
- }
- var fileList = files.map(function (file) {
- var size = util.hush_size(file.size);
- var date = file.created_at;
- var username = file.username || "";
- return (0, _preact.h)(
- 'div',
- { 'class': 'row file', key: file.name },
- (0, _preact.h)(
- 'div',
- { className: 'filename', title: file.name || file.url },
- linkFiles && file.url ? (0, _preact.h)(
- 'a',
- { target: '_blank', href: file.url },
- file.name || file.url
- ) : (0, _preact.h)(
- 'span',
- { 'class': 'link', onClick: function onClick() {
- return _onClick(file);
- } },
- file.name || file.url
- )
- ),
- fields.has('age') && (0, _preact.h)(
- 'div',
- { className: "age " + util.carbon_date(date) },
- util.get_age(date)
- ),
- fields.has('username') && (0, _preact.h)(
- 'div',
- { className: "username" },
- username
- ),
- fields.has('date') && (0, _preact.h)(
- 'div',
- { className: "date " + util.carbon_date(date) },
- (0, _moment2.default)(date).format("YYYY-MM-DD")
- ),
- fields.has('datetime') && (0, _preact.h)(
- 'div',
- { className: "datetime " + util.carbon_date(date) },
- (0, _moment2.default)(date).format("YYYY-MM-DD h:mm a")
- ),
- fields.has('size') && (0, _preact.h)(
- 'div',
- { className: "size " + size[0] },
- size[1]
- ),
- fields.has('epoch') && (0, _preact.h)(
- 'div',
- { className: 'epoch' },
- file.epoch > 0 ? 'epoch ' + file.epoch : ' '
- ),
- (fields.has('activity') || fields.has('module')) && (0, _preact.h)(
- 'div',
- { className: 'activity' },
- fields.has('activity') && file.activity,
- fields.has('module') && file.module
- ),
- _this2.props.options && _this2.props.options(file)
- );
- });
- return (0, _preact.h)(
+ var fileList = (files || []).map(function (file) {
+ return (0, _preact.h)(FileRow, {
+ file: file,
+ fields: fields || defaultFields,
+ linkFiles: true,
+ onClick: true
+ });
+ });
+ return (0, _preact.h)(
+ 'div',
+ { className: 'rows ' + className },
+ (0, _preact.h)(
+ 'div',
+ { 'class': 'row heading' },
+ files.length ? title && (0, _preact.h)(
+ 'h3',
+ null,
+ title
+ ) : (0, _preact.h)(
+ 'h4',
+ null,
+ 'No files'
+ ),
+ (0, _preact.h)(
'div',
- { className: 'rows ' + className },
- (0, _preact.h)(
- 'div',
- { 'class': 'row heading' },
- files.length ? (0, _preact.h)(
- 'h3',
- null,
- title || Files
- ) : (0, _preact.h)(
- 'h4',
- null,
- 'No files'
- ),
- (0, _preact.h)(
- 'div',
- null,
- (loading || error) && status
- )
- ),
- (0, _preact.h)(
- 'div',
- { className: 'filelist rows' },
- fileList
- )
- );
- }
- }]);
-
- return FileList;
-}(_preact.Component);
-
-var mapStateToProps = function mapStateToProps(state) {
- return {};
+ null,
+ (loading || error) && status
+ )
+ ),
+ (0, _preact.h)(
+ 'div',
+ { className: 'filelist rows' },
+ fileList
+ )
+ );
};
-var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
- return {
- // actions: bindActionCreators(liveActions, dispatch)
- };
-};
+var FileRow = exports.FileRow = function FileRow(props) {
+ var file = props.file,
+ linkFiles = props.linkFiles,
+ _onClick = props.onClick;
-exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(FileList);
+ var fields = props.fields || defaultFields;
+ var size = util.hush_size(file.size);
+ var date = file.created_at;
+ var username = file.username || "";
+ return (0, _preact.h)(
+ 'div',
+ { 'class': 'row file', key: file.name },
+ (0, _preact.h)(
+ 'div',
+ { className: 'filename', title: file.name || file.url },
+ linkFiles && file.url ? (0, _preact.h)(
+ 'a',
+ { target: '_blank', href: file.url },
+ file.name || file.url
+ ) : (0, _preact.h)(
+ 'span',
+ { 'class': 'link', onClick: function onClick() {
+ return _onClick(file);
+ } },
+ file.name || file.url
+ )
+ ),
+ fields.has('age') && (0, _preact.h)(
+ 'div',
+ { className: "age " + util.carbon_date(date) },
+ util.get_age(date)
+ ),
+ fields.has('username') && (0, _preact.h)(
+ 'div',
+ { className: "username" },
+ username
+ ),
+ fields.has('date') && (0, _preact.h)(
+ 'div',
+ { className: "date " + util.carbon_date(date) },
+ (0, _moment2.default)(date).format("YYYY-MM-DD")
+ ),
+ fields.has('datetime') && (0, _preact.h)(
+ 'div',
+ { className: "datetime " + util.carbon_date(date) },
+ (0, _moment2.default)(date).format("YYYY-MM-DD h:mm a")
+ ),
+ fields.has('size') && (0, _preact.h)(
+ 'div',
+ { className: "size " + size[0] },
+ size[1]
+ ),
+ fields.has('epoch') && (0, _preact.h)(
+ 'div',
+ { className: 'epoch' },
+ file.epoch > 0 ? 'epoch ' + file.epoch : ' '
+ ),
+ (fields.has('activity') || fields.has('module')) && (0, _preact.h)(
+ 'div',
+ { className: 'activity' },
+ fields.has('activity') && file.activity,
+ fields.has('module') && file.module
+ ),
+ undefined.props.options && undefined.props.options(file)
+ );
+};
/***/ }),