@@ -4,7 +4,7 @@ import React, { memo, useCallback, useContext } from 'react';
4
4
import { AuthDialogControllerContext } from './useAuthDialog' ;
5
5
import { CloudAuthButton } from './CloudAuthButton' ;
6
6
import DomainIcon from '@material-ui/icons/Domain' ;
7
- import { Product } from '../../../../atlclients/authInfo' ;
7
+ import { Product , ProductJira } from '../../../../atlclients/authInfo' ;
8
8
import { SiteList } from './SiteList' ;
9
9
import { SiteWithAuthInfo } from '../../../../lib/ipc/toUI/config' ;
10
10
import { Features } from 'src/util/featureFlags' ;
@@ -47,46 +47,113 @@ export const SiteAuthenticator: React.FunctionComponent<SiteAuthenticatorProps>
47
47
return (
48
48
< Box flexGrow = { 1 } >
49
49
< Grid container direction = "column" spacing = { 2 } >
50
- < Grid item hidden = { isRemote === false || useNewAuth } >
51
- < Typography >
52
- < Box component = "span" fontWeight = "fontWeightBold" >
53
- ⚠️ Authentication cannot be done while running remotely
54
- </ Box >
55
- </ Typography >
56
- < Typography >
57
- To authenticate with a new site open this (or another) workspace locally. Accounts added
58
- when running locally < em > will</ em > be accessible during remote development.
59
- </ Typography >
60
- </ Grid >
61
- < Grid item style = { { cursor : isRemote && ! useNewAuth ? 'not-allowed' : 'default' } } >
62
- < Grid
63
- container
64
- direction = "column"
65
- spacing = { 2 }
66
- style = { {
67
- pointerEvents : isRemote && ! useNewAuth ? 'none' : 'inherit' ,
68
- opacity : isRemote && ! useNewAuth ? 0.6 : 'inherit' ,
69
- } }
70
- >
71
- < Grid item >
72
- < Grid container spacing = { 2 } >
73
- < Grid item >
74
- < CloudAuthButton product = { product } />
75
- </ Grid >
76
- < Grid item >
77
- < Button color = "primary" startIcon = { < DomainIcon /> } onClick = { openProductAuth } >
78
- { `Add Custom ${ product . name } Site` }
79
- </ Button >
80
- </ Grid >
81
- </ Grid >
82
- </ Grid >
83
- < Grid item >
84
- < SiteList product = { product } sites = { sites } editServer = { handleEdit } />
85
- </ Grid >
86
- </ Grid >
87
- </ Grid >
50
+ { useNewAuth && product . key === ProductJira . key ? (
51
+ < AuthContainer
52
+ isRemote = { isRemote }
53
+ product = { product }
54
+ openProductAuth = { openProductAuth }
55
+ sites = { sites }
56
+ handleEdit = { handleEdit }
57
+ />
58
+ ) : (
59
+ < LegacyAuthContainer
60
+ isRemote = { isRemote }
61
+ product = { product }
62
+ openProductAuth = { openProductAuth }
63
+ sites = { sites }
64
+ handleEdit = { handleEdit }
65
+ />
66
+ ) }
88
67
</ Grid >
89
68
</ Box >
90
69
) ;
91
70
} ,
92
71
) ;
72
+
73
+ interface AuthContainerProps {
74
+ isRemote : boolean ;
75
+ product : Product ;
76
+ openProductAuth : ( ) => void ;
77
+ sites : SiteWithAuthInfo [ ] ;
78
+ handleEdit : ( swa : SiteWithAuthInfo ) => void ;
79
+ }
80
+
81
+ const LegacyAuthContainer = ( { isRemote, product, openProductAuth, sites, handleEdit } : AuthContainerProps ) => (
82
+ < React . Fragment >
83
+ < Grid item hidden = { isRemote === false } >
84
+ < Typography >
85
+ < Box component = "span" fontWeight = "fontWeightBold" >
86
+ ⚠️ Authentication cannot be done while running remotely
87
+ </ Box >
88
+ </ Typography >
89
+ < Typography >
90
+ To authenticate with a new site open this (or another) workspace locally. Accounts added when running
91
+ locally < em > will</ em > be accessible during remote development.
92
+ </ Typography >
93
+ </ Grid >
94
+ < Grid item style = { { cursor : isRemote ? 'not-allowed' : 'default' } } >
95
+ < Grid
96
+ container
97
+ direction = "column"
98
+ spacing = { 2 }
99
+ style = { {
100
+ pointerEvents : isRemote ? 'none' : 'inherit' ,
101
+ opacity : isRemote ? 0.6 : 'inherit' ,
102
+ } }
103
+ >
104
+ < Grid item >
105
+ < Grid container spacing = { 2 } >
106
+ < Grid item >
107
+ < CloudAuthButton product = { product } />
108
+ </ Grid >
109
+ < Grid item >
110
+ < Button color = "primary" startIcon = { < DomainIcon /> } onClick = { openProductAuth } >
111
+ { `Add Custom ${ product . name } Site` }
112
+ </ Button >
113
+ </ Grid >
114
+ </ Grid >
115
+ </ Grid >
116
+ < Grid item >
117
+ < SiteList product = { product } sites = { sites } editServer = { handleEdit } />
118
+ </ Grid >
119
+ </ Grid >
120
+ </ Grid >
121
+ </ React . Fragment >
122
+ ) ;
123
+
124
+ const AuthContainer = ( { isRemote, product, openProductAuth, sites, handleEdit } : AuthContainerProps ) => (
125
+ < React . Fragment >
126
+ < Grid item >
127
+ < Grid container direction = "column" spacing = { 2 } >
128
+ < Grid item >
129
+ < Grid container spacing = { 2 } >
130
+ { ! isRemote && (
131
+ < React . Fragment >
132
+ < Grid item >
133
+ < CloudAuthButton product = { product } />
134
+ </ Grid >
135
+ < Grid item >
136
+ < Button color = "primary" onClick = { openProductAuth } >
137
+ { `Other options...` }
138
+ </ Button >
139
+ </ Grid >
140
+ </ React . Fragment >
141
+ ) }
142
+ { isRemote && (
143
+ < React . Fragment >
144
+ < Grid item >
145
+ < Button color = "primary" variant = "contained" onClick = { openProductAuth } >
146
+ { `Login to ${ product . name } ` }
147
+ </ Button >
148
+ </ Grid >
149
+ </ React . Fragment >
150
+ ) }
151
+ </ Grid >
152
+ </ Grid >
153
+ < Grid item >
154
+ < SiteList product = { product } sites = { sites } editServer = { handleEdit } />
155
+ </ Grid >
156
+ </ Grid >
157
+ </ Grid >
158
+ </ React . Fragment >
159
+ ) ;
0 commit comments