From 17b66e495f1bc68d28a419e38e31c491598b2e60 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:50:40 +0100 Subject: [PATCH] Merge pull request #21028 from overleaf/td-bs5-history-header Migrate history header to Bootstrap 5 GitOrigin-RevId: de875cc698b0892d87d6f120131fc7fc3dc24e51 --- .../history/components/diff-view/main.tsx | 3 +- .../modals/restore-file-confirm-modal.tsx | 34 ++++++++++-------- .../modals/restore-file-error-modal.tsx | 32 +++++++++-------- .../toolbar/toolbar-restore-file-button.tsx | 20 ++++++----- ...toolbar-restore-file-to-version-button.tsx | 19 +++++----- .../bootstrap-5/pages/editor/history.scss | 35 ++++++++++++++++--- 6 files changed, 93 insertions(+), 50 deletions(-) diff --git a/services/web/frontend/js/features/history/components/diff-view/main.tsx b/services/web/frontend/js/features/history/components/diff-view/main.tsx index 34b961b677..29a82bc678 100644 --- a/services/web/frontend/js/features/history/components/diff-view/main.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/main.tsx @@ -3,6 +3,7 @@ import { Diff } from '../../services/types/doc' import DocumentDiffViewer from './document-diff-viewer' import LoadingSpinner from '../../../../shared/components/loading-spinner' import { useTranslation } from 'react-i18next' +import OLNotification from '@/features/ui/components/ol/ol-notification' type MainProps = { diff: Nullable @@ -23,7 +24,7 @@ function Main({ diff, isLoading }: MainProps) { if (diff.binary) { return (
-
{t('binary_history_error')}
+
) } diff --git a/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-confirm-modal.tsx b/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-confirm-modal.tsx index eb28ec71f6..33d0ccd09b 100644 --- a/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-confirm-modal.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-confirm-modal.tsx @@ -1,6 +1,12 @@ import { formatTime } from '@/features/utils/format-date' 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' type RestoreFileConfirmModalProps = { @@ -21,21 +27,21 @@ export function RestoreFileConfirmModal({ const time = useMemo(() => formatTime(timestamp, 'h:mm a'), [timestamp]) return ( - - - {t('restore_file_confirmation_title')} - - + + + {t('restore_file_confirmation_title')} + + {t('restore_file_confirmation_message', { date, time })} - - - - - - + + + ) } diff --git a/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-error-modal.tsx b/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-error-modal.tsx index 60a94c5ca0..c25c0ce14b 100644 --- a/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-error-modal.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/modals/restore-file-error-modal.tsx @@ -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' export function RestoreFileErrorModal({ @@ -9,20 +15,16 @@ export function RestoreFileErrorModal({ const { t } = useTranslation() return ( - - - {t('restore_file_error_title')} - - {t('restore_file_error_message')} - - - - + + + ) } diff --git a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-button.tsx b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-button.tsx index c8fbbc4047..ff998d5202 100644 --- a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-button.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-button.tsx @@ -1,4 +1,4 @@ -import { Button } from 'react-bootstrap' +import OLButton from '@/features/ui/components/ol/ol-button' import { useTranslation } from 'react-i18next' import { useRestoreDeletedFile } from '../../../context/hooks/use-restore-deleted-file' import type { HistoryContextValue } from '../../../context/types/history-context-value' @@ -15,14 +15,18 @@ export default function ToolbarRestoreFileButton({ const { restoreDeletedFile, isLoading } = useRestoreDeletedFile() return ( - + {t('restore_file')} + ) } diff --git a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-to-version-button.tsx b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-to-version-button.tsx index 17da50b17d..99cbccbcb0 100644 --- a/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-to-version-button.tsx +++ b/services/web/frontend/js/features/history/components/diff-view/toolbar/toolbar-restore-file-to-version-button.tsx @@ -1,4 +1,4 @@ -import { Button } from 'react-bootstrap' +import OLButton from '@/features/ui/components/ol/ol-button' import { useTranslation } from 'react-i18next' import type { HistoryContextValue } from '../../../context/types/history-context-value' import withErrorBoundary from '@/infrastructure/error-boundary' @@ -33,15 +33,18 @@ function ToolbarRestoreFileToVersionButton({ }} onHide={() => setShowConfirmModal(false)} /> - + {t('restore_file_version')} + ) } diff --git a/services/web/frontend/stylesheets/bootstrap-5/pages/editor/history.scss b/services/web/frontend/stylesheets/bootstrap-5/pages/editor/history.scss index 4615f6e9df..f04e056d7e 100644 --- a/services/web/frontend/stylesheets/bootstrap-5/pages/editor/history.scss +++ b/services/web/frontend/stylesheets/bootstrap-5/pages/editor/history.scss @@ -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 { height: 100%; display: block; @@ -20,8 +32,8 @@ history-root { @include body-sm; height: 40px; - background-color: var(--bg-dark-secondary); - color: var(--content-primary-dark); + background-color: var(--history-react-header-bg); + color: var(--history-react-header-color); display: flex; flex-direction: column; justify-content: center; @@ -34,7 +46,7 @@ history-root { flex-direction: column; .toolbar-container { - border-bottom: 1px solid var(--border-divider-dark); + border-bottom: 1px solid var(--history-react-separator-color); padding: 0 var(--spacing-04); } @@ -55,7 +67,7 @@ history-root { display: flex; flex-direction: column; width: 320px; - border-left: 1px solid var(--border-divider-dark); + border-left: 1px solid var(--history-react-separator-color); box-sizing: content-box; } @@ -292,6 +304,21 @@ history-root { 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 { padding: var(--history-change-list-padding);