Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { observer } from "mobx-react-lite";
import type { MouseEvent, PointerEvent } from "react";

import TooltipButton from "@/components/shared/Buttons/TooltipButton";
import { Icon } from "@/components/ui/icon";
import { InlineStack } from "@/components/ui/layout";
import { useEditorSession } from "@/routes/v2/pages/Editor/store/EditorSessionContext";
import { tracking } from "@/utils/tracking";

const stopPointer = (event: PointerEvent<HTMLButtonElement>) => {
event.stopPropagation();
};

export const HistoryWindowMiniContent = observer(
function HistoryWindowMiniContent() {
const { undo } = useEditorSession();
const { canUndo, canRedo } = undo;

const handleUndo = (event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
undo.undo();
};

const handleRedo = (event: MouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
undo.redo();
};

return (
<InlineStack gap="1">
<TooltipButton
tooltip="Undo"
tooltipSide="right"
variant="outline"
size="icon"
aria-label="Undo"
title="Undo"
disabled={!canUndo}
onClick={handleUndo}
onPointerDown={stopPointer}
{...tracking("v2.pipeline_editor.history.undo")}
>
<Icon name="Undo2" size="sm" />
</TooltipButton>
<TooltipButton
tooltip="Redo"
tooltipSide="right"
variant="outline"
size="icon"
aria-label="Redo"
title="Redo"
disabled={!canRedo}
onClick={handleRedo}
onPointerDown={stopPointer}
{...tracking("v2.pipeline_editor.history.redo")}
>
<Icon name="Redo2" size="sm" />
</TooltipButton>
</InlineStack>
);
},
);
2 changes: 2 additions & 0 deletions src/routes/v2/pages/Editor/hooks/useHistoryWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from "react";

import { HistoryContent } from "@/routes/v2/pages/Editor/components/HistoryContent/HistoryContent";
import { HistoryWindowMiniContent } from "@/routes/v2/pages/Editor/components/HistoryContent/HistoryWindowMiniContent";
import { useSharedStores } from "@/routes/v2/shared/store/SharedStoreContext";

const HISTORY_WINDOW_ID = "history";
Expand All @@ -17,6 +18,7 @@ export function useHistoryWindow() {
disabledActions: ["close"],
persisted: true,
defaultDockState: "left",
miniContent: <HistoryWindowMiniContent />,
});
}
}, [windows]);
Expand Down
Loading