Skip to content

Commit

Permalink
make export button more stylistically consistent (#6412)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren authored Jan 22, 2025
1 parent 1337d03 commit 93d74e9
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 58 deletions.
29 changes: 24 additions & 5 deletions frontend/__tests__/components/feedback-actions.test.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
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();
});

it("should render correctly", () => {
render(
<FeedbackActions
<TrajectoryActions
onPositiveFeedback={onPositiveFeedback}
onNegativeFeedback={onNegativeFeedback}
onExportTrajectory={onExportTrajectory}
/>,
);

Expand All @@ -27,9 +29,10 @@ describe("FeedbackActions", () => {

it("should call onPositiveFeedback when positive feedback is clicked", async () => {
render(
<FeedbackActions
<TrajectoryActions
onPositiveFeedback={onPositiveFeedback}
onNegativeFeedback={onNegativeFeedback}
onExportTrajectory={onExportTrajectory}
/>,
);

Expand All @@ -41,9 +44,10 @@ describe("FeedbackActions", () => {

it("should call onNegativeFeedback when negative feedback is clicked", async () => {
render(
<FeedbackActions
<TrajectoryActions
onPositiveFeedback={onPositiveFeedback}
onNegativeFeedback={onNegativeFeedback}
onExportTrajectory={onExportTrajectory}
/>,
);

Expand All @@ -52,4 +56,19 @@ describe("FeedbackActions", () => {

expect(onNegativeFeedback).toHaveBeenCalled();
});

it("should call onExportTrajectory when negative feedback is clicked", async () => {
render(
<TrajectoryActions
onPositiveFeedback={onPositiveFeedback}
onNegativeFeedback={onNegativeFeedback}
onExportTrajectory={onExportTrajectory}
/>,
);

const exportButton = screen.getByTestId("export-trajectory");
await user.click(exportButton);

expect(onExportTrajectory).toHaveBeenCalled();
});
});
7 changes: 2 additions & 5 deletions frontend/src/components/features/chat/chat-interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -155,15 +154,13 @@ export function ChatInterface() {

<div className="flex flex-col gap-[6px] px-4 pb-4">
<div className="flex justify-between relative">
<FeedbackActions
<TrajectoryActions
onPositiveFeedback={() =>
onClickShareFeedbackActionButton("positive")
}
onNegativeFeedback={() =>
onClickShareFeedbackActionButton("negative")
}
/>
<ExportActions
onExportTrajectory={() => onClickExportTrajectoryButton()}
/>

Expand Down
17 changes: 0 additions & 17 deletions frontend/src/components/features/export/export-actions.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 (
<div data-testid="feedback-actions" className="flex gap-1">
<FeedbackActionButton
<TrajectoryActionButton
testId="positive-feedback"
onClick={onPositiveFeedback}
icon={<ThumbsUpIcon width={15} height={15} />}
/>
<FeedbackActionButton
<TrajectoryActionButton
testId="negative-feedback"
onClick={onNegativeFeedback}
icon={<ThumbDownIcon width={15} height={15} />}
/>
<TrajectoryActionButton
testId="export-trajectory"
onClick={onExportTrajectory}
icon={<ExportIcon width={15} height={15} />}
/>
</div>
);
}
17 changes: 0 additions & 17 deletions frontend/src/components/shared/buttons/export-action-button.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 (
<button
type="button"
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/icons/export.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 93d74e9

Please sign in to comment.