@@ -23,6 +23,12 @@ import {
23
23
LOGIN_PAGE_INVALID_CREDS_ERROR ,
24
24
LOGIN_PAGE_INVALID_CREDS_FORGOT_PASSWORD_LINK ,
25
25
NEW_TO_APPSMITH ,
26
+ MULTI_ORG_FOOTER_NOT_RIGHT_ORG_LEFT_TEXT ,
27
+ MULTI_ORG_FOOTER_NOT_RIGHT_ORG_RIGHT_TEXT ,
28
+ MULTI_ORG_FOOTER_NOT_PART_OF_ORG_LEFT_TEXT ,
29
+ MULTI_ORG_FOOTER_NOT_PART_OF_ORG_RIGHT_TEXT ,
30
+ MULTI_ORG_FOOTER_CREATE_ORG_LEFT_TEXT ,
31
+ MULTI_ORG_FOOTER_CREATE_ORG_RIGHT_TEXT ,
26
32
createMessage ,
27
33
} from "ee/constants/messages" ;
28
34
import { FormGroup } from "@appsmith/ads-old" ;
@@ -46,6 +52,7 @@ import {
46
52
getThirdPartyAuths ,
47
53
getIsFormLoginEnabled ,
48
54
getOrganizationConfig ,
55
+ isWithinAnOrganization ,
49
56
} from "ee/selectors/organizationSelectors" ;
50
57
import Helmet from "react-helmet" ;
51
58
import { useFeatureFlag } from "utils/hooks/useFeatureFlag" ;
@@ -99,8 +106,12 @@ export function Login(props: LoginFormProps) {
99
106
const isBrandingEnabled = useFeatureFlag (
100
107
FEATURE_FLAG . license_branding_enabled ,
101
108
) ;
109
+ const isMultiOrgEnabled = useFeatureFlag (
110
+ FEATURE_FLAG . license_multi_org_enabled ,
111
+ ) ;
102
112
const organizationConfig = useSelector ( getOrganizationConfig ) ;
103
- const { instanceName } = organizationConfig ;
113
+ const withinOrg = useSelector ( isWithinAnOrganization ) ;
114
+ const { displayName, instanceName, slug } = organizationConfig ;
104
115
const htmlPageTitle = getHTMLPageTitle ( isBrandingEnabled , instanceName ) ;
105
116
const invalidCredsForgotPasswordLinkText = createMessage (
106
117
LOGIN_PAGE_INVALID_CREDS_FORGOT_PASSWORD_LINK ,
@@ -138,6 +149,33 @@ export function Login(props: LoginFormProps) {
138
149
forgotPasswordURL += `?email=${ props . emailValue } ` ;
139
150
}
140
151
152
+ const getPrimaryLoginURL = ( ) => {
153
+ const hostnameParts = window . location . hostname . split ( "." ) ;
154
+
155
+ hostnameParts [ 0 ] = "login" ;
156
+ const orgChangeURL = `https://${ hostnameParts . join ( "." ) } ` ;
157
+
158
+ return orgChangeURL ;
159
+ } ;
160
+
161
+ const multiOrgFooterContent = [
162
+ {
163
+ leftText : createMessage ( MULTI_ORG_FOOTER_NOT_RIGHT_ORG_LEFT_TEXT ) ,
164
+ rightText : createMessage ( MULTI_ORG_FOOTER_NOT_RIGHT_ORG_RIGHT_TEXT ) ,
165
+ rightTextLink : getPrimaryLoginURL ( ) + "/org" ,
166
+ } ,
167
+ {
168
+ leftText : createMessage ( MULTI_ORG_FOOTER_NOT_PART_OF_ORG_LEFT_TEXT ) ,
169
+ rightText : createMessage ( MULTI_ORG_FOOTER_NOT_PART_OF_ORG_RIGHT_TEXT ) ,
170
+ rightTextLink : getPrimaryLoginURL ( ) ,
171
+ } ,
172
+ {
173
+ leftText : createMessage ( MULTI_ORG_FOOTER_CREATE_ORG_LEFT_TEXT ) ,
174
+ rightText : createMessage ( MULTI_ORG_FOOTER_CREATE_ORG_RIGHT_TEXT ) ,
175
+ rightTextLink : getPrimaryLoginURL ( ) ,
176
+ } ,
177
+ ] ;
178
+
141
179
const footerSection = isFormLoginEnabled && (
142
180
< div className = "px-2 flex align-center justify-center text-center text-[color:var(--ads-v2\-color-fg)] text-[14px]" >
143
181
{ createMessage ( NEW_TO_APPSMITH ) }
@@ -152,8 +190,57 @@ export function Login(props: LoginFormProps) {
152
190
</ div >
153
191
) ;
154
192
193
+ const multiOrgFooterSection = (
194
+ < div className = "px-2 flex flex-col gap-3 align-center justify-center text-center text-[color:var(--ads-v2\-color-fg)] text-[14px]" >
195
+ { multiOrgFooterContent . map ( ( item ) => (
196
+ < div className = "flex align-center justify-center" key = { item . leftText } >
197
+ { item . leftText }
198
+ < Link
199
+ className = "t--sign-up t--signup-link"
200
+ kind = "primary"
201
+ target = "_self"
202
+ to = { item . rightTextLink }
203
+ >
204
+ { item . rightText }
205
+ </ Link >
206
+ </ div >
207
+ ) ) }
208
+ </ div >
209
+ ) ;
210
+
211
+ const renderTitle = ( ) => {
212
+ if ( isMultiOrgEnabled && withinOrg && displayName ) {
213
+ return (
214
+ < >
215
+ Sign in to{ " " }
216
+ < span style = { { color : "var(--ads-v2-color-fg-brand)" } } >
217
+ { displayName }
218
+ </ span >
219
+ </ >
220
+ ) ;
221
+ }
222
+
223
+ return createMessage ( LOGIN_PAGE_TITLE ) ;
224
+ } ;
225
+
226
+ const renderSubtitle = ( ) => {
227
+ if ( isMultiOrgEnabled && withinOrg && slug ) {
228
+ const lowercaseInstanceName = slug . toLowerCase ( ) ;
229
+
230
+ return `${ lowercaseInstanceName } .appsmith.com` ;
231
+ }
232
+
233
+ return undefined ;
234
+ } ;
235
+
155
236
return (
156
- < Container footer = { footerSection } title = { createMessage ( LOGIN_PAGE_TITLE ) } >
237
+ < Container
238
+ footer = {
239
+ isMultiOrgEnabled && withinOrg ? multiOrgFooterSection : footerSection
240
+ }
241
+ subtitle = { renderSubtitle ( ) }
242
+ title = { renderTitle ( ) }
243
+ >
157
244
< Helmet >
158
245
< title > { htmlPageTitle } </ title >
159
246
</ Helmet >
0 commit comments