-
Notifications
You must be signed in to change notification settings - Fork 607
feat: New deploy settings #5073
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
37 commits
Select commit
Hold shift + click to select a range
3f422bc
feat: add github section
ogzhanolguncu 4dc8ef4
feat: Add icons
ogzhanolguncu e0a3f95
Merge branch 'main' of github.com:unkeyed/unkey into deploy-settings
ogzhanolguncu 378bd1c
feat: add new sections
ogzhanolguncu 66d085b
feat: add settingsgroup
ogzhanolguncu d0f3d61
feat: add region selection
ogzhanolguncu 7b21f5c
feat: add instances
ogzhanolguncu c7bef6e
feat: add memory and cpu section
ogzhanolguncu 4166c70
feat: add sections
ogzhanolguncu bb4043e
feat: add health check
ogzhanolguncu a7e2a42
feat: add scaling
ogzhanolguncu 1016d41
fix: get rid of redundant prop
ogzhanolguncu 065b5fc
refactor: Add toasts to mutations
ogzhanolguncu 16a20da
refactor: rename component
ogzhanolguncu e2f4192
feat: add port section
ogzhanolguncu d46a6a0
feat: fix overlapping borders
ogzhanolguncu b3063d8
refactor: fix healthcheck tRPC
ogzhanolguncu d0efd8f
feat: add command section
ogzhanolguncu d2ba71f
feat: add env section
ogzhanolguncu f4dd76d
fix: finalize env-vars
ogzhanolguncu cff917e
refactor: finalize
ogzhanolguncu 9d45ef3
feat: Add custom domains
ogzhanolguncu 5080003
fix: overflwo
ogzhanolguncu e21c5da
feat: make tRPC route for each mutation
ogzhanolguncu dc226be
fix: displayValue styles
ogzhanolguncu 3aadd23
refactor: tidy
ogzhanolguncu a7d00f1
fix: revert accidental changes
ogzhanolguncu 9d26195
feat: add cname table
ogzhanolguncu a00ecb7
fix: github styling issues
ogzhanolguncu 3a9678e
refactor: tidy
ogzhanolguncu a92fcd0
refactor: rename
ogzhanolguncu bf69555
fix: linter
ogzhanolguncu 6390202
Merge branch 'main' of github.com:unkeyed/unkey into deploy-settings
ogzhanolguncu fe3db20
fix: dynamic form issue
ogzhanolguncu 3d35ab3
feat: allow env selection
ogzhanolguncu 1cac683
chore: tidy
ogzhanolguncu 12c7a05
fix: use same chevron
ogzhanolguncu 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
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
1 change: 0 additions & 1 deletion
1
...)/[workspaceSlug]/projects/[projectId]/(overview)/details/custom-domains-section/types.ts
This file was deleted.
Oops, something went wrong.
111 changes: 111 additions & 0 deletions
111
...ceSlug]/projects/[projectId]/(overview)/settings/components/advanced-settings/command.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,111 @@ | ||
| "use client"; | ||
|
|
||
| import { trpc } from "@/lib/trpc/client"; | ||
| import { zodResolver } from "@hookform/resolvers/zod"; | ||
| import { SquareTerminal } from "@unkey/icons"; | ||
| import { FormTextarea, InfoTooltip, toast } from "@unkey/ui"; | ||
| import { useEffect } from "react"; | ||
| import { useForm, useWatch } from "react-hook-form"; | ||
| import { z } from "zod"; | ||
| import { useProjectData } from "../../../data-provider"; | ||
| import { FormSettingCard } from "../shared/form-setting-card"; | ||
|
|
||
| const commandSchema = z.object({ | ||
| command: z.string(), | ||
| }); | ||
|
|
||
| type CommandFormValues = z.infer<typeof commandSchema>; | ||
|
|
||
| export const Command = () => { | ||
| const { environments } = useProjectData(); | ||
| const environmentId = environments[0]?.id; | ||
|
|
||
| const { data: settingsData } = trpc.deploy.environmentSettings.get.useQuery( | ||
| { environmentId: environmentId ?? "" }, | ||
| { enabled: Boolean(environmentId) }, | ||
| ); | ||
|
|
||
| const rawCommand = settingsData?.runtimeSettings?.command as string[] | undefined; | ||
| const defaultCommand = (rawCommand ?? []).join(" "); | ||
|
|
||
| return <CommandForm environmentId={environmentId ?? ""} defaultCommand={defaultCommand} />; | ||
| }; | ||
|
|
||
| type CommandFormProps = { | ||
| environmentId: string; | ||
| defaultCommand: string; | ||
| }; | ||
|
|
||
| const CommandForm: React.FC<CommandFormProps> = ({ environmentId, defaultCommand }) => { | ||
| const utils = trpc.useUtils(); | ||
|
|
||
| const { | ||
| register, | ||
| handleSubmit, | ||
| formState: { isValid, isSubmitting, errors }, | ||
| control, | ||
| reset, | ||
| } = useForm<CommandFormValues>({ | ||
| resolver: zodResolver(commandSchema), | ||
| mode: "onChange", | ||
| defaultValues: { command: defaultCommand }, | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| reset({ command: defaultCommand }); | ||
| }, [defaultCommand, reset]); | ||
|
|
||
| const currentCommand = useWatch({ control, name: "command" }); | ||
| const hasChanges = currentCommand !== defaultCommand; | ||
|
|
||
| const updateCommand = trpc.deploy.environmentSettings.runtime.updateCommand.useMutation({ | ||
| onSuccess: () => { | ||
| toast.success("Command updated"); | ||
| utils.deploy.environmentSettings.get.invalidate({ environmentId }); | ||
| }, | ||
| onError: (err) => { | ||
| toast.error("Failed to update command", { | ||
| description: err.message, | ||
| }); | ||
| }, | ||
| }); | ||
|
|
||
| const onSubmit = async (values: CommandFormValues) => { | ||
| const trimmed = values.command.trim(); | ||
| const command = trimmed === "" ? [] : trimmed.split(/\s+/).filter(Boolean); | ||
| await updateCommand.mutateAsync({ environmentId, command }); | ||
| }; | ||
|
|
||
| return ( | ||
| <FormSettingCard | ||
| icon={<SquareTerminal className="text-gray-12" iconSize="xl-medium" />} | ||
| title="Command" | ||
| description="The command to start your application. Changes apply on next deploy." | ||
| displayValue={ | ||
| defaultCommand ? ( | ||
| <InfoTooltip content={defaultCommand} asChild position={{ side: "bottom" }}> | ||
| <span className="font-medium text-gray-12 font-mono text-xs truncate max-w-[100px]"> | ||
| {defaultCommand} | ||
| </span> | ||
| </InfoTooltip> | ||
| ) : ( | ||
| <span className="text-gray-11 font-normal">Default</span> | ||
| ) | ||
| } | ||
| onSubmit={handleSubmit(onSubmit)} | ||
| canSave={isValid && !isSubmitting && hasChanges} | ||
| isSaving={updateCommand.isLoading || isSubmitting} | ||
| > | ||
| <FormTextarea | ||
| label="Command" | ||
| placeholder="~ npm start" | ||
| className="w-[480px] [&_textarea]:font-mono" | ||
| description=" | ||
| Overrides the default container startup command. Arguments are split on whitespace. Leave | ||
| empty to use the image's default command." | ||
| variant={errors.command ? "error" : "default"} | ||
| {...register("command")} | ||
| /> | ||
| </FormSettingCard> | ||
| ); | ||
| }; | ||
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.
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.
Guard submissions when
environmentIdis missing.environmentId ?? ""means a user can edit and submit before the ID loads, sending an empty string to the mutation (likely a no-op with a misleading success). Gate the submit and disable save whenenvironmentIdis falsy.🔒 Suggested guard
Also applies to: 73-97
🤖 Prompt for AI Agents