<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 { connect } from "react-redux";

import * as styles from "readium-desktop/renderer/assets/styles/myBooks.css";

import { libraryActions } from "readium-desktop/renderer/redux/actions";

import { PublicationView } from "readium-desktop/common/views/publication";

interface PublicationListElementProps {
    publication: PublicationView;
    displayPublicationInfo?: any;
}

interface PublicationListElementState {
    menuOpen: boolean;
}

export class PublicationListElement extends React.Component<PublicationListElementProps, PublicationListElementState> {
    constructor(props: any) {
        super(props);

        this.state = {
            menuOpen: false,
        }

        this.displayPublicationInfo = this.displayPublicationInfo.bind(this);
        this.switchMenu = this.switchMenu.bind(this);
    }

    public render(): React.ReactElement<{}>  {
        const pub = this.props.publication;

        return (
            <>
                <div className={styles.list_book_title}>
                <p className={styles.book_title} aria-label="Titre du livre">{pub.title}</p>
                <p
                    className={`${styles.book_author} ${styles.lightgrey}`}
                    aria-label="Auteur du livre"
                >
                    {pub.authors.map((author) => author).join(", ")}
                </p>
                </div>
                <p className={styles.infos_sup} aria-label="Date de sortie du livre">{pub.publishedAt}</p>
                <p className={styles.infos_sup} aria-label="Éditeur du livre">{pub.editor}</p>
                <button
                    type="button"
                    aria-haspopup="dialog"
                    aria-controls="dialog"
                    title="Voir plus"
                    onClick={this.switchMenu}
                >
                    <svg role="link" className={styles.icon_seemore}>
                        <g aria-hidden="true">
                        <path d="M0 0h24v24H0z" fill="none"/>
                        <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2
                            2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1
                            0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
                        </g>
                    </svg>
                </button>
                <div className={(this.state.menuOpen ? styles.menu_open + " " : "") + styles.list_menu}>
                    <a onClick={this.displayPublicationInfo} >Fiche livre</a>
                    <a>Retirer de la séléction</a>
                    <a>Supprimer définitivement</a>
                </div>
            </>
        );
    }

    private displayPublicationInfo(e: any) {
        e.preventDefault();
        this.props.displayPublicationInfo(this.props.publication);
    }

    private switchMenu() {
        this.setState({menuOpen: !this.state.menuOpen});
    }
}

const mapDispatchToProps = (dispatch: any, __1: PublicationListElementProps) => {
    return {
        displayPublicationInfo: (publication: PublicationView) => {
            dispatch(
                libraryActions.ActionType.PublicationInfoDisplayRequest,
            );
        },
    };
};

export default connect(undefined, mapDispatchToProps)(PublicationListElement);<commit_msg>Fix display publication from catalog list view<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 { connect } from "react-redux";

import * as styles from "readium-desktop/renderer/assets/styles/myBooks.css";

import { libraryActions } from "readium-desktop/renderer/redux/actions";

import { PublicationView } from "readium-desktop/common/views/publication";

interface PublicationListElementProps {
    publication: PublicationView;
    displayPublicationInfo?: any;
}

interface PublicationListElementState {
    menuOpen: boolean;
}

export class PublicationListElement extends React.Component<PublicationListElementProps, PublicationListElementState> {
    constructor(props: any) {
        super(props);

        this.state = {
            menuOpen: false,
        }

        this.displayPublicationInfo = this.displayPublicationInfo.bind(this);
        this.switchMenu = this.switchMenu.bind(this);
    }

    public render(): React.ReactElement<{}>  {
        const pub = this.props.publication;

        return (
            <>
                <div className={styles.list_book_title}>
                <p className={styles.book_title} aria-label="Titre du livre">{pub.title}</p>
                <p
                    className={`${styles.book_author} ${styles.lightgrey}`}
                    aria-label="Auteur du livre"
                >
                    {pub.authors.map((author) => author).join(", ")}
                </p>
                </div>
                <p className={styles.infos_sup} aria-label="Date de sortie du livre">{pub.publishedAt}</p>
                <p className={styles.infos_sup} aria-label="Éditeur du livre">{pub.editor}</p>
                <button
                    type="button"
                    aria-haspopup="dialog"
                    aria-controls="dialog"
                    title="Voir plus"
                    onClick={this.switchMenu}
                >
                    <svg role="link" className={styles.icon_seemore}>
                        <g aria-hidden="true">
                        <path d="M0 0h24v24H0z" fill="none"/>
                        <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2
                            2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1
                            0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>
                        </g>
                    </svg>
                </button>
                <div className={(this.state.menuOpen ? styles.menu_open + " " : "") + styles.list_menu}>
                    <a onClick={this.displayPublicationInfo} >Fiche livre</a>
                    <a>Retirer de la séléction</a>
                    <a>Supprimer définitivement</a>
                </div>
            </>
        );
    }

    private displayPublicationInfo(e: any) {
        e.preventDefault();
        this.props.displayPublicationInfo(this.props.publication);
    }

    private switchMenu() {
        this.setState({menuOpen: !this.state.menuOpen});
    }
}

const mapDispatchToProps = (dispatch: any, __1: PublicationListElementProps) => {
    return {
        displayPublicationInfo: (publication: PublicationView) => {
            dispatch({
                type: libraryActions.ActionType.PublicationInfoDisplayRequest,
                payload: {
                    publication: {
                        identifier: publication.identifier,
                    },
                },
            });
        },
    };
};

export default connect(undefined, mapDispatchToProps)(PublicationListElement);
{'fraction_non_alphanumeric': 0.11733684904416612, 'fraction_numerical': 0.02003955174686882, 'mean_word_length': 1.823222925195385, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2368782', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2083, 'n_words': 458}