/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pydio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Pydio. If not, see . * * The latest code can be found at . */ import React from 'react' import InfoPanelCard from './InfoPanelCard' import FilePreview from '../views/FilePreview' class GenericInfoCard extends React.Component { constructor(props) { super(props) this.state = this.build(props); } componentWillReceiveProps(nextProps) { this.setState(this.build(nextProps)); } build(props) { let isMultiple, isLeaf, isDir; // Determine if we have a multiple selection or a single const {node, nodes} = props if (nodes) { isMultiple = true } else if (node) { isLeaf = node.isLeaf() isDir = !isLeaf; } else { return {ready: false}; } return { isMultiple, isLeaf, isDir, ready: true }; } render() { if (!this.state.ready) { return null } if (this.state.isMultiple) { let nodes = this.props.nodes; let more; if(nodes.length > 10){ const moreNumber = nodes.length - 10; nodes = nodes.slice(0, 10); more =
... and {moreNumber} more.
} return (
{nodes.map(function(node){ return (
{node.getLabel()}
); })} {more}
); } else { return ( ); } return null } } export {GenericInfoCard as default}