Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: kanban view v0

Brad Barbin646d981235fa
diff --git a/apps/carbon/app/components/Gantt/Gantt.tsx b/apps/carbon/app/components/Gantt/Gantt.tsx
new file mode 100644
index 0000000000..1234da9df4
--- /dev/null
+++ b/apps/carbon/app/components/Gantt/Gantt.tsx
@@ -0,0 +1,910 @@
+import {
+ Badge,
+ Button,
+ Input,
+ InputGroup,
+ InputLeftElement,
+ Paragraph,
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+ Slider,
+ Switch,
+ cn,
+ useDebounce,
+ useInitialDimensions,
+} from "@carbon/react";
+import { formatDurationMilliseconds, lerp } from "@carbon/utils";
+import { Link, useParams } from "@remix-run/react";
+import type { Virtualizer } from "@tanstack/react-virtual";
+import { motion } from "framer-motion";
+import { useEffect, useRef, useState } from "react";
+import { useHotkeys } from "react-hotkeys-hook";
+import {
+ LuChevronDown,
+ LuChevronUp,
+ LuSearch,
+ LuZoomIn,
+ LuZoomOut,
+} from "react-icons/lu";
+import {
+ ShowParentIcon,
+ ShowParentIconSelected,
+} from "~/assets/icons/ShowParentIcon";
+import tileBgPath from "~/assets/images/[email protected]";
+import { GanttIcon } from "./components/GanttIcon";
+
+import type { GanttEvent } from "~/components/Gantt/types";
+import { ShortcutKey, variants } from "~/components/ShortcutKey";
+import * as Timeline from "~/components/Timeline";
+import type { UseTreeStateOutput } from "~/components/TreeView/TreeView";
+import { TreeView, useTree } from "~/components/TreeView/TreeView";
+import type { NodesState } from "~/components/TreeView/reducer";
+import { useShortcutKeys } from "~/hooks";
+import type { Shortcut } from "~/hooks/useShortcutKeys";
+import { setResizableGanttSettings } from "~/utils/resizablePanel";
+import {
+ GanttTaskStatusIcon,
+ runStatusClassNameColor,
+} from "./components/GanttTaskStatus";
+import { SpanTitle, eventBackgroundClassName } from "./components/SpanTitle";
+
+type GanttProps = {
+ events: GanttEvent[];
+ selectedId?: string;
+ parentReadableId?: string;
+ onSelectedIdChanged: (selectedId: string | undefined) => void;
+ totalDuration: number;
+ rootSpanStatus: "inprogress" | "completed" | "todo" | "cancelled";
+ rootStartedAt: Date | undefined;
+};
+
+const Gantt = ({
+ events,
+ selectedId,
+ parentReadableId,
+ onSelectedIdChanged,
+ totalDuration,
+ rootSpanStatus,
+ rootStartedAt,
+}: GanttProps) => {
+ const [filterText, setFilterText] = useState("");
+ const [wipOnly, setWipOnly] = useState(false);
+ const [showDurations, setShowDurations] = useState(false);
+ const [scale, setScale] = useState(0);
+ const parentRef = useRef<HTMLDivElement>(null);
+ const treeScrollRef = useRef<HTMLDivElement>(null);
+ const timelineScrollRef = useRef<HTMLDivElement>(null);
+
+ const {
+ nodes,
+ getTreeProps,
+ getNodeProps,
+ toggleNodeSelection,
+ toggleExpandNode,
+ expandAllBelowDepth,
+ toggleExpandLevel,
+ collapseAllBelowDepth,
+ selectNode,
+ scrollToNode,
+ virtualizer,
+ } = useTree({
+ tree: events,
+ selectedId,
+ // collapsedIds,
+ onSelectedIdChanged,
+ estimatedRowHeight: () => 32,
+ parentRef,
+ filter: {
+ value: { text: filterText, wipOnly },
+ fn: (value, node) => {
+ const isWIP = (value.wipOnly && node.data.isPartial) || !value.wipOnly;
+
+ if (!isWIP) return false;
+
+ if (value.text === "") return true;
+ if (
+ node.data.message.toLowerCase().includes(value.text.toLowerCase())
+ ) {
+ return true;
+ }
+ return false;
+ },
+ },
+ });
+
+ return (
+ <div className="grid h-full grid-rows-[2.5rem_1fr_3.25rem] overflow-hidden">
+ <div className="flex items-center justify-between gap-2 border-b border-border">
+ <SearchField onChange={setFilterText} />
+ <div className="flex items-center gap-2">
+ <Switch
+ variant="small"
+ label="In Process Only"
+ checked={wipOnly}
+ onCheckedChange={(e) => setWipOnly(e.valueOf())}
+ />
+ <Switch
+ variant="small"
+ label="Show Durations"
+ checked={showDurations}
+ onCheckedChange={(e) => setShowDurations(e.valueOf())}
+ />
+ </div>
+ </div>
+ <ResizablePanelGroup
+ direction="horizontal"
+ onLayout={(layout) => {
+ if (layout.length !== 2) return;
+ setResizableGanttSettings(document, layout);
+ }}
+ >
+ {/* Tree list */}
+ <ResizablePanel
+ order={1}
+ minSize={20}
+ defaultSize={50}
+ className="pl-3"
+ >
+ <div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
+ <div className="flex items-center pr-2">
+ {parentReadableId && (
+ <ShowParentLink ganttReadableId={parentReadableId} />
+ )}
+ <LiveReloadingStatus
+ rootSpanCompleted={rootSpanStatus !== "inprogress"}
+ />
+ </div>
+ <TreeView
+ parentRef={parentRef}
+ scrollRef={treeScrollRef}
+ virtualizer={virtualizer}
+ autoFocus
+ tree={events}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ renderNode={({ node, state }) => (
+ <>
+ <div
+ className={cn(
+ "flex h-8 cursor-pointer items-center overflow-hidden rounded-l-sm pr-2",
+ state.selected
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted/90"
+ )}
+ onClick={() => {
+ selectNode(node.id);
+ }}
+ >
+ <div className="flex h-8 items-center">
+ {Array.from({ length: node.level }).map((_, index) => (
+ <TaskLine
+ key={index}
+ isError={node.data.isError}
+ isSelected={state.selected}
+ />
+ ))}
+ <div
+ className={cn(
+ "flex h-8 w-4 items-center",
+ node.hasChildren && "hover:bg-accent"
+ )}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (e.altKey) {
+ if (state.expanded) {
+ collapseAllBelowDepth(node.level);
+ } else {
+ expandAllBelowDepth(node.level);
+ }
+ } else {
+ toggleExpandNode(node.id);
+ }
+ scrollToNode(node.id);
+ }}
+ >
+ {node.hasChildren ? (
+ state.expanded ? (
+ <LuChevronDown className="h-4 w-4 text-gray-400" />
+ ) : (
+ <LuChevronUp className="h-4 w-4 text-gray-400" />
+ )
+ ) : (
+ <div className="h-8 w-4" />
+ )}
+ </div>
+ </div>
+
+ <div className="flex w-full items-center justify-between gap-2 pl-1">
+ <div className="flex items-center gap-2 overflow-x-hidden">
+ <GanttIcon
+ name={node.data.style?.icon}
+ className="h-4 min-h-4 w-4 min-w-4"
+ />
+ <NodeText node={node} />
+ {node.data.isRoot && (
+ <Badge variant="outline" className="text-xs">
+ Job
+ </Badge>
+ )}
+ </div>
+ <div className="flex items-center gap-1">
+ <NodeStatusIcon node={node} />
+ </div>
+ </div>
+ </div>
+ </>
+ )}
+ onScroll={(scrollTop) => {
+ //sync the scroll to the tree
+ if (timelineScrollRef.current) {
+ timelineScrollRef.current.scrollTop = scrollTop;
+ }
+ }}
+ />
+ </div>
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ {/* Timeline */}
+ <ResizablePanel order={2} minSize={20} defaultSize={50}>
+ <GanttTimeline
+ totalDuration={totalDuration}
+ scale={scale}
+ events={events}
+ rootSpanStatus={rootSpanStatus}
+ rootStartedAt={rootStartedAt}
+ parentRef={parentRef}
+ timelineScrollRef={timelineScrollRef}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ showDurations={showDurations}
+ treeScrollRef={treeScrollRef}
+ virtualizer={virtualizer}
+ toggleNodeSelection={toggleNodeSelection}
+ />
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ <div className="flex items-center justify-between gap-2 border-t border-border px-2">
+ <div className="grow @container">
+ <div className="hidden items-center gap-4 @[42rem]:flex">
+ <KeyboardShortcuts
+ expandAllBelowDepth={expandAllBelowDepth}
+ collapseAllBelowDepth={collapseAllBelowDepth}
+ toggleExpandLevel={toggleExpandLevel}
+ setShowDurations={setShowDurations}
+ />
+ </div>
+ <div className="@[42rem]:hidden">
+ <Popover>
+ <PopoverTrigger className="text-sm">Shortcuts</PopoverTrigger>
+ <PopoverContent
+ className="min-w-[20rem] overflow-y-auto p-2 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
+ align="start"
+ >
+ <div className="flex flex-col gap-2">
+ <KeyboardShortcuts
+ expandAllBelowDepth={expandAllBelowDepth}
+ collapseAllBelowDepth={collapseAllBelowDepth}
+ toggleExpandLevel={toggleExpandLevel}
+ setShowDurations={setShowDurations}
+ />
+ </div>
+ </PopoverContent>
+ </Popover>
+ </div>
+ </div>
+ <div className="flex items-center gap-4">
+ <Slider
+ variant="primary"
+ className="w-20"
+ leftIcon={<LuZoomOut />}
+ rightIcon={<LuZoomIn />}
+ value={[scale]}
+ onValueChange={(value) => setScale(value[0])}
+ min={0}
+ max={1}
+ step={0.05}
+ />
+ </div>
+ </div>
+ </div>
+ );
+};
+
+export default Gantt;
+
+type GanttTimelineProps = Pick<
+ GanttProps,
+ "totalDuration" | "rootSpanStatus" | "events" | "rootStartedAt"
+> & {
+ scale: number;
+ parentRef: React.RefObject<HTMLDivElement>;
+ timelineScrollRef: React.RefObject<HTMLDivElement>;
+ virtualizer: Virtualizer<HTMLElement, Element>;
+ nodes: NodesState;
+ getNodeProps: UseTreeStateOutput["getNodeProps"];
+ getTreeProps: UseTreeStateOutput["getTreeProps"];
+ toggleNodeSelection: UseTreeStateOutput["toggleNodeSelection"];
+ showDurations: boolean;
+ treeScrollRef: React.RefObject<HTMLDivElement>;
+};
+
+const TICK_COUNT = 5;
+
+const GanttTimeline = ({
+ totalDuration,
+ scale,
+ rootSpanStatus,
+ rootStartedAt,
+ parentRef,
+ timelineScrollRef,
+ virtualizer,
+ events,
+ nodes,
+ getNodeProps,
+ getTreeProps,
+ toggleNodeSelection,
+ showDurations,
+ treeScrollRef,
+}: GanttTimelineProps) => {
+ const timelineContainerRef = useRef<HTMLDivElement>(null);
+ const initialTimelineDimensions = useInitialDimensions(timelineContainerRef);
+ const minTimelineWidth = initialTimelineDimensions?.width ?? 300;
+ const maxTimelineWidth = minTimelineWidth * 10;
+
+ //we want to live-update the duration if the root span is still in progress
+ const [duration, setDuration] = useState(totalDuration);
+ useEffect(() => {
+ if (rootSpanStatus !== "inprogress" || !rootStartedAt) {
+ setDuration(totalDuration);
+ return;
+ }
+
+ const interval = setInterval(() => {
+ setDuration(Date.now() - rootStartedAt.getTime());
+ }, 5000);
+
+ return () => clearInterval(interval);
+ }, [totalDuration, rootSpanStatus]);
+
+ return (
+ <div
+ className="h-full overflow-x-auto overflow-y-hidden scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
+ ref={timelineContainerRef}
+ >
+ <Timeline.Root
+ durationMs={duration * 1.05}
+ scale={scale}
+ className="h-full overflow-hidden"
+ minWidth={minTimelineWidth}
+ maxWidth={maxTimelineWidth}
+ >
+ {/* Follows the cursor */}
+ <CurrentTimeIndicator totalDuration={duration} />
+
+ <Timeline.Row className="grid h-full grid-rows-[2rem_1fr]">
+ {/* The duration labels */}
+ <Timeline.Row>
+ <Timeline.Row className="h-6">
+ <Timeline.EquallyDistribute count={TICK_COUNT}>
+ {(ms: number, index: number) => {
+ if (index === TICK_COUNT - 1) return null;
+ return (
+ <Timeline.Point
+ ms={ms}
+ className={
+ "relative bottom-[2px] text-xxs text-text-dimmed"
+ }
+ >
+ {(ms) => (
+ <div
+ className={cn(
+ "whitespace-nowrap",
+ index === 0
+ ? "ml-1"
+ : index === TICK_COUNT - 1
+ ? "-ml-1 -translate-x-full"
+ : "-translate-x-1/2"
+ )}
+ >
+ {formatDurationMilliseconds(ms, {
+ style: "short",
+ maxDecimalPoints: ms < 1000 ? 0 : 1,
+ })}
+ </div>
+ )}
+ </Timeline.Point>
+ );
+ }}
+ </Timeline.EquallyDistribute>
+ {rootSpanStatus !== "inprogress" && (
+ <Timeline.Point
+ ms={duration}
+ className={cn(
+ "relative bottom-[2px] text-xxs",
+ rootSpanStatus === "completed"
+ ? "text-emerald-500"
+ : "text-destructive"
+ )}
+ >
+ {(ms) => (
+ <div className={cn("-translate-x-1/2 whitespace-nowrap")}>
+ {formatDurationMilliseconds(ms, {
+ style: "short",
+ maxDecimalPoints: ms < 1000 ? 0 : 1,
+ })}
+ </div>
+ )}
+ </Timeline.Point>
+ )}
+ </Timeline.Row>
+ <Timeline.Row className="h-2">
+ <Timeline.EquallyDistribute count={TICK_COUNT}>
+ {(ms: number, index: number) => {
+ if (index === 0 || index === TICK_COUNT - 1) return null;
+ return (
+ <Timeline.Point
+ ms={ms}
+ className={"h-full border-r border-muted"}
+ />
+ );
+ }}
+ </Timeline.EquallyDistribute>
+ <Timeline.Point
+ ms={duration}
+ className={cn(
+ "h-full border-r",
+ rootSpanStatus === "completed"
+ ? "border-success/30"
+ : "border-error/30"
+ )}
+ />
+ </Timeline.Row>
+ </Timeline.Row>
+ {/* Main timeline body */}
+ <Timeline.Row className="overflow-hidden">
+ {/* The vertical tick lines */}
+ <Timeline.EquallyDistribute count={TICK_COUNT}>
+ {(ms: number, index: number) => {
+ if (index === 0) return null;
+ return (
+ <Timeline.Point
+ ms={ms}
+ className={"h-full border-r border-muted"}
+ />
+ );
+ }}
+ </Timeline.EquallyDistribute>
+ {/* The completed line */}
+ {rootSpanStatus !== "inprogress" && (
+ <Timeline.Point
+ ms={duration}
+ className={cn(
+ "h-full border-r",
+ rootSpanStatus === "completed"
+ ? "border-emerald-500/90"
+ : "border-destructive/30"
+ )}
+ />
+ )}
+ <TreeView
+ scrollRef={timelineScrollRef}
+ virtualizer={virtualizer}
+ tree={events}
+ nodes={nodes}
+ getNodeProps={getNodeProps}
+ getTreeProps={getTreeProps}
+ parentClassName="h-full scrollbar-hide"
+ renderNode={({
+ node,
+ state,
+ index,
+ virtualizer,
+ virtualItem,
+ }) => {
+ return (
+ <Timeline.Row
+ key={index}
+ className={cn(
+ "group flex h-8 items-center",
+ state.selected
+ ? "bg-muted hover:bg-muted/90"
+ : "bg-transparent hover:bg-muted"
+ )}
+ // onMouseOver={() => console.log(`hover ${index}`)}
+ onClick={(e) => {
+ toggleNodeSelection(node.id);
+ }}
+ >
+ {node.data.level === "TRACE" ? (
+ <SpanWithDuration
+ showDuration={state.selected ? true : showDurations}
+ startMs={node.data.offset}
+ durationMs={
+ node.data.duration
+ ? node.data.duration
+ : duration - node.data.offset
+ }
+ node={node}
+ />
+ ) : (
+ <Timeline.Point ms={node.data.offset}>
+ {(ms) => (
+ <motion.div
+ className={cn(
+ "-ml-1 h-3 w-3 rounded-full",
+ eventBackgroundClassName(node.data)
+ )}
+ layoutId={node.id}
+ />
+ )}
+ </Timeline.Point>
+ )}
+ </Timeline.Row>
+ );
+ }}
+ onScroll={(scrollTop) => {
+ //sync the scroll to the tree
+ if (treeScrollRef.current) {
+ treeScrollRef.current.scrollTop = scrollTop;
+ }
+ }}
+ />
+ </Timeline.Row>
+ </Timeline.Row>
+ </Timeline.Root>
+ </div>
+ );
+};
+
+function NodeText({ node }: { node: GanttEvent }) {
+ const className = "truncate";
+ return (
+ <Paragraph variant="small" className={cn(className)}>
+ <SpanTitle {...node.data} size="small" />
+ </Paragraph>
+ );
+}
+
+function NodeStatusIcon({ node }: { node: GanttEvent }) {
+ if (node.data.isCancelled) {
+ return (
+ <>
+ <Paragraph
+ variant="extra-small"
+ className={runStatusClassNameColor("CANCELED")}
+ >
+ Canceled
+ </Paragraph>
+ <GanttTaskStatusIcon status="CANCELED" className={cn("w-4 h-4")} />
+ </>
+ );
+ }
+
+ if (node.data.isError) {
+ return (
+ <GanttTaskStatusIcon
+ status="COMPLETED_WITH_ERRORS"
+ className={cn("w-4 h-4")}
+ />
+ );
+ }
+
+ if (node.data.isPartial) {
+ return (
+ <GanttTaskStatusIcon status={"EXECUTING"} className={cn("w-4 h-4")} />
+ );
+ }
+
+ return (
+ <GanttTaskStatusIcon
+ status="COMPLETED_SUCCESSFULLY"
+ className={cn("w-4 h-4")}
+ />
+ );
+}
+
+function TaskLine({
+ isError,
+ isSelected,
+}: {
+ isError: boolean;
+ isSelected: boolean;
+}) {
+ return (
+ <div
+ className={cn(
+ "h-8 w-2 border-r border-border",
+ isError && "border-destructive",
+ isSelected && "border-foreground"
+ )}
+ />
+ );
+}
+
+function ShowParentLink({ ganttReadableId }: { ganttReadableId: string }) {
+ const [mouseOver, setMouseOver] = useState(false);
+ const { spanParam } = useParams();
+
+ return (
+ <Button
+ onMouseEnter={() => setMouseOver(true)}
+ onMouseLeave={() => setMouseOver(false)}
+ asChild
+ className="w-full text-left flex-1"
+ >
+ <Link
+ to={
+ spanParam
+ ? "/x/scheduling/runs?span=" + spanParam
+ : "x/scheduling/runs"
+ }
+ >
+ {mouseOver ? (
+ <ShowParentIconSelected className="h-4 w-4 text-indigo-500" />
+ ) : (
+ <ShowParentIcon className="text-gray-600 h-4 w-4" />
+ )}
+ <Paragraph
+ variant="small"
+ className={cn(mouseOver ? "text-indigo-500" : "text-gray-500")}
+ >
+ Show parent items
+ </Paragraph>
+ </Link>
+ </Button>
+ );
+}
+
+function LiveReloadingStatus({
+ rootSpanCompleted,
+}: {
+ rootSpanCompleted: boolean;
+}) {
+ if (rootSpanCompleted) return null;
+
+ return (
+ <div className="flex items-center gap-1">
+ <PulsingDot />
+ <Paragraph
+ variant="extra-small"
+ className="whitespace-nowrap text-primary"
+ >
+ Live reloading
+ </Paragraph>
+ </div>
+ );
+}
+
+function PulsingDot() {
+ return (
+ <span className="relative flex h-2 w-2">
+ <span
+ className={`absolute h-full w-full animate-ping rounded-full border border-primary opacity-100 duration-1000`}
+ />
+ <span className={`h-2 w-2 rounded-full bg-primary`} />
+ </span>
+ );
+}
+
+function SpanWithDuration({
+ showDuration,
+ node,
+ ...props
+}: Timeline.SpanProps & { node: GanttEvent; showDuration: boolean }) {
+ return (
+ <Timeline.Span {...props}>
+ <motion.div
+ className={cn(
+ "relative flex h-4 w-full min-w-[2px] items-center rounded-sm",
+ eventBackgroundClassName(node.data)
+ )}
+ layoutId={node.id}
+ >
+ {node.data.isPartial && (
+ <div
+ className="absolute left-0 top-0 h-full w-full animate-tile-scroll rounded-sm opacity-30"
+ style={{
+ backgroundImage: `url(${tileBgPath})`,
+ backgroundSize: "8px 8px",
+ }}
+ />
+ )}
+ <div
+ className={cn(
+ "sticky left-0 z-10 transition group-hover:opacity-100",
+ !showDuration && "opacity-0"
+ )}
+ >
+ <div className="rounded-sm px-1 py-0.5 text-xxs text-foreground">
+ {formatDurationMilliseconds(props.durationMs, {
+ style: "short",
+ maxDecimalPoints: props.durationMs < 1000 ? 0 : 1,
+ })}
+ </div>
+ </div>
+ </motion.div>
+ </Timeline.Span>
+ );
+}
+
+const edgeBoundary = 0.05;
+
+function CurrentTimeIndicator({ totalDuration }: { totalDuration: number }) {
+ return (
+ <Timeline.FollowCursor>
+ {(ms) => {
+ const ratio = ms / totalDuration;
+ let offset = 0.5;
+ if (ratio < edgeBoundary) {
+ offset = lerp(0, 0.5, ratio / edgeBoundary);
+ } else if (ratio > 1 - edgeBoundary) {
+ offset = lerp(0.5, 1, (ratio - (1 - edgeBoundary)) / edgeBoundary);
+ }
+
+ return (
+ <div className="relative z-50 flex h-full flex-col">
+ <div className="relative flex h-6 items-end">
+ <div
+ className="absolute w-fit whitespace-nowrap rounded-sm border border-border bg-gray-700 px-1 py-0.5 text-xxs tabular-nums text-text-bright"
+ style={{
+ left: `${offset * 100}%`,
+ transform: `translateX(-${offset * 100}%)`,
+ }}
+ >
+ {formatDurationMilliseconds(ms, {
+ style: "short",
+ maxDecimalPoints: ms < 1000 ? 0 : 1,
+ })}
+ </div>
+ </div>
+ <div className="w-px grow border-r border-border" />
+ </div>
+ );
+ }}
+ </Timeline.FollowCursor>
+ );
+}
+
+function KeyboardShortcuts({
+ expandAllBelowDepth,
+ collapseAllBelowDepth,
+ toggleExpandLevel,
+ setShowDurations,
+}: {
+ expandAllBelowDepth: (depth: number) => void;
+ collapseAllBelowDepth: (depth: number) => void;
+ toggleExpandLevel: (depth: number) => void;
+ setShowDurations: (show: (show: boolean) => boolean) => void;
+}) {
+ return (
+ <>
+ <ArrowKeyShortcuts />
+ <ShortcutWithAction
+ shortcut={{ key: "e" }}
+ action={() => expandAllBelowDepth(0)}
+ title="Expand all"
+ />
+ <ShortcutWithAction
+ shortcut={{ key: "c" }}
+ action={() => collapseAllBelowDepth(1)}
+ title="Collapse all"
+ />
+ <NumberShortcuts toggleLevel={(number) => toggleExpandLevel(number)} />
+ <ShortcutWithAction
+ shortcut={{ key: "d" }}
+ action={() => setShowDurations((d) => !d)}
+ title="Toggle durations"
+ />
+ </>
+ );
+}
+
+function ArrowKeyShortcuts() {
+ return (
+ <div className="flex items-center gap-0.5">
+ <ShortcutKey
+ shortcut={{ key: "arrowup" }}
+ variant="medium"
+ className="ml-0 mr-0"
+ />
+ <ShortcutKey
+ shortcut={{ key: "arrowdown" }}
+ variant="medium"
+ className="ml-0 mr-0"
+ />
+ <ShortcutKey
+ shortcut={{ key: "arrowleft" }}
+ variant="medium"
+ className="ml-0 mr-0"
+ />
+ <ShortcutKey
+ shortcut={{ key: "arrowright" }}
+ variant="medium"
+ className="ml-0 mr-0"
+ />
+ <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
+ Navigate
+ </Paragraph>
+ </div>
+ );
+}
+
+function ShortcutWithAction({
+ shortcut,
+ title,
+ action,
+}: {
+ shortcut: Shortcut;
+ title: string;
+ action: () => void;
+}) {
+ useShortcutKeys({
+ shortcut,
+ action,
+ });
+
+ return (
+ <div className="flex items-center gap-0.5">
+ <ShortcutKey shortcut={shortcut} variant="medium" className="ml-0 mr-0" />
+ <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
+ {title}
+ </Paragraph>
+ </div>
+ );
+}
+
+function NumberShortcuts({
+ toggleLevel,
+}: {
+ toggleLevel: (depth: number) => void;
+}) {
+ useHotkeys(
+ ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
+ (event, hotkeysEvent) => {
+ toggleLevel(Number(event.key));
+ }
+ );
+
+ return (
+ <div className="flex items-center gap-0.5">
+ <span className={cn(variants.medium, "ml-0 mr-0")}>0</span>
+ <span className="text-[0.75rem] text-text-dimmed">–</span>
+ <span className={cn(variants.medium, "ml-0 mr-0")}>9</span>
+ <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
+ Toggle level
+ </Paragraph>
+ </div>
+ );
+}
+
+function SearchField({ onChange }: { onChange: (value: string) => void }) {
+ const [value, setValue] = useState("");
+
+ const updateFilterText = useDebounce((text: string) => {
+ onChange(text);
+ }, 250);
+
+ const updateValue = (value: string) => {
+ setValue(value);
+ updateFilterText(value);
+ };
+
+ return (
+ <InputGroup insetRing className="border-transparent rounded-none ring-0">
+ <InputLeftElement>
+ <LuSearch className="h-4 w-4 text-muted-foreground" />
+ </InputLeftElement>
+ <Input
+ placeholder="Search Job"
+ value={value}
+ onChange={(e) => updateValue(e.target.value)}
+ />
+ </InputGroup>
+ );
+}
diff --git a/apps/carbon/app/components/Temporary/RunIcon.tsx b/apps/carbon/app/components/Gantt/components/GanttIcon.tsx
similarity index 86%
rename from apps/carbon/app/components/Temporary/RunIcon.tsx
rename to apps/carbon/app/components/Gantt/components/GanttIcon.tsx
index fa62e927a7..ed14d9009a 100644
--- a/apps/carbon/app/components/Temporary/RunIcon.tsx
+++ b/apps/carbon/app/components/Gantt/components/GanttIcon.tsx
@@ -1,6 +1,7 @@
import { cn } from "@carbon/react";
import { AiOutlinePartition } from "react-icons/ai";
import {
+ HiBeaker,
HiClock,
HiHandRaised,
HiInformationCircle,
@@ -15,7 +16,7 @@ type TaskIconProps = {
className?: string;
};
-export function RunIcon({ name, className }: TaskIconProps) {
+export function GanttIcon({ name, className }: TaskIconProps) {
if (!name)
return <HiSquares2X2 className={cn(className, "text-muted-foreground")} />;
@@ -30,14 +31,12 @@ export function RunIcon({ name, className }: TaskIconProps) {
return <LuClock className={cn(className, "text-blue-500")} />;
case "timecard":
return <TaskIcon className={cn(className, "text-yellow-500")} />;
+ case "inspection":
+ return <HiBeaker className={cn(className, "text-teal-500")} />;
case "attempt":
return <AttemptIcon className={cn(className, "text-muted-foreground")} />;
case "wait":
- return <HiClock className={cn(className, "text-teal-500")} />;
- case "trace":
- return (
- <HiSquares2X2 className={cn(className, "text-muted-foreground")} />
- );
+ return <HiClock className={cn(className, "text-yellow-500")} />;
//log levels
case "debug":
case "log":
diff --git a/apps/carbon/app/components/Temporary/TaskRunStatus.tsx b/apps/carbon/app/components/Gantt/components/GanttTaskStatus.tsx
similarity index 78%
rename from apps/carbon/app/components/Temporary/TaskRunStatus.tsx
rename to apps/carbon/app/components/Gantt/components/GanttTaskStatus.tsx
index 8d1ce7d775..34db93806e 100644
--- a/apps/carbon/app/components/Temporary/TaskRunStatus.tsx
+++ b/apps/carbon/app/components/Gantt/components/GanttTaskStatus.tsx
@@ -13,9 +13,8 @@ import { Spinner, cn } from "@carbon/react";
import assertNever from "assert-never";
import { LuSnowflake, LuXCircle } from "react-icons/lu";
-export type TaskRunStatus =
+export type GanttTaskStatus =
| "PENDING"
- | "WAITING_FOR_DEPLOY"
| "EXECUTING"
| "RETRYING_AFTER_FAILURE"
| "WAITING_TO_RESUME"
@@ -27,8 +26,7 @@ export type TaskRunStatus =
| "PAUSED"
| "CRASHED";
-export const allTaskRunStatuses = [
- "WAITING_FOR_DEPLOY",
+export const allGanttTaskStatuses = [
"PENDING",
"EXECUTING",
"RETRYING_AFTER_FAILURE",
@@ -39,11 +37,10 @@ export const allTaskRunStatuses = [
"CRASHED",
"INTERRUPTED",
"SYSTEM_FAILURE",
-] as TaskRunStatus[];
+] as GanttTaskStatus[];
-const taskRunStatusDescriptions: Record<TaskRunStatus, string> = {
+const taskRunStatusDescriptions: Record<GanttTaskStatus, string> = {
PENDING: "Task is waiting to be executed",
- WAITING_FOR_DEPLOY: "Task needs to be deployed first to start executing",
EXECUTING: "Task is currently being executed",
RETRYING_AFTER_FAILURE: "Task is being reattempted after a failure",
WAITING_TO_RESUME: "Task has been frozen and is waiting to be resumed",
@@ -56,18 +53,15 @@ const taskRunStatusDescriptions: Record<TaskRunStatus, string> = {
CRASHED: "Task has crashed and won't be retried",
};
-export const QUEUED_STATUSES: TaskRunStatus[] = [
- "PENDING",
- "WAITING_FOR_DEPLOY",
-];
+export const QUEUED_STATUSES: GanttTaskStatus[] = ["PENDING"];
-export const RUNNING_STATUSES: TaskRunStatus[] = [
+export const RUNNING_STATUSES: GanttTaskStatus[] = [
"EXECUTING",
"RETRYING_AFTER_FAILURE",
"WAITING_TO_RESUME",
];
-export const FINISHED_STATUSES: TaskRunStatus[] = [
+export const FINISHED_STATUSES: GanttTaskStatus[] = [
"COMPLETED_SUCCESSFULLY",
"CANCELED",
"COMPLETED_WITH_ERRORS",
@@ -76,31 +70,31 @@ export const FINISHED_STATUSES: TaskRunStatus[] = [
"CRASHED",
];
-export function descriptionForTaskRunStatus(status: TaskRunStatus): string {
+export function descriptionForGanttTaskStatus(status: GanttTaskStatus): string {
return taskRunStatusDescriptions[status];
}
-export function TaskRunStatusCombo({
+export function GanttTaskStatusCombo({
status,
className,
iconClassName,
}: {
- status: TaskRunStatus;
+ status: GanttTaskStatus;
className?: string;
iconClassName?: string;
}) {
return (
<span className={cn("flex items-center gap-1", className)}>
- <TaskRunStatusIcon
+ <GanttTaskStatusIcon
status={status}
className={cn("h-4 w-4", iconClassName)}
/>
- <TaskRunStatusLabel status={status} />
+ <GanttTaskStatusLabel status={status} />
</span>
);
}
-export function TaskRunStatusLabel({ status }: { status: TaskRunStatus }) {
+export function GanttTaskStatusLabel({ status }: { status: GanttTaskStatus }) {
return (
<span className={runStatusClassNameColor(status)}>
{runStatusTitle(status)}
@@ -108,11 +102,11 @@ export function TaskRunStatusLabel({ status }: { status: TaskRunStatus }) {
);
}
-export function TaskRunStatusIcon({
+export function GanttTaskStatusIcon({
status,
className,
}: {
- status: TaskRunStatus;
+ status: GanttTaskStatus;
className: string;
}) {
switch (status) {
@@ -122,12 +116,6 @@ export function TaskRunStatusIcon({
className={cn(runStatusClassNameColor(status), className)}
/>
);
- case "WAITING_FOR_DEPLOY":
- return (
- <HiRectangleStack
- className={cn(runStatusClassNameColor(status), className)}
- />
- );
case "EXECUTING":
return (
<Spinner
@@ -189,12 +177,10 @@ export function TaskRunStatusIcon({
}
}
-export function runStatusClassNameColor(status: TaskRunStatus): string {
+export function runStatusClassNameColor(status: GanttTaskStatus): string {
switch (status) {
case "PENDING":
return "text-gray-500";
- case "WAITING_FOR_DEPLOY":
- return "text-orange-500";
case "EXECUTING":
case "RETRYING_AFTER_FAILURE":
return "text-pending";
@@ -205,27 +191,25 @@ export function runStatusClassNameColor(status: TaskRunStatus): string {
case "CANCELED":
return "text-gray-500";
case "INTERRUPTED":
- return "text-error";
+ return "text-red-500";
case "COMPLETED_SUCCESSFULLY":
return "text-success";
case "COMPLETED_WITH_ERRORS":
- return "text-error";
+ return "text-red-500";
case "SYSTEM_FAILURE":
- return "text-error";
+ return "text-red-500";
case "CRASHED":
- return "text-error";
+ return "text-red-500";
default: {
assertNever(status);
}
}
}
-export function runStatusTitle(status: TaskRunStatus): string {
+export function runStatusTitle(status: GanttTaskStatus): string {
switch (status) {
case "PENDING":
return "Queued";
- case "WAITING_FOR_DEPLOY":
- return "Waiting for deploy";
case "EXECUTING":
return "Executing";
case "WAITING_TO_RESUME":
diff --git a/apps/carbon/app/components/Temporary/SpanTitle.tsx b/apps/carbon/app/components/Gantt/components/SpanTitle.tsx
similarity index 85%
rename from apps/carbon/app/components/Temporary/SpanTitle.tsx
rename to apps/carbon/app/components/Gantt/components/SpanTitle.tsx
index 4687338db4..7cf9541d48 100644
--- a/apps/carbon/app/components/Temporary/SpanTitle.tsx
+++ b/apps/carbon/app/components/Gantt/components/SpanTitle.tsx
@@ -1,14 +1,13 @@
import { Badge, cn } from "@carbon/react";
import { Fragment } from "react";
import { LuChevronRight } from "react-icons/lu";
-import type { z } from "zod";
-import type { RunEvent, TaskEventLevel, TaskEventStyle } from "./types";
+import type { GantEventLevel, GantEventStyle, GanttEvent } from "../types";
type SpanTitleProps = {
message: string;
isError: boolean;
- style: z.infer<typeof TaskEventStyle>;
- level: TaskEventLevel;
+ style: GantEventStyle;
+ level: GantEventLevel;
isPartial: boolean;
size: "small" | "large";
};
@@ -31,7 +30,7 @@ function SpanAccessory({
accessory,
size,
}: {
- accessory: z.infer<typeof TaskEventStyle>["accessory"];
+ accessory: GantEventStyle["accessory"];
size: SpanTitleProps["size"];
}) {
if (!accessory) {
@@ -68,7 +67,7 @@ export function SpanBadgeAccessory({
accessory,
className,
}: {
- accessory: NonNullable<z.infer<typeof TaskEventStyle>["accessory"]>;
+ accessory: NonNullable<GantEventStyle["accessory"]>;
className?: string;
}) {
return (
@@ -103,10 +102,10 @@ function eventTextClassName(
return textClassNameForVariant(event.style.variant);
}
case "WARN": {
- return "text-amber-400";
+ return "text-orange-500";
}
case "ERROR": {
- return "text-error";
+ return "text-red-500";
}
default: {
return textClassNameForVariant(event.style.variant);
@@ -116,12 +115,12 @@ function eventTextClassName(
export function eventBackgroundClassName(
event: Pick<
- RunEvent["data"],
+ GanttEvent["data"],
"isError" | "style" | "level" | "isPartial" | "isCancelled"
>
) {
if (event.isError) {
- return "bg-error";
+ return "bg-red-500";
}
if (event.isCancelled) {
@@ -144,10 +143,10 @@ export function eventBackgroundClassName(
);
}
case "WARN": {
- return "bg-orange-400";
+ return "bg-orange-500";
}
case "ERROR": {
- return "bg-destructive";
+ return "bg-red-500";
}
default: {
return backgroundClassNameForVariant(
@@ -158,9 +157,7 @@ export function eventBackgroundClassName(
}
}
-function textClassNameForVariant(
- variant: z.infer<typeof TaskEventStyle>["variant"]
-) {
+function textClassNameForVariant(variant: GantEventStyle["variant"]) {
switch (variant) {
case "primary": {
return "text-foreground";
@@ -172,7 +169,7 @@ function textClassNameForVariant(
}
function backgroundClassNameForVariant(
- variant: z.infer<typeof TaskEventStyle>["variant"],
+ variant: GantEventStyle["variant"],
isPartial: boolean
) {
switch (variant) {
diff --git a/apps/carbon/app/components/Gantt/index.ts b/apps/carbon/app/components/Gantt/index.ts
new file mode 100644
index 0000000000..aac895d9d4
--- /dev/null
+++ b/apps/carbon/app/components/Gantt/index.ts
@@ -0,0 +1,4 @@
+import Gantt from "./Gantt";
+
+export * from "./types";
+export { Gantt };
diff --git a/apps/carbon/app/components/Temporary/types.ts b/apps/carbon/app/components/Gantt/types.ts
similarity index 56%
rename from apps/carbon/app/components/Temporary/types.ts
rename to apps/carbon/app/components/Gantt/types.ts
index c481d4db80..17f50acfb6 100644
--- a/apps/carbon/app/components/Temporary/types.ts
+++ b/apps/carbon/app/components/Gantt/types.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
-export enum TaskEventLevel {
+export enum GantEventLevel {
TRACE = "TRACE",
DEBUG = "DEBUG",
INFO = "INFO",
@@ -9,7 +9,7 @@ export enum TaskEventLevel {
ERROR = "ERROR",
}
-export type RunEvent = {
+export type GanttEvent = {
id: string;
parentId: string | undefined;
children: string[];
@@ -21,33 +21,36 @@ export type RunEvent = {
message: string;
isRoot: boolean;
isError: boolean;
- style: z.infer<typeof TaskEventStyle>;
- level: TaskEventLevel;
+ style: GantEventStyle;
+ level: GantEventLevel;
isPartial: boolean;
isCancelled: boolean;
};
};
-const Variant = z.enum(["primary"]);
+const variant = z.enum(["primary"]);
-const AccessoryItem = z.object({
+const accessoryItem = z.object({
text: z.string(),
variant: z.string().optional(),
url: z.string().optional(),
});
+export type AccessoryItem = z.infer<typeof accessoryItem>;
-const Accessory = z.object({
- items: z.array(AccessoryItem),
+const accessory = z.object({
+ items: z.array(accessoryItem),
style: z.enum(["person"]).optional(),
});
+export type Accessory = z.infer<typeof accessory>;
-export const TaskEventStyle = z
+export const gantEventStyle = z
.object({
icon: z.string().optional(),
- variant: Variant.optional(),
- accessory: Accessory.optional(),
+ variant: variant.optional(),
+ accessory: accessory.optional(),
})
.default({
icon: undefined,
variant: undefined,
});
+export type GantEventStyle = z.infer<typeof gantEventStyle>;
diff --git a/apps/carbon/app/components/Kanban/Kanban.tsx b/apps/carbon/app/components/Kanban/Kanban.tsx
new file mode 100644
index 0000000000..378c3f8955
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/Kanban.tsx
@@ -0,0 +1,301 @@
+import { ClientOnly } from "@carbon/react";
+import type {
+ Announcements,
+ DragEndEvent,
+ DragOverEvent,
+ DragStartEvent,
+ UniqueIdentifier,
+} from "@dnd-kit/core";
+import {
+ DndContext,
+ DragOverlay,
+ KeyboardSensor,
+ MouseSensor,
+ TouchSensor,
+ useSensor,
+ useSensors,
+} from "@dnd-kit/core";
+import { SortableContext, arrayMove } from "@dnd-kit/sortable";
+import { useMemo, useRef, useState } from "react";
+import { createPortal } from "react-dom";
+import { BoardContainer, ColumnCard } from "./components/ColumnCard";
+import { ItemCard } from "./components/ItemCard";
+import type { Column, Item } from "./types";
+import { coordinateGetter, hasDraggableData } from "./utils";
+
+type KanbanProps = {
+ columns: Column[];
+ items: Item[];
+};
+
+const Kanban = ({
+ columns: initialColumns,
+ items: initialItems,
+}: KanbanProps) => {
+ const [columns, setColumns] = useState<Column[]>(initialColumns);
+ const pickedUpItemColumn = useRef<string | null>(null);
+ const columnIds = useMemo(() => columns.map((col) => col.id), [columns]);
+
+ const [items, setItems] = useState<Item[]>(initialItems);
+
+ const [activeColumn, setActiveColumn] = useState<Column | null>(null);
+
+ const [activeItem, setActiveItem] = useState<Item | null>(null);
+
+ const sensors = useSensors(
+ useSensor(MouseSensor),
+ useSensor(TouchSensor),
+ useSensor(KeyboardSensor, {
+ coordinateGetter,
+ })
+ );
+
+ function getDraggingItemData(itemId: UniqueIdentifier, columnId: string) {
+ const itemsInColumn = items.filter((item) => item.columnId === columnId);
+ const itemPosition = itemsInColumn.findIndex((item) => item.id === itemId);
+ const column = columns.find((col) => col.id === columnId);
+ return {
+ itemsInColumn,
+ itemPosition,
+ column,
+ };
+ }
+
+ const announcements: Announcements = {
+ onDragStart({ active }) {
+ if (!hasDraggableData(active)) return;
+ if (active.data.current?.type === "column") {
+ const startstringx = columnIds.findIndex((id) => id === active.id);
+ const startColumn = columns[startstringx];
+ return `Picked up Column ${startColumn?.title} at position: ${
+ startstringx + 1
+ } of ${columnIds.length}`;
+ } else if (active.data.current?.type === "item") {
+ pickedUpItemColumn.current = active.data.current.item.columnId;
+ const { itemsInColumn, itemPosition, column } = getDraggingItemData(
+ active.id,
+ pickedUpItemColumn.current
+ );
+ return `Picked up Item ${
+ active.data.current.item.content
+ } at position: ${itemPosition + 1} of ${
+ itemsInColumn.length
+ } in column ${column?.title}`;
+ }
+ },
+ onDragOver({ active, over }) {
+ if (!hasDraggableData(active) || !hasDraggableData(over)) return;
+
+ if (
+ active.data.current?.type === "column" &&
+ over.data.current?.type === "column"
+ ) {
+ const overstringx = columnIds.findIndex((id) => id === over.id);
+ return `Column ${active.data.current.column.title} was moved over ${
+ over.data.current.column.title
+ } at position ${overstringx + 1} of ${columnIds.length}`;
+ } else if (
+ active.data.current?.type === "item" &&
+ over.data.current?.type === "item"
+ ) {
+ const { itemsInColumn, itemPosition, column } = getDraggingItemData(
+ over.id,
+ over.data.current.item.columnId
+ );
+ if (over.data.current.item.columnId !== pickedUpItemColumn.current) {
+ return `Item ${
+ active.data.current.item.content
+ } was moved over column ${column?.title} in position ${
+ itemPosition + 1
+ } of ${itemsInColumn.length}`;
+ }
+ return `Item was moved over position ${itemPosition + 1} of ${
+ itemsInColumn.length
+ } in column ${column?.title}`;
+ }
+ },
+ onDragEnd({ active, over }) {
+ if (!hasDraggableData(active) || !hasDraggableData(over)) {
+ pickedUpItemColumn.current = null;
+ return;
+ }
+ if (
+ active.data.current?.type === "column" &&
+ over.data.current?.type === "column"
+ ) {
+ const overColumnPosition = columnIds.findIndex((id) => id === over.id);
+
+ return `Column ${
+ active.data.current.column.title
+ } was dropped into position ${overColumnPosition + 1} of ${
+ columnIds.length
+ }`;
+ } else if (
+ active.data.current?.type === "item" &&
+ over.data.current?.type === "item"
+ ) {
+ const { itemsInColumn, itemPosition, column } = getDraggingItemData(
+ over.id,
+ over.data.current.item.columnId
+ );
+ if (over.data.current.item.columnId !== pickedUpItemColumn.current) {
+ return `Item was dropped into column ${column?.title} in position ${
+ itemPosition + 1
+ } of ${itemsInColumn.length}`;
+ }
+ return `Item was dropped into position ${itemPosition + 1} of ${
+ itemsInColumn.length
+ } in column ${column?.title}`;
+ }
+ pickedUpItemColumn.current = null;
+ },
+ onDragCancel({ active }) {
+ pickedUpItemColumn.current = null;
+ if (!hasDraggableData(active)) return;
+ return `Dragging ${active.data.current?.type} cancelled.`;
+ },
+ };
+
+ return (
+ <DndContext
+ accessibility={{
+ announcements,
+ }}
+ sensors={sensors}
+ onDragStart={onDragStart}
+ onDragEnd={onDragEnd}
+ onDragOver={onDragOver}
+ >
+ <BoardContainer>
+ <SortableContext items={columnIds}>
+ {columns.map((col) => (
+ <ColumnCard
+ key={col.id}
+ column={col}
+ items={items.filter((item) => item.columnId === col.id)}
+ />
+ ))}
+ </SortableContext>
+ </BoardContainer>
+
+ <ClientOnly fallback={null}>
+ {() =>
+ createPortal(
+ <DragOverlay>
+ {activeColumn && (
+ <ColumnCard
+ isOverlay
+ column={activeColumn}
+ items={items.filter(
+ (item) => item.columnId === activeColumn.id
+ )}
+ />
+ )}
+ {activeItem && <ItemCard item={activeItem} isOverlay />}
+ </DragOverlay>,
+ document.body
+ )
+ }
+ </ClientOnly>
+ </DndContext>
+ );
+
+ function onDragStart(event: DragStartEvent) {
+ if (!hasDraggableData(event.active)) return;
+ const data = event.active.data.current;
+ if (data?.type === "column") {
+ setActiveColumn(data.column);
+ return;
+ }
+
+ if (data?.type === "item") {
+ setActiveItem(data.item);
+ return;
+ }
+ }
+
+ function onDragEnd(event: DragEndEvent) {
+ setActiveColumn(null);
+ setActiveItem(null);
+
+ const { active, over } = event;
+ if (!over) return;
+
+ const activeId = active.id;
+ const overId = over.id;
+
+ if (!hasDraggableData(active)) return;
+
+ const activeData = active.data.current;
+
+ if (activeId === overId) return;
+
+ const isActiveAColumn = activeData?.type === "column";
+ if (!isActiveAColumn) return;
+
+ setColumns((columns) => {
+ const activeColumnIndex = columns.findIndex((col) => col.id === activeId);
+
+ const overColumnIndex = columns.findIndex((col) => col.id === overId);
+
+ return arrayMove(columns, activeColumnIndex, overColumnIndex);
+ });
+ }
+
+ function onDragOver(event: DragOverEvent) {
+ const { active, over } = event;
+ if (!over) return;
+
+ const activeId = active.id;
+ const overId = over.id;
+
+ if (activeId === overId) return;
+
+ if (!hasDraggableData(active) || !hasDraggableData(over)) return;
+
+ const activeData = active.data.current;
+ const overData = over.data.current;
+
+ const isActiveAItem = activeData?.type === "item";
+ const isOverAItem = overData?.type === "item";
+
+ if (!isActiveAItem) return;
+
+ // Im dropping a Item over another Item
+ if (isActiveAItem && isOverAItem) {
+ setItems((items) => {
+ const activeIndex = items.findIndex((t) => t.id === activeId);
+ const overIndex = items.findIndex((t) => t.id === overId);
+ const activeItem = items[activeIndex];
+ const overItem = items[overIndex];
+ if (
+ activeItem &&
+ overItem &&
+ activeItem.columnId !== overItem.columnId
+ ) {
+ activeItem.columnId = overItem.columnId;
+ return arrayMove(items, activeIndex, overIndex - 1);
+ }
+
+ return arrayMove(items, activeIndex, overIndex);
+ });
+ }
+
+ const isOverAColumn = overData?.type === "column";
+
+ // Im dropping a Item over a column
+ if (isActiveAItem && isOverAColumn) {
+ setItems((items) => {
+ const activeIndex = items.findIndex((t) => t.id === activeId);
+ const activeItem = items[activeIndex];
+ if (activeItem) {
+ activeItem.columnId = overId as string;
+ return arrayMove(items, activeIndex, activeIndex);
+ }
+ return items;
+ });
+ }
+ }
+};
+
+export default Kanban;
diff --git a/apps/carbon/app/components/Kanban/components/ColumnCard.tsx b/apps/carbon/app/components/Kanban/components/ColumnCard.tsx
new file mode 100644
index 0000000000..7e8609eb9b
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/components/ColumnCard.tsx
@@ -0,0 +1,122 @@
+import {
+ Button,
+ Card,
+ CardContent,
+ CardHeader,
+ ScrollArea,
+ ScrollBar,
+} from "@carbon/react";
+import { useDndContext } from "@dnd-kit/core";
+import { SortableContext, useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import { cva } from "class-variance-authority";
+import { useMemo } from "react";
+import { LuGripVertical } from "react-icons/lu";
+import type { Column, ColumnDragData, Item } from "../types";
+import { ItemCard } from "./ItemCard";
+
+type ColumnCardProps = {
+ column: Column;
+ items: Item[];
+ isOverlay?: boolean;
+};
+
+export function ColumnCard({ column, items, isOverlay }: ColumnCardProps) {
+ const itemsIds = useMemo(() => {
+ return items.map((item) => item.id);
+ }, [items]);
+
+ const {
+ setNodeRef,
+ attributes,
+ listeners,
+ transform,
+ transition,
+ isDragging,
+ } = useSortable({
+ id: column.id,
+ data: {
+ type: "column",
+ column,
+ } satisfies ColumnDragData,
+ attributes: {
+ roleDescription: `Column: ${column.title}`,
+ },
+ });
+
+ const style = {
+ transition,
+ transform: CSS.Translate.toString(transform),
+ };
+
+ const variants = cva(
+ "w-[350px] max-w-full bg-primary-foreground flex flex-col flex-shrink-0 snap-center",
+ {
+ variants: {
+ dragging: {
+ default: "border-2 border-transparent",
+ over: "ring-2 opacity-30",
+ overlay: "ring-2 ring-primary",
+ },
+ },
+ }
+ );
+
+ return (
+ <Card
+ ref={setNodeRef}
+ style={style}
+ className={variants({
+ dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
+ })}
+ >
+ <CardHeader className="p-4 font-semibold border-b-2 text-left flex flex-row space-between items-center">
+ <span className="mr-auto truncate"> {column.title}</span>
+ <Button
+ variant={"ghost"}
+ {...attributes}
+ {...listeners}
+ className=" p-1 text-foreground/50 -ml-2 h-auto cursor-grab relative"
+ >
+ <span className="sr-only">{`Move column: ${column.title}`}</span>
+ <LuGripVertical />
+ </Button>
+ </CardHeader>
+ <ScrollArea>
+ <CardContent className="flex flex-grow flex-col gap-2 p-2">
+ <SortableContext items={itemsIds}>
+ {items.map((item) => (
+ <ItemCard key={item.id} item={item} />
+ ))}
+ </SortableContext>
+ </CardContent>
+ </ScrollArea>
+ </Card>
+ );
+}
+
+export function BoardContainer({ children }: { children: React.ReactNode }) {
+ const dndContext = useDndContext();
+
+ const variations = cva("px-2 md:px-0 flex lg:justify-center pb-4", {
+ variants: {
+ dragging: {
+ default: "snap-x snap-mandatory",
+ active: "snap-none",
+ },
+ },
+ });
+
+ return (
+ <ScrollArea
+ className={variations({
+ dragging: dndContext.active ? "active" : "default",
+ })}
+ >
+ <div className="flex gap-4 items-start flex-row justify-start p-4">
+ {children}
+ </div>
+ <ScrollBar orientation="horizontal" />
+ </ScrollArea>
+ );
+}
diff --git a/apps/carbon/app/components/Kanban/components/ItemCard.tsx b/apps/carbon/app/components/Kanban/components/ItemCard.tsx
new file mode 100644
index 0000000000..80844850d7
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/components/ItemCard.tsx
@@ -0,0 +1,74 @@
+import { Badge, Button, Card, CardContent, CardHeader } from "@carbon/react";
+import { useSortable } from "@dnd-kit/sortable";
+import { CSS } from "@dnd-kit/utilities";
+import { cva } from "class-variance-authority";
+import { LuGripVertical } from "react-icons/lu";
+
+import type { Item, ItemDragData } from "../types";
+
+type ItemCardProps = {
+ item: Item;
+ isOverlay?: boolean;
+};
+
+export function ItemCard({ item, isOverlay }: ItemCardProps) {
+ const {
+ setNodeRef,
+ attributes,
+ listeners,
+ transform,
+ transition,
+ isDragging,
+ } = useSortable({
+ id: item.id,
+ data: {
+ type: "item",
+ item,
+ } satisfies ItemDragData,
+ attributes: {
+ roleDescription: "item",
+ },
+ });
+
+ const style = {
+ transition,
+ transform: CSS.Translate.toString(transform),
+ };
+
+ const variants = cva("", {
+ variants: {
+ dragging: {
+ over: "ring-2 opacity-30",
+ overlay: "ring-2 ring-primary",
+ },
+ },
+ });
+
+ return (
+ <Card
+ ref={setNodeRef}
+ style={style}
+ className={variants({
+ dragging: isOverlay ? "overlay" : isDragging ? "over" : undefined,
+ })}
+ >
+ <CardHeader className="px-3 py-3 space-between flex flex-row border-b-2 border-secondary relative">
+ <Badge variant={"outline"} className="mr-auto font-semibold truncate">
+ Item
+ </Badge>
+ <Button
+ variant={"ghost"}
+ {...attributes}
+ {...listeners}
+ className="p-1 text-secondary-foreground/50 -ml-2 h-auto cursor-grab"
+ >
+ <span className="sr-only">Move item</span>
+ <LuGripVertical />
+ </Button>
+ </CardHeader>
+ <CardContent className="px-3 pt-3 pb-6 text-left whitespace-pre-wrap">
+ {item.content}
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/apps/carbon/app/components/Kanban/index.ts b/apps/carbon/app/components/Kanban/index.ts
new file mode 100644
index 0000000000..90c062f88c
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/index.ts
@@ -0,0 +1,4 @@
+import Kanban from "./Kanban";
+
+export * from "./types";
+export { Kanban };
diff --git a/apps/carbon/app/components/Kanban/types.ts b/apps/carbon/app/components/Kanban/types.ts
new file mode 100644
index 0000000000..3eff42214e
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/types.ts
@@ -0,0 +1,22 @@
+export interface Column {
+ id: string;
+ title: string;
+}
+
+export interface ColumnDragData {
+ type: "column";
+ column: Column;
+}
+
+export type DraggableData = ColumnDragData | ItemDragData;
+
+export interface Item {
+ id: string;
+ columnId: string;
+ content: string;
+}
+
+export interface ItemDragData {
+ type: "item";
+ item: Item;
+}
diff --git a/apps/carbon/app/components/Kanban/utils.ts b/apps/carbon/app/components/Kanban/utils.ts
new file mode 100644
index 0000000000..8d39bf7a2e
--- /dev/null
+++ b/apps/carbon/app/components/Kanban/utils.ts
@@ -0,0 +1,129 @@
+import type {
+ Active,
+ DataRef,
+ DroppableContainer,
+ KeyboardCoordinateGetter,
+ Over,
+} from "@dnd-kit/core";
+import { KeyboardCode, closestCorners, getFirstCollision } from "@dnd-kit/core";
+import type { DraggableData } from "./types";
+
+const directions: string[] = [
+ KeyboardCode.Down,
+ KeyboardCode.Right,
+ KeyboardCode.Up,
+ KeyboardCode.Left,
+];
+
+export const coordinateGetter: KeyboardCoordinateGetter = (
+ event,
+ { context: { active, droppableRects, droppableContainers, collisionRect } }
+) => {
+ if (directions.includes(event.code)) {
+ event.preventDefault();
+
+ if (!active || !collisionRect) {
+ return;
+ }
+
+ const filteredContainers: DroppableContainer[] = [];
+
+ droppableContainers.getEnabled().forEach((entry) => {
+ if (!entry || entry?.disabled) {
+ return;
+ }
+
+ const rect = droppableRects.get(entry.id);
+
+ if (!rect) {
+ return;
+ }
+
+ const data = entry.data.current;
+
+ if (data) {
+ const { type, children } = data;
+
+ if (type === "Column" && children?.length > 0) {
+ if (active.data.current?.type !== "Column") {
+ return;
+ }
+ }
+ }
+
+ switch (event.code) {
+ case KeyboardCode.Down:
+ if (active.data.current?.type === "Column") {
+ return;
+ }
+ if (collisionRect.top < rect.top) {
+ // find all droppable areas below
+ filteredContainers.push(entry);
+ }
+ break;
+ case KeyboardCode.Up:
+ if (active.data.current?.type === "Column") {
+ return;
+ }
+ if (collisionRect.top > rect.top) {
+ // find all droppable areas above
+ filteredContainers.push(entry);
+ }
+ break;
+ case KeyboardCode.Left:
+ if (collisionRect.left >= rect.left + rect.width) {
+ // find all droppable areas to left
+ filteredContainers.push(entry);
+ }
+ break;
+ case KeyboardCode.Right:
+ // find all droppable areas to right
+ if (collisionRect.left + collisionRect.width <= rect.left) {
+ filteredContainers.push(entry);
+ }
+ break;
+ }
+ });
+ const collisions = closestCorners({
+ active,
+ collisionRect: collisionRect,
+ droppableRects,
+ droppableContainers: filteredContainers,
+ pointerCoordinates: null,
+ });
+ const closestId = getFirstCollision(collisions, "id");
+
+ if (closestId != null) {
+ const newDroppable = droppableContainers.get(closestId);
+ const newNode = newDroppable?.node.current;
+ const newRect = newDroppable?.rect.current;
+
+ if (newNode && newRect) {
+ return {
+ x: newRect.left,
+ y: newRect.top,
+ };
+ }
+ }
+ }
+
+ return undefined;
+};
+
+export function hasDraggableData<T extends Active | Over>(
+ entry: T | null | undefined
+): entry is T & {
+ data: DataRef<DraggableData>;
+} {
+ if (!entry) {
+ return false;
+ }
+
+ const data = entry.data.current;
+
+ if (data?.type === "column" || data?.type === "item") {
+ return true;
+ }
+
+ return false;
+}
diff --git a/apps/carbon/app/components/Layout/Navigation/useModules.tsx b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
index 6f9f51cab7..e96e9c81c9 100644
--- a/apps/carbon/app/components/Layout/Navigation/useModules.tsx
+++ b/apps/carbon/app/components/Layout/Navigation/useModules.tsx
@@ -1,5 +1,4 @@
import {
- LuCalendarRange,
LuComponent,
LuCreditCard,
LuFiles,
@@ -36,12 +35,12 @@ export function useModules() {
// to: path.to.receipts,
// icon: LuBox,
// },
- {
- permission: "scheduling",
- name: "Scheduling",
- to: path.to.scheduling,
- icon: LuCalendarRange,
- },
+ // {
+ // permission: "scheduling",
+ // name: "Scheduling",
+ // to: path.to.scheduling,
+ // icon: LuCalendarRange,
+ // },
// {
// permission: "timecards",
// name: "Timecards",
diff --git a/apps/carbon/app/components/OperatingSystem.tsx b/apps/carbon/app/components/OperatingSystem.tsx
new file mode 100644
index 0000000000..374dbdfc84
--- /dev/null
+++ b/apps/carbon/app/components/OperatingSystem.tsx
@@ -0,0 +1,33 @@
+import type { ReactNode } from "react";
+import { createContext, useContext } from "react";
+
+export type OperatingSystemPlatform = "mac" | "windows";
+
+type OperatingSystemContext = {
+ platform: OperatingSystemPlatform;
+};
+
+type OperatingSystemContextProviderProps = {
+ platform: OperatingSystemPlatform;
+ children: ReactNode;
+};
+
+const Context = createContext<OperatingSystemContext | null>(null);
+
+export const OperatingSystemContextProvider = ({
+ platform,
+ children,
+}: OperatingSystemContextProviderProps) => {
+ return <Context.Provider value={{ platform }}>{children}</Context.Provider>;
+};
+
+const throwIfNoProvider = () => {
+ throw new Error(
+ "Please wrap your application in an OperatingSystemContextProvider."
+ );
+};
+
+export const useOperatingSystem = () => {
+ const { platform } = useContext(Context) ?? throwIfNoProvider();
+ return { platform };
+};
diff --git a/apps/carbon/app/components/ShortcutKey.tsx b/apps/carbon/app/components/ShortcutKey.tsx
new file mode 100644
index 0000000000..16f6e6d2e8
--- /dev/null
+++ b/apps/carbon/app/components/ShortcutKey.tsx
@@ -0,0 +1,83 @@
+import { cn } from "@carbon/react";
+import { Fragment } from "react";
+import {
+ HiChevronDown,
+ HiChevronLeft,
+ HiChevronRight,
+ HiChevronUp,
+} from "react-icons/hi2";
+import type { Modifier, ShortcutDefinition } from "~/hooks/useShortcutKeys";
+import { useOperatingSystem } from "./OperatingSystem";
+
+export const variants = {
+ small:
+ "text-[0.6rem] font-medium min-w-[17px] rounded-[2px] px-1 ml-1 -mr-0.5 grid place-content-center border border-dimmed/40 text-text-dimmed group-hover:text-text-bright/80 group-hover:border-dimmed/60 transition uppercase",
+ medium:
+ "text-[0.75rem] font-medium min-w-[17px] rounded-[2px] px-1 ml-1 -mr-0.5 grid place-content-center border border-dimmed/40 text-text-dimmed group-hover:text-text-bright/80 group-hover:border-dimmed/60 transition uppercase",
+};
+
+export type ShortcutKeyVariant = keyof typeof variants;
+
+type ShortcutKeyProps = {
+ shortcut: ShortcutDefinition;
+ variant: ShortcutKeyVariant;
+ className?: string;
+};
+
+export const ShortcutKey = ({
+ shortcut,
+ variant,
+ className,
+}: ShortcutKeyProps) => {
+ const { platform } = useOperatingSystem();
+ const isMac = platform === "mac";
+ let relevantShortcut =
+ "mac" in shortcut ? (isMac ? shortcut.mac : shortcut.windows) : shortcut;
+ const modifiers = relevantShortcut.modifiers ?? [];
+ const character = keyString(relevantShortcut.key, isMac, variant);
+
+ return (
+ <span className={cn(variants[variant], className)}>
+ {modifiers.map((k) => (
+ <Fragment key={k}>{modifierString(k, isMac)}</Fragment>
+ ))}
+ {character}
+ </span>
+ );
+};
+
+function keyString(key: String, isMac: boolean, size: "small" | "medium") {
+ key = key.toLowerCase();
+
+ const className = size === "small" ? "w-2.5 h-4" : "w-3 h-5";
+
+ switch (key) {
+ case "enter":
+ return isMac ? "↵" : key;
+ case "arrowdown":
+ return <HiChevronDown className={className} />;
+ case "arrowup":
+ return <HiChevronUp className={className} />;
+ case "arrowleft":
+ return <HiChevronLeft className={className} />;
+ case "arrowright":
+ return <HiChevronRight className={className} />;
+ default:
+ return key;
+ }
+}
+
+function modifierString(modifier: Modifier, isMac: boolean) {
+ switch (modifier) {
+ case "alt":
+ return isMac ? "⌥" : "Alt+";
+ case "ctrl":
+ return isMac ? "⌃" : "Ctrl+";
+ case "meta":
+ return isMac ? "⌘" : "⊞+";
+ case "shift":
+ return isMac ? "⇧" : "Shift+";
+ case "mod":
+ return isMac ? "⌘" : "Ctrl+";
+ }
+}
diff --git a/apps/carbon/app/components/Temporary/index.ts b/apps/carbon/app/components/Temporary/index.ts
deleted file mode 100644
index 54002c83a9..0000000000
--- a/apps/carbon/app/components/Temporary/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./Paragraph";
-export * from "./SpanTitle";
diff --git a/apps/carbon/app/components/index.ts b/apps/carbon/app/components/index.ts
index 5c32013356..445cd9a9c8 100644
--- a/apps/carbon/app/components/index.ts
+++ b/apps/carbon/app/components/index.ts
@@ -12,6 +12,7 @@ import Hyperlink from "./Hyperlink";
import MultiSelect from "./MultiSelect";
import New from "./New";
import Select from "./Select";
+import { ShortcutKey } from "./ShortcutKey";
import SupplierAvatar from "./SupplierAvatar";
import Table from "./Table";
@@ -32,6 +33,7 @@ export {
MultiSelect,
New,
Select,
+ ShortcutKey,
SupplierAvatar,
Table,
useOptimisticAssignment,
diff --git a/apps/carbon/app/entry.client.tsx b/apps/carbon/app/entry.client.tsx
index b7481b01e2..655767e675 100644
--- a/apps/carbon/app/entry.client.tsx
+++ b/apps/carbon/app/entry.client.tsx
@@ -1,8 +1,9 @@
import { RemixBrowser } from "@remix-run/react";
-import { startTransition, StrictMode, useEffect } from "react";
-import { hydrateRoot } from "react-dom/client";
import posthog from "posthog-js";
+import { startTransition, useEffect } from "react";
+import { hydrateRoot } from "react-dom/client";
import { POSTHOG_API_HOST, POSTHOG_PROJECT_PUBLIC_KEY } from "~/config/env";
+import { OperatingSystemContextProvider } from "./components/OperatingSystem";
function PosthogInit() {
useEffect(() => {
@@ -15,23 +16,14 @@ function PosthogInit() {
return null;
}
-//hydrateRoot(
-//document,
-// <OperatingSystemContextProvider
-// platform={window.navigator.userAgent.includes("Mac") ? "mac" : "windows"}
-// >
-// <LocaleContextProvider locales={window.navigator.languages as string[]}>
-//<RemixBrowser />
-// </LocaleContextProvider>
-// </OperatingSystemContextProvider>
-//);
-
startTransition(() => {
hydrateRoot(
document,
- <StrictMode>
+ <OperatingSystemContextProvider
+ platform={window.navigator.userAgent.includes("Mac") ? "mac" : "windows"}
+ >
<RemixBrowser />
<PosthogInit />
- </StrictMode>
+ </OperatingSystemContextProvider>
);
});
diff --git a/apps/carbon/app/entry.server.tsx b/apps/carbon/app/entry.server.tsx
index 632a44e037..a439464668 100644
--- a/apps/carbon/app/entry.server.tsx
+++ b/apps/carbon/app/entry.server.tsx
@@ -1,14 +1,13 @@
-import {
- createReadableStreamFromReadable,
- type DataFunctionArgs,
- type EntryContext,
-} from "@remix-run/node"; // or cloudflare/deno
+import type { EntryContext, LoaderFunctionArgs } from "@remix-run/node";
+import { createReadableStreamFromReadable } from "@remix-run/node"; // or cloudflare/deno
import { RemixServer } from "@remix-run/react";
// import { parseAcceptLanguage } from "intl-parse-accept-language";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";
import { PassThrough } from "stream";
import logger from "~/lib/logger";
+import type { OperatingSystemPlatform } from "./components/OperatingSystem";
+import { OperatingSystemContextProvider } from "./components/OperatingSystem";
const ABORT_DELAY = 30000;
@@ -27,10 +26,12 @@ export default function handleRequest(
// validate: Intl.DateTimeFormat.supportedLocalesOf,
// });
- //get whether it's a mac or pc from the headers
- // const platform: OperatingSystemPlatform = request.headers.get("user-agent")?.includes("Mac")
- // ? "mac"
- // : "windows";
+ // get whether it's a mac or pc from the headers
+ const platform: OperatingSystemPlatform = request.headers
+ .get("user-agent")
+ ?.includes("Mac")
+ ? "mac"
+ : "windows";
// If the request is from a bot, we want to wait for the full
// response to render before sending it to the client. This
@@ -40,9 +41,9 @@ export default function handleRequest(
request,
responseStatusCode,
responseHeaders,
- remixContext
+ remixContext,
// locales,
- // platform
+ platform
);
}
@@ -50,9 +51,9 @@ export default function handleRequest(
request,
responseStatusCode,
responseHeaders,
- remixContext
+ remixContext,
// locales,
- // platform
+ platform
);
}
@@ -60,22 +61,20 @@ function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
- remixContext: EntryContext
+ remixContext: EntryContext,
// locales: string[],
- // platform: OperatingSystemPlatform
+ platform: OperatingSystemPlatform
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
- // <OperatingSystemContextProvider platform={platform}>
- // <LocaleContextProvider locales={locales}>
- <RemixServer
- context={remixContext}
- url={request.url}
- abortDelay={ABORT_DELAY}
- />,
- // </LocaleContextProvider>
- // </OperatingSystemContextProvider>,
+ <OperatingSystemContextProvider platform={platform}>
+ <RemixServer
+ context={remixContext}
+ url={request.url}
+ abortDelay={ABORT_DELAY}
+ />
+ </OperatingSystemContextProvider>,
{
onAllReady() {
shellRendered = true;
@@ -116,22 +115,20 @@ function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
- remixContext: EntryContext
+ remixContext: EntryContext,
// locales: string[],
- // platform: OperatingSystemPlatform
+ platform: OperatingSystemPlatform
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
- // <OperatingSystemContextProvider platform={platform}>
- // <LocaleContextProvider locales={locales}>
- <RemixServer
- context={remixContext}
- url={request.url}
- abortDelay={ABORT_DELAY}
- />,
- // </LocaleContextProvider>
- // </OperatingSystemContextProvider>,
+ <OperatingSystemContextProvider platform={platform}>
+ <RemixServer
+ context={remixContext}
+ url={request.url}
+ abortDelay={ABORT_DELAY}
+ />
+ </OperatingSystemContextProvider>,
{
onShellReady() {
shellRendered = true;
@@ -170,7 +167,7 @@ function handleBrowserRequest(
export function handleError(
error: unknown,
- { request, params, context }: DataFunctionArgs
+ { request, params, context }: LoaderFunctionArgs
) {
logger.error(error, request);
}
diff --git a/apps/carbon/app/hooks/index.ts b/apps/carbon/app/hooks/index.ts
index d398ae2a0d..3d7f9fb4a4 100644
--- a/apps/carbon/app/hooks/index.ts
+++ b/apps/carbon/app/hooks/index.ts
@@ -5,6 +5,7 @@ import { useOptimisticLocation } from "./useOptimisticLocation";
import { usePermissions } from "./usePermissions";
import { useRealtime } from "./useRealtime";
import { useRouteData } from "./useRouteData";
+import { useShortcutKeys } from "./useShortcutKeys";
import { useUrlParams } from "./useUrlParams";
import { useUser } from "./useUser";
@@ -16,6 +17,7 @@ export {
usePermissions,
useRealtime,
useRouteData,
+ useShortcutKeys,
useUrlParams,
useUser,
};
diff --git a/apps/carbon/app/hooks/useShortcutKeys.ts b/apps/carbon/app/hooks/useShortcutKeys.ts
new file mode 100644
index 0000000000..c92fe6b8b1
--- /dev/null
+++ b/apps/carbon/app/hooks/useShortcutKeys.ts
@@ -0,0 +1,68 @@
+import { useHotkeys } from "react-hotkeys-hook";
+import { useOperatingSystem } from "~/components/OperatingSystem";
+
+export type Modifier = "alt" | "ctrl" | "meta" | "shift" | "mod";
+
+export type Shortcut = {
+ key: string;
+ modifiers?: Modifier[];
+ enabledOnInputElements?: boolean;
+};
+
+export type ShortcutDefinition =
+ | {
+ windows: Shortcut;
+ mac: Shortcut;
+ }
+ | Shortcut;
+
+type useShortcutKeysProps = {
+ shortcut: ShortcutDefinition | undefined;
+ action: (event: KeyboardEvent) => void;
+ disabled?: boolean;
+ enabledOnInputElements?: boolean;
+};
+
+export function useShortcutKeys({
+ shortcut,
+ action,
+ disabled = false,
+ enabledOnInputElements,
+}: useShortcutKeysProps) {
+ const { platform } = useOperatingSystem();
+ const isMac = platform === "mac";
+ const relevantShortcut =
+ shortcut && "mac" in shortcut
+ ? isMac
+ ? shortcut.mac
+ : shortcut.windows
+ : shortcut;
+
+ const keys = createKeysFromShortcut(relevantShortcut);
+ useHotkeys(
+ keys,
+ (event, hotkeysEvent) => {
+ action(event);
+ },
+ {
+ enabled: !disabled,
+ enableOnFormTags:
+ enabledOnInputElements ?? relevantShortcut?.enabledOnInputElements,
+ enableOnContentEditable:
+ enabledOnInputElements ?? relevantShortcut?.enabledOnInputElements,
+ }
+ );
+}
+
+function createKeysFromShortcut(shortcut: Shortcut | undefined) {
+ if (!shortcut) {
+ return [];
+ }
+
+ const modifiers = shortcut.modifiers;
+ const character = shortcut.key;
+
+ return modifiers
+ ? modifiers.map((k) => k).join("+") + "+" + character
+ : character;
+}
diff --git a/apps/carbon/app/routes/x+/scheduling+/gantt.tsx b/apps/carbon/app/routes/x+/scheduling+/gantt.tsx
new file mode 100644
index 0000000000..07cf47a8d6
--- /dev/null
+++ b/apps/carbon/app/routes/x+/scheduling+/gantt.tsx
@@ -0,0 +1,387 @@
+import {
+ ClientOnly,
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+ cn,
+ useDebounce,
+} from "@carbon/react";
+import type { Location } from "@remix-run/react";
+import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
+import { typedjson, useTypedLoaderData } from "remix-typedjson";
+
+import type { GanttEvent } from "~/components/Gantt";
+import { Gantt } from "~/components/Gantt";
+import { useReplaceLocation } from "~/hooks/useReplaceLocation";
+import { requirePermissions } from "~/services/auth/auth.server";
+import {
+ getResizableGanttSettings,
+ setResizableGanttSettings,
+} from "~/utils/resizablePanel";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ await requirePermissions(request, {
+ view: "scheduling",
+ });
+
+ const resizeSettings = await getResizableGanttSettings(request);
+
+ return typedjson({
+ trace: {
+ events: [
+ {
+ id: "1",
+ parentId: undefined,
+ hasChildren: true,
+ children: ["2", "3"],
+ level: 0,
+ data: {
+ duration: 42000,
+ offset: 0,
+ level: "TRACE",
+ message: "WO-012345",
+ isPartial: false,
+ isRoot: true,
+ isError: false,
+ style: {
+ icon: "job",
+ },
+ },
+ },
+ {
+ id: "2",
+ parentId: "1",
+ hasChildren: true,
+ children: ["4"],
+ level: 1,
+ data: {
+ duration: 10000,
+ offset: 0,
+ level: "TRACE",
+ message: "Plasma",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "operation",
+ },
+ },
+ },
+ {
+ id: "4",
+ parentId: "2",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 10000,
+ offset: 0,
+ level: "TRACE",
+ message: "Timecard",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "timecard",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Anne Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ id: "3",
+ parentId: "1",
+ hasChildren: true,
+ children: ["5", "6"],
+ level: 1,
+ data: {
+ duration: 8000,
+ offset: 13000,
+ level: "TRACE",
+ message: "Bend",
+ isPartial: false,
+ isRoot: false,
+ isError: true,
+ style: {
+ variant: "primary",
+ icon: "operation",
+ },
+ },
+ },
+ {
+ id: "5",
+ parentId: "3",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 8000,
+ offset: 13000,
+ level: "TRACE",
+ message: "Timecard",
+ isPartial: false,
+ isRoot: false,
+ isError: true,
+ style: {
+ variant: "primary",
+ icon: "timecard",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Brad Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ id: "6",
+ parentId: "3",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 0,
+ offset: 21000,
+ level: "ERROR",
+ message: "Inspection",
+ isPartial: false,
+ isRoot: false,
+ isError: true,
+ style: {
+ icon: "inspection",
+ variant: "primary",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Brigette Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ id: "7",
+ parentId: "1",
+ hasChildren: true,
+ children: ["8"],
+ level: 1,
+ data: {
+ duration: 10000,
+ offset: 21000,
+ level: "TRACE",
+ message: "Plasma",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "operation",
+ },
+ },
+ },
+ {
+ id: "8",
+ parentId: "7",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 10000,
+ offset: 21000,
+ level: "TRACE",
+ message: "Timecard",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "timecard",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Anne Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ id: "9",
+ parentId: "1",
+ hasChildren: true,
+ children: ["10", "11"],
+ level: 1,
+ data: {
+ duration: 8000,
+ offset: 34000,
+ level: "TRACE",
+ message: "Bend",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "operation",
+ },
+ },
+ },
+ {
+ id: "10",
+ parentId: "9",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 8000,
+ offset: 34000,
+ level: "TRACE",
+ message: "Timecard",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ variant: "primary",
+ icon: "timecard",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Brad Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ id: "11",
+ parentId: "9",
+ hasChildren: false,
+ children: [],
+ level: 2,
+ data: {
+ duration: 0,
+ offset: 42000,
+ level: "LOG",
+ message: "Inspection",
+ isPartial: false,
+ isRoot: false,
+ isError: false,
+ style: {
+ icon: "inspection",
+ variant: "primary",
+ accessory: {
+ style: "person",
+ items: [
+ {
+ text: "Brigette Barbin",
+ },
+ ],
+ },
+ },
+ },
+ },
+ ] as GanttEvent[],
+ parentReadableId: "",
+ duration: 42000,
+ rootSpanStatus: "completed" as const,
+ rootStartedAt: new Date(),
+ },
+ resizeSettings,
+ });
+}
+
+function getSpanId(location: Location<any>): string | undefined {
+ const search = new URLSearchParams(location.search);
+ return search.get("span") ?? undefined;
+}
+
+export default function GanttView() {
+ const { trace, resizeSettings } = useTypedLoaderData<typeof loader>();
+
+ const { location, replaceSearchParam } = useReplaceLocation();
+ const selectedSpanId = getSpanId(location);
+
+ const { events, parentReadableId, duration, rootSpanStatus, rootStartedAt } =
+ trace;
+
+ const changeToSpan = useDebounce((selectedSpan: string) => {
+ replaceSearchParam("span", selectedSpan);
+ }, 250);
+
+ return (
+ <div
+ className={cn(
+ "grid h-full max-h-full grid-cols-1 overflow-hidden bg-background"
+ )}
+ >
+ <ClientOnly fallback={null}>
+ {() => (
+ <ResizablePanelGroup
+ direction="horizontal"
+ className="h-full max-h-full"
+ onLayout={(layout) => {
+ if (layout.length !== 2) return;
+ if (!selectedSpanId) return;
+ setResizableGanttSettings(document, layout);
+ }}
+ >
+ <ResizablePanel
+ order={1}
+ minSize={30}
+ defaultSize={resizeSettings.layout?.[0]}
+ >
+ <Gantt
+ selectedId={selectedSpanId}
+ key={events[0]?.id ?? "-"}
+ events={events}
+ parentReadableId={parentReadableId}
+ onSelectedIdChanged={(selectedSpan) => {
+ //instantly close the panel if no span is selected
+ if (!selectedSpan) {
+ replaceSearchParam("span");
+ return;
+ }
+
+ changeToSpan(selectedSpan);
+ }}
+ totalDuration={duration}
+ rootSpanStatus={rootSpanStatus}
+ rootStartedAt={rootStartedAt}
+ />
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ {selectedSpanId && (
+ <ResizablePanel
+ order={2}
+ minSize={30}
+ defaultSize={resizeSettings.layout?.[1]}
+ >
+ {/* <SpanView
+ runParam={run.readableId}
+ spanId={selectedSpanId}
+ closePanel={() => replaceSearchParam("span")}
+ /> */}
+ </ResizablePanel>
+ )}
+ </ResizablePanelGroup>
+ )}
+ </ClientOnly>
+ </div>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/scheduling+/index.tsx b/apps/carbon/app/routes/x+/scheduling+/index.tsx
index 2fcc862666..3476e774c5 100644
--- a/apps/carbon/app/routes/x+/scheduling+/index.tsx
+++ b/apps/carbon/app/routes/x+/scheduling+/index.tsx
@@ -1,1138 +1,125 @@
-import {
- Badge,
- Button,
- ClientOnly,
- Input,
- InputGroup,
- InputLeftElement,
- ResizableHandle,
- ResizablePanel,
- ResizablePanelGroup,
- Slider,
- Switch,
- cn,
- useDebounce,
- useInitialDimensions,
-} from "@carbon/react";
-import { formatDurationMilliseconds, lerp } from "@carbon/utils";
-import type { Location } from "@remix-run/react";
-import { Link, useParams } from "@remix-run/react";
-import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
-import type { Virtualizer } from "@tanstack/react-virtual";
-import { motion } from "framer-motion";
-import { useEffect, useRef, useState } from "react";
-import {
- LuChevronDown,
- LuChevronUp,
- LuSearch,
- LuZoomIn,
- LuZoomOut,
-} from "react-icons/lu";
+import { Button, HStack, cn } from "@carbon/react";
+import type { LoaderFunctionArgs } from "@remix-run/node";
+import { LuListFilter } from "react-icons/lu";
import { typedjson, useTypedLoaderData } from "remix-typedjson";
-import {
- ShowParentIcon,
- ShowParentIconSelected,
-} from "~/assets/icons/ShowParentIcon";
-import tileBgPath from "~/assets/images/[email protected]";
-
-import {
- Paragraph,
- SpanTitle,
- eventBackgroundClassName,
-} from "~/components/Temporary";
-import { RunIcon } from "~/components/Temporary/RunIcon";
-
-import {
- TaskRunStatusIcon,
- runStatusClassNameColor,
-} from "~/components/Temporary/TaskRunStatus";
-import type { RunEvent } from "~/components/Temporary/types";
-import * as Timeline from "~/components/Timeline";
-import type { UseTreeStateOutput } from "~/components/TreeView/TreeView";
-import { TreeView, useTree } from "~/components/TreeView/TreeView";
-import type { NodesState } from "~/components/TreeView/reducer";
-import { useReplaceLocation } from "~/hooks/useReplaceLocation";
-import { useUser } from "~/hooks/useUser";
-import { requirePermissions } from "~/services/auth/auth.server";
-import {
- getResizableRunSettings,
- setResizableRunSettings,
-} from "~/utils/resizablePanel";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- await requirePermissions(request, {
- view: "scheduling",
- });
-
- const resizeSettings = await getResizableRunSettings(request);
+import type { Column, Item } from "~/components/Kanban";
+import { Kanban } from "~/components/Kanban";
+import { DebouncedInput } from "~/components/Search";
+export async function loader({ request }: LoaderFunctionArgs) {
return typedjson({
- trace: {
- events: [
- {
- id: "1",
- parentId: undefined,
- hasChildren: true,
- children: ["2", "3"],
- level: 0,
- data: {
- duration: 21000,
- offset: 0,
- level: "TRACE",
- message: "F01234",
- isPartial: true,
- isRoot: true,
- isError: false,
- style: {
- icon: "job",
- },
- },
- },
- {
- id: "2",
- parentId: "1",
- hasChildren: true,
- children: ["4"],
- level: 1,
- data: {
- duration: 10000,
- offset: 0,
- level: "TRACE",
- message: "Plasma",
- isPartial: false,
- isRoot: false,
- isError: false,
- style: {
- variant: "primary",
- icon: "operation",
- },
- },
- },
- {
- id: "4",
- parentId: "2",
- hasChildren: false,
- children: [],
- level: 2,
- data: {
- duration: 10000,
- offset: 0,
- level: "TRACE",
- message: "Timecard",
- isPartial: false,
- isRoot: false,
- isError: false,
- style: {
- variant: "primary",
- icon: "timecard",
- accessory: {
- style: "person",
- items: [
- {
- text: "Anne Barbin",
- },
- ],
- },
- },
- },
- },
- {
- id: "3",
- parentId: "1",
- hasChildren: true,
- children: ["5"],
- level: 1,
- data: {
- duration: 8000,
- offset: 13000,
- level: "TRACE",
- message: "Bend",
- isPartial: true,
- isRoot: false,
- isError: false,
- style: {
- variant: "primary",
- icon: "operation",
- },
- },
- },
- {
- id: "5",
- parentId: "3",
- hasChildren: false,
- children: [],
- level: 2,
- data: {
- duration: 8000,
- offset: 13000,
- level: "TRACE",
- message: "Timecard",
- isPartial: true,
- isRoot: false,
- isError: false,
- style: {
- variant: "primary",
- icon: "timecard",
- accessory: {
- style: "person",
- items: [
- {
- text: "Brad Barbin",
- },
- ],
- },
- },
- },
- },
- ] as RunEvent[],
- parentRunFriendlyId: "",
- duration: 21000,
- rootSpanStatus: "completed" as const,
- rootStartedAt: new Date(),
- },
- resizeSettings,
- });
-}
-
-function getSpanId(location: Location<any>): string | undefined {
- const search = new URLSearchParams(location.search);
- return search.get("span") ?? undefined;
-}
-
-export default function LiveView() {
- const { trace, resizeSettings } = useTypedLoaderData<typeof loader>();
- const user = useUser();
- const { location, replaceSearchParam } = useReplaceLocation();
- const selectedSpanId = getSpanId(location);
-
- const {
- events,
- parentRunFriendlyId,
- duration,
- rootSpanStatus,
- rootStartedAt,
- } = trace;
-
- const changeToSpan = useDebounce((selectedSpan: string) => {
- replaceSearchParam("span", selectedSpan);
- }, 250);
-
- return (
- <div
- className={cn(
- "grid h-full max-h-full grid-cols-1 overflow-hidden bg-background"
- )}
- >
- <ClientOnly fallback={null}>
- {() => (
- <ResizablePanelGroup
- direction="horizontal"
- className="h-full max-h-full"
- onLayout={(layout) => {
- if (layout.length !== 2) return;
- if (!selectedSpanId) return;
- setResizableRunSettings(document, layout);
- }}
- >
- <ResizablePanel
- order={1}
- minSize={30}
- defaultSize={resizeSettings.layout?.[0]}
- >
- <TasksTreeView
- selectedId={selectedSpanId}
- key={events[0]?.id ?? "-"}
- events={events}
- parentRunFriendlyId={parentRunFriendlyId}
- onSelectedIdChanged={(selectedSpan) => {
- //instantly close the panel if no span is selected
- if (!selectedSpan) {
- replaceSearchParam("span");
- return;
- }
-
- changeToSpan(selectedSpan);
- }}
- totalDuration={duration}
- rootSpanStatus={rootSpanStatus}
- rootStartedAt={rootStartedAt}
- />
- </ResizablePanel>
- <ResizableHandle withHandle />
- {selectedSpanId && (
- <ResizablePanel
- order={2}
- minSize={30}
- defaultSize={resizeSettings.layout?.[1]}
- >
- {/* <SpanView
- runParam={run.friendlyId}
- spanId={selectedSpanId}
- closePanel={() => replaceSearchParam("span")}
- /> */}
- </ResizablePanel>
- )}
- </ResizablePanelGroup>
- )}
- </ClientOnly>
- </div>
- );
-}
-
-type TasksTreeViewProps = {
- events: RunEvent[];
- selectedId?: string;
- parentRunFriendlyId?: string;
- onSelectedIdChanged: (selectedId: string | undefined) => void;
- totalDuration: number;
- rootSpanStatus: "inprogress" | "completed" | "todo" | "cancelled";
- rootStartedAt: Date | undefined;
-};
-
-function TasksTreeView({
- events,
- selectedId,
- parentRunFriendlyId,
- onSelectedIdChanged,
- totalDuration,
- rootSpanStatus,
- rootStartedAt,
-}: TasksTreeViewProps) {
- const [filterText, setFilterText] = useState("");
- const [wipOnly, setWipOnly] = useState(false);
- const [showDurations, setShowDurations] = useState(false);
- const [scale, setScale] = useState(0);
- const parentRef = useRef<HTMLDivElement>(null);
- const treeScrollRef = useRef<HTMLDivElement>(null);
- const timelineScrollRef = useRef<HTMLDivElement>(null);
-
- const {
- nodes,
- getTreeProps,
- getNodeProps,
- toggleNodeSelection,
- toggleExpandNode,
- expandAllBelowDepth,
- toggleExpandLevel,
- collapseAllBelowDepth,
- selectNode,
- scrollToNode,
- virtualizer,
- } = useTree({
- tree: events,
- selectedId,
- // collapsedIds,
- onSelectedIdChanged,
- estimatedRowHeight: () => 32,
- parentRef,
- filter: {
- value: { text: filterText, wipOnly },
- fn: (value, node) => {
- const isWIP = (value.wipOnly && node.data.isPartial) || !value.wipOnly;
-
- if (!isWIP) return false;
-
- if (value.text === "") return true;
- if (
- node.data.message.toLowerCase().includes(value.text.toLowerCase())
- ) {
- return true;
- }
- return false;
+ columns: [
+ {
+ id: "1",
+ title: "Assembly Station 1",
+ },
+ {
+ id: "2",
+ title: "Assembly Station 2",
+ },
+ {
+ id: "3",
+ title: "Band Saw",
+ },
+ {
+ id: "4",
+ title: "Bench Grinder",
+ },
+ {
+ id: "5",
+ title: "CNC Mill 1",
+ },
+ ] satisfies Column[],
+ items: [
+ {
+ id: "item1",
+ columnId: "3",
+ content: "Project initiation and planning",
+ },
+ {
+ id: "item2",
+ columnId: "3",
+ content: "Gather requirements from stakeholders",
+ },
+ {
+ id: "item3",
+ columnId: "3",
+ content: "Create wireframes and mockups",
},
- },
+ {
+ id: "item4",
+ columnId: "2",
+ content: "Develop homepage layout",
+ },
+ {
+ id: "item5",
+ columnId: "2",
+ content: "Design color scheme and typography",
+ },
+ {
+ id: "item6",
+ columnId: "1",
+ content: "Implement user authentication",
+ },
+ {
+ id: "item7",
+ columnId: "1",
+ content: "Build contact us page",
+ },
+ {
+ id: "item8",
+ columnId: "1",
+ content: "Create product catalog",
+ },
+ {
+ id: "item9",
+ columnId: "1",
+ content: "Develop about us page",
+ },
+ {
+ id: "item10",
+ columnId: "1",
+ content: "Optimize website for mobile devices",
+ },
+ {
+ id: "item11",
+ columnId: "1",
+ content: "Integrate payment gateway",
+ },
+ {
+ id: "item12",
+ columnId: "1",
+ content: "Perform testing and bug fixing",
+ },
+ {
+ id: "item13",
+ columnId: "1",
+ content: "Launch website and deploy to server",
+ },
+ ] satisfies Item[],
});
-
- return (
- <div className="grid h-full grid-rows-[2.5rem_1fr_3.25rem] overflow-hidden">
- <div className="flex items-center justify-between gap-2 border-b border-border">
- <SearchField onChange={setFilterText} />
- <div className="flex items-center gap-2">
- <Switch
- variant="small"
- label="In Process Only"
- checked={wipOnly}
- onCheckedChange={(e) => setWipOnly(e.valueOf())}
- />
- <Switch
- variant="small"
- label="Show Durations"
- checked={showDurations}
- onCheckedChange={(e) => setShowDurations(e.valueOf())}
- />
- </div>
- </div>
- <ResizablePanelGroup
- direction="horizontal"
- onLayout={(layout) => {
- if (layout.length !== 2) return;
- setResizableRunSettings(document, layout);
- }}
- >
- {/* Tree list */}
- <ResizablePanel
- order={1}
- minSize={20}
- defaultSize={50}
- className="pl-3"
- >
- <div className="grid h-full grid-rows-[2rem_1fr] overflow-hidden">
- <div className="flex items-center pr-2">
- {parentRunFriendlyId && (
- <ShowParentLink runFriendlyId={parentRunFriendlyId} />
- )}
- <LiveReloadingStatus
- rootSpanCompleted={rootSpanStatus !== "inprogress"}
- />
- </div>
- <TreeView
- parentRef={parentRef}
- scrollRef={treeScrollRef}
- virtualizer={virtualizer}
- autoFocus
- tree={events}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- renderNode={({ node, state }) => (
- <>
- <div
- className={cn(
- "flex h-8 cursor-pointer items-center overflow-hidden rounded-l-sm pr-2",
- state.selected
- ? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted/90"
- )}
- onClick={() => {
- selectNode(node.id);
- }}
- >
- <div className="flex h-8 items-center">
- {Array.from({ length: node.level }).map((_, index) => (
- <TaskLine
- key={index}
- isError={node.data.isError}
- isSelected={state.selected}
- />
- ))}
- <div
- className={cn(
- "flex h-8 w-4 items-center",
- node.hasChildren && "hover:bg-accent"
- )}
- onClick={(e) => {
- e.stopPropagation();
- if (e.altKey) {
- if (state.expanded) {
- collapseAllBelowDepth(node.level);
- } else {
- expandAllBelowDepth(node.level);
- }
- } else {
- toggleExpandNode(node.id);
- }
- scrollToNode(node.id);
- }}
- >
- {node.hasChildren ? (
- state.expanded ? (
- <LuChevronDown className="h-4 w-4 text-gray-400" />
- ) : (
- <LuChevronUp className="h-4 w-4 text-gray-400" />
- )
- ) : (
- <div className="h-8 w-4" />
- )}
- </div>
- </div>
-
- <div className="flex w-full items-center justify-between gap-2 pl-1">
- <div className="flex items-center gap-2 overflow-x-hidden">
- <RunIcon
- name={node.data.style?.icon}
- className="h-4 min-h-4 w-4 min-w-4"
- />
- <NodeText node={node} />
- {node.data.isRoot && (
- <Badge variant="outline" className="text-xs">
- Job
- </Badge>
- )}
- </div>
- <div className="flex items-center gap-1">
- <NodeStatusIcon node={node} />
- </div>
- </div>
- </div>
- </>
- )}
- onScroll={(scrollTop) => {
- //sync the scroll to the tree
- if (timelineScrollRef.current) {
- timelineScrollRef.current.scrollTop = scrollTop;
- }
- }}
- />
- </div>
- </ResizablePanel>
- <ResizableHandle withHandle />
- {/* Timeline */}
- <ResizablePanel order={2} minSize={20} defaultSize={50}>
- <TimelineView
- totalDuration={totalDuration}
- scale={scale}
- events={events}
- rootSpanStatus={rootSpanStatus}
- rootStartedAt={rootStartedAt}
- parentRef={parentRef}
- timelineScrollRef={timelineScrollRef}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- showDurations={showDurations}
- treeScrollRef={treeScrollRef}
- virtualizer={virtualizer}
- toggleNodeSelection={toggleNodeSelection}
- />
- </ResizablePanel>
- </ResizablePanelGroup>
- <div className="flex items-center justify-between gap-2 border-t border-border px-2">
- <div className="grow @container">
- {/*
- <div className="hidden items-center gap-4 @[42rem]:flex">
- <KeyboardShortcuts
- expandAllBelowDepth={expandAllBelowDepth}
- collapseAllBelowDepth={collapseAllBelowDepth}
- toggleExpandLevel={toggleExpandLevel}
- setShowDurations={setShowDurations}
- />
- </div>
- <div className="@[42rem]:hidden">
- <Popover>
- <PopoverTrigger>Shortcuts</PopoverTrigger>
- <PopoverContent
- className="min-w-[20rem] overflow-y-auto p-2 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
- align="start"
- >
- <Heading size="h3">Keyboard shortcuts</Heading>
- <div className="flex flex-col gap-2">
- <KeyboardShortcuts
- expandAllBelowDepth={expandAllBelowDepth}
- collapseAllBelowDepth={collapseAllBelowDepth}
- toggleExpandLevel={toggleExpandLevel}
- setShowDurations={setShowDurations}
- />
- </div>
- </PopoverContent>
- </Popover>
- </div> */}
- </div>
- <div className="flex items-center gap-4">
- <Slider
- variant="primary"
- className="w-20"
- leftIcon={<LuZoomOut />}
- rightIcon={<LuZoomIn />}
- value={[scale]}
- onValueChange={(value) => setScale(value[0])}
- min={0}
- max={1}
- step={0.05}
- />
- </div>
- </div>
- </div>
- );
-}
-
-type TimelineViewProps = Pick<
- TasksTreeViewProps,
- "totalDuration" | "rootSpanStatus" | "events" | "rootStartedAt"
-> & {
- scale: number;
- parentRef: React.RefObject<HTMLDivElement>;
- timelineScrollRef: React.RefObject<HTMLDivElement>;
- virtualizer: Virtualizer<HTMLElement, Element>;
- nodes: NodesState;
- getNodeProps: UseTreeStateOutput["getNodeProps"];
- getTreeProps: UseTreeStateOutput["getTreeProps"];
- toggleNodeSelection: UseTreeStateOutput["toggleNodeSelection"];
- showDurations: boolean;
- treeScrollRef: React.RefObject<HTMLDivElement>;
-};
-
-const tickCount = 5;
-
-function TimelineView({
- totalDuration,
- scale,
- rootSpanStatus,
- rootStartedAt,
- parentRef,
- timelineScrollRef,
- virtualizer,
- events,
- nodes,
- getNodeProps,
- getTreeProps,
- toggleNodeSelection,
- showDurations,
- treeScrollRef,
-}: TimelineViewProps) {
- const timelineContainerRef = useRef<HTMLDivElement>(null);
- const initialTimelineDimensions = useInitialDimensions(timelineContainerRef);
- const minTimelineWidth = initialTimelineDimensions?.width ?? 300;
- const maxTimelineWidth = minTimelineWidth * 10;
-
- //we want to live-update the duration if the root span is still in progress
- const [duration, setDuration] = useState(totalDuration);
- useEffect(() => {
- if (rootSpanStatus !== "inprogress" || !rootStartedAt) {
- setDuration(totalDuration);
- return;
- }
-
- const interval = setInterval(() => {
- setDuration(Date.now() - rootStartedAt.getTime());
- }, 5000);
-
- return () => clearInterval(interval);
- }, [totalDuration, rootSpanStatus]);
-
- return (
- <div
- className="h-full overflow-x-auto overflow-y-hidden scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
- ref={timelineContainerRef}
- >
- <Timeline.Root
- durationMs={duration * 1.05}
- scale={scale}
- className="h-full overflow-hidden"
- minWidth={minTimelineWidth}
- maxWidth={maxTimelineWidth}
- >
- {/* Follows the cursor */}
- <CurrentTimeIndicator totalDuration={duration} />
-
- <Timeline.Row className="grid h-full grid-rows-[2rem_1fr]">
- {/* The duration labels */}
- <Timeline.Row>
- <Timeline.Row className="h-6">
- <Timeline.EquallyDistribute count={tickCount}>
- {(ms: number, index: number) => {
- if (index === tickCount - 1) return null;
- return (
- <Timeline.Point
- ms={ms}
- className={
- "relative bottom-[2px] text-xxs text-text-dimmed"
- }
- >
- {(ms) => (
- <div
- className={cn(
- "whitespace-nowrap",
- index === 0
- ? "ml-1"
- : index === tickCount - 1
- ? "-ml-1 -translate-x-full"
- : "-translate-x-1/2"
- )}
- >
- {formatDurationMilliseconds(ms, {
- style: "short",
- maxDecimalPoints: ms < 1000 ? 0 : 1,
- })}
- </div>
- )}
- </Timeline.Point>
- );
- }}
- </Timeline.EquallyDistribute>
- {rootSpanStatus !== "inprogress" && (
- <Timeline.Point
- ms={duration}
- className={cn(
- "relative bottom-[2px] text-xxs",
- rootSpanStatus === "completed"
- ? "text-emerald-500"
- : "text-destructive"
- )}
- >
- {(ms) => (
- <div className={cn("-translate-x-1/2 whitespace-nowrap")}>
- {formatDurationMilliseconds(ms, {
- style: "short",
- maxDecimalPoints: ms < 1000 ? 0 : 1,
- })}
- </div>
- )}
- </Timeline.Point>
- )}
- </Timeline.Row>
- <Timeline.Row className="h-2">
- <Timeline.EquallyDistribute count={tickCount}>
- {(ms: number, index: number) => {
- if (index === 0 || index === tickCount - 1) return null;
- return (
- <Timeline.Point
- ms={ms}
- className={"h-full border-r border-muted"}
- />
- );
- }}
- </Timeline.EquallyDistribute>
- <Timeline.Point
- ms={duration}
- className={cn(
- "h-full border-r",
- rootSpanStatus === "completed"
- ? "border-success/30"
- : "border-error/30"
- )}
- />
- </Timeline.Row>
- </Timeline.Row>
- {/* Main timeline body */}
- <Timeline.Row className="overflow-hidden">
- {/* The vertical tick lines */}
- <Timeline.EquallyDistribute count={tickCount}>
- {(ms: number, index: number) => {
- if (index === 0) return null;
- return (
- <Timeline.Point
- ms={ms}
- className={"h-full border-r border-muted"}
- />
- );
- }}
- </Timeline.EquallyDistribute>
- {/* The completed line */}
- {rootSpanStatus !== "inprogress" && (
- <Timeline.Point
- ms={duration}
- className={cn(
- "h-full border-r",
- rootSpanStatus === "completed"
- ? "border-emerald-500/90"
- : "border-destructive/30"
- )}
- />
- )}
- <TreeView
- scrollRef={timelineScrollRef}
- virtualizer={virtualizer}
- tree={events}
- nodes={nodes}
- getNodeProps={getNodeProps}
- getTreeProps={getTreeProps}
- parentClassName="h-full scrollbar-hide"
- renderNode={({
- node,
- state,
- index,
- virtualizer,
- virtualItem,
- }) => {
- return (
- <Timeline.Row
- key={index}
- className={cn(
- "group flex h-8 items-center",
- state.selected
- ? "bg-muted hover:bg-muted/90"
- : "bg-transparent hover:bg-muted"
- )}
- // onMouseOver={() => console.log(`hover ${index}`)}
- onClick={(e) => {
- toggleNodeSelection(node.id);
- }}
- >
- {node.data.level === "TRACE" ? (
- <SpanWithDuration
- showDuration={state.selected ? true : showDurations}
- startMs={node.data.offset}
- durationMs={
- node.data.duration
- ? node.data.duration
- : duration - node.data.offset
- }
- node={node}
- />
- ) : (
- <Timeline.Point ms={node.data.offset}>
- {(ms) => (
- <motion.div
- className={cn(
- "-ml-1 h-3 w-3 rounded-full border-2 border-border",
- eventBackgroundClassName(node.data)
- )}
- layoutId={node.id}
- />
- )}
- </Timeline.Point>
- )}
- </Timeline.Row>
- );
- }}
- onScroll={(scrollTop) => {
- //sync the scroll to the tree
- if (treeScrollRef.current) {
- treeScrollRef.current.scrollTop = scrollTop;
- }
- }}
- />
- </Timeline.Row>
- </Timeline.Row>
- </Timeline.Root>
- </div>
- );
-}
-
-function NodeText({ node }: { node: RunEvent }) {
- const className = "truncate";
- return (
- <Paragraph variant="small" className={cn(className)}>
- <SpanTitle {...node.data} size="small" />
- </Paragraph>
- );
-}
-
-function NodeStatusIcon({ node }: { node: RunEvent }) {
- if (node.data.level !== "TRACE") return null;
- if (node.data.style.variant !== "primary") return null;
-
- if (node.data.isCancelled) {
- return (
- <>
- <Paragraph
- variant="extra-small"
- className={runStatusClassNameColor("CANCELED")}
- >
- Canceled
- </Paragraph>
- <TaskRunStatusIcon status="CANCELED" className={cn("w-4 h-4")} />
- </>
- );
- }
-
- if (node.data.isError) {
- return (
- <TaskRunStatusIcon
- status="COMPLETED_WITH_ERRORS"
- className={cn("w-4 h-4")}
- />
- );
- }
-
- if (node.data.isPartial) {
- return <TaskRunStatusIcon status={"EXECUTING"} className={cn("w-4 h-4")} />;
- }
-
- return (
- <TaskRunStatusIcon
- status="COMPLETED_SUCCESSFULLY"
- className={cn("w-4 h-4")}
- />
- );
-}
-
-function TaskLine({
- isError,
- isSelected,
-}: {
- isError: boolean;
- isSelected: boolean;
-}) {
- return <div className={cn("h-8 w-2 border-r border-border")} />;
-}
-
-function ShowParentLink({ runFriendlyId }: { runFriendlyId: string }) {
- const [mouseOver, setMouseOver] = useState(false);
- const { spanParam } = useParams();
-
- return (
- <Button
- onMouseEnter={() => setMouseOver(true)}
- onMouseLeave={() => setMouseOver(false)}
- asChild
- className="w-full text-left flex-1"
- >
- <Link
- to={
- spanParam
- ? "/x/scheduling/runs?span=" + spanParam
- : "x/scheduling/runs"
- }
- >
- {mouseOver ? (
- <ShowParentIconSelected className="h-4 w-4 text-indigo-500" />
- ) : (
- <ShowParentIcon className="text-gray-600 h-4 w-4" />
- )}
- <Paragraph
- variant="small"
- className={cn(mouseOver ? "text-indigo-500" : "text-gray-500")}
- >
- Show parent items
- </Paragraph>
- </Link>
- </Button>
- );
}
-function LiveReloadingStatus({
- rootSpanCompleted,
-}: {
- rootSpanCompleted: boolean;
-}) {
- if (rootSpanCompleted) return null;
-
- return (
- <div className="flex items-center gap-1">
- <PulsingDot />
- <Paragraph
- variant="extra-small"
- className="whitespace-nowrap text-primary"
- >
- Live reloading
- </Paragraph>
- </div>
- );
-}
-
-function PulsingDot() {
- return (
- <span className="relative flex h-2 w-2">
- <span
- className={`absolute h-full w-full animate-ping rounded-full border border-primary opacity-100 duration-1000`}
- />
- <span className={`h-2 w-2 rounded-full bg-primary`} />
- </span>
- );
-}
-
-function SpanWithDuration({
- showDuration,
- node,
- ...props
-}: Timeline.SpanProps & { node: RunEvent; showDuration: boolean }) {
- return (
- <Timeline.Span {...props}>
- <motion.div
- className={cn(
- "relative flex h-4 w-full min-w-[2px] items-center rounded-sm",
- eventBackgroundClassName(node.data)
- )}
- layoutId={node.id}
- >
- {node.data.isPartial && (
- <div
- className="absolute left-0 top-0 h-full w-full animate-tile-scroll rounded-sm opacity-30"
- style={{
- backgroundImage: `url(${tileBgPath})`,
- backgroundSize: "8px 8px",
- }}
- />
- )}
- <div
- className={cn(
- "sticky left-0 z-10 transition group-hover:opacity-100",
- !showDuration && "opacity-0"
- )}
- >
- <div className="rounded-sm px-1 py-0.5 text-xxs text-foreground">
- {formatDurationMilliseconds(props.durationMs, {
- style: "short",
- maxDecimalPoints: props.durationMs < 1000 ? 0 : 1,
- })}
- </div>
- </div>
- </motion.div>
- </Timeline.Span>
- );
-}
-
-const edgeBoundary = 0.05;
-
-function CurrentTimeIndicator({ totalDuration }: { totalDuration: number }) {
+export default function KanbanView() {
+ const { columns, items } = useTypedLoaderData<typeof loader>();
return (
- <Timeline.FollowCursor>
- {(ms) => {
- const ratio = ms / totalDuration;
- let offset = 0.5;
- if (ratio < edgeBoundary) {
- offset = lerp(0, 0.5, ratio / edgeBoundary);
- } else if (ratio > 1 - edgeBoundary) {
- offset = lerp(0.5, 1, (ratio - (1 - edgeBoundary)) / edgeBoundary);
- }
-
- return (
- <div className="relative z-50 flex h-full flex-col">
- <div className="relative flex h-6 items-end">
- <div
- className="absolute w-fit whitespace-nowrap rounded-sm border border-border bg-gray-700 px-1 py-0.5 text-xxs tabular-nums text-text-bright"
- style={{
- left: `${offset * 100}%`,
- transform: `translateX(-${offset * 100}%)`,
- }}
- >
- {formatDurationMilliseconds(ms, {
- style: "short",
- maxDecimalPoints: ms < 1000 ? 0 : 1,
- })}
- </div>
- </div>
- <div className="w-px grow border-r border-border" />
- </div>
- );
- }}
- </Timeline.FollowCursor>
- );
-}
-
-/*
-function KeyboardShortcuts({
- expandAllBelowDepth,
- collapseAllBelowDepth,
- toggleExpandLevel,
- setShowDurations,
-}: {
- expandAllBelowDepth: (depth: number) => void;
- collapseAllBelowDepth: (depth: number) => void;
- toggleExpandLevel: (depth: number) => void;
- setShowDurations: (show: (show: boolean) => boolean) => void;
-}) {
- return (
- <>
- <ArrowKeyShortcuts />
- <ShortcutWithAction
- shortcut={{ key: "e" }}
- action={() => expandAllBelowDepth(0)}
- title="Expand all"
- />
- <ShortcutWithAction
- shortcut={{ key: "c" }}
- action={() => collapseAllBelowDepth(1)}
- title="Collapse all"
- />
- <NumberShortcuts toggleLevel={(number) => toggleExpandLevel(number)} />
- <ShortcutWithAction
- shortcut={{ key: "d" }}
- action={() => setShowDurations((d) => !d)}
- title="Toggle durations"
- />
- </>
- );
-}
-
-function ArrowKeyShortcuts() {
- return (
- <div className="flex items-center gap-0.5">
- <ShortcutKey
- shortcut={{ key: "arrowup" }}
- variant="medium"
- className="ml-0 mr-0"
- />
- <ShortcutKey
- shortcut={{ key: "arrowdown" }}
- variant="medium"
- className="ml-0 mr-0"
- />
- <ShortcutKey
- shortcut={{ key: "arrowleft" }}
- variant="medium"
- className="ml-0 mr-0"
- />
- <ShortcutKey
- shortcut={{ key: "arrowright" }}
- variant="medium"
- className="ml-0 mr-0"
- />
- <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
- Navigate
- </Paragraph>
- </div>
- );
-}
-
-function ShortcutWithAction({
- shortcut,
- title,
- action,
-}: {
- shortcut: Shortcut;
- title: string;
- action: () => void;
-}) {
- useKeyboardShortcuts({
- shortcut,
- action,
- });
-
- return (
- <div className="flex items-center gap-0.5">
- <ShortcutKey shortcut={shortcut} variant="medium" className="ml-0 mr-0" />
- <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
- {title}
- </Paragraph>
- </div>
- );
-}
-
-function NumberShortcuts({
- toggleLevel,
-}: {
- toggleLevel: (depth: number) => void;
-}) {
- useKeyboardShortcuts({
- "1": () => toggleLevel(1),
- "2": () => toggleLevel(2),
- "3": () => toggleLevel(3),
- "4": () => toggleLevel(4),
- "5": () => toggleLevel(5),
- "6": () => toggleLevel(6),
- "7": () => toggleLevel(7),
- "8": () => toggleLevel(8),
- "9": () => toggleLevel(9),
- "0": () => toggleLevel(0),
- });
+ <div className={cn("grid grid-cols-1 h-full max-h-full overflow-hidden")}>
+ <HStack className="px-4 py-2 justify-between bg-card border-b border-border w-full">
+ <HStack>
+ <DebouncedInput param="search" size="sm" placeholder="Search" />
+ {/* <Filter filters={filters} /> */}
+ <Button
+ rightIcon={<LuListFilter />}
+ role="combobox"
+ variant="secondary"
+ className={"!border-dashed border-border"}
+ >
+ Filter
+ </Button>
+ </HStack>
+ </HStack>
- return (
- <div className="flex items-center gap-0.5">
- <span className={cn(variants.medium, "ml-0 mr-0")}>0</span>
- <span className="text-[0.75rem] text-text-dimmed">–</span>
- <span className={cn(variants.medium, "ml-0 mr-0")}>9</span>
- <Paragraph variant="extra-small" className="ml-1.5 whitespace-nowrap">
- Toggle level
- </Paragraph>
+ <Kanban columns={columns} items={items} />
</div>
);
}
-*/
-
-function SearchField({ onChange }: { onChange: (value: string) => void }) {
- const [value, setValue] = useState("");
-
- const updateFilterText = useDebounce((text: string) => {
- onChange(text);
- }, 250);
-
- const updateValue = (value: string) => {
- setValue(value);
- updateFilterText(value);
- };
-
- return (
- <InputGroup insetRing className="border-transparent rounded-none ring-0">
- <InputLeftElement>
- <LuSearch className="h-4 w-4 text-muted-foreground" />
- </InputLeftElement>
- <Input
- placeholder="Search Job"
- value={value}
- onChange={(e) => updateValue(e.target.value)}
- />
- </InputGroup>
- );
-}
diff --git a/apps/carbon/app/utils/resizablePanel.ts b/apps/carbon/app/utils/resizablePanel.ts
index 47f30a814d..a3ca7ec8d5 100644
--- a/apps/carbon/app/utils/resizablePanel.ts
+++ b/apps/carbon/app/utils/resizablePanel.ts
@@ -24,14 +24,14 @@ function getCookieValue(
//run page
const runResizableName = "resizable-panels:run";
-export async function getResizableRunSettings(
+export async function getResizableGanttSettings(
request: Request
): Promise<ResizableConfig> {
const cookieHeader = request.headers.get("Cookie");
return getCookieValue(cookieHeader, runResizableName);
}
-export async function setResizableRunSettings(
+export async function setResizableGanttSettings(
document: Document,
layout: number[]
) {
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 2997fdea72..13324adeda 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -9,6 +9,8 @@
"@carbon/redis": "*",
"@carbon/remix-validated-form": "*",
"@carbon/utils": "*",
+ "@dnd-kit/core": "^6.1.0",
+ "@dnd-kit/sortable": "^8.0.0",
"@internationalized/date": "^3.5.2",
"@nanostores/react": "^0.7.1",
"@react-email/components": "0.0.16",
@@ -58,6 +60,7 @@
"posthog-js": "^1.116.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-hotkeys-hook": "~4.5.0",
"react-icons": "^4.12.0",
"react-pdf": "^7.7.1",
"react-phone-number-input": "^3.3.9",
diff --git a/package-lock.json b/package-lock.json
index a11fbc2f47..32386638c3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -34,6 +34,8 @@
"@carbon/redis": "*",
"@carbon/remix-validated-form": "*",
"@carbon/utils": "*",
+ "@dnd-kit/core": "^6.1.0",
+ "@dnd-kit/sortable": "^8.0.0",
"@internationalized/date": "^3.5.2",
"@nanostores/react": "^0.7.1",
"@react-email/components": "0.0.16",
@@ -83,6 +85,7 @@
"posthog-js": "^1.116.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
+ "react-hotkeys-hook": "~4.5.0",
"react-icons": "^4.12.0",
"react-pdf": "^7.7.1",
"react-phone-number-input": "^3.3.9",
@@ -1310,6 +1313,55 @@
"node": ">=0.1.90"
}
},
+ "node_modules/@dnd-kit/accessibility": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.1.0.tgz",
+ "integrity": "sha512-ea7IkhKvlJUv9iSHJOnxinBcoOI3ppGnnL+VDJ75O45Nss6HtZd8IdN8touXPDtASfeI2T2LImb8VOZcL47wjQ==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/core": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.1.0.tgz",
+ "integrity": "sha512-J3cQBClB4TVxwGo3KEjssGEXNJqGVWx17aRTZ1ob0FliR5IjYgTxl5YJbKTzA6IzrtelotH19v6y7uoIRUZPSg==",
+ "dependencies": {
+ "@dnd-kit/accessibility": "^3.1.0",
+ "@dnd-kit/utilities": "^3.2.2",
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0",
+ "react-dom": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/sortable": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/sortable/-/sortable-8.0.0.tgz",
+ "integrity": "sha512-U3jk5ebVXe1Lr7c2wU7SBZjcWdQP+j7peHJfCspnA81enlu88Mgd7CC8Q+pub9ubP7eKVETzJW+IBAhsqbSu/g==",
+ "dependencies": {
+ "@dnd-kit/utilities": "^3.2.2",
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "@dnd-kit/core": "^6.1.0",
+ "react": ">=16.8.0"
+ }
+ },
+ "node_modules/@dnd-kit/utilities": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/@dnd-kit/utilities/-/utilities-3.2.2.tgz",
+ "integrity": "sha512-+MKAJEOfaBe5SmV6t34p80MMKhjvUz0vRrvVJbPT0WElzaOJ/1xs+D+KDv+tD/NE5ujfrChEcshd4fLn0wpiqg==",
+ "dependencies": {
+ "tslib": "^2.0.0"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
"node_modules/@emotion/hash": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz",
@@ -32245,6 +32297,15 @@
"react": "^16.8.0 || ^17 || ^18"
}
},
+ "node_modules/react-hotkeys-hook": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-4.5.0.tgz",
+ "integrity": "sha512-Samb85GSgAWFQNvVt3PS90LPPGSf9mkH/r4au81ZP1yOIFayLC3QAvqTgGtJ8YEDMXtPmaVBs6NgipHO6h4Mug==",
+ "peerDependencies": {
+ "react": ">=16.8.1",
+ "react-dom": ">=16.8.1"
+ }
+ },
"node_modules/react-icons": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.12.0.tgz",
diff --git a/apps/carbon/app/components/Temporary/Paragraph.tsx b/packages/react/src/Paragraph.tsx
similarity index 100%
rename from apps/carbon/app/components/Temporary/Paragraph.tsx
rename to packages/react/src/Paragraph.tsx
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index 2b7726957d..f2ddfff9a5 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -181,6 +181,7 @@ import {
NumberInputGroup,
NumberInputStepper,
} from "./Number";
+import { Paragraph } from "./Paragraph";
import {
Popover,
PopoverContent,
@@ -393,6 +394,7 @@ export {
NumberInput,
NumberInputGroup,
NumberInputStepper,
+ Paragraph,
Popover,
PopoverContent,
PopoverFooter,
diff --git a/packages/utils/src/duration.ts b/packages/utils/src/duration.ts
index 9290c72611..93653901aa 100644
--- a/packages/utils/src/duration.ts
+++ b/packages/utils/src/duration.ts
@@ -23,24 +23,6 @@ export function formatDuration(
return formatDurationMilliseconds(dateDifference(start, end), options);
}
-export function nanosecondsToMilliseconds(nanoseconds: number): number {
- return nanoseconds / 1_000_000;
-}
-
-export function millisecondsToNanoseconds(milliseconds: number): number {
- return milliseconds * 1_000_000;
-}
-
-export function formatDurationNanoseconds(
- nanoseconds: number,
- options?: DurationOptions
-): string {
- return formatDurationMilliseconds(
- nanosecondsToMilliseconds(nanoseconds),
- options
- );
-}
-
const aboveOneSecondUnits = ["d", "h", "m", "s"] as Unit[];
const belowOneSecondUnits = ["ms"] as Unit[];