import * as React from 'react'; import { Actions } from './components/Actions'; import { GlobalSettings } from './components/GlobalSettings'; import { OtherActions } from './components/OtherActions'; import { SeoStatus } from './components/SeoStatus'; import { Spinner } from './components/Spinner'; import { FolderAndFiles } from './components/FolderAndFiles'; import { Metadata } from './components/Metadata'; import { SponsorMsg } from './components/SponsorMsg'; import useMessages from './hooks/useMessages'; import { FeatureFlag } from '../components/features/FeatureFlag'; import { FEATURE_FLAG } from '../constants/Features'; import { GitAction } from './components/Git/GitAction'; import { CustomView } from './components/CustomView'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { usePrevious } from './hooks/usePrevious'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; import { InitializeAction } from './components/InitializeAction'; import { DEFAULT_PANEL_FEATURE_FLAGS } from '../constants/DefaultFeatureFlags'; export interface IViewPanelProps { } export const ViewPanel: React.FunctionComponent = () => { const [isDevMode, setIsDevMode] = useState(false); const { loading, mediaSelecting, metadata, settings, folderAndFiles, focusElm, unsetFocus, mode } = useMessages(); const prevMediaSelection = usePrevious(mediaSelecting); const [scrollY, setScrollY] = useState(0); const scollListener = useCallback(() => { if (!mediaSelecting) { setScrollY(window.scrollY); } }, [mediaSelecting]); const isSomethingShown = useMemo(() => { const panelModeValues = (mode?.features || DEFAULT_PANEL_FEATURE_FLAGS).filter(v => v.startsWith('panel.')); if (panelModeValues.length === 0) { return false; } if (panelModeValues.includes(FEATURE_FLAG.panel.globalSettings) || panelModeValues.includes(FEATURE_FLAG.panel.actions) || panelModeValues.includes(FEATURE_FLAG.panel.recentlyModified) || panelModeValues.includes(FEATURE_FLAG.panel.otherActions) || panelModeValues.includes(FEATURE_FLAG.panel.gitActions)) { return true; } }, [mode?.features]); useEffect(() => { if (prevMediaSelection && !mediaSelecting) { setTimeout(() => { window.scrollTo({ top: scrollY, }) }, 10); } }, [mediaSelecting, prevMediaSelection]); useEffect(() => { window.addEventListener('scroll', scollListener, true); return () => { window.removeEventListener('scroll', scollListener, true); } }, [mediaSelecting]); useEffect(() => { if (window.fmExternal && window.fmExternal.isDevelopment) { setIsDevMode(true); } }, []); if (mediaSelecting) { return (

{l10n.t(LocalizationKey.panelViewPanelMediaInsert)}

); } if (loading) { return ; } return (
{ isDevMode && (
{l10n.t(LocalizationKey.developerReloadLabel)} {l10n.t(LocalizationKey.developerDevToolsLabel)}
) }
{ !loading && metadata && ( ) } {!loading && ()} { !loading && metadata && settings && settings.seo && ( ) } {!loading && settings && ( s.bulk && (s.type === 'content' || !s.type))} /> )} { !isSomethingShown && (
{l10n.t(LocalizationKey.panelBaseViewEmpty)}
) }
); };