From 96e5c8a7926a75a968f3cb21eb4241b6d65bfc9a Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 8 Oct 2024 09:25:49 +0100 Subject: [PATCH] Add feedback link in spelling suggestion footer (#20867) GitOrigin-RevId: 3bef428f810b88f56a76e3645cebcf22dd5ad9e3 --- .../spelling-suggestions-feedback.tsx | 56 +++++++++++++++++++ .../spelling/spelling-suggestions.tsx | 35 ++---------- .../js/shared/components/beta-badge.tsx | 26 ++++----- .../js/shared/context/split-test-context.tsx | 20 +++++-- ...mirror-editor-spellchecker-client.spec.tsx | 6 +- services/web/types/split-test.ts | 4 ++ 6 files changed, 98 insertions(+), 49 deletions(-) create mode 100644 services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx new file mode 100644 index 0000000000..fa2dd9768e --- /dev/null +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions-feedback.tsx @@ -0,0 +1,56 @@ +import { FC, memo } from 'react' +import { useTranslation } from 'react-i18next' +import { useSplitTest } from '@/shared/context/split-test-context' +import { chooseBadgeClass } from '@/shared/components/beta-badge' +import OLTooltip from '@/features/ui/components/ol/ol-tooltip' +import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher' +import classnames from 'classnames' +import MaterialIcon from '@/shared/components/material-icon' + +const SpellingSuggestionsFeedback: FC = () => { + const { t } = useTranslation() + const { info } = useSplitTest('spell-check-client') + + if (!info) { + return null + } + + const { tooltipText, url } = info.badgeInfo ?? {} + const badgeClass = chooseBadgeClass(info.phase) + + return ( + + We are testing an updated spellchecker. +
+ Click to give feedback + + ) + } + tooltipProps={{ className: 'split-test-badge-tooltip' }} + overlayProps={{ placement: 'bottom', delay: 100 }} + > + + } + bs5={ + + } + /> + {t('give_feedback')} + +
+ ) +} + +export default memo(SpellingSuggestionsFeedback) diff --git a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx index d3ab0644f7..de53d815f0 100644 --- a/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx +++ b/services/web/frontend/js/features/source-editor/extensions/spelling/spelling-suggestions.tsx @@ -8,19 +8,14 @@ import { } from 'react' import { SpellChecker, Word } from './spellchecker' import { useTranslation } from 'react-i18next' -import SplitTestBadge from '@/shared/components/split-test-badge' import getMeta from '@/utils/meta' import classnames from 'classnames' -import { SpellCheckLanguage } from '../../../../../../types/project-settings' -import Icon from '@/shared/components/icon' import { useFeatureFlag } from '@/shared/context/split-test-context' import { sendMB } from '@/infrastructure/event-tracking' +import SpellingSuggestionsFeedback from './spelling-suggestions-feedback' const ITEMS_TO_SHOW = 8 -// TODO: messaging below the spelling suggestions -const SHOW_FOOTER = false - // (index % length) that works for negative index const wrapArrayIndex = (index: number, length: number) => ((index % length) + length) % length @@ -76,6 +71,8 @@ export const SpellingSuggestions: FC<{ } }, [spellCheckLanguage]) + const spellCheckClientEnabled = useFeatureFlag('spell-check-client') + return (