@niledatabase/react 2.4.2-alpha.4 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/GoogleLoginButton/GoogleLoginButton.d.ts +1 -1
- package/dist/GoogleLoginButton/GoogleLoginButton.stories.d.ts +0 -1
- package/dist/SignInForm/SignInForm.d.ts +3 -0
- package/dist/SignInForm/index.d.ts +1 -0
- package/dist/{LoginForm → SignInForm}/types.d.ts +1 -2
- package/dist/SignUpForm/types.d.ts +4 -4
- package/dist/UserTenantList/CreateUser.d.ts +1 -2
- package/dist/UserTenantList/UserList.d.ts +2 -2
- package/dist/UserTenantList/UserModal.d.ts +1 -2
- package/dist/index.d.ts +6 -7
- package/dist/lib/SimpleForm/types.d.ts +1 -0
- package/dist/react.cjs.development.js +52 -344
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/react.esm.d.ts +6 -7
- package/dist/react.esm.js +44 -339
- package/dist/react.esm.js.map +1 -1
- package/package.json +4 -3
- package/dist/LoginForm/LoginForm.d.ts +0 -3
- package/dist/LoginForm/SingleSignOn.d.ts +0 -7
- package/dist/LoginForm/index.d.ts +0 -2
- package/dist/SSO/BaseSSOForm.d.ts +0 -8
- package/dist/SSO/Okta.d.ts +0 -3
- package/dist/SSO/SSO.stories.d.ts +0 -6
- package/dist/SSO/index.d.ts +0 -3
- package/dist/SSO/types.d.ts +0 -8
- /package/dist/{LoginForm → SignInForm}/UserLoginForm.stories.d.ts +0 -0
|
@@ -7,6 +7,5 @@ declare const meta: {
|
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
export declare function Basic(): React.JSX.Element;
|
|
10
|
-
export declare function BasicWithTenantNameProvider(): React.JSX.Element;
|
|
11
10
|
export declare function AlphaVersionWithOutProvider(): React.JSX.Element;
|
|
12
11
|
export declare function AlphaVersionWithProvider(): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SignInForm';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LoginRequest } from '@niledatabase/browser';
|
|
2
1
|
import { Attribute } from '../lib/SimpleForm/types';
|
|
3
2
|
export type AllowedAny = any;
|
|
4
3
|
export type LoginInfo = {
|
|
5
4
|
email: string;
|
|
6
5
|
password: string;
|
|
7
6
|
};
|
|
8
|
-
type LoginSuccess = (response:
|
|
7
|
+
type LoginSuccess = (response: AllowedAny, formValues: LoginInfo, ...args: AllowedAny) => void;
|
|
9
8
|
export interface Props {
|
|
10
9
|
beforeMutate?: (data: AllowedAny) => AllowedAny;
|
|
11
10
|
onSuccess: LoginSuccess;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateBasicUserRequest, User } from '@niledatabase/browser';
|
|
2
2
|
import { Attribute } from '../lib/SimpleForm/types';
|
|
3
|
-
export type
|
|
4
|
-
type SignInSuccess = (response: void |
|
|
3
|
+
export type SignUpInfo = CreateBasicUserRequest;
|
|
4
|
+
type SignInSuccess = (response: void | User, formValues: SignUpInfo) => void;
|
|
5
5
|
export type AllowedAny = any;
|
|
6
6
|
export interface Props {
|
|
7
7
|
onSuccess: SignInSuccess;
|
|
8
|
-
onError?: (e: Error, info:
|
|
8
|
+
onError?: (e: Error, info: SignUpInfo) => void;
|
|
9
9
|
beforeMutate?: (data: AllowedAny) => AllowedAny;
|
|
10
10
|
attributes?: Attribute[];
|
|
11
11
|
buttonText?: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SignUp201Response } from '@niledatabase/browser';
|
|
3
2
|
type Props = {
|
|
4
3
|
allowCreation: boolean;
|
|
5
4
|
buttonText: string;
|
|
6
|
-
onUserCreateSuccess?: (user:
|
|
5
|
+
onUserCreateSuccess?: (user: any) => void;
|
|
7
6
|
};
|
|
8
7
|
export default function CreateUser(props: Props): React.JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';
|
|
3
3
|
import { Theme } from '@mui/system/createTheme';
|
|
4
|
-
import {
|
|
4
|
+
import { User } from '@niledatabase/browser';
|
|
5
5
|
type ColumnNames = string;
|
|
6
6
|
type Props = {
|
|
7
7
|
data: void | User[];
|
|
8
8
|
allowCreation?: boolean;
|
|
9
9
|
buttonText?: string;
|
|
10
|
-
onUserCreateSuccess?: (user:
|
|
10
|
+
onUserCreateSuccess?: (user: any) => void;
|
|
11
11
|
slots?: {
|
|
12
12
|
dataGrid?: SxProps<Theme>;
|
|
13
13
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SignUp201Response } from '@niledatabase/browser';
|
|
3
2
|
export type UserFormProps = {
|
|
4
3
|
open: boolean;
|
|
5
4
|
setOpen: (open: boolean) => void;
|
|
6
|
-
refetch?: (user:
|
|
5
|
+
refetch?: (user: any) => void;
|
|
7
6
|
};
|
|
8
7
|
export default function AddUser(props: UserFormProps): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export { NileProvider } from './context';
|
|
2
|
-
export { default as
|
|
1
|
+
export { NileProvider, useApi } from './context';
|
|
2
|
+
export { default as Google } from './GoogleLoginButton';
|
|
3
3
|
export * from './GoogleLoginButton';
|
|
4
4
|
export * from './SignUpForm';
|
|
5
|
-
export { default as
|
|
6
|
-
export * from './
|
|
7
|
-
export { default as
|
|
5
|
+
export { default as SignUpForm } from './SignUpForm';
|
|
6
|
+
export * from './SignInForm';
|
|
7
|
+
export { default as SignInForm } from './SignInForm';
|
|
8
8
|
export * from './UserTenantList';
|
|
9
9
|
export { default as UserTenantList } from './UserTenantList';
|
|
10
|
-
export * from './SSO';
|
|
11
|
-
export { default as SSOForm } from './SSO';
|
|
12
10
|
export { Attribute as FormAttribute, AttributeType as FormAttributeType, } from './lib/SimpleForm/types';
|
|
11
|
+
export * from 'next-auth/react';
|
|
@@ -11,6 +11,7 @@ var Box = require('@mui/joy/Box');
|
|
|
11
11
|
var Button = require('@mui/joy/Button');
|
|
12
12
|
var Stack = require('@mui/joy/Stack');
|
|
13
13
|
var Typography = require('@mui/joy/Typography');
|
|
14
|
+
var react = require('next-auth/react');
|
|
14
15
|
var Alert = require('@mui/joy/Alert');
|
|
15
16
|
var reactHookForm = require('react-hook-form');
|
|
16
17
|
var Input = require('@mui/joy/Input');
|
|
@@ -27,8 +28,6 @@ var List = require('@mui/joy/List');
|
|
|
27
28
|
var ListItem = require('@mui/joy/ListItem');
|
|
28
29
|
var xDataGrid = require('@mui/x-data-grid');
|
|
29
30
|
var Add = require('@mui/icons-material/Add');
|
|
30
|
-
var CopyAll = require('@mui/icons-material/CopyAll');
|
|
31
|
-
var CheckCircleOutlined = require('@mui/icons-material/CheckCircleOutlined');
|
|
32
31
|
|
|
33
32
|
function _interopNamespaceDefault(e) {
|
|
34
33
|
var n = Object.create(null);
|
|
@@ -63,7 +62,6 @@ function Themer({
|
|
|
63
62
|
}), children);
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
67
65
|
const queryClient = /*#__PURE__*/new reactQuery.QueryClient();
|
|
68
66
|
const defaultContext = {
|
|
69
67
|
api: /*#__PURE__*/new Browser({
|
|
@@ -101,7 +99,8 @@ const NileProvider = props => {
|
|
|
101
99
|
credentials: 'include'
|
|
102
100
|
}),
|
|
103
101
|
tenantId: String(tenantId),
|
|
104
|
-
apiUrl
|
|
102
|
+
apiUrl,
|
|
103
|
+
appUrl
|
|
105
104
|
};
|
|
106
105
|
}, [api, apiUrl, appUrl, tenantId]);
|
|
107
106
|
return /*#__PURE__*/React.createElement(QueryProvider, null, /*#__PURE__*/React.createElement(Themer, {
|
|
@@ -157,7 +156,6 @@ var SvgGoogle = function SvgGoogle(props) {
|
|
|
157
156
|
}))));
|
|
158
157
|
};
|
|
159
158
|
|
|
160
|
-
const LOGIN_PATH = 'users/oidc/google/login';
|
|
161
159
|
/**
|
|
162
160
|
* A component for a Google login button, according to their design language.
|
|
163
161
|
* This works when an identity provider is configured in the admin dashboard.
|
|
@@ -166,25 +164,18 @@ const LOGIN_PATH = 'users/oidc/google/login';
|
|
|
166
164
|
*/
|
|
167
165
|
function GoogleSSOButton(props) {
|
|
168
166
|
const {
|
|
169
|
-
|
|
167
|
+
callbackUrl
|
|
170
168
|
} = props;
|
|
171
|
-
const {
|
|
172
|
-
apiUrl
|
|
173
|
-
} = useNileConfig();
|
|
174
|
-
if (!apiUrl) {
|
|
175
|
-
// eslint-disable-next-line no-console
|
|
176
|
-
console.error('apiUrl is missing from <NileProvider />');
|
|
177
|
-
}
|
|
178
|
-
const contextHref = `${apiUrl}/${LOGIN_PATH}`;
|
|
179
|
-
const query = newTenantName ? '?newTenant=' + encodeURIComponent(newTenantName) : '';
|
|
180
|
-
const href = contextHref + query;
|
|
181
169
|
return /*#__PURE__*/React.createElement(Box, {
|
|
182
|
-
component: "a",
|
|
183
|
-
href: href,
|
|
184
170
|
display: "flex",
|
|
185
171
|
flex: 1,
|
|
186
172
|
sx: {
|
|
187
173
|
textDecoration: 'none'
|
|
174
|
+
},
|
|
175
|
+
onClick: () => {
|
|
176
|
+
react.signIn('google', {
|
|
177
|
+
callbackUrl
|
|
178
|
+
});
|
|
188
179
|
}
|
|
189
180
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
|
|
190
181
|
sx: {
|
|
@@ -323,6 +314,7 @@ function CheckGroup(props) {
|
|
|
323
314
|
exports.FormAttributeType = void 0;
|
|
324
315
|
(function (AttributeType) {
|
|
325
316
|
AttributeType["Text"] = "text";
|
|
317
|
+
AttributeType["Email"] = "email";
|
|
326
318
|
AttributeType["Password"] = "password";
|
|
327
319
|
AttributeType["Select"] = "select";
|
|
328
320
|
AttributeType["Number"] = "number";
|
|
@@ -426,7 +418,8 @@ function SimpleForm(props) {
|
|
|
426
418
|
orientation: "horizontal",
|
|
427
419
|
sx: {
|
|
428
420
|
alignItems: 'center'
|
|
429
|
-
}
|
|
421
|
+
},
|
|
422
|
+
required: attr.required
|
|
430
423
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Labler, {
|
|
431
424
|
error: error,
|
|
432
425
|
attr: attr
|
|
@@ -469,7 +462,8 @@ function SimpleForm(props) {
|
|
|
469
462
|
case exports.FormAttributeType.Select:
|
|
470
463
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
471
464
|
key: display.key,
|
|
472
|
-
id: display.id
|
|
465
|
+
id: display.id,
|
|
466
|
+
required: attr.required
|
|
473
467
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
474
468
|
error: error,
|
|
475
469
|
attr: attr
|
|
@@ -509,7 +503,8 @@ function SimpleForm(props) {
|
|
|
509
503
|
case exports.FormAttributeType.Password:
|
|
510
504
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
511
505
|
key: display.key,
|
|
512
|
-
id: display.id
|
|
506
|
+
id: display.id,
|
|
507
|
+
required: attr.required
|
|
513
508
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
514
509
|
error: error,
|
|
515
510
|
attr: attr
|
|
@@ -523,7 +518,8 @@ function SimpleForm(props) {
|
|
|
523
518
|
case exports.FormAttributeType.Number:
|
|
524
519
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
525
520
|
key: display.key,
|
|
526
|
-
id: display.id
|
|
521
|
+
id: display.id,
|
|
522
|
+
required: attr.required
|
|
527
523
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
528
524
|
error: error,
|
|
529
525
|
attr: attr
|
|
@@ -538,7 +534,8 @@ function SimpleForm(props) {
|
|
|
538
534
|
default:
|
|
539
535
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
540
536
|
key: display.key,
|
|
541
|
-
id: display.id
|
|
537
|
+
id: display.id,
|
|
538
|
+
required: attr.required
|
|
542
539
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
543
540
|
error: error,
|
|
544
541
|
attr: attr
|
|
@@ -576,24 +573,33 @@ function SignUpForm(props) {
|
|
|
576
573
|
const mutation = reactQuery.useMutation(async _data => {
|
|
577
574
|
setError(undefined);
|
|
578
575
|
const possibleData = beforeMutate && beforeMutate(_data);
|
|
579
|
-
const data =
|
|
576
|
+
const data = {
|
|
577
|
+
..._data,
|
|
578
|
+
...possibleData
|
|
579
|
+
};
|
|
580
580
|
const {
|
|
581
|
+
name,
|
|
582
|
+
givenName,
|
|
583
|
+
familyName,
|
|
584
|
+
picture,
|
|
581
585
|
email,
|
|
582
586
|
password,
|
|
583
|
-
|
|
584
|
-
newTenant,
|
|
587
|
+
newTenantName,
|
|
585
588
|
...metadata
|
|
586
589
|
} = data;
|
|
587
590
|
if (Object.keys(metadata).length > 0) {
|
|
588
591
|
// eslint-disable-next-line no-console
|
|
589
592
|
console.warn('additional metadata not supported yet.');
|
|
590
593
|
}
|
|
591
|
-
return api.
|
|
592
|
-
|
|
594
|
+
return await api.users.createUser({
|
|
595
|
+
createBasicUserRequest: {
|
|
593
596
|
email,
|
|
594
597
|
password,
|
|
595
|
-
|
|
596
|
-
|
|
598
|
+
name,
|
|
599
|
+
familyName,
|
|
600
|
+
picture,
|
|
601
|
+
givenName,
|
|
602
|
+
newTenantName
|
|
597
603
|
}
|
|
598
604
|
});
|
|
599
605
|
}, {
|
|
@@ -607,7 +613,7 @@ function SignUpForm(props) {
|
|
|
607
613
|
const mainAttributes = [{
|
|
608
614
|
name: 'email',
|
|
609
615
|
label: 'Email',
|
|
610
|
-
type: exports.FormAttributeType.
|
|
616
|
+
type: exports.FormAttributeType.Email,
|
|
611
617
|
defaultValue: '',
|
|
612
618
|
required: true
|
|
613
619
|
}, {
|
|
@@ -633,7 +639,7 @@ function SignUpForm(props) {
|
|
|
633
639
|
}));
|
|
634
640
|
}
|
|
635
641
|
|
|
636
|
-
function
|
|
642
|
+
function SignInForm(props) {
|
|
637
643
|
const [error, setError] = React.useState();
|
|
638
644
|
const {
|
|
639
645
|
attributes,
|
|
@@ -641,14 +647,11 @@ function LoginForm(props) {
|
|
|
641
647
|
onError,
|
|
642
648
|
beforeMutate
|
|
643
649
|
} = props;
|
|
644
|
-
const api = useApi();
|
|
645
650
|
const mutation = reactQuery.useMutation(async _data => {
|
|
646
651
|
setError(undefined);
|
|
647
652
|
const possibleData = beforeMutate && beforeMutate(_data);
|
|
648
653
|
const data = possibleData ?? _data;
|
|
649
|
-
|
|
650
|
-
loginRequest: data
|
|
651
|
-
});
|
|
654
|
+
react.signIn('credentials', data);
|
|
652
655
|
}, {
|
|
653
656
|
onSuccess,
|
|
654
657
|
onError
|
|
@@ -683,78 +686,7 @@ function LoginForm(props) {
|
|
|
683
686
|
}));
|
|
684
687
|
}
|
|
685
688
|
|
|
686
|
-
|
|
687
|
-
const {
|
|
688
|
-
attributes,
|
|
689
|
-
onSuccess,
|
|
690
|
-
onError,
|
|
691
|
-
beforeMutate,
|
|
692
|
-
nextButtonText = 'Next',
|
|
693
|
-
loginButtonText = 'Log in',
|
|
694
|
-
disableSSO = false
|
|
695
|
-
} = props;
|
|
696
|
-
const api = useApi();
|
|
697
|
-
const [buttonText, setButtonText] = React.useState(disableSSO ? loginButtonText : nextButtonText);
|
|
698
|
-
const mutation = reactQuery.useMutation(async _data => {
|
|
699
|
-
const possibleData = beforeMutate && beforeMutate(_data);
|
|
700
|
-
const data = possibleData ?? _data;
|
|
701
|
-
return await api.auth.login({
|
|
702
|
-
loginRequest: {
|
|
703
|
-
email: data.email,
|
|
704
|
-
password: data.password
|
|
705
|
-
},
|
|
706
|
-
sso: !disableSSO
|
|
707
|
-
});
|
|
708
|
-
}, {
|
|
709
|
-
onSuccess: (token, data) => {
|
|
710
|
-
if (token) {
|
|
711
|
-
if (token?.redirectURI) {
|
|
712
|
-
window.location.href = token.redirectURI;
|
|
713
|
-
} else if (buttonText !== loginButtonText) {
|
|
714
|
-
setButtonText(loginButtonText);
|
|
715
|
-
} else {
|
|
716
|
-
onSuccess && onSuccess(token, data);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
onError: (error, data) => {
|
|
721
|
-
// it is possible SSO failed, so only show errors on if the password is available
|
|
722
|
-
if (buttonText === loginButtonText) {
|
|
723
|
-
onError && onError(error, data);
|
|
724
|
-
} else {
|
|
725
|
-
setButtonText(loginButtonText);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
const completeAttributes = React.useMemo(() => {
|
|
730
|
-
const mainAttributes = [{
|
|
731
|
-
name: 'email',
|
|
732
|
-
label: 'Email',
|
|
733
|
-
type: exports.FormAttributeType.Text,
|
|
734
|
-
defaultValue: '',
|
|
735
|
-
required: true
|
|
736
|
-
}];
|
|
737
|
-
if (buttonText === loginButtonText) {
|
|
738
|
-
mainAttributes.push({
|
|
739
|
-
name: 'password',
|
|
740
|
-
label: 'Password',
|
|
741
|
-
type: exports.FormAttributeType.Password,
|
|
742
|
-
defaultValue: '',
|
|
743
|
-
required: true
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
if (attributes && attributes.length > 0) {
|
|
747
|
-
return mainAttributes.concat(attributes);
|
|
748
|
-
}
|
|
749
|
-
return mainAttributes;
|
|
750
|
-
}, [attributes, buttonText, loginButtonText]);
|
|
751
|
-
return /*#__PURE__*/React.createElement(SimpleForm, {
|
|
752
|
-
mutation: mutation,
|
|
753
|
-
buttonText: buttonText,
|
|
754
|
-
attributes: completeAttributes
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
|
|
689
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
758
690
|
function AddUser(props) {
|
|
759
691
|
const {
|
|
760
692
|
open,
|
|
@@ -780,7 +712,7 @@ function AddUser(props) {
|
|
|
780
712
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
781
713
|
}, [email]);
|
|
782
714
|
const mutation = reactQuery.useMutation(data => api.users.createTenantUser({
|
|
783
|
-
|
|
715
|
+
createBasicUserRequest: data,
|
|
784
716
|
tenantId: String(tenantId)
|
|
785
717
|
}), {
|
|
786
718
|
onSuccess(data) {
|
|
@@ -969,7 +901,7 @@ function UserList(props) {
|
|
|
969
901
|
buttonText = 'Add a user',
|
|
970
902
|
onUserCreateSuccess,
|
|
971
903
|
slots,
|
|
972
|
-
include = ['email', '
|
|
904
|
+
include = ['email', 'preferredName']
|
|
973
905
|
} = props;
|
|
974
906
|
const dataGridSx = {
|
|
975
907
|
width: '100%',
|
|
@@ -991,240 +923,16 @@ function UserList(props) {
|
|
|
991
923
|
}));
|
|
992
924
|
}
|
|
993
925
|
|
|
994
|
-
|
|
995
|
-
const {
|
|
996
|
-
config,
|
|
997
|
-
providerName,
|
|
998
|
-
onSuccess,
|
|
999
|
-
onError,
|
|
1000
|
-
allowEdit = true,
|
|
1001
|
-
configurationGuide
|
|
1002
|
-
} = props;
|
|
1003
|
-
const api = useApi();
|
|
1004
|
-
const [loading, setLoading] = React.useState(false);
|
|
1005
|
-
const [success, setSuccess] = React.useState(false);
|
|
1006
|
-
const [optimisticConfig, setConfig] = React.useState(config);
|
|
1007
|
-
const timer = React.useRef();
|
|
1008
|
-
const attributes = React.useMemo(() => {
|
|
1009
|
-
const attributes = [{
|
|
1010
|
-
name: 'enabled',
|
|
1011
|
-
label: 'Allow Okta logins',
|
|
1012
|
-
type: exports.FormAttributeType.Switch,
|
|
1013
|
-
defaultValue: optimisticConfig?.enabled === true,
|
|
1014
|
-
options: [{
|
|
1015
|
-
label: 'Enabled'
|
|
1016
|
-
}, {
|
|
1017
|
-
label: 'Disabled'
|
|
1018
|
-
}],
|
|
1019
|
-
disabled: !allowEdit
|
|
1020
|
-
}, {
|
|
1021
|
-
name: 'clientId',
|
|
1022
|
-
label: 'Client id',
|
|
1023
|
-
type: exports.FormAttributeType.Text,
|
|
1024
|
-
defaultValue: optimisticConfig?.clientId ?? '',
|
|
1025
|
-
required: true,
|
|
1026
|
-
disabled: !allowEdit
|
|
1027
|
-
}, {
|
|
1028
|
-
name: 'configUrl',
|
|
1029
|
-
label: 'Config url',
|
|
1030
|
-
type: exports.FormAttributeType.Text,
|
|
1031
|
-
defaultValue: optimisticConfig?.configUrl ?? '',
|
|
1032
|
-
helpText: 'The URL of the .well-known/openid-configuration for the identity provider',
|
|
1033
|
-
required: true,
|
|
1034
|
-
disabled: !allowEdit
|
|
1035
|
-
}, {
|
|
1036
|
-
name: 'emailDomains',
|
|
1037
|
-
label: 'Email domains',
|
|
1038
|
-
type: exports.FormAttributeType.Text,
|
|
1039
|
-
defaultValue: optimisticConfig?.emailDomains?.join(', ') ?? '',
|
|
1040
|
-
required: true,
|
|
1041
|
-
helpText: 'A comma seperated list of email domains (yourDomain.com) to be used',
|
|
1042
|
-
disabled: !allowEdit
|
|
1043
|
-
}];
|
|
1044
|
-
if (!optimisticConfig?.clientId) {
|
|
1045
|
-
attributes.splice(2, 0, {
|
|
1046
|
-
name: 'clientSecret',
|
|
1047
|
-
label: 'Client secret',
|
|
1048
|
-
type: exports.FormAttributeType.Password,
|
|
1049
|
-
defaultValue: '',
|
|
1050
|
-
required: true,
|
|
1051
|
-
disabled: !allowEdit
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
return attributes;
|
|
1055
|
-
}, [allowEdit, optimisticConfig?.clientId, optimisticConfig?.configUrl, optimisticConfig?.emailDomains, optimisticConfig?.enabled]);
|
|
1056
|
-
const handleTimer = () => {
|
|
1057
|
-
if (timer.current) {
|
|
1058
|
-
clearTimeout(timer.current);
|
|
1059
|
-
}
|
|
1060
|
-
timer.current = setTimeout(() => {
|
|
1061
|
-
setSuccess(false);
|
|
1062
|
-
}, 3000);
|
|
1063
|
-
};
|
|
1064
|
-
const mutation = reactQuery.useMutation(ssoRequest => {
|
|
1065
|
-
setLoading(true);
|
|
1066
|
-
const payload = {
|
|
1067
|
-
providerName: providerName.toLowerCase(),
|
|
1068
|
-
updateProviderRequest: {
|
|
1069
|
-
...ssoRequest,
|
|
1070
|
-
emailDomains: ssoRequest.emailDomains.split(',')
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
if (optimisticConfig != null) {
|
|
1074
|
-
return api.auth.updateProvider(payload);
|
|
1075
|
-
} else {
|
|
1076
|
-
return api.auth.createProvider(payload);
|
|
1077
|
-
}
|
|
1078
|
-
}, {
|
|
1079
|
-
onSuccess: (data, vars) => {
|
|
1080
|
-
setConfig(data);
|
|
1081
|
-
setSuccess(true);
|
|
1082
|
-
onSuccess && onSuccess(data, vars);
|
|
1083
|
-
},
|
|
1084
|
-
onError,
|
|
1085
|
-
onSettled: (data, error, vars) => {
|
|
1086
|
-
setLoading(false);
|
|
1087
|
-
handleTimer();
|
|
1088
|
-
if (!data) {
|
|
1089
|
-
if (!error || error?.message.includes('Unterminated string')) {
|
|
1090
|
-
// something unexpected happened on the BE, but it's non-fatal
|
|
1091
|
-
setConfig({
|
|
1092
|
-
enabled: vars.enabled,
|
|
1093
|
-
clientId: vars.clientId,
|
|
1094
|
-
configUrl: vars.configUrl,
|
|
1095
|
-
emailDomains: vars.emailDomains.split(', ')
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
setSuccess(true);
|
|
1099
|
-
onSuccess && onSuccess(data, vars);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
|
-
React.useEffect(() => {
|
|
1104
|
-
});
|
|
1105
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
1106
|
-
gap: 2,
|
|
1107
|
-
position: "relative"
|
|
1108
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1109
|
-
level: "h4"
|
|
1110
|
-
}, "Step 1"), configurationGuide, /*#__PURE__*/React.createElement(Typography, {
|
|
1111
|
-
level: "h4"
|
|
1112
|
-
}, "Step 2"), /*#__PURE__*/React.createElement(SimpleForm, {
|
|
1113
|
-
mutation: mutation,
|
|
1114
|
-
buttonText: "Update",
|
|
1115
|
-
attributes: attributes,
|
|
1116
|
-
loading: loading,
|
|
1117
|
-
successMessage: /*#__PURE__*/React.createElement(Alert, {
|
|
1118
|
-
color: "success",
|
|
1119
|
-
sx: {
|
|
1120
|
-
opacity: success ? 1 : 0,
|
|
1121
|
-
transition: 'opacity 200ms',
|
|
1122
|
-
height: '0.9rem'
|
|
1123
|
-
},
|
|
1124
|
-
startDecorator: /*#__PURE__*/React.createElement(CheckCircleOutlined, null)
|
|
1125
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1126
|
-
textAlign: "center",
|
|
1127
|
-
fontSize: "sm"
|
|
1128
|
-
}, "Provider updated"))
|
|
1129
|
-
}));
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
function ConfigGuide({
|
|
1133
|
-
callbackUrl
|
|
1134
|
-
}) {
|
|
1135
|
-
const [copied, setCopied] = React.useState(false);
|
|
1136
|
-
const timer = React.useRef();
|
|
1137
|
-
React.useEffect(() => {
|
|
1138
|
-
if (timer.current) {
|
|
1139
|
-
clearTimeout(timer.current);
|
|
1140
|
-
}
|
|
1141
|
-
timer.current = setTimeout(() => {
|
|
1142
|
-
setCopied(false);
|
|
1143
|
-
}, 3250);
|
|
1144
|
-
}, [copied]);
|
|
1145
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
1146
|
-
gap: 2
|
|
1147
|
-
}, /*#__PURE__*/React.createElement(Typography, null, "In order for Okta to redirect properly, provide the following URL as the", ' ', /*#__PURE__*/React.createElement(Box, {
|
|
1148
|
-
component: "span",
|
|
1149
|
-
sx: {
|
|
1150
|
-
fontFamily: 'monospace'
|
|
1151
|
-
}
|
|
1152
|
-
}, "Sign-in redirect URIs"), ' ', "in the admin configuration of your application."), /*#__PURE__*/React.createElement(Input, {
|
|
1153
|
-
onClick: async () => {
|
|
1154
|
-
if (callbackUrl) {
|
|
1155
|
-
await navigator.clipboard.writeText(callbackUrl);
|
|
1156
|
-
setCopied(true);
|
|
1157
|
-
}
|
|
1158
|
-
},
|
|
1159
|
-
sx: theme => ({
|
|
1160
|
-
input: {
|
|
1161
|
-
cursor: 'pointer'
|
|
1162
|
-
},
|
|
1163
|
-
span: {
|
|
1164
|
-
cursor: 'pointer'
|
|
1165
|
-
},
|
|
1166
|
-
'&:hover svg': {
|
|
1167
|
-
'--Icon-color': theme.palette.primary[500]
|
|
1168
|
-
}
|
|
1169
|
-
}),
|
|
1170
|
-
value: callbackUrl,
|
|
1171
|
-
readOnly: true,
|
|
1172
|
-
endDecorator: /*#__PURE__*/React.createElement(Tooltip, {
|
|
1173
|
-
title: "Copy Okta redirect URL"
|
|
1174
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
1175
|
-
position: "relative",
|
|
1176
|
-
width: copied ? '82px' : '24px',
|
|
1177
|
-
height: "24px"
|
|
1178
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
1179
|
-
position: "absolute",
|
|
1180
|
-
top: "0",
|
|
1181
|
-
left: "0",
|
|
1182
|
-
sx: {
|
|
1183
|
-
opacity: copied ? 0 : 1,
|
|
1184
|
-
transition: 'opacity 300ms'
|
|
1185
|
-
}
|
|
1186
|
-
}, /*#__PURE__*/React.createElement(CopyAll, null)), /*#__PURE__*/React.createElement(Box, {
|
|
1187
|
-
position: "absolute",
|
|
1188
|
-
top: "0",
|
|
1189
|
-
left: "0",
|
|
1190
|
-
sx: {
|
|
1191
|
-
opacity: !copied ? 0 : 1,
|
|
1192
|
-
transition: 'opacity 300ms'
|
|
1193
|
-
}
|
|
1194
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
1195
|
-
direction: "row",
|
|
1196
|
-
gap: 1
|
|
1197
|
-
}, /*#__PURE__*/React.createElement(CheckCircleOutlined, null), /*#__PURE__*/React.createElement(Typography, {
|
|
1198
|
-
color: "primary"
|
|
1199
|
-
}, "Copied!")))))
|
|
1200
|
-
}));
|
|
1201
|
-
}
|
|
1202
|
-
function Okta(props) {
|
|
1203
|
-
const {
|
|
1204
|
-
callbackUrl,
|
|
1205
|
-
providers,
|
|
1206
|
-
...remaining
|
|
1207
|
-
} = props;
|
|
1208
|
-
if (!providers) {
|
|
1209
|
-
return null;
|
|
1210
|
-
}
|
|
1211
|
-
const config = providers?.find(provider => provider.provider === 'okta');
|
|
1212
|
-
return /*#__PURE__*/React.createElement(BaseSSOForm, {
|
|
1213
|
-
...remaining,
|
|
1214
|
-
config: config,
|
|
1215
|
-
providerName: "Okta",
|
|
1216
|
-
configurationGuide: /*#__PURE__*/React.createElement(ConfigGuide, {
|
|
1217
|
-
callbackUrl: callbackUrl
|
|
1218
|
-
})
|
|
1219
|
-
});
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
exports.GoogleLoginButton = GoogleSSOButton;
|
|
926
|
+
exports.Google = GoogleSSOButton;
|
|
1223
927
|
exports.NileProvider = NileProvider;
|
|
1224
|
-
exports.
|
|
1225
|
-
exports.
|
|
1226
|
-
exports.SingleSignOnForm = SingleSignOnForm;
|
|
1227
|
-
exports.UserLoginForm = LoginForm;
|
|
1228
|
-
exports.UserSignupForm = SignUpForm;
|
|
928
|
+
exports.SignInForm = SignInForm;
|
|
929
|
+
exports.SignUpForm = SignUpForm;
|
|
1229
930
|
exports.UserTenantList = UserList;
|
|
931
|
+
exports.useApi = useApi;
|
|
932
|
+
Object.keys(react).forEach(function (k) {
|
|
933
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
934
|
+
enumerable: true,
|
|
935
|
+
get: function () { return react[k]; }
|
|
936
|
+
});
|
|
937
|
+
});
|
|
1230
938
|
//# sourceMappingURL=react.cjs.development.js.map
|