mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui-default: init
将ui-default合并至主存储库便于维护
This commit is contained in:
1 parent
6317c9057f
commit
5faa54c7ca
564 files changed
+23083
-14
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { connect } from 'react-redux';
|
||||
import TimeAgo from 'timeago-react';
|
||||
import moment from 'moment';
|
||||
import _ from 'lodash';
|
||||
|
||||
import substitute from 'vj/utils/substitute';
|
||||
import emulateAnchorClick from 'vj/utils/emulateAnchorClick';
|
||||
import { parse as parseMongoId } from 'vj/utils/mongoId';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
import * as recordEnum from 'vj/constant/record';
|
||||
|
||||
const shouldShowDetail = (data) => recordEnum.STATUS_SCRATCHPAD_SHOW_DETAIL_FLAGS[data.status];
|
||||
|
||||
const getRecordDetail = (data) => {
|
||||
if (!shouldShowDetail(data)) {
|
||||
return (
|
||||
<span className={`record-status--text ${recordEnum.STATUS_CODES[data.status]}`}>
|
||||
{recordEnum.STATUS_TEXTS[data.status]}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const stat = _.pick(
|
||||
_.groupBy(data.testCases || [], 'status'),
|
||||
_.keys(recordEnum.STATUS_SCRATCHPAD_SHORT_TEXTS),
|
||||
);
|
||||
return _.map(recordEnum.STATUS_SCRATCHPAD_SHORT_TEXTS, (text, status) => {
|
||||
const count = (stat[status] && stat[status].length) || 0;
|
||||
const cn = classNames('icol icol--stat', {
|
||||
'record-status--text': count > 0,
|
||||
[recordEnum.STATUS_CODES[data.status]]: count > 0,
|
||||
});
|
||||
return (
|
||||
<span key={text} className={cn}>
|
||||
{text}: {count}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
items: state.records.items,
|
||||
});
|
||||
|
||||
const mergeProps = (stateProps, dispatchProps, ownProps) => ({
|
||||
...dispatchProps,
|
||||
data: stateProps.items[ownProps.id],
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, null, mergeProps)(class ScratchpadRecordsRowContainer extends React.PureComponent {
|
||||
handleRowClick(ev, id) {
|
||||
const url = substitute(
|
||||
decodeURIComponent(UiContext.getRecordDetailUrl),
|
||||
{ rid: id }
|
||||
);
|
||||
emulateAnchorClick(ev, url, true);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
const submitAt = parseMongoId(data._id).timestamp * 1000;
|
||||
return data.hidden ? null : (
|
||||
<tr onClick={(ev) => this.handleRowClick(ev, data._id)}>
|
||||
<td className={`col--detail record-status--border ${recordEnum.STATUS_CODES[data.status]}`}>
|
||||
<span className={`icon record-status--icon ${recordEnum.STATUS_CODES[data.status]}`}></span>
|
||||
<span className="icol icol--pretest"></span>
|
||||
{getRecordDetail(data)}
|
||||
</td>
|
||||
<td className="col--memory">
|
||||
{shouldShowDetail(data) ? `${Math.ceil(data.memory / 1000)} MB` : '-'}
|
||||
</td>
|
||||
<td className="col--time">
|
||||
{shouldShowDetail(data) ? `${(data.time / 1000).toFixed(1)}s` : '-'}
|
||||
</td>
|
||||
<td className="col--at">
|
||||
<time data-tooltip={moment(submitAt).format('YYYY-MM-DD HH:mm:ss')}>
|
||||
<TimeAgo datetime={submitAt} locale={i18n('timeago_locale')} />
|
||||
</time>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user