Repository navigation
feat(web): rename saved environments from settings #31245
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
edaec2e
feat(web): rename saved environments from settings
paperless 1d065e9
fix(client-runtime): renaming an environment keeps its connection
paperless ed77b47
fix(client-runtime): reconnects after a rename keep the new label
paperless 85390be
fix(client-runtime): a rename survives route learning, and failures show
paperless 98b039b
fix(client-runtime): renaming keeps the saved SSH target
paperless 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
apps/web/src/components/settings/RenameEnvironmentDialog.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,94 @@ | ||
| import type { EnvironmentId } from "@t3tools/contracts"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { environmentCatalog } from "~/connection/catalog"; | ||
| import { useAtomCommand } from "~/state/use-atom-command"; | ||
| import { Button } from "../ui/button"; | ||
| import { | ||
| Dialog, | ||
| DialogClose, | ||
| DialogFooter, | ||
| DialogHeader, | ||
| DialogPanel, | ||
| DialogPopup, | ||
| DialogTitle, | ||
| } from "../ui/dialog"; | ||
| import { Input } from "../ui/input"; | ||
| import { Label } from "../ui/label"; | ||
|
|
||
| // The popup unmounts when closed, so each open starts from the current label. | ||
| function RenameEnvironmentForm({ | ||
| environmentId, | ||
| label: currentLabel, | ||
| onDone, | ||
| }: { | ||
| readonly environmentId: EnvironmentId; | ||
| readonly label: string; | ||
| readonly onDone: () => void; | ||
| }) { | ||
| const [label, setLabel] = useState(currentLabel); | ||
| const setEnvironmentLabel = useAtomCommand(environmentCatalog.setLabel, "Rename environment"); | ||
| const canSave = label.trim() !== ""; | ||
|
|
||
| const save = async () => { | ||
| if (!canSave) return; | ||
| const result = await setEnvironmentLabel({ environmentId, label }); | ||
| if (result._tag === "Success") onDone(); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <DialogHeader> | ||
| <DialogTitle>Rename environment</DialogTitle> | ||
| </DialogHeader> | ||
| <DialogPanel> | ||
| <form | ||
| id="rename-environment-form" | ||
| className="grid gap-1.5" | ||
| onSubmit={(event) => { | ||
| event.preventDefault(); | ||
| void save(); | ||
| }} | ||
| > | ||
| <Label htmlFor="environment-label">Label</Label> | ||
| <Input | ||
| id="environment-label" | ||
| value={label} | ||
| onChange={(event) => setLabel(event.target.value)} | ||
| autoFocus | ||
| /> | ||
| </form> | ||
| </DialogPanel> | ||
| <DialogFooter variant="bare"> | ||
| <DialogClose render={<Button variant="outline" />}>Cancel</DialogClose> | ||
| <Button type="submit" form="rename-environment-form" disabled={!canSave}> | ||
| Save | ||
| </Button> | ||
| </DialogFooter> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export function RenameEnvironmentDialog({ | ||
| open, | ||
| onOpenChange, | ||
| environmentId, | ||
| label, | ||
| }: { | ||
| readonly open: boolean; | ||
| readonly onOpenChange: (open: boolean) => void; | ||
| readonly environmentId: EnvironmentId; | ||
| readonly label: string; | ||
| }) { | ||
| return ( | ||
| <Dialog open={open} onOpenChange={onOpenChange}> | ||
| <DialogPopup className="max-w-md"> | ||
| <RenameEnvironmentForm | ||
| environmentId={environmentId} | ||
| label={label} | ||
| onDone={() => onOpenChange(false)} | ||
| /> | ||
| </DialogPopup> | ||
| </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
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.
Uh oh!
There was an error while loading. Please reload this page.