diff --git a/src/components/CodeBlock.tsx b/src/components/CodeBlock.tsx new file mode 100644 index 00000000..b707de62 --- /dev/null +++ b/src/components/CodeBlock.tsx @@ -0,0 +1,100 @@ +import React from "react"; +import styled, { css } from "styled-components"; + +import { CopyButton } from "./CopyButton"; + +const CodeContainer = styled.div` + position: relative; + width: 100%; + min-width: 0; +`; + +const Pre = styled.pre<{ $maxHeight?: string; $copyable?: boolean }>` + counter-reset: line; + overflow-y: auto; + + max-height: ${({ $maxHeight = "none" }) => $maxHeight}; + margin: 0; + padding: ${({ theme }) => theme.spacing.sm} 0; + padding-right: ${({ $copyable }) => ($copyable ? "2.5rem" : 0)}; + border: 1px solid ${({ theme }) => theme.colors.border.light}; + border-radius: ${({ theme }) => theme.radius.md}; + + font: ${({ theme }) => theme.typography.code.font}; + color: ${({ theme }) => theme.colors.text.primary}; + + background: ${({ theme }) => theme.colors.background.secondary}; +`; + +// Long lines wrap, so the block never scrolls sideways. Numbers stay out of a copy. +const Line = styled.span<{ $numbered: boolean }>` + display: block; + padding-inline: ${({ theme }) => theme.spacing.md}; + white-space: pre-wrap; + overflow-wrap: anywhere; + + ${({ $numbered, theme }) => + $numbered && + css` + counter-increment: line; + display: grid; + grid-template-columns: 2.5em minmax(0, 1fr); + padding-left: ${theme.spacing.xs}; + + &::before { + content: counter(line); + padding-right: ${theme.spacing.sm}; + color: ${theme.colors.text.tertiary}; + text-align: right; + user-select: none; + } + `} +`; + +const CopyCorner = styled.div` + position: absolute; + top: ${({ theme }) => theme.spacing.xs}; + right: ${({ theme }) => theme.spacing.xs}; +`; + +export interface CodeBlockProps extends React.HTMLAttributes { + $code: string; + $copyable?: boolean; + $maxHeight?: string; +} + +/** + * Read-only block of code or preformatted text. Lines are numbered when there is more than one. + * @param $code - The text to show. + * @param $copyable - Shows a copy button in the top-right corner (default: false). + * @param $maxHeight - CSS max-height; longer content scrolls (default: none). + * @example + * + */ +export const CodeBlock: React.FC = ({ + $code, + $copyable = false, + $maxHeight, + ...rest +}) => { + const lines = $code.split("\n"); + const numbered = lines.length > 1; + return ( + +
+        {lines.map((line, index) => (
+          
+            {line || " "}
+          
+        ))}
+      
+ {$copyable && ( + + + + )} +
+ ); +}; + +export default CodeBlock; diff --git a/src/components/index.ts b/src/components/index.ts index d3a92fcd..ddf130bb 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,6 +1,7 @@ // Export all styled components for easy importing export * from "./Badge"; export * from "./Button"; +export * from "./CodeBlock"; export * from "./CodeEditor"; export * from "./ConfirmDialog"; export * from "./Containers"; diff --git a/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.styles.tsx b/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.styles.tsx index 2bea185b..1fdce9e2 100644 --- a/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.styles.tsx +++ b/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.styles.tsx @@ -14,18 +14,6 @@ export const DetailedItemSummary = styled.div` color: ${({ theme }) => theme.colors.text.secondary}; `; -export const CodeBlock = styled.pre` - width: 100%; - background: ${({ theme }) => theme.colors.background.secondary}; - border: 1px solid ${({ theme }) => theme.colors.border.light}; - border-radius: ${({ theme }) => theme.radius.md}; - padding: ${({ theme }) => theme.spacing.md}; - font-family: ${({ theme }) => theme.fonts.family.mono}; - font-size: ${({ theme }) => theme.fonts.size.sm}; - color: ${({ theme }) => theme.colors.text.primary}; - overflow: auto; -`; - export const VariableListContainer = styled.div` width: 100%; display: flex; diff --git a/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.tsx b/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.tsx index d9c36263..a439ce8b 100644 --- a/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.tsx +++ b/src/pages/main-page/monitoring-page/details-tab-view/DetailsTabView.tsx @@ -3,6 +3,7 @@ import React from "react"; import { Badge, + CodeBlock, CopyButton, DetailsGrid, DetailsItem, @@ -28,7 +29,6 @@ import { formatDuration, } from "@/utils"; import { - CodeBlock, DetailedContainer, DetailedItemSummary, Placeholder, @@ -200,12 +200,13 @@ export const DetailsTabView: React.FC = ({ steps }) => { {Array.isArray(step.commands_b64) && step.commands_b64.length > 0 ? ( step.commands_b64.map((cmd, i) => ( - - {decodeBase64(cmd) || cmd} - + )) ) : ( - // no commands + )} diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/CommandList.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/CommandList.tsx new file mode 100644 index 00000000..c40f6f24 --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/CommandList.tsx @@ -0,0 +1,66 @@ +import { Badge, ThemeVariant } from "@/components"; +import type { Command } from "@/types"; + +import { Description } from "./PlaybookDetailPage.styles"; +import { CodeField, DetailField, Section } from "./PlaybookDetails"; +import { readContent, readText } from "./stepFields"; + +const CommandSection = ({ command, title }: { command: Command; title: string }) => { + const body = readText(command.command, command.command_b64); + const content = readText(command.content, command.content_b64); + const formatted = content && readContent(content.text); + const headers = Object.entries(command.headers ?? {}); + + return ( +
+ + {command.type} + + {command.version && {command.version}} + {command.playbook_activity && ( + + {command.playbook_activity} + + )} + {command.description && ( + + {command.description} + + )} + {body && ( + + )} + {headers.length > 0 && ( + `${name}: ${values.join(", ")}`) + .join("\n")} + /> + )} + {content && formatted && ( + + )} +
+ ); +}; + +/** The commands of an action step, as they will be sent. */ +export const CommandList = ({ commands }: { commands: Command[] }) => ( + <> + {commands.map((command, index) => ( + + ))} + +); diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailCards.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailCards.tsx deleted file mode 100644 index ca2ef50d..00000000 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailCards.tsx +++ /dev/null @@ -1,181 +0,0 @@ -import React from "react"; - -import { - Badge, - DetailsGrid, - DetailsItem, - FormLabel, - Link, - Spacer, - Text, - ThemeVariant, -} from "@/components"; -import { Playbook } from "@/types"; - -import { theme } from "@/theme"; -import { formatDateTime } from "@/utils"; - -interface PlaybookMainDetailsProps { - playbook: Playbook; -} - -export const PlaybookMainDetails: React.FC = ({ - playbook, -}) => { - const { - name, - id, - playbook_types, - spec_version, - created, - modified, - priority, - severity, - description, - } = playbook; - - return ( - - - - Name - {name} - - - ID - {id} - - - Type - - {playbook_types?.map((type, idx) => ( - - {type} - - )) || "N/A"} - - - - Spec version - {spec_version} - - - Created - {formatDateTime(created)} - - - Modified - {formatDateTime(modified)} - - {priority !== undefined && ( - - Priority - - {priority} - - - )} - {severity !== undefined && ( - - Severity - - {severity} - - - )} - - {description && ( - - Description - {description} - - )} - - ); -}; - -interface PlaybookAdditionalDetailsProps { - playbook: Playbook; -} - -export const PlaybookAdditionalDetails: React.FC< - PlaybookAdditionalDetailsProps -> = ({ playbook }) => { - const { - created_by, - valid_from, - valid_until, - impact, - labels, - external_references, - } = playbook; - return ( - - - Created by - {created_by} - - {impact && ( - - Impact - - {impact} - - - )} - {valid_from && ( - - Valid from - {formatDateTime(valid_from)} - - )} - {valid_until && ( - - Valid until - {formatDateTime(valid_until)} - - )} - {labels && labels.length > 0 && ( - - Labels - - {labels.map((label, idx) => ( - - {label} - - ))} - - - )} - {external_references && external_references.length > 0 && ( - - External references - - {external_references.map((ref, idx) => ( - - - {ref.name} - - {ref.url && ( - - {ref.url} - - )} - - ))} - - - )} - - ); -}; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.styles.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.styles.tsx index 18f663c8..e35c3f7b 100644 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.styles.tsx +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.styles.tsx @@ -1,29 +1,154 @@ import styled from "styled-components"; -export const TwoColumnLayout = styled.div` - width: 100%; +import { panelWidth } from "../visual-editor/pages/panelWidth"; + +// Fills the content area so the page itself never scrolls. +export const DetailPage = styled.div` + display: flex; + flex-direction: column; + gap: ${({ theme }) => theme.spacing.lg}; + + height: 100%; + min-height: 30rem; +`; + +export const DetailHeader = styled.header` + display: flex; + flex-wrap: wrap; + gap: ${({ theme }) => theme.spacing.md}; + align-items: center; + justify-content: space-between; +`; + +export const TitleRow = styled.div` + display: flex; + flex: 1 1 20rem; + gap: ${({ theme }) => theme.spacing.sm}; + align-items: center; + + min-width: 0; +`; + +export const PageTitle = styled.h2` + overflow: hidden; + + margin: 0; + + font: ${({ theme }) => theme.typography.h2.font}; + color: ${({ theme }) => theme.colors.text.primary}; + text-overflow: ellipsis; + white-space: nowrap; +`; + +// The step panel on the left is wide, so commands and scripts fit. +export const DetailBody = styled.div<{ + $stepCollapsed: boolean; + $detailsCollapsed: boolean; +}>` display: grid; - grid-template-columns: 40% 60%; + grid-template-columns: + ${({ $stepCollapsed }) => panelWidth("right", $stepCollapsed)} + minmax(0, 1fr) + ${({ $detailsCollapsed }) => panelWidth("right", $detailsCollapsed)}; + flex: 1; gap: ${({ theme }) => theme.spacing.lg}; - align-items: start; - @media (max-width: 1200px) { - grid-template-columns: 1fr; + min-height: 0; + + transition: grid-template-columns ${({ theme }) => theme.transitions.base}; + + @media (prefers-reduced-motion: reduce) { + transition: none; } `; -export const LeftColumn = styled.div` +export const DiagramFrame = styled.div` + overflow: hidden; + min-height: 0; + border: 1px solid ${({ theme }) => theme.colors.border.light}; + background: ${({ theme }) => theme.colors.background.primary}; +`; + +export const DetailSection = styled.section` display: flex; flex-direction: column; + gap: ${({ theme }) => theme.spacing.md}; + + & + & { + padding-top: ${({ theme }) => theme.spacing.lg}; + border-top: 1px solid ${({ theme }) => theme.colors.border.light}; + } +`; + +export const FieldGrid = styled.dl` + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); gap: ${({ theme }) => theme.spacing.lg}; + margin: 0; +`; + +export const Field = styled.div<{ $wide?: boolean }>` + display: flex; + grid-column: ${({ $wide }) => ($wide ? "1 / -1" : "auto")}; + flex-direction: column; + gap: ${({ theme }) => theme.spacing.xs}; + + min-width: 0; +`; + +export const FieldLabel = styled.dt` + font: ${({ theme }) => theme.typography.small.font}; + color: ${({ theme }) => theme.colors.text.tertiary}; +`; + +export const FieldValue = styled.dd` + margin: 0; + font: ${({ theme }) => theme.typography.body.font}; + color: ${({ theme }) => theme.colors.text.primary}; `; -export const RightColumn = styled.div` +// The ID stays on one line; the full value is in the tooltip and the copy button. +export const IdValue = styled.div` + display: flex; + gap: ${({ theme }) => theme.spacing.sm}; + align-items: center; + + & > span { + overflow: hidden; + flex: 1; + + font: ${({ theme }) => theme.typography.code.font}; + text-overflow: ellipsis; + white-space: nowrap; + } +`; + +export const BadgeList = styled.div` + display: flex; + flex-wrap: wrap; + gap: ${({ theme }) => theme.spacing.xs}; +`; + +export const ReferenceItem = styled.div` display: flex; flex-direction: column; - padding-right: ${({ theme }) => theme.spacing.lg}; + gap: ${({ theme }) => theme.spacing.xs}; + overflow-wrap: anywhere; - @media (max-width: 1200px) { - padding-right: 0; + & + & { + margin-top: ${({ theme }) => theme.spacing.md}; } `; + +export const Description = styled.p` + margin: 0; + font: ${({ theme }) => theme.typography.body.font}; + color: ${({ theme }) => theme.colors.text.primary}; + white-space: pre-line; +`; + +export const EmptyText = styled.p` + margin: 0; + font: ${({ theme }) => theme.typography.caption.font}; + color: ${({ theme }) => theme.colors.text.secondary}; +`; \ No newline at end of file diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.tsx index 4554e2ad..e04c9099 100644 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.tsx +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetailPage.tsx @@ -6,7 +6,7 @@ import { IconPlayerPlay, IconTrash, } from "@tabler/icons-react"; -import React, { useState } from "react"; +import React, { Suspense, useState } from "react"; import toast from "react-hot-toast"; import { useNavigate, useParams } from "react-router"; @@ -35,23 +35,25 @@ import { import { Execution, Playbook } from "@/types"; import { PATHS } from "@/utils"; -import { generatePlaybookFilename, getOrderedSteps } from "../utils"; +import { generatePlaybookFilename } from "../utils"; import { - PlaybookAdditionalDetails, - PlaybookMainDetails, -} from "./PlaybookDetailCards"; -import { - LeftColumn, - RightColumn, - TwoColumnLayout, + DetailHeader, + DetailPage, + PageTitle, + TitleRow, } from "./PlaybookDetailPage.styles"; -import PlaybookTimeline from "./PlaybookTimeline"; +import { PlaybookPanels } from "./PlaybookPanels"; import { RunPlaybookModal } from "./RunPlaybookModal"; +const loading = ( + + + +); + export const PlaybookDetailPage: React.FC = () => { const navigate = useNavigate(); const { playbookId } = useParams(); - const [expandedSteps, setExpandedSteps] = useState>(new Set()); const { data, isLoading, isError, error } = useQuery({ queryKey: ["playbook", playbookId], @@ -102,39 +104,7 @@ export const PlaybookDetailPage: React.FC = () => { ).some((v) => v.external === true); const parsedError = getErrorFromApiResponse(error); - const toggleStep = (stepId: string) => { - setExpandedSteps((prev) => { - const newSet = new Set(prev); - if (newSet.has(stepId)) { - newSet.delete(stepId); - } else { - newSet.add(stepId); - } - return newSet; - }); - }; - - const orderedSteps = playbook - ? getOrderedSteps(playbook.workflow, playbook.workflow_start) - : []; - - if (isLoading) { - return ( - - - - Back to playbooks - - - - - - - - - - ); - } + if (isLoading) return loading; if (isError || !playbook) { return ( @@ -159,24 +129,19 @@ export const PlaybookDetailPage: React.FC = () => { ); } - return ( - - - - - Back to playbooks - + const content = ( + + + + + + + {playbook.name} + - + - - + + - - + toast.success("Playbook exported")} $onError={(err) => - toast.error(formatErrorForToast(err, "Failed to export playbook")) + toast.error( + formatErrorForToast(err, "Failed to export playbook"), + ) } > Export - - setOpenRunConfirm(false)} - $onConfirm={() => { - setOpenRunConfirm(false); - mutation.mutate(); - }} - /> - - setOpenDeleteConfirm(false)} - $onConfirm={() => { - setOpenDeleteConfirm(false); - deleteMutation.mutate(); - }} - /> - {openRunModal && ( - setOpenRunModal(false)} - onSuccess={navigateToExecution} - /> - )} - - - - - - - Playbook information - - - - - - - - Additional details - - - - - - - - - - Workflow steps ({orderedSteps.length}) - - - - - - - - + + + + setOpenRunConfirm(false)} + $onConfirm={() => { + setOpenRunConfirm(false); + mutation.mutate(); + }} + /> + setOpenDeleteConfirm(false)} + $onConfirm={() => { + setOpenDeleteConfirm(false); + deleteMutation.mutate(); + }} + /> + {openRunModal && ( + setOpenRunModal(false)} + onSuccess={navigateToExecution} + /> + )} + ); + + // The diagram chunk loads after the playbook; one fallback covers both waits. + return {content}; }; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetails.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetails.tsx new file mode 100644 index 00000000..4fcb7724 --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookDetails.tsx @@ -0,0 +1,202 @@ +import type { ReactNode } from "react"; + +import { + Badge, + CodeBlock, + CopyButton, + Link, + Spacer, + ThemeVariant, +} from "@/components"; +import type { Playbook } from "@/types"; +import { formatDateTime } from "@/utils"; + +import { + BadgeList, + DetailSection, + Description, + EmptyText, + Field, + FieldGrid, + FieldLabel, + FieldValue, + IdValue, + ReferenceItem, +} from "./PlaybookDetailPage.styles"; +import { FieldMessage, SectionTitle } from "../visual-editor/panels/Panel.styles"; + +// Labels match the playbook fields of the visual editor. + +export const DetailField = ({ + label, + wide, + children, +}: { + label: string; + wide?: boolean; + children: ReactNode; +}) => ( + + {label} + {children} + +); + +const NotSet = () => Not set; + +/** Read-only code with a copy button, and an optional warning under it. */ +export const CodeField = ({ + label, + code, + warning, +}: { + label: string; + code: string; + warning?: string; +}) => ( + + + + {warning && {warning}} + + +); + +const BadgeField = ({ + label, + values, + variant, +}: { + label: string; + values?: string[]; + variant: ThemeVariant; +}) => ( + + {values && values.length > 0 ? ( + + {values.map((value) => ( + + {value} + + ))} + + ) : ( + + )} + +); + +const ScoreField = ({ + label, + value, + variant, +}: { + label: string; + value?: number; + variant: ThemeVariant; +}) => ( + + {value === undefined ? : {value}} + +); + +const DateField = ({ label, value }: { label: string; value?: string }) => ( + + {value ? formatDateTime(value) : } + +); + +export const Section = ({ title, children }: { title: string; children: ReactNode }) => ( + + {title} + {children} + +); + +export const PlaybookOverview = ({ playbook }: { playbook: Playbook }) => ( + <> +
+ + + {playbook.id} + + + + + {playbook.created_by || } + + + + + {playbook.spec_version} + +
+
+ + + +
+
+ + + +
+
+ + +
+ +); + +export const PlaybookDescription = ({ playbook }: { playbook: Playbook }) => + playbook.description ? ( + {playbook.description} + ) : ( + This playbook has no description. + ); + +export const PlaybookReferences = ({ playbook }: { playbook: Playbook }) => { + const references = playbook.external_references ?? []; + if (references.length === 0) { + return This playbook has no external references.; + } + return ( +
+ {references.map((reference, index) => ( + + {reference.name} + {reference.description && {reference.description}} + {reference.url && ( + + {reference.url} + + )} + + ))} +
+ ); +}; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookPanels.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookPanels.tsx new file mode 100644 index 00000000..6224bb55 --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookPanels.tsx @@ -0,0 +1,89 @@ +import { lazy, useState } from "react"; + +import { Tabs, TabsProvider, ThemeSize, useTabs } from "@/components"; +import type { Playbook } from "@/types"; + +import { CollapsibleSidePanel } from "../visual-editor/panels/CollapsibleSidePanel"; +import { PanelBody, PanelTabBar, PanelTabContent } from "../visual-editor/panels/Panel.styles"; +import { DetailBody, DiagramFrame } from "./PlaybookDetailPage.styles"; +import { + PlaybookDescription, + PlaybookOverview, + PlaybookReferences, +} from "./PlaybookDetails"; +import { StepDetails } from "./StepDetails"; + +// Loaded on demand because it pulls in React Flow. +const PlaybookDiagram = lazy(() => + import("../visual-editor/pages/PlaybookDiagram").then((m) => ({ + default: m.PlaybookDiagram, + })), +); + +const DETAIL_TABS = [ + { id: "overview", label: "Overview" }, + { id: "description", label: "Description" }, + { id: "references", label: "References" }, +]; + +const DetailTabContent = ({ playbook }: { playbook: Playbook }) => { + const { activeTab } = useTabs(); + if (activeTab === "description") return ; + if (activeTab === "references") return ; + return ; +}; + +/** Step details, diagram and playbook details. Starts with the start step selected. */ +export const PlaybookPanels = ({ playbook }: { playbook: Playbook }) => { + const [stepCollapsed, setStepCollapsed] = useState(false); + const [detailsCollapsed, setDetailsCollapsed] = useState(false); + const [selectedStepId, setSelectedStepId] = useState( + playbook.workflow_start, + ); + + // Selecting a step opens its panel; clearing the selection leaves the panel as it is. + const selectStep = (stepId: string | undefined) => { + setSelectedStepId(stepId); + if (stepId) setStepCollapsed(false); + }; + + return ( + + setStepCollapsed(!stepCollapsed)} + > + + + + + + setDetailsCollapsed(!detailsCollapsed)} + > + + + + + + + + + + + + + ); +}; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.styles.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.styles.tsx deleted file mode 100644 index 8cfba9ea..00000000 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.styles.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { fadeInSlide } from "@/theme/animations"; -import styled from "styled-components"; - -export const TimelineVertical = styled.div` - position: relative; - padding: ${({ theme }) => theme.spacing.lg} 0; -`; - -export const TimelineRow = styled.div<{ $delay?: number }>` - display: block; - animation: ${fadeInSlide} 0.28s ease-out forwards; - animation-delay: ${({ $delay = 0 }) => $delay}s; - opacity: 0; -`; - -export const TimelineVerticalLine = styled.div` - position: absolute; - left: 50%; - top: 0; - bottom: 0; - width: 2px; - background-color: ${({ theme }) => theme.colors.palette.primary}; - transform: translateX(-50%); -`; - -export const TimelineStepCard = styled.div<{ $align: "left" | "right" }>` - position: relative; - margin-bottom: ${({ theme }) => theme.spacing.lg}; - display: flex; - justify-content: ${({ $align }) => - $align === "left" ? "flex-start" : "flex-end"}; -`; - -export const StepCardWrapper = styled.div<{ $align: "left" | "right" }>` - width: 45%; - position: relative; - - /* Connector line from card to center timeline */ - &::before { - content: ""; - position: absolute; - top: 24px; - ${({ $align }) => ($align === "left" ? "right: -20px" : "left: -20px")}; - width: 20px; - height: 2px; - background-color: ${({ theme }) => theme.colors.palette.primary}; - } -`; - -export const TimelineDotCenter = styled.div<{ $type: string }>` - position: absolute; - left: 50%; - top: 24px; - transform: translate(-50%, -50%); - width: 22px; - height: 22px; - border-radius: ${({ theme }) => theme.radius.full}; - background-color: ${({ theme, $type }) => { - switch ($type) { - case "start": - return theme.colors.success.solidBg; - case "end": - return theme.colors.error.solidBg; - case "if-condition": - return theme.colors.palette.background; - case "parallel": - return theme.colors.palette.accent; - case "action": - return theme.colors.warning.solidBg; - default: - return theme.colors.info.solidBg; - } - }}; - border: 3px solid ${({ theme }) => theme.colors.background.primary}; - box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); - z-index: 2; -`; - -export const StepCard = styled.div` - border-radius: ${({ theme }) => theme.radius.md}; - background-color: ${({ theme }) => theme.colors.background.primary}; - border: 1px solid ${({ theme }) => theme.colors.primary.border}; - overflow: hidden; - transition: all ${({ theme }) => theme.transitions.base}; - - &:hover { - border-color: ${({ theme }) => theme.colors.primary.hover}; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); - } -`; - -export const StepCardHeader = styled.div<{ $expanded: boolean }>` - padding: ${({ theme }) => theme.spacing.md}; - cursor: pointer; - display: flex; - justify-content: space-between; - align-items: center; - background-color: ${({ theme, $expanded }) => - $expanded ? theme.colors.info.bg : theme.colors.background.primary}; - transition: all ${({ theme }) => theme.transitions.base}; - - &:hover { - background-color: ${({ theme }) => theme.colors.info.bg}; - } -`; - -export const StepCardTitle = styled.h3` - font: ${({ theme }) => theme.typography.h3.font}; - color: ${({ theme }) => theme.colors.text.primary}; -`; - -export const StepCardBody = styled.div` - padding: ${({ theme }) => theme.spacing.md}; - background-color: ${({ theme }) => theme.colors.background.primary}; -`; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.tsx deleted file mode 100644 index c7efb27d..00000000 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/PlaybookTimeline.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { Badge, Icon, Text } from "@/components"; -import { ThemeSize, ThemeVariant } from "@/components/utils"; -import { Step } from "@/types"; -import { IconChevronDown, IconChevronRight } from "@tabler/icons-react"; -import React from "react"; -import { - StepCard, - StepCardBody, - StepCardHeader, - StepCardTitle, - StepCardWrapper, - TimelineDotCenter, - TimelineRow, - TimelineStepCard, - TimelineVertical, - TimelineVerticalLine, -} from "./PlaybookTimeline.styles"; - -export interface PlaybookTimelineProps { - steps: Array; - expandedSteps: Set; - toggleStep: (id: string) => void; - playbookWorkflow?: Record; -} - -export const PlaybookTimeline: React.FC = ({ - steps, - expandedSteps, - toggleStep, - playbookWorkflow, -}) => { - return ( - - - {steps.map((step, index) => { - const align = index % 2 === 0 ? "left" : "right"; - const isExpanded = expandedSteps.has(step.id); - const delay = index * 0.06; - - return ( - - - - - - toggleStep(step.id)} - > - - {step.name || step.type || "Step"} - - - - {isExpanded && ( - -
-
- - Type - - - - {step.type} - - -
- - {step.description && ( -
- - Description - - {step.description} -
- )} - - {step.timeout && ( -
- - Timeout - - {step.timeout}ms -
- )} - - {step.delay && ( -
- - Delay - - {step.delay}ms -
- )} - - {step.on_completion && ( -
- - On completion - - - - {playbookWorkflow?.[step.on_completion]?.name ?? - step.on_completion} - - -
- )} - - {step.on_success && ( -
- - On success - - - - {playbookWorkflow?.[step.on_success]?.name ?? - step.on_success} - - -
- )} - - {step.on_failure && ( -
- - On failure - - - - {playbookWorkflow?.[step.on_failure]?.name ?? - step.on_failure} - - -
- )} -
-
- )} -
-
-
-
- ); - })} -
- ); -}; - -export default PlaybookTimeline; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/RunPlaybookModal.styles.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/RunPlaybookModal.styles.tsx index 4a1378e3..e9cc117e 100644 --- a/src/pages/main-page/playbooks-page/playbook-detail-page/RunPlaybookModal.styles.tsx +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/RunPlaybookModal.styles.tsx @@ -1,9 +1,9 @@ import styled from "styled-components"; export const Description = styled.p` + margin: 0 0 ${({ theme }) => theme.spacing.lg} 0; font: ${({ theme }) => theme.typography.body.font}; color: ${({ theme }) => theme.colors.text.secondary}; - margin: 0 0 ${({ theme }) => theme.spacing.lg} 0; `; export { diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/StepDetails.tsx b/src/pages/main-page/playbooks-page/playbook-detail-page/StepDetails.tsx new file mode 100644 index 00000000..336d5984 --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/StepDetails.tsx @@ -0,0 +1,75 @@ +import { Badge, CopyButton, Spacer } from "@/components"; +import type { Playbook } from "@/types"; + +import { CommandList } from "./CommandList"; +import { + BadgeList, + Description, + EmptyText, + IdValue, +} from "./PlaybookDetailPage.styles"; +import { CodeField, DetailField, Section } from "./PlaybookDetails"; +import { getStepDetails } from "./stepFields"; + +const isPlain = (value: unknown) => value === null || typeof value !== "object"; + +const StepField = ({ label, value }: { label: string; value: unknown }) => { + if (isPlain(value)) + return {String(value)}; + if (Array.isArray(value) && value.every(isPlain)) + return ( + + + {value.map((item) => ( + {String(item)} + ))} + + + ); + return ; +}; + +/** All fields of the step selected in the read-only diagram. */ +export const StepDetails = ({ + playbook, + stepId, +}: { + playbook: Playbook; + stepId?: string; +}) => { + const step = stepId ? playbook.workflow[stepId] : undefined; + if (!stepId || !step) + return Select a step in the diagram to see its details.; + + const { typeLabel, details } = getStepDetails(step, playbook); + + return ( + +
+ {step.name && ( + + {step.name} + + )} + + {typeLabel} + + + + {stepId} + + + + {step.description && ( + + {step.description} + + )} + {details.map(({ key, label, value }) => ( + + ))} +
+ +
+ ); +}; diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.test.ts b/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.test.ts new file mode 100644 index 00000000..5bc2461b --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.test.ts @@ -0,0 +1,63 @@ +import { describe, expect, it } from "vitest"; + +import type { Playbook, Step } from "@/types"; + +import { getStepDetails, readContent, readText } from "./stepFields"; + +describe("getStepDetails", () => { + const playbook = { spec_version: "cacao-2.0" } as Playbook; + + it("lists spec fields with their labels, then other fields, and leaves out the rest", () => { + const step = { + type: "action", + name: "Scan", + description: "Runs a scan", + x_vendor: "acme", + agent: "soarca--1", + timeout: 500, + on_completion: "end--1", + commands: [], + } as unknown as Step; + + const { typeLabel, details } = getStepDetails(step, playbook); + + expect(typeLabel).toBe("Action"); + expect(details).toEqual([ + { key: "timeout", label: "Timeout (ms)", value: 500 }, + { key: "agent", label: "Agent", value: "soarca--1" }, + { key: "x_vendor", label: "X vendor", value: "acme" }, + ]); + }); + + it("falls back to the raw type and key names for an unknown spec version", () => { + const step = { type: "custom", out_args: ["a"] } as unknown as Step; + + expect(getStepDetails(step, { spec_version: "cacao-9" } as Playbook)).toEqual({ + typeLabel: "custom", + details: [{ key: "out_args", label: "Out args", value: ["a"] }], + }); + }); +}); + +describe("readText", () => { + it("prefers the plain value and otherwise decodes base64", () => { + expect(readText("ls", btoa("pwd"))).toEqual({ text: "ls", decoded: false }); + expect(readText(undefined, btoa("pwd"))).toEqual({ text: "pwd", decoded: true }); + expect(readText()).toBeUndefined(); + }); +}); + +describe("readContent", () => { + it("pretty-prints valid JSON", () => { + expect(readContent('{"a":1}')).toEqual({ code: '{\n "a": 1\n}', invalid: false }); + }); + + it("flags JSON-like text that does not parse and leaves it as written", () => { + const text = '{"severity":__severity__:value}'; + expect(readContent(text)).toEqual({ code: text, invalid: true }); + }); + + it("does not flag text that is not meant to be JSON", () => { + expect(readContent("name=value")).toEqual({ code: "name=value", invalid: false }); + }); +}); diff --git a/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.ts b/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.ts new file mode 100644 index 00000000..d746292b --- /dev/null +++ b/src/pages/main-page/playbooks-page/playbook-detail-page/stepFields.ts @@ -0,0 +1,66 @@ +import type { Playbook, Step } from "@/types"; +import { decodeBase64 } from "@/utils"; + +import { getStepFields } from "../visual-editor/model/fields"; +import { getSpec } from "../visual-editor/model/specs"; + +// Shown elsewhere: at the top of "General", in their own section, or as arrows in the diagram. +const OMITTED_FIELDS = new Set([ + "id", + "uuid", + "type", + "name", + "description", + "commands", + "cases", + "next_steps", + "on_completion", + "on_failure", + "on_false", + "on_success", + "on_true", + "step_extensions", +]); + +/** `out_args` reads as "Out args", matching the spec field labels. */ +const toLabel = (key: string) => { + const words = key.replaceAll("_", " "); + return words.charAt(0).toUpperCase() + words.slice(1); +}; + +export type StepDetail = { key: string; label: string; value: unknown }; + +/** The type label and the remaining fields of a step: spec fields first, in spec order, then any others. */ +export const getStepDetails = (step: Step, playbook: Playbook) => { + const spec = getSpec(playbook.spec_version); + const definition = spec?.stepTypes[step.type]; + const fields = spec ? getStepFields(spec, definition) : []; + const known = new Set(fields.map((field) => field.key)); + const details: StepDetail[] = [ + ...fields + .filter((field) => !OMITTED_FIELDS.has(field.key) && step[field.key] !== undefined) + .map((field) => ({ key: field.key, label: field.label, value: step[field.key] })), + ...Object.entries(step) + .filter( + ([key, value]) => !known.has(key) && !OMITTED_FIELDS.has(key) && value !== undefined, + ) + .map(([key, value]) => ({ key, label: toLabel(key), value })), + ]; + return { typeLabel: definition?.label ?? step.type, details }; +}; + +/** The plain value, or else the base64 one decoded. */ +export const readText = (plain?: string, base64?: string) => { + if (plain) return { text: plain, decoded: false }; + if (!base64) return undefined; + return { text: decodeBase64(base64) ?? base64, decoded: true }; +}; + +/** Pretty-printed JSON; text that looks like JSON but does not parse is flagged. */ +export const readContent = (text: string) => { + try { + return { code: JSON.stringify(JSON.parse(text), null, 2), invalid: false }; + } catch { + return { code: text, invalid: /^\s*[[{]/.test(text) }; + } +}; diff --git a/src/pages/main-page/playbooks-page/visual-editor/canvas/FlowCanvas.tsx b/src/pages/main-page/playbooks-page/visual-editor/canvas/FlowCanvas.tsx index 8e991ccf..f800dc85 100644 --- a/src/pages/main-page/playbooks-page/visual-editor/canvas/FlowCanvas.tsx +++ b/src/pages/main-page/playbooks-page/visual-editor/canvas/FlowCanvas.tsx @@ -33,7 +33,6 @@ import { FIT_VIEW_OPTIONS, STEP_TYPE_MIME } from "./constants"; import { ContextMenu } from "./ContextMenu"; import { CanvasWrapper } from "./FlowCanvas.styles"; import { nodeTypes } from "./nodeTypes"; -import { StepDetailsCard } from "./StepDetailsCard"; import type { StepFlowNode } from "./StepNode"; import { useCanvasMenu } from "./useCanvasMenu"; @@ -53,6 +52,9 @@ type FlowCanvasProps = { spec: CacaoSpec; /** Leave out for a read-only diagram. */ editor?: CanvasEditor; + /** Selected step of a read-only diagram. */ + selectedStepId?: string; + onSelectStep?: (stepId: string | undefined) => void; }; const toLink = (connection: Connection | Edge) => ({ @@ -66,12 +68,13 @@ export const FlowCanvas: React.FC = ({ playbook, spec, editor, + selectedStepId, + onSelectStep, }) => { const { screenToFlowPosition } = useReactFlow(); const theme = useTheme(); const [selectedEdgeId, setSelectedEdgeId] = useState(); const [showMinimap, setShowMinimap] = useState(true); - const [readOnlySelectedId, setReadOnlySelectedId] = useState(); const readOnly = !editor; // The line drawn while connecting has the colour of the port it starts from. const draggedKind = useConnection((connection) => @@ -99,9 +102,9 @@ export const FlowCanvas: React.FC = ({ measured: sizes[node.id], selected: editorSelectedIds ? editorSelectedIds.includes(node.id) - : node.id === readOnlySelectedId, + : node.id === selectedStepId, })), - [graph.nodes, sizes, editorSelectedIds, readOnlySelectedId], + [graph.nodes, sizes, editorSelectedIds, selectedStepId], ); const edges = useMemo( (): Edge[] => @@ -150,14 +153,12 @@ export const FlowCanvas: React.FC = ({ const handleNodeClick = (_: React.MouseEvent, node: StepFlowNode) => { // In the editor, React Flow selects on click and reports it through onNodesChange. if (editor) return; - setReadOnlySelectedId((selectedId) => - selectedId === node.id ? undefined : node.id, - ); + onSelectStep?.(selectedStepId === node.id ? undefined : node.id); }; const handlePaneClick = () => { editor?.onSelect([]); - setReadOnlySelectedId(undefined); + onSelectStep?.(undefined); setSelectedEdgeId(undefined); }; @@ -172,9 +173,6 @@ export const FlowCanvas: React.FC = ({ }; const menu = useCanvasMenu(playbook, spec, editor); - const readOnlySelected = readOnly - ? graph.nodes.find((node) => node.id === readOnlySelectedId) - : undefined; return ( event.preventDefault()}> @@ -219,14 +217,6 @@ export const FlowCanvas: React.FC = ({ {!readOnly && showMinimap && } {editor && } - {readOnlySelected && ( - setReadOnlySelectedId(undefined)} - /> - )} ); }; diff --git a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.styles.tsx b/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.styles.tsx deleted file mode 100644 index feeed4a0..00000000 --- a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.styles.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import styled from "styled-components"; - -import type { StepColor } from "../model/specs"; -import { getStepColors } from "./colors"; -import { StepTypeText } from "./StepNode.styles"; - -// Matches the look of a step on the canvas: type-coloured top border, square corners. -// z-index 5 is the layer of React Flow's panels. -export const DetailsCard = styled.aside<{ $color: StepColor }>` - position: absolute; - z-index: 5; - top: ${({ theme }) => theme.spacing.md}; - right: ${({ theme }) => theme.spacing.md}; - - display: flex; - flex-direction: column; - - width: min(24rem, calc(100% - ${({ theme }) => theme.spacing["3xl"]})); - max-height: calc(100% - ${({ theme }) => theme.spacing["3xl"]}); - border: 1px solid ${({ theme }) => theme.colors.border.light}; - border-top: ${({ theme, $color }) => - `${theme.spacing.xs} solid ${getStepColors(theme, $color).solidBg}`}; - - background: ${({ theme }) => theme.colors.background.primary}; - box-shadow: ${({ theme }) => theme.shadows.md}; -`; - -export const DetailsHeader = styled.div` - display: flex; - gap: ${({ theme }) => theme.spacing.sm}; - align-items: flex-start; - - padding: ${({ theme }) => theme.spacing.md}; - border-bottom: 1px solid ${({ theme }) => theme.colors.border.light}; -`; - -export const DetailsHeading = styled.div` - display: flex; - flex: 1; - flex-direction: column; - gap: ${({ theme }) => theme.spacing.sm}; - - min-width: 0; -`; - -export const DetailsType = styled(StepTypeText)` - display: flex; - gap: ${({ theme }) => theme.spacing.sm}; - align-items: center; -`; - -export const DetailsTitle = styled.h3` - margin: 0; - font: ${({ theme }) => theme.typography.h3.font}; - color: ${({ theme }) => theme.colors.text.primary}; - overflow-wrap: anywhere; -`; - -export const DetailsBody = styled.dl` - overflow-y: auto; - display: flex; - flex-direction: column; - gap: ${({ theme }) => theme.spacing.md}; - - margin: 0; - padding: ${({ theme }) => theme.spacing.md}; -`; - -export const DetailsField = styled.div` - display: flex; - flex-direction: column; - gap: ${({ theme }) => theme.spacing.xs}; -`; - -export const DetailsLabel = styled.dt` - font: ${({ theme }) => theme.typography.small.font}; - color: ${({ theme }) => theme.colors.text.tertiary}; -`; - -export const DetailsValue = styled.dd` - margin: 0; - font: ${({ theme }) => theme.typography.body.font}; - color: ${({ theme }) => theme.colors.text.primary}; - overflow-wrap: anywhere; -`; - -export const DetailsCode = styled.pre` - overflow-x: auto; - - margin: 0; - padding: ${({ theme }) => theme.spacing.sm}; - border: 1px solid ${({ theme }) => theme.colors.border.light}; - - font: ${({ theme }) => theme.typography.code.font}; - color: ${({ theme }) => theme.colors.text.secondary}; - - background: ${({ theme }) => theme.colors.background.tertiary}; -`; - -export const DetailsEmpty = styled.p` - margin: 0; - font: ${({ theme }) => theme.typography.caption.font}; - color: ${({ theme }) => theme.colors.text.secondary}; -`; diff --git a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.tsx b/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.tsx deleted file mode 100644 index a64ac84e..00000000 --- a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepDetailsCard.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { IconX } from "@tabler/icons-react"; - -import { Button, Icon, ThemeSize, ThemeVariant } from "@/components"; -import type { Step } from "@/types"; - -import { getStepFields } from "../model/fields"; -import type { CacaoSpec, StepTypeDefinition } from "../model/specs"; -import { UNKNOWN_STEP_COLOR, UNKNOWN_STEP_ICON } from "./constants"; -import { - DetailsBody, - DetailsCard, - DetailsCode, - DetailsEmpty, - DetailsField, - DetailsHeader, - DetailsHeading, - DetailsLabel, - DetailsTitle, - DetailsType, - DetailsValue, -} from "./StepDetailsCard.styles"; -import { StepIcon } from "./StepIcon"; - -type StepDetailsCardProps = { - step: Step; - definition: StepTypeDefinition | undefined; - spec: CacaoSpec; - onClose: () => void; -}; - -const OMITTED_FIELDS = new Set([ - "id", - "uuid", - "type", - "cases", - "next_steps", - "on_completion", - "on_failure", - "on_false", - "on_success", - "on_true", - "step_extensions", -]); - -/** `out_args` reads as "Out args", matching the spec field labels. */ -const toLabel = (key: string) => { - const words = key.replaceAll("_", " "); - return words.charAt(0).toUpperCase() + words.slice(1); -}; - -const isPlain = (value: unknown) => - value === null || typeof value !== "object"; - -/** Plain values and lists of them read as text; anything structured as JSON. */ -const FieldValue: React.FC<{ value: unknown }> = ({ value }) => { - if (isPlain(value)) return {String(value)}; - if (Array.isArray(value) && value.every(isPlain)) - return {value.join(", ")}; - return ( - - {JSON.stringify(value, null, 2)} - - ); -}; - -/** Fields of a step in the read-only diagram, shown when it is clicked. */ -export const StepDetailsCard: React.FC = ({ - step, - definition, - spec, - onClose, -}) => { - const typeLabel = definition?.label ?? step.type; - const fields = getStepFields(spec, definition); - const knownFields = new Set(fields.map((field) => field.key)); - const details = [ - ...fields - .filter((field) => field.key !== "name" && step[field.key] !== undefined) - .map((field) => [field.label, step[field.key]] as const), - ...Object.entries(step) - .filter( - ([key, value]) => - !knownFields.has(key) && - !OMITTED_FIELDS.has(key) && - value !== undefined, - ) - .map(([key, value]) => [toLabel(key), value] as const), - ]; - - const color = definition?.color ?? UNKNOWN_STEP_COLOR; - - return ( - - - - - - {typeLabel} - - {step.name || typeLabel} - - - - - {details.length ? ( - details.map(([label, value]) => ( - - {label} - - - )) - ) : ( - No additional details - )} - - - ); -}; diff --git a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepNode.styles.tsx b/src/pages/main-page/playbooks-page/visual-editor/canvas/StepNode.styles.tsx index 772a36c2..9df538e3 100644 --- a/src/pages/main-page/playbooks-page/visual-editor/canvas/StepNode.styles.tsx +++ b/src/pages/main-page/playbooks-page/visual-editor/canvas/StepNode.styles.tsx @@ -54,8 +54,8 @@ const ellipsis = css` white-space: nowrap; `; -/** The small uppercase step type label, also used by StepDetailsCard. */ -export const StepTypeText = styled.span` +/** The small uppercase step type label. */ +const StepTypeText = styled.span` font: ${({ theme }) => theme.typography.small.font}; color: ${({ theme }) => theme.colors.text.tertiary}; text-transform: uppercase; diff --git a/src/pages/main-page/playbooks-page/visual-editor/pages/PlaybookDiagram.tsx b/src/pages/main-page/playbooks-page/visual-editor/pages/PlaybookDiagram.tsx index d08f489b..c050e331 100644 --- a/src/pages/main-page/playbooks-page/visual-editor/pages/PlaybookDiagram.tsx +++ b/src/pages/main-page/playbooks-page/visual-editor/pages/PlaybookDiagram.tsx @@ -6,16 +6,29 @@ import { FlowCanvas } from "../canvas/FlowCanvas"; import { getSpec } from "../model/specs"; import { UnsupportedSpec } from "./UnsupportedSpec"; +type PlaybookDiagramProps = { + playbook: Playbook; + selectedStepId?: string; + onSelectStep?: (stepId: string | undefined) => void; +}; + /** Read-only diagram of a playbook, for the detail page. */ -export const PlaybookDiagram: React.FC<{ playbook: Playbook }> = ({ +export const PlaybookDiagram: React.FC = ({ playbook, + selectedStepId, + onSelectStep, }) => { const spec = getSpec(playbook.spec_version); if (!spec) return ; return ( - + ); }; diff --git a/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.styles.tsx b/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.styles.tsx index 264a0a62..fc85ad93 100644 --- a/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.styles.tsx +++ b/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.styles.tsx @@ -134,11 +134,19 @@ export const SidePanelToggle = styled.button` `; // Fixed width so the content does not reflow while the panel animates. -export const SidePanelContent = styled.div<{ $side: Side; $collapsed: boolean }>` +// A wide panel has the width of the right panel on either side. +export const SidePanelContent = styled.div<{ + $side: Side; + $wide?: boolean; + $collapsed: boolean; +}>` overflow-y: auto; flex: 1; - width: calc(${({ $side }) => PANEL_WIDTH[$side]} - ${PANEL_BORDERS_WIDTH}); + width: calc( + ${({ $side, $wide }) => PANEL_WIDTH[$wide ? "right" : $side]} - + ${PANEL_BORDERS_WIDTH} + ); min-height: 0; padding: ${({ theme }) => `${theme.spacing.sm} ${theme.spacing.lg} ${theme.spacing.lg}`}; diff --git a/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.tsx b/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.tsx index 445f7d22..1bad84c3 100644 --- a/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.tsx +++ b/src/pages/main-page/playbooks-page/visual-editor/pages/VisualEditor.tsx @@ -3,7 +3,7 @@ import { ReactFlowProvider, useReactFlow } from "@xyflow/react"; import { useMemo, useRef, useState } from "react"; import toast from "react-hot-toast"; -import { Badge, Button, Icon, ThemeSize, ThemeVariant } from "@/components"; +import { Badge, Button, Icon, ThemeVariant } from "@/components"; import type { Playbook } from "@/types"; import { validatePlaybookJson } from "../../utils"; @@ -179,16 +179,14 @@ const EditorContent: React.FC = ({