1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/packages/unleash-frontend-next/src/component/history/history-list-component.jsx
2020-02-20 08:30:32 +01:00

59 lines
1.4 KiB
JavaScript

import React, { Component } from 'react';
import { List, ListItem, ListSubHeader } from 'react-toolbox/lib/list';
class HistoryList extends Component {
componentDidMount () {
this.props.fetchHistory();
}
getIcon (type) {
if (type.indexOf('created') > -1 ) {
return 'add';
}
if (type.indexOf('deleted') > -1 ) {
return 'remove';
}
if (type.indexOf('updated') > -1 ) {
return 'update';
}
if (type.indexOf('archived') > -1 ) {
return 'archived';
}
return 'bookmark';
}
render () {
const { history } = this.props; // eslint-disable-line no-shadow
return (
<List ripple >
<ListSubHeader caption="History" />
{history.length > 0 ? history.map((log, i) => {
const actions = [];
const icon = this.getIcon(log.type);
const caption = <div>{log.data.name} <small>{log.type}</small></div>;
return (
<ListItem key={i}
leftIcon={icon}
rightActions={actions}
caption={caption}
legend={log.createdAt} />
);
}) : <ListItem caption="No log entries" />}
</List>
);
}
}
export default HistoryList;