Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.9 KB
Raw Blame
import { Center, cssVar, Drawer, Flexbox } from '@lobehub/ui';
import { Suspense, useCallback } from 'react';

import { BrandTextLoading } from '@/components/Loading';
import LoginStep from '@/features/DesktopOnboarding/steps/LoginStep';
import { useElectronStore } from '@/store/electron';
import { isMacOS } from '@/utils/platform';

import RemoteStatus from './RemoteStatus';

const isMac = isMacOS();

/** `statusHidden` drops only the title bar icon; the drawer still opens from elsewhere. */
const Connection = ({ statusHidden }: { statusHidden?: boolean }) => {
  const [isOpen, setConnectionDrawerOpen] = useElectronStore((s) => [
    s.isConnectionDrawerOpen,
    s.setConnectionDrawerOpen,
  ]);

  const handleClose = useCallback(() => {
    setConnectionDrawerOpen(false);
  }, [setConnectionDrawerOpen]);

  return (
    <>
      <RemoteStatus
        hidden={statusHidden}
        onClick={() => {
          setConnectionDrawerOpen(true);
        }}
      />
      <Drawer
        noHeader
        height={'100vh'}
        open={isOpen}
        placement={'top'}
        style={{
          background: cssVar.colorBgLayout,
        }}
        styles={{
          bodyContent: { padding: 0 },
          // Clears the Electron title bar, which only overlaps the drawer off macOS.
          extra: { insetBlockStart: isMac ? 12 : 46, insetInlineEnd: 6 },
        }}
        onClose={handleClose}
      >
        <Suspense
          fallback={
            <Center style={{ height: '100%' }}>
              <BrandTextLoading debugId="Connection" />
            </Center>
          }
        >
          <Center style={{ height: '100%', overflow: 'auto', padding: 24 }}>
            <Flexbox style={{ maxWidth: 560, width: '100%' }}>
              <LoginStep mode={'status'} onBack={handleClose} onNext={handleClose} />
            </Flexbox>
          </Center>
        </Suspense>
      </Drawer>
    </>
  );
};

export default Connection;