[web] Disable various editor buttons during network stall (#34247)

Co-authored-by: Davinder Singh <davibaweja@gmail.com>
GitOrigin-RevId: 9e169f3591cfff2fdae63b461b946fde4611f2d7
This commit is contained in:
Mathias Jakobsen
2026-09-17 11:25:49 +00:00
committed by Copybot
co-authored by Davinder Singh
parent 8741846df8
commit 1acb00407e
21 changed files with 351 additions and 20 deletions
@@ -17,6 +17,7 @@ import CommandDropdown, {
MenuStructure,
} from './command-dropdown'
import { useRailContext } from '../../context/rail-context'
import useIsNetworkStalled from '@/features/ide-react/hooks/use-is-network-stalled'
import WordCountModal from '@/features/word-count-modal/components/word-count-modal'
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
@@ -44,6 +45,7 @@ export const ToolbarMenuBar = () => {
const { setView, view } = useLayoutContext()
const { pdfUrl } = useCompileContext()
const wordCountEnabled = pdfUrl || isSplitTestEnabled('word-count-client')
const isDisabledDueToNetworkStall = useIsNetworkStalled()
const [showWordCountModal, setShowWordCountModal] = useState(false)
const [showCloneProjectModal, setShowCloneProjectModal] = useState(false)
const openProject = useOpenProject()
@@ -59,6 +61,7 @@ export const ToolbarMenuBar = () => {
{
type: 'command',
label: t('show_version_history'),
disabled: isDisabledDueToNetworkStall,
handler: () => {
setView(view === 'history' ? 'editor' : 'history')
},
@@ -76,14 +79,14 @@ export const ToolbarMenuBar = () => {
{
type: 'command',
label: t('make_a_copy'),
disabled: anonymous,
disabled: anonymous || isDisabledDueToNetworkStall,
handler: () => {
setShowCloneProjectModal(true)
},
id: 'copy_project',
},
],
[t, setView, view, wordCountEnabled, anonymous]
[t, setView, view, wordCountEnabled, anonymous, isDisabledDueToNetworkStall]
)
const fileMenuStructure: MenuStructure = useMemo(
() => [
@@ -4,11 +4,13 @@ import OLTooltip from '@/shared/components/ol/ol-tooltip'
import { useLayoutContext } from '@/shared/context/layout-context'
import { useCallback } from 'react'
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
import useIsNetworkStalled from '@/features/ide-react/hooks/use-is-network-stalled'
export default function ShowHistoryButton() {
const { t } = useTranslation()
const { view, setView, restoreView } = useLayoutContext()
const { sendEvent } = useEditorAnalytics()
const isDisabledDueToNetworkStall = useIsNetworkStalled()
const toggleHistoryOpen = useCallback(() => {
const action = view === 'history' ? 'close' : 'open'
@@ -32,6 +34,7 @@ export default function ShowHistoryButton() {
className="ide-redesign-toolbar-button-subdued ide-redesign-toolbar-button-icon"
onClick={toggleHistoryOpen}
accessibilityLabel={t('history')}
disabled={isDisabledDueToNetworkStall}
/>
</OLTooltip>
</div>