overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-clear-cache-button.jsx

41 lines
1.1 KiB
React
Raw Normal View History

import Icon from '../../../shared/components/icon'
2024-10-23 03:32:40 -04:00
import OLButton from '@/features/ui/components/ol/ol-button'
import { useTranslation } from 'react-i18next'
import { memo } from 'react'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
2024-10-23 03:32:40 -04:00
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
function PdfClearCacheButton() {
const { compiling, clearCache, clearingCache } = useCompileContext()
const { t } = useTranslation()
return (
2024-10-23 03:32:40 -04:00
<OLButton
size="sm"
variant="danger"
className="logs-pane-actions-clear-cache"
onClick={() => clearCache()}
2024-10-23 03:32:40 -04:00
isLoading={clearingCache}
disabled={clearingCache || compiling}
2024-10-23 03:32:40 -04:00
leadingIcon="delete"
>
2024-10-23 03:32:40 -04:00
<BootstrapVersionSwitcher
bs3={
<>
{clearingCache ? (
<Icon type="refresh" spin />
) : (
<Icon type="trash-o" />
)}
&nbsp;
</>
}
/>
<span>{t('clear_cached_files')}</span>
2024-10-23 03:32:40 -04:00
</OLButton>
)
}
export default memo(PdfClearCacheButton)