diff -r 000000000000 -r 5f4fcbc80b37 clientjs/packages/dashboard-components/src/pages/term.jsx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/clientjs/packages/dashboard-components/src/pages/term.jsx Fri Sep 14 17:57:34 2018 +0200
@@ -0,0 +1,135 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
+
+import { FormattedMessage } from 'react-intl';
+import {
+ Tab,
+ Tabs,
+ TabList,
+ TabPanel,
+} from 'react-tabs';
+
+import AnnotationsCards from '../ui/AnnotationsCards';
+import DefinitionsCards from '../ui/DefinitionsCards';
+import IssoThread from '../ui/IssoThread';
+import { toBase64 } from '../utils';
+
+import './term.scss';
+
+const TermPage = ({
+ term,
+ term64,
+ defAndRef: defAndRefProp,
+ messageId,
+ activeTab,
+ location,
+ metacategories,
+ topics,
+ viaBaseUrl,
+ discussionUrl,
+}) => {
+ const defAndRef = defAndRefProp || { definitions: [], references: [] };
+ let { pathname } = location;
+ const m = pathname.match(/(\/[^/]+\/[^/]+)(?:\/\d)?(?:\/.+)?/);
+ pathname = m ? m[1] : pathname;
+ return (
+
+
{term}
+
+
+
+
+ {' ('}
+ {defAndRef.definitions && defAndRef.definitions.length}
+ {')'}
+
+
+
+ {' ('}
+ {defAndRef.references && defAndRef.references.length}
+ {')'}
+
+
+
+ {' ('}
+ {defAndRef.messagesCount}
+ {')'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+TermPage.propTypes = {
+ location: PropTypes.object.isRequired,
+ term: PropTypes.string.isRequired,
+ term64: PropTypes.string.isRequired,
+ viaBaseUrl: PropTypes.string.isRequired,
+ discussionUrl: PropTypes.string.isRequired,
+ defAndRef: PropTypes.object,
+ messageId: PropTypes.string,
+ activeTab: PropTypes.number,
+ metacategories: PropTypes.arrayOf(PropTypes.object).isRequired,
+ topics: PropTypes.arrayOf(PropTypes.string).isRequired,
+ dashboardId: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
+};
+
+TermPage.defaultProps = {
+ defAndRef: {},
+ messageId: null,
+ activeTab: 0,
+ dashboardId: '',
+};
+
+export default connect(
+ (state, props) => {
+ const { match, dashboardId } = props;
+ const { params } = match;
+
+ let { term } = (params || {});
+ term = term ? decodeURIComponent(term) : term;
+
+ const defAndRef = term ? state.terms[term] : {};
+
+ const term64 = toBase64(dashboardId ? `${dashboardId}::${term}` : term);
+
+ const { messageId } = (params || {});
+
+ const activeTab = Number((match.params || {}).activeTab || 0);
+
+ return {
+ term,
+ term64,
+ defAndRef,
+ messageId,
+ activeTab,
+ };
+ },
+)(TermPage);