<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { computed, action } from 'mobx';
import Button from 'grommet/components/Button';
import LinkIcon from 'grommet/components/icons/base/Link';
import CircleInformationIcon from 'grommet/components/icons/base/CircleInformation';

import ShowModel from '../../models/show';

export default class InfoButton extends React.PureComponent {
    static propTypes = {
        show: PropTypes.instanceOf(ShowModel),
        onClick: PropTypes.func.isRequired,
    }

    @computed get Icon() {
        const { hasPage, external_url } = this.props.show;
        if (external_url) {
            return LinkIcon;
        } else if (hasPage) {
            return CircleInformationIcon;
        }
        return null;
    }

    @action.bound
    onClick(ev) {
        if (this.props.show.page) {
            ev.preventDefault();
            this.props.onClick();
        }
    }


    render() {
        const { Icon, onClick } = this;
        if (!Icon) { return null; }

        return (
            <Button
                icon={<Icon />}
                label="Information"
                onClick={onClick}
                target="_blank"
                href={this.props.show.external_url}
            />
        );
    }
}
<commit_msg>Only load page if external_url isn't set<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { computed, action } from 'mobx';
import Button from 'grommet/components/Button';
import LinkIcon from 'grommet/components/icons/base/Link';
import CircleInformationIcon from 'grommet/components/icons/base/CircleInformation';

import ShowModel from '../../models/show';

export default class InfoButton extends React.PureComponent {
    static propTypes = {
        show: PropTypes.instanceOf(ShowModel),
        onClick: PropTypes.func.isRequired,
    }

    @computed get Icon() {
        const { hasPage, external_url } = this.props.show;
        if (external_url) {
            return LinkIcon;
        } else if (hasPage) {
            return CircleInformationIcon;
        }
        return null;
    }

    @action.bound
    onClick(ev) {
        if (!this.props.show.external_url && this.props.show.page) {
            ev.preventDefault();
            this.props.onClick();
        }
    }


    render() {
        const { Icon, onClick } = this;
        if (!Icon) { return null; }

        return (
            <Button
                icon={<Icon />}
                label="Information"
                onClick={onClick}
                target="_blank"
                href={this.props.show.external_url}
            />
        );
    }
}

{'fraction_non_alphanumeric': 0.11214605067064083, 'fraction_numerical': 0.0, 'mean_word_length': 1.9635761589403973, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1770543', 'n_tokens_mistral': 741, 'n_tokens_neox': 735, 'n_words': 169}