Skip to content
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
15 changes: 15 additions & 0 deletions site/src/pages/TasksPage/TasksPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ export const LoadingTemplates: Story = {
},
};

export const EmptyTemplates: Story = {
parameters: {
queries: [
{
key: ["templates", { q: "has-ai-task:true" }],
data: [],
},
{
key: ["tasks", { owner: MockUserOwner.username }],
data: [],
},
],
},
};

export const LoadingTemplatesError: Story = {
beforeEach: () => {
spyOn(API, "getTemplates").mockRejectedValue(
Expand Down
90 changes: 46 additions & 44 deletions site/src/pages/TasksPage/TasksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,52 +68,54 @@ const TasksPage: FC = () => {
error={aiTemplatesQuery.error}
onRetry={aiTemplatesQuery.refetch}
/>
{aiTemplatesQuery.isSuccess && (
<section className="py-8">
{permissions.viewDeploymentConfig && (
<section
className="mt-6 flex justify-between"
aria-label="Controls"
>
<div className="flex items-center bg-surface-secondary rounded p-1">
<PillButton
active={tab.value === "all"}
onClick={() => tab.setValue("all")}
>
All tasks
</PillButton>
<PillButton
disabled={!idleTasks || idleTasks.length === 0}
active={tab.value === "waiting-for-input"}
onClick={() => tab.setValue("waiting-for-input")}
>
Waiting for input
{idleTasks && idleTasks.length > 0 && (
<Badge className="-mr-0.5" size="xs" variant="info">
{idleTasks.length}
</Badge>
)}
</PillButton>
</div>
{aiTemplatesQuery.isSuccess &&
aiTemplatesQuery.data &&
aiTemplatesQuery.data.length > 0 && (
<section className="py-8">
{permissions.viewDeploymentConfig && (
<section
className="mt-6 flex justify-between"
aria-label="Controls"
>
<div className="flex items-center bg-surface-secondary rounded p-1">
<PillButton
active={tab.value === "all"}
onClick={() => tab.setValue("all")}
>
All tasks
</PillButton>
<PillButton
disabled={!idleTasks || idleTasks.length === 0}
active={tab.value === "waiting-for-input"}
onClick={() => tab.setValue("waiting-for-input")}
>
Waiting for input
{idleTasks && idleTasks.length > 0 && (
<Badge className="-mr-0.5" size="xs" variant="info">
{idleTasks.length}
</Badge>
)}
</PillButton>
</div>

<UsersCombobox
value={ownerFilter.value}
onValueChange={(username) => {
ownerFilter.setValue(
username === ownerFilter.value ? "" : username,
);
}}
/>
</section>
)}
<UsersCombobox
value={ownerFilter.value}
onValueChange={(username) => {
ownerFilter.setValue(
username === ownerFilter.value ? "" : username,
);
}}
/>
</section>
)}

<TasksTable
tasks={displayedTasks}
error={tasksQuery.error}
onRetry={tasksQuery.refetch}
/>
</section>
)}
<TasksTable
tasks={displayedTasks}
error={tasksQuery.error}
onRetry={tasksQuery.refetch}
/>
</section>
)}
</main>
</Margins>
</>
Expand Down
Loading