cluedin-widget
Version:
This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.
97 lines (84 loc) • 2.27 kB
JSX
import React, { Component, PropTypes } from 'react';
import { fetchAggregationSearch } from '../../../core/action/search';
import { register } from '../../../core/registry';
import { connect } from 'react-redux';
import SearchFilter from '../../../core/components/search/SearchFilter.jsx';
import Widget from '../../../core/components/generics/widget.jsx';
class FactWidget extends Component {
static propTypes = {
dispatch: PropTypes.func,
aggregationSearchResult: PropTypes.object,
isFetchingAggregationSearch: PropTypes.bool,
entityId: PropTypes.string,
};
constructor(props) {
super(props);
this.state = {
timestamp: Date.now(),
};
}
componentWillMount() {
this.fetch();
}
fetch() {
const { entityId } = this.props;
this.props.dispatch(fetchAggregationSearch(entityId));
}
render() {
const {
aggregationSearchResult,
entityId,
isFetchingAggregationSearch,
} = this.props;
let content;
if (aggregationSearchResult && aggregationSearchResult.Facets && aggregationSearchResult.Facets.entityType) {
content = (
<SearchFilter
type="entityType"
entitydId={entityId}
allVisible={true}
usePartialLink={true}
facets={aggregationSearchResult.Facets.entityType}
name="Related Information"
/>
);
} else {
if (!isFetchingAggregationSearch) {
content = (
<div>Currently, no information related.</div>
);
}
}
return (
<Widget noMaxHeight={true} loading={isFetchingAggregationSearch} title="Related Information">
{content}
</Widget>
);
}
}
function select(state) {
return {
isFetchingAggregationSearch: state.search.isFetchingAggregationSearch,
aggregationSearchResult: state.search.aggregationSearchResult,
};
}
register('Fact', connect(select)(FactWidget), {
name: 'Fact',
displayName: 'Related Information',
description: 'Document related to the current context.',
relatedProviders: [
'dropbox',
'office365',
'googledrive',
'box',
'dropbox',
'slack',
'sharepoint',
],
tags: [
'support',
'sales',
'marketing',
],
requireEntity: false,
});