<commit_before>// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import * as React from "react";

import { OpdsPublicationView } from "readium-desktop/common/views/opds";

import * as importAction from "readium-desktop/common/redux/actions/import";

import { withApi } from "readium-desktop/renderer/components/utils/api";

import * as styles from "readium-desktop/renderer/assets/styles/bookDetailsDialog.css";
import { TranslatorProps, withTranslator } from "readium-desktop/renderer/components/utils/translator";

interface CatalogControlsProps extends TranslatorProps {
    publication: OpdsPublicationView;
    verifyImport?: (publication: OpdsPublicationView, downloadSample?: boolean) => void;
}

export class OpdsControls extends React.Component<CatalogControlsProps, undefined> {
    public render(): React.ReactElement<{}> {
        const { publication, verifyImport } = this.props;
        const { __ } = this.props;

        if (!publication) {
            return <></>;
        }

        return publication.isFree ? (
            <button
                onClick={() => verifyImport(publication)}
                className={styles.lire}
            >
                {__("catalog.addTeaser")}
            </button>
        ) : publication.hasSample && (
            <button<commit_msg>fix: incorrect button label / locale key for OPDS teaser download (PR #421 Fixes #413)<commit_after>// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import * as React from "react";

import { OpdsPublicationView } from "readium-desktop/common/views/opds";

import * as importAction from "readium-desktop/common/redux/actions/import";

import { withApi } from "readium-desktop/renderer/components/utils/api";

import * as styles from "readium-desktop/renderer/assets/styles/bookDetailsDialog.css";
import { TranslatorProps, withTranslator } from "readium-desktop/renderer/components/utils/translator";

interface CatalogControlsProps extends TranslatorProps {
    publication: OpdsPublicationView;
    verifyImport?: (publication: OpdsPublicationView, downloadSample?: boolean) => void;
}

export class OpdsControls extends React.Component<CatalogControlsProps, undefined> {
    public render(): React.ReactElement<{}> {
        const { publication, verifyImport } = this.props;
        const { __ } = this.props;

        if (!publication) {
            return <></>;
        }

        return publication.isFree ? (
            <button
                onClick={() => verifyImport(publication)}
                className={styles.lire}
            >
                {__("catalog.addBookToLib")}
            </button>
        ) : publication.hasSample && (
            <button
{'fraction_non_alphanumeric': 0.10596833130328867, 'fraction_numerical': 0.004263093788063338, 'mean_word_length': 3.168781725888325, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3403877', 'n_tokens_mistral': 878, 'n_tokens_neox': 853, 'n_words': 250}