-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(site): add startup script error alerts to Task Page #20820
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2be4511
feat(site): add startup script error alerts to Task Page
DanielleMaywood 9c8af27
fix(site): use sentence case for alert link titles and change to 'A w…
DanielleMaywood a043669
feat(site): refactor startup alerts to compact warning button in topbar
DanielleMaywood 1be03bf
refactor(site): improve TaskStartupWarningButton API and file naming
DanielleMaywood 8a8b966
refactor(site): improve TaskStartupWarningButton API
DanielleMaywood c8ec4d3
Merge branch 'main' into feat/task-page-startup-error-alert
DanielleMaywood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
site/src/pages/TaskPage/TaskStartupWarningButton.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
| import { TaskStartupWarningButton } from "./TaskStartupWarningButton"; | ||
|
|
||
| const meta: Meta<typeof TaskStartupWarningButton> = { | ||
| title: "pages/TaskPage/TaskStartupWarningButton", | ||
| component: TaskStartupWarningButton, | ||
| parameters: { | ||
| layout: "padded", | ||
| }, | ||
| }; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof TaskStartupWarningButton>; | ||
|
|
||
| export const StartError: Story = { | ||
| args: { | ||
| lifecycleState: "start_error", | ||
| }, | ||
| }; | ||
|
|
||
| export const StartTimeout: Story = { | ||
| args: { | ||
| lifecycleState: "start_timeout", | ||
| }, | ||
| }; | ||
|
|
||
| export const NoWarning: Story = { | ||
| args: { | ||
| lifecycleState: "ready", | ||
| }, | ||
| }; | ||
|
|
||
| export const NullLifecycle: Story = { | ||
| args: { | ||
| lifecycleState: null, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import type { WorkspaceAgentLifecycle } from "api/typesGenerated"; | ||
| import { Button } from "components/Button/Button"; | ||
| import { Link } from "components/Link/Link"; | ||
| import { | ||
| Tooltip, | ||
| TooltipContent, | ||
| TooltipProvider, | ||
| TooltipTrigger, | ||
| } from "components/Tooltip/Tooltip"; | ||
| import { TriangleAlertIcon } from "lucide-react"; | ||
| import type { FC } from "react"; | ||
| import { docs } from "utils/docs"; | ||
|
|
||
| type TaskStartupWarningButtonProps = { | ||
| lifecycleState?: WorkspaceAgentLifecycle | null; | ||
| }; | ||
|
|
||
| export const TaskStartupWarningButton: FC<TaskStartupWarningButtonProps> = ({ | ||
| lifecycleState, | ||
| }) => { | ||
| switch (lifecycleState) { | ||
| case "start_error": | ||
| return <ErrorScriptButton />; | ||
| case "start_timeout": | ||
| return <TimeoutScriptButton />; | ||
| default: | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| type StartupWarningButtonBaseProps = { | ||
| label: string; | ||
| errorMessage: string; | ||
| }; | ||
|
|
||
| const StartupWarningButtonBase: FC<StartupWarningButtonBaseProps> = ({ | ||
| label, | ||
| errorMessage, | ||
| }) => { | ||
| return ( | ||
| <TooltipProvider delayDuration={250}> | ||
| <Tooltip> | ||
| <TooltipTrigger asChild> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| className="border-amber-500 text-amber-600 dark:border-amber-600 dark:text-amber-400" | ||
| > | ||
| <TriangleAlertIcon /> | ||
| {label} | ||
| </Button> | ||
| </TooltipTrigger> | ||
| <TooltipContent className="max-w-sm bg-surface-secondary p-4"> | ||
| <p className="m-0 text-sm font-normal text-content-primary leading-snug"> | ||
| A workspace{" "} | ||
| <Link | ||
| href={docs( | ||
| "/admin/templates/troubleshooting#startup-script-exited-with-an-error", | ||
| )} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| {errorMessage} | ||
| </Link> | ||
| . We recommend{" "} | ||
| <Link | ||
| href={docs( | ||
| "/admin/templates/troubleshooting#startup-script-issues", | ||
| )} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| debugging the startup script | ||
| </Link>{" "} | ||
| because{" "} | ||
| <Link | ||
| href={docs( | ||
| "/admin/templates/troubleshooting#your-workspace-may-be-incomplete", | ||
| )} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| your workspace may be incomplete | ||
| </Link> | ||
| . | ||
| </p> | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| </TooltipProvider> | ||
| ); | ||
| }; | ||
|
|
||
| const ErrorScriptButton: FC = () => { | ||
| return ( | ||
| <StartupWarningButtonBase | ||
| label="Startup Error" | ||
| errorMessage="startup script has exited with an error" | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| const TimeoutScriptButton: FC = () => { | ||
| return ( | ||
| <StartupWarningButtonBase | ||
| label="Startup Timeout" | ||
| errorMessage="startup script has timed out" | ||
| /> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.