pdf-clear-cache-button.jsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Icon from '../../../shared/components/icon'
  2. import OLButton from '@/features/ui/components/ol/ol-button'
  3. import { useTranslation } from 'react-i18next'
  4. import { memo } from 'react'
  5. import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
  6. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  7. function PdfClearCacheButton() {
  8. const { compiling, clearCache, clearingCache } = useCompileContext()
  9. const { t } = useTranslation()
  10. return (
  11. <OLButton
  12. size="sm"
  13. variant="danger"
  14. className="logs-pane-actions-clear-cache"
  15. onClick={() => clearCache()}
  16. isLoading={clearingCache}
  17. disabled={clearingCache || compiling}
  18. leadingIcon="delete"
  19. >
  20. <BootstrapVersionSwitcher
  21. bs3={
  22. <>
  23. {clearingCache ? (
  24. <Icon type="refresh" spin />
  25. ) : (
  26. <Icon type="trash-o" />
  27. )}
  28. &nbsp;
  29. </>
  30. }
  31. />
  32. <span>{t('clear_cached_files')}</span>
  33. </OLButton>
  34. )
  35. }
  36. export default memo(PdfClearCacheButton)