-
Notifications
You must be signed in to change notification settings - Fork 928
feat: add ephemeral parameter dialog for workspace start/restart #18413
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
+290
−66
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99f7a2d
feat: add ephemeral parameter dialog for workspace start/restart
blink-so[bot] 7f56518
fix: use asChild prop instead of as prop for Button components
blink-so[bot] abea8ec
fix: improvements to UX and flow
jaaydenh 1ff6988
fix: format
jaaydenh c7e1fad
chore: update stories
jaaydenh 6d69706
fix: remove index.ts
jaaydenh 718350d
chore: cleanup html
jaaydenh 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
86 changes: 86 additions & 0 deletions
86
site/src/components/EphemeralParametersDialog/EphemeralParametersDialog.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,86 @@ | ||
import type { TemplateVersionParameter } from "api/typesGenerated"; | ||
import { Button } from "components/Button/Button"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "components/Dialog/Dialog"; | ||
import type { FC } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
interface EphemeralParametersDialogProps { | ||
open: boolean; | ||
onClose: () => void; | ||
onContinue: () => void; | ||
ephemeralParameters: TemplateVersionParameter[]; | ||
workspaceOwner: string; | ||
workspaceName: string; | ||
templateVersionId: string; | ||
} | ||
|
||
export const EphemeralParametersDialog: FC<EphemeralParametersDialogProps> = ({ | ||
open, | ||
onClose, | ||
onContinue, | ||
ephemeralParameters, | ||
workspaceOwner, | ||
workspaceName, | ||
templateVersionId, | ||
}) => { | ||
const navigate = useNavigate(); | ||
|
||
const handleGoToParameters = () => { | ||
onClose(); | ||
navigate( | ||
`/@${workspaceOwner}/${workspaceName}/settings/parameters?templateVersionId=${templateVersionId}`, | ||
); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>Ephemeral Parameters Detected</DialogTitle> | ||
<DialogDescription> | ||
This workspace template has{" "} | ||
<strong className="text-content-primary"> | ||
{ephemeralParameters.length} | ||
</strong>{" "} | ||
ephemeral parameters that will be reset to their default values | ||
</DialogDescription> | ||
<DialogDescription> | ||
<ul className="list-none pl-6 space-y-2"> | ||
{ephemeralParameters.map((param) => ( | ||
<li key={param.name}> | ||
<p className="text-content-primary m-0 font-bold"> | ||
{param.display_name || param.name} | ||
</p> | ||
{param.description && ( | ||
<p className="m-0 text-sm text-content-secondary"> | ||
{param.description} | ||
</p> | ||
)} | ||
</li> | ||
))} | ||
</ul> | ||
</DialogDescription> | ||
<DialogDescription> | ||
Would you like to go to the workspace parameters page to review and | ||
update these parameters before continuing? | ||
</DialogDescription> | ||
</DialogHeader> | ||
<DialogFooter> | ||
<Button onClick={onContinue} variant="outline"> | ||
Continue | ||
</Button> | ||
<Button onClick={handleGoToParameters}> | ||
Go to workspace parameters | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
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
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only meant to be used for ephemeral parameters and no other use cases. It felt like calling this ephemeral is too specific for the badge component so I left it as a generic green for now.