overleaf/services/web/frontend/js/features/preview/components/preview-download-button.js
Paulo Jorge Reis 4e74fb2694 Log pane improvements (#3418)
* Ordering of log entries in the new errors UI

* Don't show the expand-collapse widget when not needed; smaller font size in the raw log output

* Expose log actions in the log pane.

* Use "This project" instead of "Your project" in the new errors UI

* Better handling of long log messages; left-ellipsize the file/line number button

* Make log location more button-like; add tooltip when needed.

* Add a PDF expand button to the toolbar.

* Add a stop compilation button to the new compile UI

* Use aria-label for button accessible text; improve handling of long filenames in the log location button

* Set max-height correctly for the logs pane dropdown

* Avoid changing raw logs sizing when expanded and collapsed

* Add comment on the solution for right-to-left text and ellipsis

* Improve logs pane actions

GitOrigin-RevId: 4098d77a9ee6d333644906876b9ff27035b79319
2020-12-03 03:04:28 +00:00

75 lines
1.8 KiB
JavaScript

import React from 'react'
import PropTypes from 'prop-types'
import { Dropdown, OverlayTrigger, Tooltip } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import PreviewDownloadFileList from './preview-download-file-list'
import Icon from '../../../shared/components/icon'
function PreviewDownloadButton({
isCompiling,
outputFiles,
pdfDownloadUrl,
showText
}) {
const { t } = useTranslation()
let textStyle = {}
if (!showText) {
textStyle = {
position: 'absolute',
right: '-100vw'
}
}
const buttonElement = (
<a
className="btn btn-xs btn-info"
disabled={isCompiling || !pdfDownloadUrl}
download
href={pdfDownloadUrl || '#'}
>
<Icon type="download" modifier="fw" />
<span className="toolbar-text" style={textStyle}>
{t('download_pdf')}
</span>
</a>
)
return (
<Dropdown
id="download-dropdown"
className="toolbar-item"
disabled={isCompiling}
>
{showText ? (
buttonElement
) : (
<OverlayTrigger
placement="bottom"
overlay={
<Tooltip id="tooltip-download-pdf">{t('download_pdf')}</Tooltip>
}
>
{buttonElement}
</OverlayTrigger>
)}
<Dropdown.Toggle
className="btn btn-xs btn-info dropdown-toggle"
aria-label={t('toggle_output_files_list')}
bsStyle="info"
/>
<Dropdown.Menu id="download-dropdown-list">
<PreviewDownloadFileList fileList={outputFiles} />
</Dropdown.Menu>
</Dropdown>
)
}
PreviewDownloadButton.propTypes = {
isCompiling: PropTypes.bool.isRequired,
outputFiles: PropTypes.array,
pdfDownloadUrl: PropTypes.string,
showText: PropTypes.bool.isRequired
}
export default PreviewDownloadButton