@@ -60,6 +60,8 @@ import {
6060 githubAppInstallPath ,
6161 EnvironmentParamSchema ,
6262 v3ProjectSettingsPath ,
63+ docsPath ,
64+ v3BillingPath ,
6365} from "~/utils/pathBuilder" ;
6466import React , { useEffect , useState } from "react" ;
6567import { Select , SelectItem } from "~/components/primitives/Select" ;
@@ -77,6 +79,7 @@ import { TextLink } from "~/components/primitives/TextLink";
7779import { cn } from "~/utils/cn" ;
7880import { ProjectSettingsPresenter } from "~/services/projectSettingsPresenter.server" ;
7981import { type BuildSettings } from "~/v3/buildSettings" ;
82+ import { InfoIconTooltip } from "~/components/primitives/Tooltip" ;
8083
8184export const meta : MetaFunction = ( ) => {
8285 return [
@@ -126,6 +129,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
126129 githubAppEnabled : gitHubApp . enabled ,
127130 githubAppInstallations : gitHubApp . installations ,
128131 connectedGithubRepository : gitHubApp . connectedRepository ,
132+ isPreviewEnvironmentEnabled : gitHubApp . isPreviewEnvironmentEnabled ,
129133 buildSettings,
130134 } ) ;
131135} ;
@@ -433,8 +437,13 @@ export const action: ActionFunction = async ({ request, params }) => {
433437} ;
434438
435439export default function Page ( ) {
436- const { githubAppInstallations, connectedGithubRepository, githubAppEnabled, buildSettings } =
437- useTypedLoaderData < typeof loader > ( ) ;
440+ const {
441+ githubAppInstallations,
442+ connectedGithubRepository,
443+ githubAppEnabled,
444+ buildSettings,
445+ isPreviewEnvironmentEnabled,
446+ } = useTypedLoaderData < typeof loader > ( ) ;
438447 const project = useProject ( ) ;
439448 const organization = useOrganization ( ) ;
440449 const environment = useEnvironment ( ) ;
@@ -561,7 +570,10 @@ export default function Page() {
561570 < Header2 spacing > Git settings</ Header2 >
562571 < div className = "w-full rounded-sm border border-grid-dimmed p-4" >
563572 { connectedGithubRepository ? (
564- < ConnectedGitHubRepoForm connectedGitHubRepo = { connectedGithubRepository } />
573+ < ConnectedGitHubRepoForm
574+ connectedGitHubRepo = { connectedGithubRepository }
575+ previewEnvironmentEnabled = { isPreviewEnvironmentEnabled }
576+ />
565577 ) : (
566578 < GitHubConnectionPrompt
567579 gitHubAppInstallations = { githubAppInstallations ?? [ ] }
@@ -903,11 +915,14 @@ type ConnectedGitHubRepo = {
903915
904916function ConnectedGitHubRepoForm ( {
905917 connectedGitHubRepo,
918+ previewEnvironmentEnabled,
906919} : {
907920 connectedGitHubRepo : ConnectedGitHubRepo ;
921+ previewEnvironmentEnabled ?: boolean ;
908922} ) {
909923 const lastSubmission = useActionData ( ) as any ;
910924 const navigation = useNavigation ( ) ;
925+ const organization = useOrganization ( ) ;
911926
912927 const [ hasGitSettingsChanges , setHasGitSettingsChanges ] = useState ( false ) ;
913928 const [ gitSettingsValues , setGitSettingsValues ] = useState ( {
@@ -1003,10 +1018,10 @@ function ConnectedGitHubRepoForm({
10031018 < Fieldset >
10041019 < InputGroup fullWidth >
10051020 < Hint >
1006- Every commit on the selected tracking branch creates a deployment in the corresponding
1021+ Every push to the selected tracking branch creates a deployment in the corresponding
10071022 environment.
10081023 </ Hint >
1009- < div className = "grid grid-cols-[120px_1fr] gap-3" >
1024+ < div className = "mt-1 grid grid-cols-[120px_1fr] gap-3" >
10101025 < div className = "flex items-center gap-1.5" >
10111026 < EnvironmentIcon environment = { { type : "PRODUCTION" } } className = "size-4" />
10121027 < span className = { `text-sm ${ environmentTextClassName ( { type : "PRODUCTION" } ) } ` } >
@@ -1054,19 +1069,34 @@ function ConnectedGitHubRepoForm({
10541069 { environmentFullTitle ( { type : "PREVIEW" } ) }
10551070 </ span >
10561071 </ div >
1057- < Switch
1058- name = "previewDeploymentsEnabled"
1059- defaultChecked = { connectedGitHubRepo . previewDeploymentsEnabled }
1060- variant = "small"
1061- label = "create preview deployments for pull requests"
1062- labelPosition = "right"
1063- onCheckedChange = { ( checked ) => {
1064- setGitSettingsValues ( ( prev ) => ( {
1065- ...prev ,
1066- previewDeploymentsEnabled : checked ,
1067- } ) ) ;
1068- } }
1069- />
1072+ < div className = "flex items-center gap-1.5" >
1073+ < Switch
1074+ name = "previewDeploymentsEnabled"
1075+ disabled = { ! previewEnvironmentEnabled }
1076+ defaultChecked = {
1077+ connectedGitHubRepo . previewDeploymentsEnabled && previewEnvironmentEnabled
1078+ }
1079+ variant = "small"
1080+ label = "Create preview deployments for pull requests"
1081+ labelPosition = "right"
1082+ onCheckedChange = { ( checked ) => {
1083+ setGitSettingsValues ( ( prev ) => ( {
1084+ ...prev ,
1085+ previewDeploymentsEnabled : checked ,
1086+ } ) ) ;
1087+ } }
1088+ />
1089+ { ! previewEnvironmentEnabled && (
1090+ < InfoIconTooltip
1091+ content = {
1092+ < span className = "text-xs" >
1093+ < TextLink to = { v3BillingPath ( organization ) } > Upgrade</ TextLink > your plan to
1094+ enable preview branches
1095+ </ span >
1096+ }
1097+ />
1098+ ) }
1099+ </ div >
10701100 </ div >
10711101 < FormError > { fields . productionBranch ?. error } </ FormError >
10721102 < FormError > { fields . stagingBranch ?. error } </ FormError >
0 commit comments