import EventsList from './../events/EventsList';
const Meta = ({ component }) => {
- const { qualifier, description, links, profiles, gate } = component;
+ const { qualifier, description, profiles, gate } = component;
const isProject = qualifier === 'TRK';
const isView = qualifier === 'VW' || qualifier === 'SVW';
const isDeveloper = qualifier === 'DEV';
const hasDescription = !!description;
- const hasLinks = Array.isArray(links) && !!links.length;
const hasQualityProfiles = Array.isArray(profiles) && profiles.length > 0;
const hasQualityGate = !!gate;
</div>
)}
- {hasLinks && (
- <MetaLinks links={links}/>
- )}
+ <MetaLinks component={component}/>
<MetaKey component={component}/>
</div>
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import React from 'react';
+import { getProjectLinks } from '../../../api/projectLinks';
+import { isProvided } from '../../project-admin/links/utils';
-const MetaLinks = ({ links }) => {
- return (
- <ul className="overview-meta-list big-spacer-bottom">
- {links.map(link => (
- <li key={link.type}>
- <a
- className="link-with-icon"
- href={link.href}
- target="_blank">
- <i className={`icon-color-link icon-${link.type}`}/>
-
- {link.name}
- </a>
- </li>
- ))}
- </ul>
- );
-};
-
-export default MetaLinks;
+export default class MetaLinks extends React.Component {
+ static propTypes = {
+ component: React.PropTypes.object.isRequired
+ };
+
+ state = {};
+
+ componentDidMount () {
+ this.mounted = true;
+ this.loadLinks();
+ }
+
+ componentDidUpdate (prevProps) {
+ if (prevProps.component !== this.props.component) {
+ this.loadLinks();
+ }
+ }
+
+ componentWillUnmount () {
+ this.mounted = false;
+ }
+
+ loadLinks () {
+ getProjectLinks(this.props.component.key).then(links => {
+ if (this.mounted) {
+ this.setState({ links });
+ }
+ });
+ }
+
+ renderLinkIcon (link) {
+ return isProvided(link) ?
+ <i className={`icon-color-link icon-${link.type}`}/> :
+ <i className="icon-color-link icon-detach"/>;
+ }
+
+ render () {
+ const { links } = this.state;
+
+ if (links == null || links.length === 0) {
+ return null;
+ }
+
+ return (
+ <ul className="overview-meta-list big-spacer-bottom">
+ {links.map(link => (
+ <li key={link.id}>
+ <a className="link-with-icon" href={link.url} target="_blank">
+ {this.renderLinkIcon(link)}
+
+ {link.name}
+ </a>
+ </li>
+ ))}
+ </ul>
+ );
+ }
+}