<commit_before>import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Renderer from '@widget-editor/renderer';

import {
    Tooltip
} from 'vizzuality-components';

// components
import TextChart from 'components/widgets/charts/TextChart';
import LoginRequired from 'components/ui/login-required';
import Icon from 'components/ui/icon';
import Title from 'components/ui/Title';
import Spinner from 'components/ui/Spinner';
import CollectionsPanel from 'components/collections-panel';
import Modal from 'components/modal/modal-component';
import ShareModal from 'components/modal/share-modal';
import ErrorBoundary from 'components/ui/error-boundary';
import RankingWidget from './ranking-widget';

// utils
import { logEvent } from 'utils/analytics';

// helpers
import { belongsToACollection } from 'components/collections-panel/collections-panel-helpers';

// Styles
import './styles.scss';

function DashboardWidgetCard(props) {
    const { user, widget, loading, explicitHeight } = props;
    const widgetConfig = widget && widget.widgetConfig;
    const [shareModalOpen, setShareModalOpen] = useState(false);
    const [infoCardOpen, setInfoCardOpen] = useState(false);
    const widgetType = widget && widget.type;
    const metadataInfo = (widget && (widget.metadata && widget.metadata.length > 0 &&
        widget.metadata[0].info)) || {};

    const widgetLinks = metadataInfo.widgetLinks || [];
    const widgetIsEmbed = widgetConfig && widgetConfig.type === 'embed';
    const widgetIsRanking = widgetConfig && widgetConfig.type === 'ranking';
    const widgetEmbedUrl = widgetIsEmbed && widgetConfig.url;
    const isInACollection = belongsToACollection(user, widget);
    const starIconName = classnames({
        'icon-star-full': isInACollection,
        'icon-star-empty': !isInACollection
    });
    const modalIcon = classnames({
        'icon-cross': infoCardOpen,
        'icon-info': !infoCardOpen
    });

    const classNameValue = classnames({
        'c-dashboard-widget-card': true,
        '-embed-widget': widgetIsEmbed
    });

    return (
        <div className={classNameValue}>
            <header>
                <div className="header-container">
                    <Title className="-default">{widget ? widget.name : '–'}</Title>

                    <div className="buttons">
                        <ul>
                            <li><commit_msg>extra check at dashboard widget card<commit_after>import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import Renderer from '@widget-editor/renderer';

import {
    Tooltip
} from 'vizzuality-components';

// components
import TextChart from 'components/widgets/charts/TextChart';
import LoginRequired from 'components/ui/login-required';
import Icon from 'components/ui/icon';
import Title from 'components/ui/Title';
import Spinner from 'components/ui/Spinner';
import CollectionsPanel from 'components/collections-panel';
import Modal from 'components/modal/modal-component';
import ShareModal from 'components/modal/share-modal';
import ErrorBoundary from 'components/ui/error-boundary';
import RankingWidget from './ranking-widget';

// utils
import { logEvent } from 'utils/analytics';

// helpers
import { belongsToACollection } from 'components/collections-panel/collections-panel-helpers';

// Styles
import './styles.scss';

function DashboardWidgetCard(props) {
    const { user, widget, loading, explicitHeight } = props;
    const widgetConfig = widget && widget.widgetConfig;
    const [shareModalOpen, setShareModalOpen] = useState(false);
    const [infoCardOpen, setInfoCardOpen] = useState(false);
    const widgetType = widget && widget.type;
    const metadataInfo = (widget && (widget.metadata && widget.metadata.length > 0 &&
        widget.metadata[0].info)) || {};

    const widgetLinks = metadataInfo.widgetLinks || [];
    const widgetIsEmbed = widgetConfig && widgetConfig.type === 'embed';
    const widgetIsRanking = widgetConfig && widgetConfig.type === 'ranking';
    const widgetEmbedUrl = widgetIsEmbed && widgetConfig.url;
    const isInACollection = widget && belongsToACollection(user, widget);
    const starIconName = classnames({
        'icon-star-full': isInACollection,
        'icon-star-empty': !isInACollection
    });
    const modalIcon = classnames({
        'icon-cross': infoCardOpen,
        'icon-info': !infoCardOpen
    });

    const classNameValue = classnames({
        'c-dashboard-widget-card': true,
        '-embed-widget': widgetIsEmbed
    });

    return (
        <div className={classNameValue}>
            <header>
                <div className="header-container">
                    <Title className="-default">{widget ? widget.name : '–'}</Title>

                    <div className="buttons">
                        <ul>
                            <li>
{'fraction_non_alphanumeric': 0.12214357937310415, 'fraction_numerical': 0.0008088978766430738, 'mean_word_length': 3.431899641577061, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '1563420', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1318, 'n_words': 329}