@@ -51,6 +51,7 @@ import {
5151 redirectBackWithSuccessMessage ,
5252 redirectWithErrorMessage ,
5353 redirectWithSuccessMessage ,
54+ getSession ,
5455} from "~/models/message.server" ;
5556import { findProjectBySlug } from "~/models/project.server" ;
5657import { DeleteProjectService } from "~/services/deleteProject.server" ;
@@ -92,11 +93,15 @@ export const meta: MetaFunction = () => {
9293export const loader = async ( { request, params } : LoaderFunctionArgs ) => {
9394 const githubAppEnabled = env . GITHUB_APP_ENABLED === "1" ;
9495
96+ const session = await getSession ( request . headers . get ( "Cookie" ) ) ;
97+ const openGitHubRepoConnectionModal = session . get ( "gitHubAppInstalled" ) === true ;
98+
9599 if ( ! githubAppEnabled ) {
96100 return typedjson ( {
97101 githubAppEnabled,
98102 githubAppInstallations : undefined ,
99103 connectedGithubRepository : undefined ,
104+ openGitHubRepoConnectionModal,
100105 } ) ;
101106 }
102107
@@ -143,6 +148,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
143148 branchTracking : branchTrackingOrFailure . success ? branchTrackingOrFailure . data : undefined ,
144149 } ,
145150 githubAppInstallations : undefined ,
151+ openGitHubRepoConnectionModal,
146152 } ) ;
147153 }
148154
@@ -181,6 +187,7 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
181187 githubAppEnabled,
182188 githubAppInstallations,
183189 connectedGithubRepository : undefined ,
190+ openGitHubRepoConnectionModal,
184191 } ) ;
185192} ;
186193
@@ -466,8 +473,12 @@ export const action: ActionFunction = async ({ request, params }) => {
466473} ;
467474
468475export default function Page ( ) {
469- const { githubAppInstallations, connectedGithubRepository, githubAppEnabled } =
470- useTypedLoaderData < typeof loader > ( ) ;
476+ const {
477+ githubAppInstallations,
478+ connectedGithubRepository,
479+ githubAppEnabled,
480+ openGitHubRepoConnectionModal,
481+ } = useTypedLoaderData < typeof loader > ( ) ;
471482 const project = useProject ( ) ;
472483 const organization = useOrganization ( ) ;
473484 const environment = useEnvironment ( ) ;
@@ -600,6 +611,7 @@ export default function Page() {
600611 organizationSlug = { organization . slug }
601612 projectSlug = { project . slug }
602613 environmentSlug = { environment . slug }
614+ openGitHubRepoConnectionModal = { openGitHubRepoConnectionModal }
603615 />
604616 ) }
605617 </ div >
@@ -674,13 +686,15 @@ function ConnectGitHubRepoModal({
674686 organizationSlug,
675687 projectSlug,
676688 environmentSlug,
689+ open = false ,
677690} : {
678691 gitHubAppInstallations : GitHubAppInstallation [ ] ;
679692 organizationSlug : string ;
680693 projectSlug : string ;
681694 environmentSlug : string ;
695+ open ?: boolean ;
682696} ) {
683- const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
697+ const [ isModalOpen , setIsModalOpen ] = useState ( open ) ;
684698 const lastSubmission = useActionData ( ) as any ;
685699 const navigate = useNavigate ( ) ;
686700
@@ -861,11 +875,13 @@ function GitHubConnectionPrompt({
861875 organizationSlug,
862876 projectSlug,
863877 environmentSlug,
878+ openGitHubRepoConnectionModal = false ,
864879} : {
865880 gitHubAppInstallations : GitHubAppInstallation [ ] ;
866881 organizationSlug : string ;
867882 projectSlug : string ;
868883 environmentSlug : string ;
884+ openGitHubRepoConnectionModal ?: boolean ;
869885} ) {
870886 return (
871887 < Fieldset >
@@ -893,6 +909,7 @@ function GitHubConnectionPrompt({
893909 organizationSlug = { organizationSlug }
894910 projectSlug = { projectSlug }
895911 environmentSlug = { environmentSlug }
912+ open = { openGitHubRepoConnectionModal }
896913 />
897914 < span className = "flex items-center gap-1 text-xs text-text-dimmed" >
898915 < CheckCircleIcon className = "size-4 text-success" /> GitHub app is installed
0 commit comments