@@ -14,6 +14,7 @@ import {
14
14
useActionData ,
15
15
useNavigation ,
16
16
useNavigate ,
17
+ useSearchParams ,
17
18
} from "@remix-run/react" ;
18
19
import { type ActionFunction , type LoaderFunctionArgs , json } from "@remix-run/server-runtime" ;
19
20
import { typedjson , useTypedLoaderData } from "remix-typedjson" ;
@@ -49,8 +50,6 @@ import {
49
50
redirectBackWithSuccessMessage ,
50
51
redirectWithErrorMessage ,
51
52
redirectWithSuccessMessage ,
52
- getSession ,
53
- commitSession ,
54
53
} from "~/models/message.server" ;
55
54
import { ProjectSettingsService } from "~/services/projectSettings.server" ;
56
55
import { logger } from "~/services/logger.server" ;
@@ -123,22 +122,12 @@ export const loader = async ({ request, params }: LoaderFunctionArgs) => {
123
122
124
123
const { gitHubApp, buildSettings } = resultOrFail . value ;
125
124
126
- const session = await getSession ( request . headers . get ( "Cookie" ) ) ;
127
- const openGitHubRepoConnectionModal = session . get ( "gitHubAppInstalled" ) === true ;
128
- const headers = new Headers ( {
129
- "Set-Cookie" : await commitSession ( session ) ,
125
+ return typedjson ( {
126
+ githubAppEnabled : gitHubApp . enabled ,
127
+ githubAppInstallations : gitHubApp . installations ,
128
+ connectedGithubRepository : gitHubApp . connectedRepository ,
129
+ buildSettings,
130
130
} ) ;
131
-
132
- return typedjson (
133
- {
134
- githubAppEnabled : gitHubApp . enabled ,
135
- githubAppInstallations : gitHubApp . installations ,
136
- connectedGithubRepository : gitHubApp . connectedRepository ,
137
- openGitHubRepoConnectionModal,
138
- buildSettings,
139
- } ,
140
- { headers }
141
- ) ;
142
131
} ;
143
132
144
133
const ConnectGitHubRepoFormSchema = z . object ( {
@@ -444,13 +433,8 @@ export const action: ActionFunction = async ({ request, params }) => {
444
433
} ;
445
434
446
435
export default function Page ( ) {
447
- const {
448
- githubAppInstallations,
449
- connectedGithubRepository,
450
- githubAppEnabled,
451
- openGitHubRepoConnectionModal,
452
- buildSettings,
453
- } = useTypedLoaderData < typeof loader > ( ) ;
436
+ const { githubAppInstallations, connectedGithubRepository, githubAppEnabled, buildSettings } =
437
+ useTypedLoaderData < typeof loader > ( ) ;
454
438
const project = useProject ( ) ;
455
439
const organization = useOrganization ( ) ;
456
440
const environment = useEnvironment ( ) ;
@@ -584,7 +568,6 @@ export default function Page() {
584
568
organizationSlug = { organization . slug }
585
569
projectSlug = { project . slug }
586
570
environmentSlug = { environment . slug }
587
- openGitHubRepoConnectionModal = { openGitHubRepoConnectionModal }
588
571
/>
589
572
) }
590
573
</ div >
@@ -667,15 +650,14 @@ function ConnectGitHubRepoModal({
667
650
organizationSlug,
668
651
projectSlug,
669
652
environmentSlug,
670
- open = false ,
671
653
} : {
672
654
gitHubAppInstallations : GitHubAppInstallation [ ] ;
673
655
organizationSlug : string ;
674
656
projectSlug : string ;
675
657
environmentSlug : string ;
676
658
open ?: boolean ;
677
659
} ) {
678
- const [ isModalOpen , setIsModalOpen ] = useState ( open ) ;
660
+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
679
661
const lastSubmission = useActionData ( ) as any ;
680
662
const navigate = useNavigate ( ) ;
681
663
@@ -703,6 +685,17 @@ function ConnectGitHubRepoModal({
703
685
} ,
704
686
} ) ;
705
687
688
+ const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
689
+ useEffect ( ( ) => {
690
+ const params = new URLSearchParams ( searchParams ) ;
691
+
692
+ if ( params . get ( "openGithubRepoModal" ) === "1" ) {
693
+ setIsModalOpen ( true ) ;
694
+ params . delete ( "openGithubRepoModal" ) ;
695
+ setSearchParams ( params ) ;
696
+ }
697
+ } , [ searchParams , setSearchParams ] ) ;
698
+
706
699
useEffect ( ( ) => {
707
700
if ( lastSubmission && "success" in lastSubmission && lastSubmission . success === true ) {
708
701
setIsModalOpen ( false ) ;
@@ -759,11 +752,11 @@ function ConnectGitHubRepoModal({
759
752
navigate (
760
753
githubAppInstallPath (
761
754
organizationSlug ,
762
- v3ProjectSettingsPath (
755
+ ` ${ v3ProjectSettingsPath (
763
756
{ slug : organizationSlug } ,
764
757
{ slug : projectSlug } ,
765
758
{ slug : environmentSlug }
766
- )
759
+ ) } ?openGithubRepoModal=1`
767
760
)
768
761
) ;
769
762
} }
@@ -856,13 +849,11 @@ function GitHubConnectionPrompt({
856
849
organizationSlug,
857
850
projectSlug,
858
851
environmentSlug,
859
- openGitHubRepoConnectionModal = false ,
860
852
} : {
861
853
gitHubAppInstallations : GitHubAppInstallation [ ] ;
862
854
organizationSlug : string ;
863
855
projectSlug : string ;
864
856
environmentSlug : string ;
865
- openGitHubRepoConnectionModal ?: boolean ;
866
857
} ) {
867
858
return (
868
859
< Fieldset >
@@ -871,11 +862,11 @@ function GitHubConnectionPrompt({
871
862
< LinkButton
872
863
to = { githubAppInstallPath (
873
864
organizationSlug ,
874
- v3ProjectSettingsPath (
865
+ ` ${ v3ProjectSettingsPath (
875
866
{ slug : organizationSlug } ,
876
867
{ slug : projectSlug } ,
877
868
{ slug : environmentSlug }
878
- )
869
+ ) } ?openGithubRepoModal=1`
879
870
) }
880
871
variant = { "secondary/medium" }
881
872
LeadingIcon = { OctoKitty }
@@ -890,7 +881,6 @@ function GitHubConnectionPrompt({
890
881
organizationSlug = { organizationSlug }
891
882
projectSlug = { projectSlug }
892
883
environmentSlug = { environmentSlug }
893
- open = { openGitHubRepoConnectionModal }
894
884
/>
895
885
< span className = "flex items-center gap-1 text-xs text-text-dimmed" >
896
886
< CheckCircleIcon className = "size-4 text-success" /> GitHub app is installed
0 commit comments