@abpjs/tenant-management 2.2.0 → 2.7.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/__tests__/enums/components.test.d.ts +1 -0
- package/dist/__tests__/enums/index.test.d.ts +1 -0
- package/dist/__tests__/enums/route-names.test.d.ts +1 -0
- package/dist/__tests__/index.test.d.ts +1 -0
- package/dist/components/TenantManagementModal/TenantManagementModal.d.ts +3 -0
- package/dist/enums/components.d.ts +16 -0
- package/dist/enums/index.d.ts +6 -0
- package/dist/enums/route-names.d.ts +23 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +171 -18
- package/dist/index.mjs +169 -18
- package/dist/models/index.d.ts +12 -2
- package/dist/services/tenant-management.service.d.ts +6 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -62,4 +62,7 @@ export interface TenantManagementModalProps {
|
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
64
|
export declare function TenantManagementModal({ visible, onVisibleChange, tenantId, initialView, onSave, onVisibleFeaturesChange, }: TenantManagementModalProps): React.ReactElement;
|
|
65
|
+
export declare namespace TenantManagementModal {
|
|
66
|
+
var componentKey: "TenantManagement.TenantsComponent";
|
|
67
|
+
}
|
|
65
68
|
export default TenantManagementModal;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component keys for the Tenant Management module.
|
|
3
|
+
* These keys are used for component replacement/customization.
|
|
4
|
+
* @since 2.7.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const eTenantManagementComponents: {
|
|
7
|
+
/**
|
|
8
|
+
* Key for the Tenants component.
|
|
9
|
+
* Use this to replace the default TenantsComponent with a custom implementation.
|
|
10
|
+
*/
|
|
11
|
+
readonly Tenants: "TenantManagement.TenantsComponent";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Type for tenant management component key values
|
|
15
|
+
*/
|
|
16
|
+
export type TenantManagementComponentKey = (typeof eTenantManagementComponents)[keyof typeof eTenantManagementComponents];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route name keys for the Tenant Management module.
|
|
3
|
+
* These keys are used for route localization and identification.
|
|
4
|
+
* @since 2.7.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const eTenantManagementRouteNames: {
|
|
7
|
+
/**
|
|
8
|
+
* Administration menu route name key.
|
|
9
|
+
*/
|
|
10
|
+
readonly Administration: "AbpUiNavigation::Menu:Administration";
|
|
11
|
+
/**
|
|
12
|
+
* Tenant Management menu route name key.
|
|
13
|
+
*/
|
|
14
|
+
readonly TenantManagement: "AbpTenantManagement::Menu:TenantManagement";
|
|
15
|
+
/**
|
|
16
|
+
* Tenants route name key.
|
|
17
|
+
*/
|
|
18
|
+
readonly Tenants: "AbpTenantManagement::Tenants";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Type for tenant management route name key values
|
|
22
|
+
*/
|
|
23
|
+
export type TenantManagementRouteNameKey = (typeof eTenantManagementRouteNames)[keyof typeof eTenantManagementRouteNames];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @abpjs/tenant-management
|
|
3
3
|
* ABP Framework Tenant Management module for React
|
|
4
|
-
* Translated from @abp/ng.tenant-management v2.
|
|
4
|
+
* Translated from @abp/ng.tenant-management v2.7.0
|
|
5
|
+
*
|
|
6
|
+
* Changes in v2.7.0:
|
|
7
|
+
* - Added eTenantManagementComponents enum for component replacement keys
|
|
8
|
+
* - Added eTenantManagementRouteNames enum for route name keys
|
|
9
|
+
* - Added componentKey static property to TenantManagementModal
|
|
10
|
+
*
|
|
11
|
+
* Changes in v2.4.0:
|
|
12
|
+
* - Added apiName property to TenantManagementService (defaults to 'default')
|
|
13
|
+
* - Added adminEmailAddress and adminPassword fields to AddRequest interface
|
|
14
|
+
* - UpdateRequest no longer extends AddRequest (now only has id and name)
|
|
5
15
|
*
|
|
6
16
|
* Changes in v2.2.0:
|
|
7
17
|
* - Added openFeaturesModal(providerKey: string) to useTenantManagement hook
|
|
@@ -26,6 +36,7 @@
|
|
|
26
36
|
* - Updated onSearch signature: (value: any) -> (value: string)
|
|
27
37
|
* - Updated onPageChange signature: (data: any) -> (page: number)
|
|
28
38
|
*/
|
|
39
|
+
export * from './enums';
|
|
29
40
|
export * from './models';
|
|
30
41
|
export * from './services';
|
|
31
42
|
export * from './hooks';
|
package/dist/index.js
CHANGED
|
@@ -25,14 +25,46 @@ __export(index_exports, {
|
|
|
25
25
|
TenantManagementModal: () => TenantManagementModal,
|
|
26
26
|
TenantManagementService: () => TenantManagementService,
|
|
27
27
|
TenantManagementStateService: () => TenantManagementStateService,
|
|
28
|
+
eTenantManagementComponents: () => eTenantManagementComponents,
|
|
29
|
+
eTenantManagementRouteNames: () => eTenantManagementRouteNames,
|
|
28
30
|
getTenantManagementStateService: () => getTenantManagementStateService,
|
|
29
31
|
useTenantManagement: () => useTenantManagement
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(index_exports);
|
|
32
34
|
|
|
35
|
+
// src/enums/components.ts
|
|
36
|
+
var eTenantManagementComponents = {
|
|
37
|
+
/**
|
|
38
|
+
* Key for the Tenants component.
|
|
39
|
+
* Use this to replace the default TenantsComponent with a custom implementation.
|
|
40
|
+
*/
|
|
41
|
+
Tenants: "TenantManagement.TenantsComponent"
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/enums/route-names.ts
|
|
45
|
+
var eTenantManagementRouteNames = {
|
|
46
|
+
/**
|
|
47
|
+
* Administration menu route name key.
|
|
48
|
+
*/
|
|
49
|
+
Administration: "AbpUiNavigation::Menu:Administration",
|
|
50
|
+
/**
|
|
51
|
+
* Tenant Management menu route name key.
|
|
52
|
+
*/
|
|
53
|
+
TenantManagement: "AbpTenantManagement::Menu:TenantManagement",
|
|
54
|
+
/**
|
|
55
|
+
* Tenants route name key.
|
|
56
|
+
*/
|
|
57
|
+
Tenants: "AbpTenantManagement::Tenants"
|
|
58
|
+
};
|
|
59
|
+
|
|
33
60
|
// src/services/tenant-management.service.ts
|
|
34
61
|
var TenantManagementService = class {
|
|
35
62
|
constructor(rest) {
|
|
63
|
+
/**
|
|
64
|
+
* The API name used for REST requests.
|
|
65
|
+
* @since 2.4.0
|
|
66
|
+
*/
|
|
67
|
+
this.apiName = "default";
|
|
36
68
|
this.rest = rest;
|
|
37
69
|
}
|
|
38
70
|
/**
|
|
@@ -575,6 +607,10 @@ function TenantManagementModal({
|
|
|
575
607
|
const [currentView, setCurrentView] = (0, import_react2.useState)(initialView);
|
|
576
608
|
const [tenantName, setTenantName] = (0, import_react2.useState)("");
|
|
577
609
|
const [tenantNameError, setTenantNameError] = (0, import_react2.useState)(null);
|
|
610
|
+
const [adminEmail, setAdminEmail] = (0, import_react2.useState)("");
|
|
611
|
+
const [adminEmailError, setAdminEmailError] = (0, import_react2.useState)(null);
|
|
612
|
+
const [adminPassword, setAdminPassword] = (0, import_react2.useState)("");
|
|
613
|
+
const [adminPasswordError, setAdminPasswordError] = (0, import_react2.useState)(null);
|
|
578
614
|
const [localConnectionString, setLocalConnectionString] = (0, import_react2.useState)("");
|
|
579
615
|
const [localUseSharedDatabase, setLocalUseSharedDatabase] = (0, import_react2.useState)(true);
|
|
580
616
|
const isEditing = !!tenantId;
|
|
@@ -598,6 +634,10 @@ function TenantManagementModal({
|
|
|
598
634
|
reset();
|
|
599
635
|
setTenantName("");
|
|
600
636
|
setTenantNameError(null);
|
|
637
|
+
setAdminEmail("");
|
|
638
|
+
setAdminEmailError(null);
|
|
639
|
+
setAdminPassword("");
|
|
640
|
+
setAdminPasswordError(null);
|
|
601
641
|
setLocalConnectionString("");
|
|
602
642
|
setLocalUseSharedDatabase(true);
|
|
603
643
|
}
|
|
@@ -628,6 +668,39 @@ function TenantManagementModal({
|
|
|
628
668
|
},
|
|
629
669
|
[t]
|
|
630
670
|
);
|
|
671
|
+
const validateAdminEmail = (0, import_react2.useCallback)(
|
|
672
|
+
(email) => {
|
|
673
|
+
if (!email || email.trim().length === 0) {
|
|
674
|
+
setAdminEmailError(t("AbpValidation::ThisFieldIsRequired"));
|
|
675
|
+
return false;
|
|
676
|
+
}
|
|
677
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
678
|
+
if (!emailRegex.test(email)) {
|
|
679
|
+
setAdminEmailError(t("AbpValidation::ThisFieldIsNotAValidEmailAddress"));
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
setAdminEmailError(null);
|
|
683
|
+
return true;
|
|
684
|
+
},
|
|
685
|
+
[t]
|
|
686
|
+
);
|
|
687
|
+
const validateAdminPassword = (0, import_react2.useCallback)(
|
|
688
|
+
(password) => {
|
|
689
|
+
if (!password || password.length === 0) {
|
|
690
|
+
setAdminPasswordError(t("AbpValidation::ThisFieldIsRequired"));
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
if (password.length < 6) {
|
|
694
|
+
setAdminPasswordError(
|
|
695
|
+
t("AbpValidation::ThisFieldMustBeAStringWithAMinimumLengthOf{0}", "6")
|
|
696
|
+
);
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
setAdminPasswordError(null);
|
|
700
|
+
return true;
|
|
701
|
+
},
|
|
702
|
+
[t]
|
|
703
|
+
);
|
|
631
704
|
const handleTenantSubmit = (0, import_react2.useCallback)(async () => {
|
|
632
705
|
if (!validateTenantName(tenantName)) {
|
|
633
706
|
return;
|
|
@@ -636,7 +709,16 @@ function TenantManagementModal({
|
|
|
636
709
|
if (isEditing && tenantId) {
|
|
637
710
|
result = await updateTenant({ id: tenantId, name: tenantName.trim() });
|
|
638
711
|
} else {
|
|
639
|
-
|
|
712
|
+
const emailValid = validateAdminEmail(adminEmail);
|
|
713
|
+
const passwordValid = validateAdminPassword(adminPassword);
|
|
714
|
+
if (!emailValid || !passwordValid) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
result = await createTenant({
|
|
718
|
+
name: tenantName.trim(),
|
|
719
|
+
adminEmailAddress: adminEmail.trim(),
|
|
720
|
+
adminPassword
|
|
721
|
+
});
|
|
640
722
|
}
|
|
641
723
|
if (result.success) {
|
|
642
724
|
onSave?.();
|
|
@@ -644,9 +726,13 @@ function TenantManagementModal({
|
|
|
644
726
|
}
|
|
645
727
|
}, [
|
|
646
728
|
tenantName,
|
|
729
|
+
adminEmail,
|
|
730
|
+
adminPassword,
|
|
647
731
|
isEditing,
|
|
648
732
|
tenantId,
|
|
649
733
|
validateTenantName,
|
|
734
|
+
validateAdminEmail,
|
|
735
|
+
validateAdminPassword,
|
|
650
736
|
createTenant,
|
|
651
737
|
updateTenant,
|
|
652
738
|
onSave,
|
|
@@ -686,6 +772,26 @@ function TenantManagementModal({
|
|
|
686
772
|
},
|
|
687
773
|
[tenantNameError, validateTenantName]
|
|
688
774
|
);
|
|
775
|
+
const handleAdminEmailChange = (0, import_react2.useCallback)(
|
|
776
|
+
(e) => {
|
|
777
|
+
const value = e.target.value;
|
|
778
|
+
setAdminEmail(value);
|
|
779
|
+
if (adminEmailError) {
|
|
780
|
+
validateAdminEmail(value);
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
[adminEmailError, validateAdminEmail]
|
|
784
|
+
);
|
|
785
|
+
const handleAdminPasswordChange = (0, import_react2.useCallback)(
|
|
786
|
+
(e) => {
|
|
787
|
+
const value = e.target.value;
|
|
788
|
+
setAdminPassword(value);
|
|
789
|
+
if (adminPasswordError) {
|
|
790
|
+
validateAdminPassword(value);
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
[adminPasswordError, validateAdminPassword]
|
|
794
|
+
);
|
|
689
795
|
const handleUseSharedDatabaseChange = (0, import_react2.useCallback)(() => {
|
|
690
796
|
setLocalUseSharedDatabase((prev) => {
|
|
691
797
|
const newValue = !prev;
|
|
@@ -698,26 +804,70 @@ function TenantManagementModal({
|
|
|
698
804
|
const handleConnectionStringChange = (0, import_react2.useCallback)((e) => {
|
|
699
805
|
setLocalConnectionString(e.target.value);
|
|
700
806
|
}, []);
|
|
701
|
-
const renderTenantForm = () => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
807
|
+
const renderTenantForm = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react3.VStack, { gap: 4, align: "stretch", children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
809
|
+
import_theme_shared.FormField,
|
|
810
|
+
{
|
|
811
|
+
label: t("AbpTenantManagement::TenantName"),
|
|
812
|
+
htmlFor: "tenant-name",
|
|
813
|
+
invalid: !!tenantNameError,
|
|
814
|
+
errorText: tenantNameError || void 0,
|
|
815
|
+
required: true,
|
|
816
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
817
|
+
import_react3.Input,
|
|
818
|
+
{
|
|
819
|
+
id: "tenant-name",
|
|
820
|
+
value: tenantName,
|
|
821
|
+
onChange: handleTenantNameChange,
|
|
822
|
+
placeholder: t("AbpTenantManagement::TenantName"),
|
|
823
|
+
maxLength: 256
|
|
824
|
+
}
|
|
825
|
+
)
|
|
826
|
+
}
|
|
827
|
+
),
|
|
828
|
+
!isEditing && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
830
|
+
import_theme_shared.FormField,
|
|
831
|
+
{
|
|
832
|
+
label: t("AbpTenantManagement::DisplayName:AdminEmailAddress"),
|
|
833
|
+
htmlFor: "admin-email",
|
|
834
|
+
invalid: !!adminEmailError,
|
|
835
|
+
errorText: adminEmailError || void 0,
|
|
836
|
+
required: true,
|
|
837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
838
|
+
import_react3.Input,
|
|
839
|
+
{
|
|
840
|
+
id: "admin-email",
|
|
841
|
+
type: "email",
|
|
842
|
+
value: adminEmail,
|
|
843
|
+
onChange: handleAdminEmailChange,
|
|
844
|
+
placeholder: t("AbpTenantManagement::DisplayName:AdminEmailAddress")
|
|
845
|
+
}
|
|
846
|
+
)
|
|
847
|
+
}
|
|
848
|
+
),
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
850
|
+
import_theme_shared.FormField,
|
|
711
851
|
{
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
852
|
+
label: t("AbpTenantManagement::DisplayName:AdminPassword"),
|
|
853
|
+
htmlFor: "admin-password",
|
|
854
|
+
invalid: !!adminPasswordError,
|
|
855
|
+
errorText: adminPasswordError || void 0,
|
|
856
|
+
required: true,
|
|
857
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
858
|
+
import_react3.Input,
|
|
859
|
+
{
|
|
860
|
+
id: "admin-password",
|
|
861
|
+
type: "password",
|
|
862
|
+
value: adminPassword,
|
|
863
|
+
onChange: handleAdminPasswordChange,
|
|
864
|
+
placeholder: t("AbpTenantManagement::DisplayName:AdminPassword")
|
|
865
|
+
}
|
|
866
|
+
)
|
|
717
867
|
}
|
|
718
868
|
)
|
|
719
|
-
}
|
|
720
|
-
|
|
869
|
+
] })
|
|
870
|
+
] });
|
|
721
871
|
const renderConnectionStringForm = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react3.VStack, { gap: 4, align: "stretch", children: [
|
|
722
872
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
723
873
|
import_theme_shared.Checkbox,
|
|
@@ -775,6 +925,7 @@ function TenantManagementModal({
|
|
|
775
925
|
}
|
|
776
926
|
);
|
|
777
927
|
}
|
|
928
|
+
TenantManagementModal.componentKey = eTenantManagementComponents.Tenants;
|
|
778
929
|
// Annotate the CommonJS export names for ESM import in node:
|
|
779
930
|
0 && (module.exports = {
|
|
780
931
|
TENANT_MANAGEMENT_POLICIES,
|
|
@@ -782,6 +933,8 @@ function TenantManagementModal({
|
|
|
782
933
|
TenantManagementModal,
|
|
783
934
|
TenantManagementService,
|
|
784
935
|
TenantManagementStateService,
|
|
936
|
+
eTenantManagementComponents,
|
|
937
|
+
eTenantManagementRouteNames,
|
|
785
938
|
getTenantManagementStateService,
|
|
786
939
|
useTenantManagement
|
|
787
940
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
+
// src/enums/components.ts
|
|
2
|
+
var eTenantManagementComponents = {
|
|
3
|
+
/**
|
|
4
|
+
* Key for the Tenants component.
|
|
5
|
+
* Use this to replace the default TenantsComponent with a custom implementation.
|
|
6
|
+
*/
|
|
7
|
+
Tenants: "TenantManagement.TenantsComponent"
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/enums/route-names.ts
|
|
11
|
+
var eTenantManagementRouteNames = {
|
|
12
|
+
/**
|
|
13
|
+
* Administration menu route name key.
|
|
14
|
+
*/
|
|
15
|
+
Administration: "AbpUiNavigation::Menu:Administration",
|
|
16
|
+
/**
|
|
17
|
+
* Tenant Management menu route name key.
|
|
18
|
+
*/
|
|
19
|
+
TenantManagement: "AbpTenantManagement::Menu:TenantManagement",
|
|
20
|
+
/**
|
|
21
|
+
* Tenants route name key.
|
|
22
|
+
*/
|
|
23
|
+
Tenants: "AbpTenantManagement::Tenants"
|
|
24
|
+
};
|
|
25
|
+
|
|
1
26
|
// src/services/tenant-management.service.ts
|
|
2
27
|
var TenantManagementService = class {
|
|
3
28
|
constructor(rest) {
|
|
29
|
+
/**
|
|
30
|
+
* The API name used for REST requests.
|
|
31
|
+
* @since 2.4.0
|
|
32
|
+
*/
|
|
33
|
+
this.apiName = "default";
|
|
4
34
|
this.rest = rest;
|
|
5
35
|
}
|
|
6
36
|
/**
|
|
@@ -549,6 +579,10 @@ function TenantManagementModal({
|
|
|
549
579
|
const [currentView, setCurrentView] = useState2(initialView);
|
|
550
580
|
const [tenantName, setTenantName] = useState2("");
|
|
551
581
|
const [tenantNameError, setTenantNameError] = useState2(null);
|
|
582
|
+
const [adminEmail, setAdminEmail] = useState2("");
|
|
583
|
+
const [adminEmailError, setAdminEmailError] = useState2(null);
|
|
584
|
+
const [adminPassword, setAdminPassword] = useState2("");
|
|
585
|
+
const [adminPasswordError, setAdminPasswordError] = useState2(null);
|
|
552
586
|
const [localConnectionString, setLocalConnectionString] = useState2("");
|
|
553
587
|
const [localUseSharedDatabase, setLocalUseSharedDatabase] = useState2(true);
|
|
554
588
|
const isEditing = !!tenantId;
|
|
@@ -572,6 +606,10 @@ function TenantManagementModal({
|
|
|
572
606
|
reset();
|
|
573
607
|
setTenantName("");
|
|
574
608
|
setTenantNameError(null);
|
|
609
|
+
setAdminEmail("");
|
|
610
|
+
setAdminEmailError(null);
|
|
611
|
+
setAdminPassword("");
|
|
612
|
+
setAdminPasswordError(null);
|
|
575
613
|
setLocalConnectionString("");
|
|
576
614
|
setLocalUseSharedDatabase(true);
|
|
577
615
|
}
|
|
@@ -602,6 +640,39 @@ function TenantManagementModal({
|
|
|
602
640
|
},
|
|
603
641
|
[t]
|
|
604
642
|
);
|
|
643
|
+
const validateAdminEmail = useCallback2(
|
|
644
|
+
(email) => {
|
|
645
|
+
if (!email || email.trim().length === 0) {
|
|
646
|
+
setAdminEmailError(t("AbpValidation::ThisFieldIsRequired"));
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
650
|
+
if (!emailRegex.test(email)) {
|
|
651
|
+
setAdminEmailError(t("AbpValidation::ThisFieldIsNotAValidEmailAddress"));
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
setAdminEmailError(null);
|
|
655
|
+
return true;
|
|
656
|
+
},
|
|
657
|
+
[t]
|
|
658
|
+
);
|
|
659
|
+
const validateAdminPassword = useCallback2(
|
|
660
|
+
(password) => {
|
|
661
|
+
if (!password || password.length === 0) {
|
|
662
|
+
setAdminPasswordError(t("AbpValidation::ThisFieldIsRequired"));
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
if (password.length < 6) {
|
|
666
|
+
setAdminPasswordError(
|
|
667
|
+
t("AbpValidation::ThisFieldMustBeAStringWithAMinimumLengthOf{0}", "6")
|
|
668
|
+
);
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
setAdminPasswordError(null);
|
|
672
|
+
return true;
|
|
673
|
+
},
|
|
674
|
+
[t]
|
|
675
|
+
);
|
|
605
676
|
const handleTenantSubmit = useCallback2(async () => {
|
|
606
677
|
if (!validateTenantName(tenantName)) {
|
|
607
678
|
return;
|
|
@@ -610,7 +681,16 @@ function TenantManagementModal({
|
|
|
610
681
|
if (isEditing && tenantId) {
|
|
611
682
|
result = await updateTenant({ id: tenantId, name: tenantName.trim() });
|
|
612
683
|
} else {
|
|
613
|
-
|
|
684
|
+
const emailValid = validateAdminEmail(adminEmail);
|
|
685
|
+
const passwordValid = validateAdminPassword(adminPassword);
|
|
686
|
+
if (!emailValid || !passwordValid) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
result = await createTenant({
|
|
690
|
+
name: tenantName.trim(),
|
|
691
|
+
adminEmailAddress: adminEmail.trim(),
|
|
692
|
+
adminPassword
|
|
693
|
+
});
|
|
614
694
|
}
|
|
615
695
|
if (result.success) {
|
|
616
696
|
onSave?.();
|
|
@@ -618,9 +698,13 @@ function TenantManagementModal({
|
|
|
618
698
|
}
|
|
619
699
|
}, [
|
|
620
700
|
tenantName,
|
|
701
|
+
adminEmail,
|
|
702
|
+
adminPassword,
|
|
621
703
|
isEditing,
|
|
622
704
|
tenantId,
|
|
623
705
|
validateTenantName,
|
|
706
|
+
validateAdminEmail,
|
|
707
|
+
validateAdminPassword,
|
|
624
708
|
createTenant,
|
|
625
709
|
updateTenant,
|
|
626
710
|
onSave,
|
|
@@ -660,6 +744,26 @@ function TenantManagementModal({
|
|
|
660
744
|
},
|
|
661
745
|
[tenantNameError, validateTenantName]
|
|
662
746
|
);
|
|
747
|
+
const handleAdminEmailChange = useCallback2(
|
|
748
|
+
(e) => {
|
|
749
|
+
const value = e.target.value;
|
|
750
|
+
setAdminEmail(value);
|
|
751
|
+
if (adminEmailError) {
|
|
752
|
+
validateAdminEmail(value);
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
[adminEmailError, validateAdminEmail]
|
|
756
|
+
);
|
|
757
|
+
const handleAdminPasswordChange = useCallback2(
|
|
758
|
+
(e) => {
|
|
759
|
+
const value = e.target.value;
|
|
760
|
+
setAdminPassword(value);
|
|
761
|
+
if (adminPasswordError) {
|
|
762
|
+
validateAdminPassword(value);
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
[adminPasswordError, validateAdminPassword]
|
|
766
|
+
);
|
|
663
767
|
const handleUseSharedDatabaseChange = useCallback2(() => {
|
|
664
768
|
setLocalUseSharedDatabase((prev) => {
|
|
665
769
|
const newValue = !prev;
|
|
@@ -672,26 +776,70 @@ function TenantManagementModal({
|
|
|
672
776
|
const handleConnectionStringChange = useCallback2((e) => {
|
|
673
777
|
setLocalConnectionString(e.target.value);
|
|
674
778
|
}, []);
|
|
675
|
-
const renderTenantForm = () => /* @__PURE__ */
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
779
|
+
const renderTenantForm = () => /* @__PURE__ */ jsxs(VStack, { gap: 4, align: "stretch", children: [
|
|
780
|
+
/* @__PURE__ */ jsx(
|
|
781
|
+
FormField,
|
|
782
|
+
{
|
|
783
|
+
label: t("AbpTenantManagement::TenantName"),
|
|
784
|
+
htmlFor: "tenant-name",
|
|
785
|
+
invalid: !!tenantNameError,
|
|
786
|
+
errorText: tenantNameError || void 0,
|
|
787
|
+
required: true,
|
|
788
|
+
children: /* @__PURE__ */ jsx(
|
|
789
|
+
Input,
|
|
790
|
+
{
|
|
791
|
+
id: "tenant-name",
|
|
792
|
+
value: tenantName,
|
|
793
|
+
onChange: handleTenantNameChange,
|
|
794
|
+
placeholder: t("AbpTenantManagement::TenantName"),
|
|
795
|
+
maxLength: 256
|
|
796
|
+
}
|
|
797
|
+
)
|
|
798
|
+
}
|
|
799
|
+
),
|
|
800
|
+
!isEditing && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
801
|
+
/* @__PURE__ */ jsx(
|
|
802
|
+
FormField,
|
|
803
|
+
{
|
|
804
|
+
label: t("AbpTenantManagement::DisplayName:AdminEmailAddress"),
|
|
805
|
+
htmlFor: "admin-email",
|
|
806
|
+
invalid: !!adminEmailError,
|
|
807
|
+
errorText: adminEmailError || void 0,
|
|
808
|
+
required: true,
|
|
809
|
+
children: /* @__PURE__ */ jsx(
|
|
810
|
+
Input,
|
|
811
|
+
{
|
|
812
|
+
id: "admin-email",
|
|
813
|
+
type: "email",
|
|
814
|
+
value: adminEmail,
|
|
815
|
+
onChange: handleAdminEmailChange,
|
|
816
|
+
placeholder: t("AbpTenantManagement::DisplayName:AdminEmailAddress")
|
|
817
|
+
}
|
|
818
|
+
)
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
/* @__PURE__ */ jsx(
|
|
822
|
+
FormField,
|
|
685
823
|
{
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
824
|
+
label: t("AbpTenantManagement::DisplayName:AdminPassword"),
|
|
825
|
+
htmlFor: "admin-password",
|
|
826
|
+
invalid: !!adminPasswordError,
|
|
827
|
+
errorText: adminPasswordError || void 0,
|
|
828
|
+
required: true,
|
|
829
|
+
children: /* @__PURE__ */ jsx(
|
|
830
|
+
Input,
|
|
831
|
+
{
|
|
832
|
+
id: "admin-password",
|
|
833
|
+
type: "password",
|
|
834
|
+
value: adminPassword,
|
|
835
|
+
onChange: handleAdminPasswordChange,
|
|
836
|
+
placeholder: t("AbpTenantManagement::DisplayName:AdminPassword")
|
|
837
|
+
}
|
|
838
|
+
)
|
|
691
839
|
}
|
|
692
840
|
)
|
|
693
|
-
}
|
|
694
|
-
|
|
841
|
+
] })
|
|
842
|
+
] });
|
|
695
843
|
const renderConnectionStringForm = () => /* @__PURE__ */ jsxs(VStack, { gap: 4, align: "stretch", children: [
|
|
696
844
|
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
697
845
|
Checkbox,
|
|
@@ -749,12 +897,15 @@ function TenantManagementModal({
|
|
|
749
897
|
}
|
|
750
898
|
);
|
|
751
899
|
}
|
|
900
|
+
TenantManagementModal.componentKey = eTenantManagementComponents.Tenants;
|
|
752
901
|
export {
|
|
753
902
|
TENANT_MANAGEMENT_POLICIES,
|
|
754
903
|
TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
755
904
|
TenantManagementModal,
|
|
756
905
|
TenantManagementService,
|
|
757
906
|
TenantManagementStateService,
|
|
907
|
+
eTenantManagementComponents,
|
|
908
|
+
eTenantManagementRouteNames,
|
|
758
909
|
getTenantManagementStateService,
|
|
759
910
|
useTenantManagement
|
|
760
911
|
};
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tenant Management module type definitions
|
|
3
|
-
* Translated from @abp/ng.tenant-management v2.
|
|
3
|
+
* Translated from @abp/ng.tenant-management v2.4.0
|
|
4
4
|
*/
|
|
5
5
|
import type { ABP } from '@abpjs/core';
|
|
6
6
|
/**
|
|
@@ -27,15 +27,25 @@ export declare namespace TenantManagement {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Request payload for creating a new tenant
|
|
30
|
+
* @since 2.4.0 Added adminEmailAddress and adminPassword fields
|
|
30
31
|
*/
|
|
31
32
|
interface AddRequest {
|
|
33
|
+
/** Admin email address for the new tenant */
|
|
34
|
+
adminEmailAddress: string;
|
|
35
|
+
/** Admin password for the new tenant */
|
|
36
|
+
adminPassword: string;
|
|
37
|
+
/** Tenant name */
|
|
32
38
|
name: string;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Request payload for updating an existing tenant
|
|
42
|
+
* @since 2.4.0 No longer extends AddRequest (only id and name needed for update)
|
|
36
43
|
*/
|
|
37
|
-
interface UpdateRequest
|
|
44
|
+
interface UpdateRequest {
|
|
45
|
+
/** Tenant ID */
|
|
38
46
|
id: string;
|
|
47
|
+
/** Tenant name */
|
|
48
|
+
name: string;
|
|
39
49
|
}
|
|
40
50
|
/**
|
|
41
51
|
* Request payload for updating tenant's default connection string
|
|
@@ -2,10 +2,15 @@ import { RestService, ABP } from '@abpjs/core';
|
|
|
2
2
|
import { TenantManagement } from '../models';
|
|
3
3
|
/**
|
|
4
4
|
* Service for tenant management API calls
|
|
5
|
-
* Translated from @abp/ng.tenant-management
|
|
5
|
+
* Translated from @abp/ng.tenant-management v2.4.0
|
|
6
6
|
*/
|
|
7
7
|
export declare class TenantManagementService {
|
|
8
8
|
private rest;
|
|
9
|
+
/**
|
|
10
|
+
* The API name used for REST requests.
|
|
11
|
+
* @since 2.4.0
|
|
12
|
+
*/
|
|
13
|
+
apiName: string;
|
|
9
14
|
constructor(rest: RestService);
|
|
10
15
|
/**
|
|
11
16
|
* Get all tenants (paginated)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/tenant-management",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "ABP Framework tenant-management components for React - translated from @abp/ng.tenant-management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@chakra-ui/react": "^3.2.0",
|
|
25
25
|
"@emotion/react": "^11.11.0",
|
|
26
|
-
"@abpjs/
|
|
27
|
-
"@abpjs/
|
|
26
|
+
"@abpjs/core": "2.7.0",
|
|
27
|
+
"@abpjs/theme-shared": "2.7.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abp/ng.tenant-management": "2.
|
|
30
|
+
"@abp/ng.tenant-management": "2.7.0",
|
|
31
31
|
"@testing-library/jest-dom": "^6.4.0",
|
|
32
32
|
"@testing-library/react": "^14.2.0",
|
|
33
33
|
"@types/react": "^18.2.0",
|