Merge pull request #3549 from overleaf/jpa-disable-downloads-before-clearing-cache

[frontend] PdfController: disable download buttons before clearing cache

GitOrigin-RevId: e685411c12c9962732a5ab88fcb7466b0f6df7ce
This commit is contained in:
Jakob Ackermann 2021-01-12 11:24:21 +00:00 committed by Copybot
parent 36cc89299b
commit 9d47b05486
5 changed files with 31 additions and 3 deletions

View file

@ -115,6 +115,14 @@ div.full-size.pdf(ng-controller="PdfController")
}" }"
) {{ pdf.logEntries.errors.length + pdf.logEntries.warnings.length }} ) {{ pdf.logEntries.errors.length + pdf.logEntries.warnings.length }}
a(
ng-if="!pdf.downloadUrl"
disabled
href="#"
tooltip=translate('please_compile_pdf_before_download')
tooltip-placement="bottom"
)
i.fa.fa-fw.fa-download
a( a(
ng-href="{{pdf.downloadUrl || pdf.url}}" ng-href="{{pdf.downloadUrl || pdf.url}}"
target="_blank" target="_blank"

View file

@ -55,6 +55,7 @@
"pdf_compile_rate_limit_hit", "pdf_compile_rate_limit_hit",
"pdf_compile_try_again", "pdf_compile_try_again",
"pdf_rendering_error", "pdf_rendering_error",
"please_compile_pdf_before_download",
"please_set_main_file", "please_set_main_file",
"proj_timed_out_reason", "proj_timed_out_reason",
"project_flagged_too_many_compiles", "project_flagged_too_many_compiles",

View file

@ -21,12 +21,14 @@ function PreviewDownloadButton({
} }
} }
const pdfDownloadDisabled = isCompiling || !pdfDownloadUrl
const buttonElement = ( const buttonElement = (
<a <a
className="btn btn-xs btn-info" className="btn btn-xs btn-info"
disabled={isCompiling || !pdfDownloadUrl} disabled={pdfDownloadDisabled}
download download
href={pdfDownloadUrl || '#'} href={pdfDownloadUrl || '#'}
style={{ pointerEvents: 'auto' }}
> >
<Icon type="download" modifier="fw" /> <Icon type="download" modifier="fw" />
<span className="toolbar-text" style={textStyle}> <span className="toolbar-text" style={textStyle}>
@ -35,19 +37,25 @@ function PreviewDownloadButton({
</a> </a>
) )
const hideTooltip = showText && pdfDownloadUrl
return ( return (
<Dropdown <Dropdown
id="download-dropdown" id="download-dropdown"
className="toolbar-item" className="toolbar-item"
disabled={isCompiling} disabled={isCompiling}
> >
{showText ? ( {hideTooltip ? (
buttonElement buttonElement
) : ( ) : (
<OverlayTrigger <OverlayTrigger
placement="bottom" placement="bottom"
overlay={ overlay={
<Tooltip id="tooltip-download-pdf">{t('download_pdf')}</Tooltip> <Tooltip id="tooltip-download-pdf">
{pdfDownloadDisabled
? t('please_compile_pdf_before_download')
: t('download_pdf')}
</Tooltip>
} }
> >
{buttonElement} {buttonElement}

View file

@ -844,6 +844,11 @@ App.controller('PdfController', function(
$scope.pdf.clearingCache = true $scope.pdf.clearingCache = true
const deferred = $q.defer() const deferred = $q.defer()
// disable various download buttons
$scope.pdf.url = null
$scope.pdf.downloadUrl = null
$scope.pdf.outputFiles = []
$http({ $http({
url: `/project/${$scope.project_id}/output`, url: `/project/${$scope.project_id}/output`,
method: 'DELETE', method: 'DELETE',

View file

@ -363,3 +363,9 @@
.formatting-menu-item:nth-of-type(4n + 1) > .formatting-btn { .formatting-menu-item:nth-of-type(4n + 1) > .formatting-btn {
border-left: none; border-left: none;
} }
.toolbar.toolbar-pdf > a[disabled] {
cursor: not-allowed;
.opacity(0.65);
.box-shadow(none);
}