@@ -25,9 +25,11 @@ export interface TermsOfServiceProps {
25
25
}
26
26
interface TermsOfServiceState {
27
27
isUpdate : boolean ;
28
+ flowId : string ;
28
29
userInfo ?: any ;
29
30
terms ?: Terms ;
30
31
acceptsTos : boolean ;
32
+ submitted : boolean ;
31
33
}
32
34
export class TermsOfService extends React . Component < TermsOfServiceProps , TermsOfServiceState > {
33
35
protected gitpodHost = new GitpodHostUrl ( window . location . href ) ;
@@ -38,7 +40,9 @@ export class TermsOfService extends React.Component<TermsOfServiceProps, TermsOf
38
40
super ( props ) ;
39
41
this . state = {
40
42
isUpdate : false ,
41
- acceptsTos : false
43
+ acceptsTos : false ,
44
+ submitted : false ,
45
+ flowId : "ignore" ,
42
46
} ;
43
47
this . formRef = React . createRef ( ) ;
44
48
this . onDecline = this . onDecline . bind ( this ) ;
@@ -53,6 +57,7 @@ export class TermsOfService extends React.Component<TermsOfServiceProps, TermsOf
53
57
const tosHints = Cookies . getJSON ( 'tosHints' ) ;
54
58
this . setState ( {
55
59
isUpdate : tosHints ?. isUpdate === true ,
60
+ flowId : typeof tosHints ?. flowId === "string" ? tosHints ?. flowId : this . state . flowId ,
56
61
userInfo : typeof tosHints ?. userInfo === "object" ? tosHints ?. userInfo : undefined
57
62
} ) ;
58
63
this . props . terms . then ( terms => this . setState ( { terms } ) ) ;
@@ -63,10 +68,10 @@ export class TermsOfService extends React.Component<TermsOfServiceProps, TermsOf
63
68
}
64
69
65
70
onAccept ( ) {
66
- this . setState ( { acceptsTos : true } , ( ) => this . doSubmit ( ) ) ;
71
+ this . setState ( { acceptsTos : true , submitted : true } , ( ) => this . doSubmit ( ) ) ;
67
72
}
68
73
onDecline ( ) {
69
- this . setState ( { acceptsTos : false } , ( ) => this . doSubmit ( ) ) ;
74
+ this . setState ( { acceptsTos : false , submitted : true } , ( ) => this . doSubmit ( ) ) ;
70
75
}
71
76
protected doSubmit ( ) {
72
77
this . formRef . current ! . submit ( ) ;
@@ -126,6 +131,7 @@ export class TermsOfService extends React.Component<TermsOfServiceProps, TermsOf
126
131
</ AppBar >
127
132
< div className = 'content content-area' >
128
133
< form ref = { this . formRef } action = { this . actionUrl } method = "post" id = "accept-tos-form" >
134
+ < input type = "hidden" id = "flowId" name = "flowId" value = { this . state . flowId } />
129
135
< div className = "tos-checks" >
130
136
< Typography className = "tos-content" dangerouslySetInnerHTML = { { __html : update ? updateMessage : content } } />
131
137
< p >
@@ -148,13 +154,15 @@ export class TermsOfService extends React.Component<TermsOfServiceProps, TermsOf
148
154
variant = 'text'
149
155
color = { 'secondary' }
150
156
onClick = { this . onDecline }
157
+ disabled = { this . state . submitted }
151
158
data-testid = "decline" >
152
159
{ 'Decline and log out' }
153
160
</ ButtonWithProgress >
154
161
) }
155
162
< ButtonWithProgress
156
163
className = 'button'
157
164
onClick = { this . onAccept }
165
+ disabled = { this . state . submitted }
158
166
variant = 'outlined'
159
167
color = { 'primary' }
160
168
data-testid = "submit" >
0 commit comments