All files / src/components/debugger DebuggerScriptCtxBreadcrumb.tsx

0% Statements 0/13
0% Branches 0/17
0% Functions 0/1
0% Lines 0/13

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                                                                                                                     
import React from "react";
import DebuggerActorLink from "components/debugger/DebuggerActorLink";
import DebuggerCustomEventLink from "components/debugger/DebuggerCustomEventLink";
import DebuggerSceneLink from "components/debugger/DebuggerSceneLink";
import DebuggerTriggerLink from "components/debugger/DebuggerTriggerLink";
import type { ScriptEditorCtx } from "shared/lib/scripts/context";
import styled from "styled-components";
 
interface DebuggerScriptCtxBreadcrumbProps {
  context: ScriptEditorCtx;
}
 
const Separator = styled.span`
  margin: 0 5px;
  opacity: 0.5;
`;
 
const DebuggerScriptCtxBreadcrumb = ({
  context,
}: DebuggerScriptCtxBreadcrumbProps) => {
  const { sceneId, entityType, entityId, instanceId, scriptKey } = context;
 
  const actorId = entityType === "actorPrefab" ? instanceId : entityId;
  const triggerId = entityType === "triggerPrefab" ? instanceId : entityId;
 
  return (
    <>
      {sceneId && entityType !== "customEvent" && (
        <>
          <DebuggerSceneLink id={sceneId} />
          <Separator>/</Separator>
        </>
      )}
      {(entityType === "actor" || entityType === "actorPrefab") && actorId && (
        <>
          <DebuggerActorLink id={actorId} sceneId={sceneId} />
          <Separator>/</Separator>
        </>
      )}
      {(entityType === "trigger" || entityType === "triggerPrefab") &&
        triggerId && (
          <>
            <DebuggerTriggerLink id={triggerId} sceneId={sceneId} />
            <Separator>/</Separator>
          </>
        )}
      {entityType === "customEvent" && (
        <>
          <DebuggerCustomEventLink id={entityId} />
          <Separator>/</Separator>
        </>
      )}
      {scriptKey}
    </>
  );
};
 
export default DebuggerScriptCtxBreadcrumb;