@@ -423,6 +423,8 @@ export default function Page() {
423423 const lastSubmission = useActionData ( ) ;
424424 const navigation = useNavigation ( ) ;
425425
426+ const [ hasRenameFormChanges , setHasRenameFormChanges ] = useState ( false ) ;
427+
426428 const [ renameForm , { projectName } ] = useForm ( {
427429 id : "rename-project" ,
428430 // TODO: type this
@@ -508,6 +510,9 @@ export default function Page() {
508510 placeholder = "Project name"
509511 icon = { FolderIcon }
510512 autoFocus
513+ onChange = { ( e ) => {
514+ setHasRenameFormChanges ( e . target . value !== project . name ) ;
515+ } }
511516 />
512517 < FormError id = { projectName . errorId } > { projectName . error } </ FormError >
513518 </ InputGroup >
@@ -518,7 +523,7 @@ export default function Page() {
518523 name = "action"
519524 value = "rename"
520525 variant = { "secondary/small" }
521- disabled = { isRenameLoading }
526+ disabled = { isRenameLoading || ! hasRenameFormChanges }
522527 LeadingIcon = { isRenameLoading ? SpinnerWhite : undefined }
523528 >
524529 Save
@@ -812,7 +817,7 @@ function GitHubConnectionPrompt({
812817 variant = { "secondary/medium" }
813818 LeadingIcon = { OctoKitty }
814819 >
815- Install GitHub App
820+ Install GitHub app
816821 </ LinkButton >
817822 ) }
818823 { gitHubAppInstallations . length !== 0 && (
@@ -850,6 +855,23 @@ function ConnectedGitHubRepoForm({
850855 const lastSubmission = useActionData ( ) as any ;
851856 const navigation = useNavigation ( ) ;
852857
858+ const [ hasGitSettingsChanges , setHasGitSettingsChanges ] = useState ( false ) ;
859+ const [ gitSettingsValues , setGitSettingsValues ] = useState ( {
860+ productionBranch : connectedGitHubRepo . branchTracking ?. production ?. branch || "" ,
861+ stagingBranch : connectedGitHubRepo . branchTracking ?. staging ?. branch || "" ,
862+ previewDeploymentsEnabled : connectedGitHubRepo . previewDeploymentsEnabled ,
863+ } ) ;
864+
865+ useEffect ( ( ) => {
866+ const hasChanges =
867+ gitSettingsValues . productionBranch !==
868+ ( connectedGitHubRepo . branchTracking ?. production ?. branch || "" ) ||
869+ gitSettingsValues . stagingBranch !==
870+ ( connectedGitHubRepo . branchTracking ?. staging ?. branch || "" ) ||
871+ gitSettingsValues . previewDeploymentsEnabled !== connectedGitHubRepo . previewDeploymentsEnabled ;
872+ setHasGitSettingsChanges ( hasChanges ) ;
873+ } , [ gitSettingsValues , connectedGitHubRepo ] ) ;
874+
853875 const [ gitSettingsForm , fields ] = useForm ( {
854876 id : "update-git-settings" ,
855877 lastSubmission : lastSubmission ,
@@ -908,6 +930,12 @@ function ConnectedGitHubRepoForm({
908930 placeholder = "none"
909931 variant = "tertiary"
910932 icon = { GitBranchIcon }
933+ onChange = { ( e ) => {
934+ setGitSettingsValues ( ( prev ) => ( {
935+ ...prev ,
936+ productionBranch : e . target . value ,
937+ } ) ) ;
938+ } }
911939 />
912940 < div className = "flex items-center gap-1.5" >
913941 < EnvironmentIcon environment = { { type : "STAGING" } } className = "size-4" />
@@ -921,6 +949,12 @@ function ConnectedGitHubRepoForm({
921949 placeholder = "none"
922950 variant = "tertiary"
923951 icon = { GitBranchIcon }
952+ onChange = { ( e ) => {
953+ setGitSettingsValues ( ( prev ) => ( {
954+ ...prev ,
955+ stagingBranch : e . target . value ,
956+ } ) ) ;
957+ } }
924958 />
925959
926960 < div className = "flex items-center gap-1.5" >
@@ -935,6 +969,12 @@ function ConnectedGitHubRepoForm({
935969 variant = "small"
936970 label = "create preview deployments for pull requests"
937971 labelPosition = "right"
972+ onCheckedChange = { ( checked ) => {
973+ setGitSettingsValues ( ( prev ) => ( {
974+ ...prev ,
975+ previewDeploymentsEnabled : checked ,
976+ } ) ) ;
977+ } }
938978 />
939979 </ div >
940980 < FormError > { fields . productionBranch ?. error } </ FormError >
@@ -950,7 +990,7 @@ function ConnectedGitHubRepoForm({
950990 name = "action"
951991 value = "update-git-settings"
952992 variant = "secondary/small"
953- disabled = { isGitSettingsLoading }
993+ disabled = { isGitSettingsLoading || ! hasGitSettingsChanges }
954994 LeadingIcon = { isGitSettingsLoading ? SpinnerWhite : undefined }
955995 >
956996 Save
0 commit comments