From 93d74e9b41db659c81f210af5d958966d313bbff Mon Sep 17 00:00:00 2001 From: Robert Brennan Date: Wed, 22 Jan 2025 11:18:43 -0500 Subject: [PATCH] make export button more stylistically consistent (#6412) --- .../components/feedback-actions.test.tsx | 29 +++++++++++++++---- .../features/chat/chat-interface.tsx | 7 ++--- .../features/export/export-actions.tsx | 17 ----------- .../trajectory-actions.tsx} | 20 +++++++++---- .../shared/buttons/export-action-button.tsx | 17 ----------- ...utton.tsx => trajectory-action-button.tsx} | 6 ++-- frontend/src/icons/export.svg | 6 +--- 7 files changed, 44 insertions(+), 58 deletions(-) delete mode 100644 frontend/src/components/features/export/export-actions.tsx rename frontend/src/components/features/{feedback/feedback-actions.tsx => trajectory/trajectory-actions.tsx} (53%) delete mode 100644 frontend/src/components/shared/buttons/export-action-button.tsx rename frontend/src/components/shared/buttons/{feedback-action-button.tsx => trajectory-action-button.tsx} (71%) diff --git a/frontend/__tests__/components/feedback-actions.test.tsx b/frontend/__tests__/components/feedback-actions.test.tsx index c4f8170eea33..d705cfc44f11 100644 --- a/frontend/__tests__/components/feedback-actions.test.tsx +++ b/frontend/__tests__/components/feedback-actions.test.tsx @@ -1,12 +1,13 @@ import { render, screen, within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { FeedbackActions } from "#/components/features/feedback/feedback-actions"; +import { TrajectoryActions } from "#/components/features/trajectory/trajectory-actions"; -describe("FeedbackActions", () => { +describe("TrajectoryActions", () => { const user = userEvent.setup(); const onPositiveFeedback = vi.fn(); const onNegativeFeedback = vi.fn(); + const onExportTrajectory = vi.fn(); afterEach(() => { vi.clearAllMocks(); @@ -14,9 +15,10 @@ describe("FeedbackActions", () => { it("should render correctly", () => { render( - , ); @@ -27,9 +29,10 @@ describe("FeedbackActions", () => { it("should call onPositiveFeedback when positive feedback is clicked", async () => { render( - , ); @@ -41,9 +44,10 @@ describe("FeedbackActions", () => { it("should call onNegativeFeedback when negative feedback is clicked", async () => { render( - , ); @@ -52,4 +56,19 @@ describe("FeedbackActions", () => { expect(onNegativeFeedback).toHaveBeenCalled(); }); + + it("should call onExportTrajectory when negative feedback is clicked", async () => { + render( + , + ); + + const exportButton = screen.getByTestId("export-trajectory"); + await user.click(exportButton); + + expect(onExportTrajectory).toHaveBeenCalled(); + }); }); diff --git a/frontend/src/components/features/chat/chat-interface.tsx b/frontend/src/components/features/chat/chat-interface.tsx index e04efa19b3cc..bb49411b3302 100644 --- a/frontend/src/components/features/chat/chat-interface.tsx +++ b/frontend/src/components/features/chat/chat-interface.tsx @@ -4,8 +4,7 @@ import React from "react"; import posthog from "posthog-js"; import { useParams } from "react-router"; import { convertImageToBase64 } from "#/utils/convert-image-to-base-64"; -import { FeedbackActions } from "../feedback/feedback-actions"; -import { ExportActions } from "../export/export-actions"; +import { TrajectoryActions } from "../trajectory/trajectory-actions"; import { createChatMessage } from "#/services/chat-service"; import { InteractiveChatBox } from "./interactive-chat-box"; import { addUserMessage } from "#/state/chat-slice"; @@ -155,15 +154,13 @@ export function ChatInterface() {
- onClickShareFeedbackActionButton("positive") } onNegativeFeedback={() => onClickShareFeedbackActionButton("negative") } - /> - onClickExportTrajectoryButton()} /> diff --git a/frontend/src/components/features/export/export-actions.tsx b/frontend/src/components/features/export/export-actions.tsx deleted file mode 100644 index faafd98af293..000000000000 --- a/frontend/src/components/features/export/export-actions.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import ExportIcon from "#/icons/export.svg?react"; -import { ExportActionButton } from "#/components/shared/buttons/export-action-button"; - -interface ExportActionsProps { - onExportTrajectory: () => void; -} - -export function ExportActions({ onExportTrajectory }: ExportActionsProps) { - return ( -
- } - /> -
- ); -} diff --git a/frontend/src/components/features/feedback/feedback-actions.tsx b/frontend/src/components/features/trajectory/trajectory-actions.tsx similarity index 53% rename from frontend/src/components/features/feedback/feedback-actions.tsx rename to frontend/src/components/features/trajectory/trajectory-actions.tsx index 2293789c201f..a11cb002b103 100644 --- a/frontend/src/components/features/feedback/feedback-actions.tsx +++ b/frontend/src/components/features/trajectory/trajectory-actions.tsx @@ -1,28 +1,36 @@ import ThumbsUpIcon from "#/icons/thumbs-up.svg?react"; import ThumbDownIcon from "#/icons/thumbs-down.svg?react"; -import { FeedbackActionButton } from "#/components/shared/buttons/feedback-action-button"; +import ExportIcon from "#/icons/export.svg?react"; +import { TrajectoryActionButton } from "#/components/shared/buttons/trajectory-action-button"; -interface FeedbackActionsProps { +interface TrajectoryActionsProps { onPositiveFeedback: () => void; onNegativeFeedback: () => void; + onExportTrajectory: () => void; } -export function FeedbackActions({ +export function TrajectoryActions({ onPositiveFeedback, onNegativeFeedback, -}: FeedbackActionsProps) { + onExportTrajectory, +}: TrajectoryActionsProps) { return (
- } /> - } /> + } + />
); } diff --git a/frontend/src/components/shared/buttons/export-action-button.tsx b/frontend/src/components/shared/buttons/export-action-button.tsx deleted file mode 100644 index b76443591d39..000000000000 --- a/frontend/src/components/shared/buttons/export-action-button.tsx +++ /dev/null @@ -1,17 +0,0 @@ -interface ExportActionButtonProps { - onClick: () => void; - icon: React.ReactNode; -} - -export function ExportActionButton({ onClick, icon }: ExportActionButtonProps) { - return ( - - ); -} diff --git a/frontend/src/components/shared/buttons/feedback-action-button.tsx b/frontend/src/components/shared/buttons/trajectory-action-button.tsx similarity index 71% rename from frontend/src/components/shared/buttons/feedback-action-button.tsx rename to frontend/src/components/shared/buttons/trajectory-action-button.tsx index cef1d9184f12..30aab054312c 100644 --- a/frontend/src/components/shared/buttons/feedback-action-button.tsx +++ b/frontend/src/components/shared/buttons/trajectory-action-button.tsx @@ -1,14 +1,14 @@ -interface FeedbackActionButtonProps { +interface TrajectoryActionButtonProps { testId?: string; onClick: () => void; icon: React.ReactNode; } -export function FeedbackActionButton({ +export function TrajectoryActionButton({ testId, onClick, icon, -}: FeedbackActionButtonProps) { +}: TrajectoryActionButtonProps) { return (