<commit_before>import React from 'react';
import { Link } from 'react-router-dom';
import { FormattedMessage } from 'react-intl';
import { ButtonGroup } from '@blueprintjs/core';

import { Toolbar, CloseButton, DownloadButton } from 'src/components/Toolbar';
import getEntityLink from 'src/util/getEntityLink';


class EntityToolbar extends React.Component {
  render() {
    const { entity, isPreview } = this.props;
    const isThing = entity && entity.schema.isThing();

    return (
      <Toolbar className="toolbar-preview">
        <ButtonGroup>
          {isPreview && isThing && (
            <Link to={getEntityLink(entity)} className="bp3-button button-link">
              <span className="bp3-icon-share" />
              <FormattedMessage id="sidebar.open" defaultMessage="Open" />
            </Link>
          )}
          {entity.schema.isDocument() && (
            <DownloadButton document={entity} />
          )}
        </ButtonGroup>
        { isPreview && (
          <CloseButton />
        )}
      </Toolbar>
    );
  }
}

export default EntityToolbar;<commit_msg>hid entity toolbar when no buttons present<commit_after>import React from 'react';
import { Link } from 'react-router-dom';
import { FormattedMessage } from 'react-intl';
import { ButtonGroup } from '@blueprintjs/core';

import { Toolbar, CloseButton, DownloadButton } from 'src/components/Toolbar';
import getEntityLink from 'src/util/getEntityLink';


class EntityToolbar extends React.Component {
  render() {
    const { entity, isPreview } = this.props;
    const isThing = entity && entity.schema.isThing();
    const isDocument = entity && entity.schema.isDocument();
    const showDownloadButton = isDocument && entity.links && entity.links.file;

    if (!isPreview && !showDownloadButton) {
      return null;
    }

    return (
      <Toolbar className="toolbar-preview">
        <ButtonGroup>
          {isPreview && isThing && (
            <Link to={getEntityLink(entity)} className="bp3-button button-link">
              <span className="bp3-icon-share" />
              <FormattedMessage id="sidebar.open" defaultMessage="Open" />
            </Link>
          )}
          {showDownloadButton && (
            <DownloadButton document={entity} />
          )}
        </ButtonGroup>
        { isPreview && (
          <CloseButton />
        )}
      </Toolbar>
    );
  }
}

export default EntityToolbar;
{'fraction_non_alphanumeric': 0.12919254658385093, 'fraction_numerical': 0.0016563146997929607, 'mean_word_length': 2.6005961251862892, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4362038', 'n_tokens_mistral': 665, 'n_tokens_neox': 662, 'n_words': 149}