Files
superset2/superset/assets/javascripts/profile/components/RecentActivity.jsx
Maxime Beauchemin e055e6d2c2 Fixing PropTypes warning messages (#2670)
* Fixing PropTypes warning message

React recently started warning on the upcoming deprecation of
React.PropTypes, the new approach is to use the `prop-types`
npm package instead.

* Fixing the tests
2017-04-24 17:39:57 -07:00

47 lines
1.1 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import $ from 'jquery';
import TableLoader from './TableLoader';
const propTypes = {
user: PropTypes.object,
};
export default class RecentActivity extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
recentActions: [],
};
}
componentWillMount() {
$.get(`/superset/recent_activity/${this.props.user.userId}/`, (data) => {
this.setState({ recentActions: data });
});
}
render() {
const mutator = function (data) {
return data.map(row => ({
action: row.action,
item: <a href={row.item_url}>{row.item_title}</a>,
time: moment.utc(row.time).fromNow(),
_time: row.time,
}));
};
return (
<div>
<TableLoader
className="table table-condensed"
mutator={mutator}
sortable
dataEndpoint={`/superset/recent_activity/${this.props.user.userId}/`}
/>
</div>
);
}
}
RecentActivity.propTypes = propTypes;