From 867b37b76f2bbae9ce157d692062bc108070dd57 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:54:53 +0300 Subject: [PATCH] Merge pull request #12417 from overleaf/ii-history-react-toggle-switch [web] Toggle switch history migration GitOrigin-RevId: c0812d03d576bc66dd8878fa80d4ac18dd8576d0 --- .../web/frontend/extracted-translations.json | 3 ++ .../components/change-list/change-list.tsx | 14 ++++-- .../components/change-list/toggle-switch.tsx | 44 ++++++++++++++++++- .../history/context/history-context.tsx | 18 +++----- .../context/types/history-context-value.ts | 4 +- .../stories/history/toggle-switch.stories.tsx | 41 +++++++++++++++++ .../stylesheets/app/editor/history-react.less | 8 ++++ .../history/components/chnage-list.spec.tsx | 35 +++++++++++++++ 8 files changed, 147 insertions(+), 20 deletions(-) create mode 100644 services/web/frontend/stories/history/toggle-switch.stories.tsx create mode 100644 services/web/test/frontend/features/history/components/chnage-list.spec.tsx diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 0bbc244b92..a85966ac07 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -347,6 +347,9 @@ "hide_document_preamble": "", "hide_outline": "", "history": "", + "history_view_a11y_description": "", + "history_view_all": "", + "history_view_labels": "", "hotkey_add_a_comment": "", "hotkey_autocomplete_menu": "", "hotkey_beginning_of_document": "", diff --git a/services/web/frontend/js/features/history/components/change-list/change-list.tsx b/services/web/frontend/js/features/history/components/change-list/change-list.tsx index ed66c4cbbd..f93018de73 100644 --- a/services/web/frontend/js/features/history/components/change-list/change-list.tsx +++ b/services/web/frontend/js/features/history/components/change-list/change-list.tsx @@ -1,15 +1,21 @@ +import usePersistedState from '../../../../shared/hooks/use-persisted-state' import ToggleSwitch from './toggle-switch' import Main from './main' -import { useState } from 'react' +import { useHistoryContext } from '../../context/history-context' function ChangeList() { - // eslint-disable-next-line no-unused-vars - const [labelsOnly, setLabelsOnly] = useState(false) + const { projectId, isError } = useHistoryContext() + const [labelsOnly, setLabelsOnly] = usePersistedState( + `history.userPrefs.showOnlyLabels.${projectId}`, + false + ) return (