mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
fix goal view properties toggle
This commit is contained in:
parent
6a72faf83b
commit
32fe1056e7
2 changed files with 60 additions and 3 deletions
26
ui/src/pages/GoalDetail.test.tsx
Normal file
26
ui/src/pages/GoalDetail.test.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// @vitest-environment node
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { GoalPropertiesToggleButton } from "./GoalDetail";
|
||||
|
||||
describe("GoalPropertiesToggleButton", () => {
|
||||
it("shows the reopen control when the properties panel is hidden", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<GoalPropertiesToggleButton panelVisible={false} onShowProperties={() => {}} />,
|
||||
);
|
||||
|
||||
expect(html).toContain('title="Show properties"');
|
||||
expect(html).toContain("opacity-100");
|
||||
});
|
||||
|
||||
it("collapses the reopen control while the properties panel is already visible", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<GoalPropertiesToggleButton panelVisible onShowProperties={() => {}} />,
|
||||
);
|
||||
|
||||
expect(html).toContain("opacity-0");
|
||||
expect(html).toContain("pointer-events-none");
|
||||
expect(html).toContain("w-0");
|
||||
});
|
||||
});
|
||||
|
|
@ -15,17 +15,42 @@ import { StatusBadge } from "../components/StatusBadge";
|
|||
import { InlineEditor } from "../components/InlineEditor";
|
||||
import { EntityRow } from "../components/EntityRow";
|
||||
import { PageSkeleton } from "../components/PageSkeleton";
|
||||
import { projectUrl } from "../lib/utils";
|
||||
import { cn, projectUrl } from "../lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Plus } from "lucide-react";
|
||||
import { Plus, SlidersHorizontal } from "lucide-react";
|
||||
import type { Goal, Project } from "@paperclipai/shared";
|
||||
|
||||
interface GoalPropertiesToggleButtonProps {
|
||||
panelVisible: boolean;
|
||||
onShowProperties: () => void;
|
||||
}
|
||||
|
||||
export function GoalPropertiesToggleButton({
|
||||
panelVisible,
|
||||
onShowProperties,
|
||||
}: GoalPropertiesToggleButtonProps) {
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className={cn(
|
||||
"hidden md:inline-flex shrink-0 transition-opacity duration-200",
|
||||
panelVisible ? "opacity-0 pointer-events-none w-0 overflow-hidden" : "opacity-100",
|
||||
)}
|
||||
onClick={onShowProperties}
|
||||
title="Show properties"
|
||||
>
|
||||
<SlidersHorizontal className="h-4 w-4" />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export function GoalDetail() {
|
||||
const { goalId } = useParams<{ goalId: string }>();
|
||||
const { selectedCompanyId, setSelectedCompanyId } = useCompany();
|
||||
const { openNewGoal } = useDialog();
|
||||
const { openPanel, closePanel } = usePanel();
|
||||
const { openPanel, closePanel, panelVisible, setPanelVisible } = usePanel();
|
||||
const { setBreadcrumbs } = useBreadcrumbs();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
|
@ -122,6 +147,12 @@ export function GoalDetail() {
|
|||
{goal.level}
|
||||
</span>
|
||||
<StatusBadge status={goal.status} />
|
||||
<div className="ml-auto">
|
||||
<GoalPropertiesToggleButton
|
||||
panelVisible={panelVisible}
|
||||
onShowProperties={() => setPanelVisible(true)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<InlineEditor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue