All files / src/components/debugger DebuggerState.tsx

0% Statements 0/27
0% Branches 0/8
0% Functions 0/7
0% Lines 0/25

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74                                                                                                                                                   
import React, { useCallback } from "react";
import { useAppDispatch, useAppSelector } from "store/hooks";
import styled from "styled-components";
import { SplitPaneHeader } from "ui/splitpane/SplitPaneHeader";
import { getSettings } from "store/features/settings/settingsState";
import settingsActions from "store/features/settings/settingsActions";
import DebuggerSceneLink from "components/debugger/DebuggerSceneLink";
import l10n from "shared/lib/lang/l10n";
 
const Content = styled.div`
  background: ${(props) => props.theme.colors.scripting.form.background};
  padding: 10px;
`;
 
export const DataRow = styled.div`
  padding-bottom: 5px;
  &:last-of-type {
    padding-bottom: 0;
  }
`;
 
export const DataLabel = styled.span`
  font-weight: bold;
  padding-right: 5px;
`;
 
const DebuggerState = () => {
  const dispatch = useAppDispatch();
 
  const sceneMap = useAppSelector((state) => state.debug.sceneMap);
  const currentSceneSymbol = useAppSelector(
    (state) => state.debug.currentSceneSymbol
  );
  const scriptContexts = useAppSelector((state) => state.debug.scriptContexts);
 
  const currentSceneData = sceneMap[currentSceneSymbol] ?? undefined;
 
  const isCollapsed = useAppSelector((state) =>
    getSettings(state).debuggerCollapsedPanes.includes("state")
  );
 
  const onToggleCollapsed = useCallback(() => {
    dispatch(settingsActions.toggleDebuggerPaneCollapsed("state"));
  }, [dispatch]);
 
  return (
    <>
      <SplitPaneHeader
        onToggle={onToggleCollapsed}
        collapsed={isCollapsed}
        variant="secondary"
      >
        {l10n("FIELD_CURRENT_STATE")}
      </SplitPaneHeader>
      {!isCollapsed && (
        <Content>
          {currentSceneData && (
            <DataRow>
              <DataLabel>{l10n("SCENE")}:</DataLabel>
              <DebuggerSceneLink id={currentSceneData.id} />
            </DataRow>
          )}
          <DataRow>
            <DataLabel>{l10n("FIELD_THREADS")}:</DataLabel>
            {scriptContexts.length}
          </DataRow>
        </Content>
      )}
    </>
  );
};
 
export default DebuggerState;