From 1807f18b7d1fc2436ea06da5681d89bfe6b66d55 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Thu, 16 Feb 2023 13:21:17 +0000 Subject: [PATCH] Add a tooltip to the disabled Rich Text toggle (#11843) GitOrigin-RevId: e7be96c68d87ab1f1ed40c8e9784160689ee8e96 --- .../web/frontend/extracted-translations.json | 1 + .../components/editor-switch.tsx | 59 ++++++++++++++----- .../stylesheets/app/editor/toolbar.less | 1 - services/web/locales/en.json | 1 + 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 8cc4e5b046..b68d0a8d1f 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -636,6 +636,7 @@ "review": "", "revoke": "", "revoke_invite": "", + "rich_text_is_only_available_for_tex_files": "", "role": "", "save_money_groups_companies_research_organizations_can_save_money": "", "save_or_cancel-cancel": "", diff --git a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx index db69bf9f18..9d65d766b9 100644 --- a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx +++ b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx @@ -1,10 +1,11 @@ -import { memo, useCallback } from 'react' +import { ChangeEvent, FC, memo, useCallback } from 'react' import useScopeValue from '../../../shared/hooks/use-scope-value' import Tooltip from '../../../shared/components/tooltip' import { sendMB } from '../../../infrastructure/event-tracking' import getMeta from '../../../utils/meta' import SplitTestBadge from '../../../shared/components/split-test-badge' import isValidTeXFile from '../../../main/is-valid-tex-file' +import { useTranslation } from 'react-i18next' function Badge() { const content = ( @@ -130,22 +131,11 @@ function EditorSwitch() { ) : null} - - {!!richTextOrVisual && ( @@ -155,4 +145,45 @@ function EditorSwitch() { ) } +const RichTextToggle: FC<{ + checked: boolean + disabled: boolean + handleChange: (event: ChangeEvent) => void +}> = ({ checked, disabled, handleChange }) => { + const { t } = useTranslation() + + const toggle = ( + + + + + ) + + if (disabled) { + return ( + + {toggle} + + ) + } + + return toggle +} + export default memo(EditorSwitch) diff --git a/services/web/frontend/stylesheets/app/editor/toolbar.less b/services/web/frontend/stylesheets/app/editor/toolbar.less index c617dc048f..afe5bb2024 100644 --- a/services/web/frontend/stylesheets/app/editor/toolbar.less +++ b/services/web/frontend/stylesheets/app/editor/toolbar.less @@ -283,7 +283,6 @@ } .toggle-switch-input:disabled + .toggle-switch-label { - color: @gray-lighter; cursor: not-allowed; } diff --git a/services/web/locales/en.json b/services/web/locales/en.json index cccabcc031..1acef3f5e6 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1250,6 +1250,7 @@ "review_your_peers_work": "Review your peers’ work", "revoke": "Revoke", "revoke_invite": "Revoke Invite", + "rich_text_is_only_available_for_tex_files": "Rich Text is only available for TeX files", "ro": "Romanian", "role": "Role", "ru": "Russian",