Merge pull request #21028 from overleaf/td-bs5-history-header

Migrate history header to Bootstrap 5

GitOrigin-RevId: de875cc698b0892d87d6f120131fc7fc3dc24e51
This commit is contained in:
Tim Down 2024-10-16 11:50:40 +01:00 committed by Copybot
parent 76f8680db0
commit 17b66e495f
6 changed files with 93 additions and 50 deletions

View file

@ -3,6 +3,7 @@ import { Diff } from '../../services/types/doc'
import DocumentDiffViewer from './document-diff-viewer' import DocumentDiffViewer from './document-diff-viewer'
import LoadingSpinner from '../../../../shared/components/loading-spinner' import LoadingSpinner from '../../../../shared/components/loading-spinner'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import OLNotification from '@/features/ui/components/ol/ol-notification'
type MainProps = { type MainProps = {
diff: Nullable<Diff> diff: Nullable<Diff>
@ -23,7 +24,7 @@ function Main({ diff, isLoading }: MainProps) {
if (diff.binary) { if (diff.binary) {
return ( return (
<div className="history-content"> <div className="history-content">
<div className="alert alert-info">{t('binary_history_error')}</div> <OLNotification content={t('binary_history_error')} type="info" />
</div> </div>
) )
} }

View file

@ -1,6 +1,12 @@
import { formatTime } from '@/features/utils/format-date' import { formatTime } from '@/features/utils/format-date'
import { useMemo } from 'react' import { useMemo } from 'react'
import { Button, Modal } from 'react-bootstrap' import OLModal, {
OLModalBody,
OLModalFooter,
OLModalHeader,
OLModalTitle,
} from '@/features/ui/components/ol/ol-modal'
import OLButton from '@/features/ui/components/ol/ol-button'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
type RestoreFileConfirmModalProps = { type RestoreFileConfirmModalProps = {
@ -21,21 +27,21 @@ export function RestoreFileConfirmModal({
const time = useMemo(() => formatTime(timestamp, 'h:mm a'), [timestamp]) const time = useMemo(() => formatTime(timestamp, 'h:mm a'), [timestamp])
return ( return (
<Modal show={show} onHide={onHide}> <OLModal show={show} onHide={onHide}>
<Modal.Header closeButton> <OLModalHeader closeButton>
<Modal.Title>{t('restore_file_confirmation_title')}</Modal.Title> <OLModalTitle>{t('restore_file_confirmation_title')}</OLModalTitle>
</Modal.Header> </OLModalHeader>
<Modal.Body> <OLModalBody>
{t('restore_file_confirmation_message', { date, time })} {t('restore_file_confirmation_message', { date, time })}
</Modal.Body> </OLModalBody>
<Modal.Footer> <OLModalFooter>
<Button bsStyle={null} className="btn-secondary" onClick={onHide}> <OLButton variant="secondary" onClick={onHide}>
{t('cancel')} {t('cancel')}
</Button> </OLButton>
<Button bsStyle={null} className="btn-primary" onClick={onConfirm}> <OLButton variant="primary" onClick={onConfirm}>
{t('restore')} {t('restore')}
</Button> </OLButton>
</Modal.Footer> </OLModalFooter>
</Modal> </OLModal>
) )
} }

View file

@ -1,4 +1,10 @@
import { Button, Modal } from 'react-bootstrap' import OLModal, {
OLModalBody,
OLModalFooter,
OLModalHeader,
OLModalTitle,
} from '@/features/ui/components/ol/ol-modal'
import OLButton from '@/features/ui/components/ol/ol-button'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
export function RestoreFileErrorModal({ export function RestoreFileErrorModal({
@ -9,20 +15,16 @@ export function RestoreFileErrorModal({
const { t } = useTranslation() const { t } = useTranslation()
return ( return (
<Modal show onHide={resetErrorBoundary}> <OLModal show onHide={resetErrorBoundary}>
<Modal.Header closeButton> <OLModalHeader closeButton>
<Modal.Title>{t('restore_file_error_title')}</Modal.Title> <OLModalTitle>{t('restore_file_error_title')}</OLModalTitle>
</Modal.Header> </OLModalHeader>
<Modal.Body>{t('restore_file_error_message')}</Modal.Body> <OLModalBody>{t('restore_file_error_message')}</OLModalBody>
<Modal.Footer> <OLModalFooter>
<Button <OLButton variant="secondary" onClick={resetErrorBoundary}>
bsStyle={null}
className="btn-secondary"
onClick={resetErrorBoundary}
>
{t('close')} {t('close')}
</Button> </OLButton>
</Modal.Footer> </OLModalFooter>
</Modal> </OLModal>
) )
} }

View file

@ -1,4 +1,4 @@
import { Button } from 'react-bootstrap' import OLButton from '@/features/ui/components/ol/ol-button'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useRestoreDeletedFile } from '../../../context/hooks/use-restore-deleted-file' import { useRestoreDeletedFile } from '../../../context/hooks/use-restore-deleted-file'
import type { HistoryContextValue } from '../../../context/types/history-context-value' import type { HistoryContextValue } from '../../../context/types/history-context-value'
@ -15,14 +15,18 @@ export default function ToolbarRestoreFileButton({
const { restoreDeletedFile, isLoading } = useRestoreDeletedFile() const { restoreDeletedFile, isLoading } = useRestoreDeletedFile()
return ( return (
<Button <OLButton
className="btn-secondary history-react-toolbar-restore-file-button" variant="secondary"
bsSize="xs" size="sm"
bsStyle={null} className="history-react-toolbar-restore-file-button"
isLoading={isLoading}
onClick={() => restoreDeletedFile(selection)} onClick={() => restoreDeletedFile(selection)}
disabled={isLoading} bs3Props={{
bsSize: 'xsmall',
loading: isLoading ? `${t('restoring')}` : t('restore_file'),
}}
> >
{isLoading ? `${t('restoring')}` : t('restore_file')} {t('restore_file')}
</Button> </OLButton>
) )
} }

View file

@ -1,4 +1,4 @@
import { Button } from 'react-bootstrap' import OLButton from '@/features/ui/components/ol/ol-button'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import type { HistoryContextValue } from '../../../context/types/history-context-value' import type { HistoryContextValue } from '../../../context/types/history-context-value'
import withErrorBoundary from '@/infrastructure/error-boundary' import withErrorBoundary from '@/infrastructure/error-boundary'
@ -33,15 +33,18 @@ function ToolbarRestoreFileToVersionButton({
}} }}
onHide={() => setShowConfirmModal(false)} onHide={() => setShowConfirmModal(false)}
/> />
<Button <OLButton
className="btn-secondary" variant="secondary"
bsSize="xs" size="sm"
bsStyle={null} isLoading={isLoading}
onClick={() => setShowConfirmModal(true)} onClick={() => setShowConfirmModal(true)}
disabled={isLoading} bs3Props={{
bsSize: 'xsmall',
loading: isLoading ? `${t('restoring')}` : t('restore_file_version'),
}}
> >
{isLoading ? `${t('restoring')}` : t('restore_file_version')} {t('restore_file_version')}
</Button> </OLButton>
</> </>
) )
} }

View file

@ -1,3 +1,15 @@
:root {
--history-react-header-bg: var(--bg-dark-secondary);
--history-react-header-color: var(--content-primary-dark);
--history-react-separator-color: var(--border-divider-dark);
}
@include theme('light') {
--history-react-header-bg: var(--bg-light-primary);
--history-react-header-color: var(--content-primary);
--history-react-separator-color: var(--border-divider);
}
history-root { history-root {
height: 100%; height: 100%;
display: block; display: block;
@ -20,8 +32,8 @@ history-root {
@include body-sm; @include body-sm;
height: 40px; height: 40px;
background-color: var(--bg-dark-secondary); background-color: var(--history-react-header-bg);
color: var(--content-primary-dark); color: var(--history-react-header-color);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
@ -34,7 +46,7 @@ history-root {
flex-direction: column; flex-direction: column;
.toolbar-container { .toolbar-container {
border-bottom: 1px solid var(--border-divider-dark); border-bottom: 1px solid var(--history-react-separator-color);
padding: 0 var(--spacing-04); padding: 0 var(--spacing-04);
} }
@ -55,7 +67,7 @@ history-root {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 320px; width: 320px;
border-left: 1px solid var(--border-divider-dark); border-left: 1px solid var(--history-react-separator-color);
box-sizing: content-box; box-sizing: content-box;
} }
@ -292,6 +304,21 @@ history-root {
text-align: center; text-align: center;
} }
.history-react-toolbar {
display: flex;
align-items: center;
gap: var(--spacing-04);
.history-react-toolbar-file-info {
flex: 1;
text-align: right;
}
.history-react-toolbar-time {
font-weight: 700;
}
}
.history-paywall-prompt { .history-paywall-prompt {
padding: var(--history-change-list-padding); padding: var(--history-change-list-padding);