Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI v2] feat: Adds EmptyState for Task Run Concurrency Limits #16203

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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,18 @@
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { describe, expect, it, vi } from "vitest";
import { TaskRunConcurrencyLimitEmptyState } from "./task-run-concurrency-limit-empty-state";

describe("TaskRunConcurrencyLimitEmptyState", () => {
it("when adding task run concurrency limit, callback gets fired", async () => {
const user = userEvent.setup();

const mockFn = vi.fn();

render(<TaskRunConcurrencyLimitEmptyState onClick={mockFn} />);
await user.click(
screen.getByRole("button", { name: /Add Concurrency Limit/i }),
);
expect(mockFn).toHaveBeenCalledOnce();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Button } from "@/components/ui/button";
import { DocsLink } from "@/components/ui/docs-link";
import {
EmptyState,
EmptyStateActions,
EmptyStateDescription,
EmptyStateIcon,
EmptyStateTitle,
} from "@/components/ui/empty-state";
import { PlusIcon } from "lucide-react";

type Props = {
onClick: () => void;
};
export const TaskRunConcurrencyLimitEmptyState = ({ onClick }: Props) => (
<EmptyState>
<EmptyStateIcon id="CircleArrowOutUpRight" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random thought: does defining the icon by ID like this affect tree shaking for react-lucide?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: https://lucide.dev/guide/packages/lucide-react#one-generic-icon-component

I think the next followup PR, we can create a list of Icons only available to the ui using its direct imports.

And then we can create a Record of ui-v2's Icons and export it that way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, that sounds like a good way to abstract icon stuff and make it easy to introduce icons from other sources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing in this PR: #16208

<EmptyStateTitle>
Add a concurrency limit for your task runs
</EmptyStateTitle>
<EmptyStateDescription>
Creating a limit allows you to limit the number of tasks running
simultaneously with a given tag.
</EmptyStateDescription>
<EmptyStateActions>
<Button onClick={onClick}>
Add Concurrency Limit <PlusIcon className="h-4 w-4 ml-2" />
</Button>
<DocsLink id="task-concurrency-guide" />
</EmptyStateActions>
</EmptyState>
);
2 changes: 2 additions & 0 deletions ui-v2/src/components/ui/docs-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Button } from "./button";
const DOCS_LINKS = {
"global-concurrency-guide":
"https://docs.prefect.io/v3/develop/global-concurrency-limits",
"task-concurrency-guide":
"https://docs.prefect.io/v3/develop/task-run-limits",
"variables-guide": "https://docs.prefect.io/latest/guides/variables/",
} as const;

Expand Down
Loading