1
+ import { type Interpolation , type Theme } from "@emotion/react" ;
1
2
import OpenInNewIcon from "@mui/icons-material/OpenInNew" ;
2
3
import RefreshIcon from "@mui/icons-material/Refresh" ;
3
4
import CircularProgress from "@mui/material/CircularProgress" ;
4
5
import Link from "@mui/material/Link" ;
5
6
import Tooltip from "@mui/material/Tooltip" ;
6
- import { makeStyles } from "@mui/styles" ;
7
- import { ApiErrorResponse } from "api/errors" ;
8
- import { ExternalAuth , ExternalAuthDevice } from "api/typesGenerated" ;
7
+ import type { ApiErrorResponse } from "api/errors" ;
8
+ import type { ExternalAuth , ExternalAuthDevice } from "api/typesGenerated" ;
9
9
import { Alert } from "components/Alert/Alert" ;
10
10
import { Avatar } from "components/Avatar/Avatar" ;
11
11
import { CopyButton } from "components/CopyButton/CopyButton" ;
12
12
import { SignInLayout } from "components/SignInLayout/SignInLayout" ;
13
13
import { Welcome } from "components/Welcome/Welcome" ;
14
- import { type FC } from "react" ;
14
+ import { type FC , type ReactNode } from "react" ;
15
15
16
16
export interface ExternalAuthPageViewProps {
17
17
externalAuth : ExternalAuth ;
@@ -30,8 +30,6 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
30
30
onReauthenticate,
31
31
viewExternalAuthConfig,
32
32
} ) => {
33
- const styles = useStyles ( ) ;
34
-
35
33
if ( ! externalAuth . authenticated ) {
36
34
return (
37
35
< SignInLayout >
@@ -50,7 +48,7 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
50
48
const hasInstallations = externalAuth . installations . length > 0 ;
51
49
52
50
// We only want to wrap this with a link if an install URL is available!
53
- let installTheApp : React . ReactNode = `install the ${ externalAuth . display_name } App` ;
51
+ let installTheApp : ReactNode = `install the ${ externalAuth . display_name } App` ;
54
52
if ( externalAuth . app_install_url ) {
55
53
installTheApp = (
56
54
< Link
@@ -68,15 +66,15 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
68
66
< Welcome
69
67
message = { `You've authenticated with ${ externalAuth . display_name } !` }
70
68
/>
71
- < p className = { styles . text } >
69
+ < p css = { styles . text } >
72
70
{ externalAuth . user ?. login && `Hey @${ externalAuth . user ?. login } ! 👋 ` }
73
71
{ ( ! externalAuth . app_installable ||
74
72
externalAuth . installations . length > 0 ) &&
75
73
"You are now authenticated. Feel free to close this window!" }
76
74
</ p >
77
75
78
76
{ externalAuth . installations . length > 0 && (
79
- < div className = { styles . authorizedInstalls } >
77
+ < div css = { styles . authorizedInstalls } >
80
78
{ externalAuth . installations . map ( ( install ) => {
81
79
if ( ! install . account ) {
82
80
return ;
@@ -105,9 +103,9 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
105
103
</ div >
106
104
) }
107
105
108
- < div className = { styles . links } >
106
+ < div css = { styles . links } >
109
107
{ ! hasInstallations && externalAuth . app_installable && (
110
- < Alert severity = "warning" className = { styles . installAlert } >
108
+ < Alert severity = "warning" css = { styles . installAlert } >
111
109
You must { installTheApp } to clone private repositories. Accounts
112
110
will appear here once authorized.
113
111
</ Alert >
@@ -120,7 +118,7 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
120
118
href = { externalAuth . app_install_url }
121
119
target = "_blank"
122
120
rel = "noreferrer"
123
- className = { styles . link }
121
+ css = { styles . link }
124
122
>
125
123
< OpenInNewIcon fontSize = "small" />
126
124
{ externalAuth . installations . length > 0
@@ -130,7 +128,7 @@ const ExternalAuthPageView: FC<ExternalAuthPageViewProps> = ({
130
128
</ Link >
131
129
) }
132
130
< Link
133
- className = { styles . link }
131
+ css = { styles . link }
134
132
href = "#"
135
133
onClick = { ( ) => {
136
134
onReauthenticate ( ) ;
@@ -147,10 +145,8 @@ const GitDeviceAuth: FC<{
147
145
externalAuthDevice ?: ExternalAuthDevice ;
148
146
deviceExchangeError ?: ApiErrorResponse ;
149
147
} > = ( { externalAuthDevice, deviceExchangeError } ) => {
150
- const styles = useStyles ( ) ;
151
-
152
148
let status = (
153
- < p className = { styles . status } >
149
+ < p css = { styles . status } >
154
150
< CircularProgress size = { 16 } color = "secondary" data-chromatic = "ignore" />
155
151
Checking for authentication...
156
152
</ p >
@@ -189,18 +185,18 @@ const GitDeviceAuth: FC<{
189
185
190
186
return (
191
187
< div >
192
- < p className = { styles . text } >
188
+ < p css = { styles . text } >
193
189
Copy your one-time code:
194
- < div className = { styles . copyCode } >
195
- < span className = { styles . code } > { externalAuthDevice . user_code } </ span >
190
+ < div css = { styles . copyCode } >
191
+ < span css = { styles . code } > { externalAuthDevice . user_code } </ span >
196
192
< CopyButton text = { externalAuthDevice . user_code } />
197
193
</ div >
198
194
< br />
199
195
Then open the link below and paste it:
200
196
</ p >
201
- < div className = { styles . links } >
197
+ < div css = { styles . links } >
202
198
< Link
203
- className = { styles . link }
199
+ css = { styles . link }
204
200
href = { externalAuthDevice . verification_uri }
205
201
target = "_blank"
206
202
rel = "noreferrer"
@@ -217,56 +213,56 @@ const GitDeviceAuth: FC<{
217
213
218
214
export default ExternalAuthPageView ;
219
215
220
- const useStyles = makeStyles ( ( theme ) => ( {
221
- text : {
216
+ const styles = {
217
+ text : ( theme ) => ( {
222
218
fontSize : 16 ,
223
219
color : theme . palette . text . secondary ,
224
220
textAlign : "center" ,
225
221
lineHeight : "160%" ,
226
222
margin : 0 ,
227
- } ,
223
+ } ) ,
228
224
229
225
copyCode : {
230
226
display : "inline-flex" ,
231
227
alignItems : "center" ,
232
228
} ,
233
229
234
- code : {
230
+ code : ( theme ) => ( {
235
231
fontWeight : "bold" ,
236
232
color : theme . palette . text . primary ,
237
- } ,
233
+ } ) ,
238
234
239
- installAlert : {
235
+ installAlert : ( theme ) => ( {
240
236
margin : theme . spacing ( 2 ) ,
241
- } ,
237
+ } ) ,
242
238
243
- links : {
239
+ links : ( theme ) => ( {
244
240
display : "flex" ,
245
241
gap : theme . spacing ( 0.5 ) ,
246
242
margin : theme . spacing ( 2 ) ,
247
243
flexDirection : "column" ,
248
- } ,
244
+ } ) ,
249
245
250
- link : {
246
+ link : ( theme ) => ( {
251
247
display : "flex" ,
252
248
alignItems : "center" ,
253
249
justifyContent : "center" ,
254
250
fontSize : 16 ,
255
251
gap : theme . spacing ( 1 ) ,
256
- } ,
252
+ } ) ,
257
253
258
- status : {
254
+ status : ( theme ) => ( {
259
255
display : "flex" ,
260
256
alignItems : "center" ,
261
257
justifyContent : "center" ,
262
258
gap : theme . spacing ( 1 ) ,
263
259
color : theme . palette . text . disabled ,
264
- } ,
260
+ } ) ,
265
261
266
- authorizedInstalls : {
262
+ authorizedInstalls : ( theme ) => ( {
267
263
display : "flex" ,
268
264
gap : 4 ,
269
265
color : theme . palette . text . disabled ,
270
266
margin : theme . spacing ( 4 ) ,
271
- } ,
272
- } ) ) ;
267
+ } ) ,
268
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments