-
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathindex.tsx
More file actions
53 lines (43 loc) · 2.2 KB
/
index.tsx
File metadata and controls
53 lines (43 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import { useTranslation } from 'react-i18next';
import cn from 'classnames';
import { Box, NavigateLink, SpaceBetween } from 'components';
import { UnauthorizedLayout } from 'layouts/UnauthorizedLayout';
import { ROUTES } from 'routes';
import { useGetEntraInfoQuery, useGetOktaInfoQuery, useGetGoogleInfoQuery } from 'services/auth';
import { LoginByEntraID } from '../EntraID/LoginByEntraID';
import { LoginByOkta } from '../LoginByOkta';
import { LoginByGoogle } from '../LoginByGoogle';
import { LoginByTokenForm } from '../LoginByTokenForm';
import styles from './styles.module.scss';
export const EnterpriseLogin: React.FC = () => {
const { t } = useTranslation();
const { data: oktaData, isLoading: isLoadingOkta } = useGetOktaInfoQuery();
const { data: entraData, isLoading: isLoadingEntra } = useGetEntraInfoQuery();
const { data: googleData, isLoading: isLoadingGoogle } = useGetGoogleInfoQuery();
const oktaEnabled = oktaData?.enabled;
const entraEnabled = entraData?.enabled;
const googleEnabled = googleData?.enabled;
const isLoading = isLoadingOkta || isLoadingEntra;
const isShowTokenForm = !oktaEnabled && !entraEnabled;
return (
<UnauthorizedLayout>
<div className={cn(styles.form)}>
<SpaceBetween size="xl" alignItems="center">
<Box variant="h1" textAlign="center">
{t('auth.sign_in_to_dstack_enterprise')}
</Box>
{!isLoading && isShowTokenForm && <LoginByTokenForm />}
{!isLoadingOkta && oktaEnabled && <LoginByOkta className={styles.okta} />}
{!isLoadingEntra && entraEnabled && <LoginByEntraID className={styles.entra} />}
{!isLoadingGoogle && googleEnabled && <LoginByGoogle className={styles.google} />}
{!isLoading && !isShowTokenForm && (
<Box color="text-body-secondary">
<NavigateLink href={ROUTES.AUTH.TOKEN}>{t('auth.login_by_token')}</NavigateLink>
</Box>
)}
</SpaceBetween>
</div>
</UnauthorizedLayout>
);
};