@abpjs/tenant-management 1.0.0 → 1.1.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__/tenant-management-state.service.test.d.ts +1 -0
- package/dist/hooks/useTenantManagement.d.ts +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +92 -0
- package/dist/index.mjs +90 -0
- package/dist/models/index.d.ts +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/tenant-management-state.service.d.ts +61 -0
- package/package.json +6 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,11 @@ export interface TenantManagementResult {
|
|
|
12
12
|
* @since 1.0.0
|
|
13
13
|
*/
|
|
14
14
|
export type SortOrder = 'asc' | 'desc' | '';
|
|
15
|
+
/**
|
|
16
|
+
* Modal content type for tenant management
|
|
17
|
+
* @since 1.1.0
|
|
18
|
+
*/
|
|
19
|
+
export type ModalContentType = 'saveConnStr' | 'saveTenant';
|
|
15
20
|
/**
|
|
16
21
|
* Return type for useTenantManagement hook
|
|
17
22
|
*/
|
|
@@ -34,6 +39,8 @@ export interface UseTenantManagementReturn {
|
|
|
34
39
|
sortKey: string;
|
|
35
40
|
/** Current sort order @since 1.0.0 */
|
|
36
41
|
sortOrder: SortOrder;
|
|
42
|
+
/** Whether the save button should be disabled @since 1.1.0 */
|
|
43
|
+
isDisabledSaveButton: boolean;
|
|
37
44
|
/** Fetch all tenants (with optional params) */
|
|
38
45
|
fetchTenants: (params?: ABP.PageQueryParams) => Promise<TenantManagementResult>;
|
|
39
46
|
/** Fetch a tenant by ID */
|
|
@@ -60,6 +67,8 @@ export interface UseTenantManagementReturn {
|
|
|
60
67
|
setSortKey: (key: string) => void;
|
|
61
68
|
/** Set sort order @since 1.0.0 */
|
|
62
69
|
setSortOrder: (order: SortOrder) => void;
|
|
70
|
+
/** Handle shared database checkbox change @since 1.1.0 */
|
|
71
|
+
onSharedDatabaseChange: (value: boolean) => void;
|
|
63
72
|
/** Reset all state */
|
|
64
73
|
reset: () => void;
|
|
65
74
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -25,6 +25,8 @@ __export(index_exports, {
|
|
|
25
25
|
TENANT_MANAGEMENT_ROUTE_PATHS: () => TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
26
26
|
TenantManagementModal: () => TenantManagementModal,
|
|
27
27
|
TenantManagementService: () => TenantManagementService,
|
|
28
|
+
TenantManagementStateService: () => TenantManagementStateService,
|
|
29
|
+
getTenantManagementStateService: () => getTenantManagementStateService,
|
|
28
30
|
useTenantManagement: () => useTenantManagement
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -130,6 +132,83 @@ var TenantManagementService = class {
|
|
|
130
132
|
}
|
|
131
133
|
};
|
|
132
134
|
|
|
135
|
+
// src/services/tenant-management-state.service.ts
|
|
136
|
+
var TenantManagementStateService = class {
|
|
137
|
+
constructor() {
|
|
138
|
+
this._tenants = [];
|
|
139
|
+
this._totalCount = 0;
|
|
140
|
+
this._subscribers = /* @__PURE__ */ new Set();
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get all tenants
|
|
144
|
+
* Equivalent to Angular's TenantManagementState selector
|
|
145
|
+
*/
|
|
146
|
+
get() {
|
|
147
|
+
return [...this._tenants];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the total count of tenants
|
|
151
|
+
* @since 1.1.0
|
|
152
|
+
*/
|
|
153
|
+
getTenantsTotalCount() {
|
|
154
|
+
return this._totalCount;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Set tenants data (called internally by the hook)
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
setTenants(tenants) {
|
|
161
|
+
this._tenants = [...tenants];
|
|
162
|
+
this.notifySubscribers();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Set total count (called internally by the hook)
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
setTotalCount(count) {
|
|
169
|
+
this._totalCount = count;
|
|
170
|
+
this.notifySubscribers();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Update state from a response
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
updateFromResponse(response) {
|
|
177
|
+
this._tenants = [...response.items];
|
|
178
|
+
this._totalCount = response.totalCount;
|
|
179
|
+
this.notifySubscribers();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Reset the state to initial values
|
|
183
|
+
*/
|
|
184
|
+
reset() {
|
|
185
|
+
this._tenants = [];
|
|
186
|
+
this._totalCount = 0;
|
|
187
|
+
this.notifySubscribers();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Subscribe to state changes
|
|
191
|
+
* @param callback Function to call when state changes
|
|
192
|
+
* @returns Unsubscribe function
|
|
193
|
+
*/
|
|
194
|
+
subscribe(callback) {
|
|
195
|
+
this._subscribers.add(callback);
|
|
196
|
+
return () => {
|
|
197
|
+
this._subscribers.delete(callback);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
notifySubscribers() {
|
|
201
|
+
this._subscribers.forEach((callback) => callback());
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var _stateInstance = null;
|
|
205
|
+
function getTenantManagementStateService() {
|
|
206
|
+
if (!_stateInstance) {
|
|
207
|
+
_stateInstance = new TenantManagementStateService();
|
|
208
|
+
}
|
|
209
|
+
return _stateInstance;
|
|
210
|
+
}
|
|
211
|
+
|
|
133
212
|
// src/hooks/useTenantManagement.ts
|
|
134
213
|
var import_react = require("react");
|
|
135
214
|
var import_core = require("@abpjs/core");
|
|
@@ -293,6 +372,15 @@ function useTenantManagement() {
|
|
|
293
372
|
},
|
|
294
373
|
[service]
|
|
295
374
|
);
|
|
375
|
+
const onSharedDatabaseChange = (0, import_react.useCallback)((value) => {
|
|
376
|
+
setUseSharedDatabase(value);
|
|
377
|
+
if (value) {
|
|
378
|
+
setDefaultConnectionString("");
|
|
379
|
+
}
|
|
380
|
+
}, []);
|
|
381
|
+
const isDisabledSaveButton = (0, import_react.useMemo)(() => {
|
|
382
|
+
return !useSharedDatabase && !defaultConnectionString.trim();
|
|
383
|
+
}, [useSharedDatabase, defaultConnectionString]);
|
|
296
384
|
const reset = (0, import_react.useCallback)(() => {
|
|
297
385
|
setTenants([]);
|
|
298
386
|
setTotalCount(0);
|
|
@@ -312,6 +400,7 @@ function useTenantManagement() {
|
|
|
312
400
|
useSharedDatabase,
|
|
313
401
|
sortKey,
|
|
314
402
|
sortOrder,
|
|
403
|
+
isDisabledSaveButton,
|
|
315
404
|
fetchTenants,
|
|
316
405
|
fetchTenantById,
|
|
317
406
|
createTenant,
|
|
@@ -325,6 +414,7 @@ function useTenantManagement() {
|
|
|
325
414
|
setDefaultConnectionString,
|
|
326
415
|
setSortKey,
|
|
327
416
|
setSortOrder,
|
|
417
|
+
onSharedDatabaseChange,
|
|
328
418
|
reset
|
|
329
419
|
};
|
|
330
420
|
}
|
|
@@ -616,5 +706,7 @@ function TenantManagementModal({
|
|
|
616
706
|
TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
617
707
|
TenantManagementModal,
|
|
618
708
|
TenantManagementService,
|
|
709
|
+
TenantManagementStateService,
|
|
710
|
+
getTenantManagementStateService,
|
|
619
711
|
useTenantManagement
|
|
620
712
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -99,6 +99,83 @@ var TenantManagementService = class {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
// src/services/tenant-management-state.service.ts
|
|
103
|
+
var TenantManagementStateService = class {
|
|
104
|
+
constructor() {
|
|
105
|
+
this._tenants = [];
|
|
106
|
+
this._totalCount = 0;
|
|
107
|
+
this._subscribers = /* @__PURE__ */ new Set();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get all tenants
|
|
111
|
+
* Equivalent to Angular's TenantManagementState selector
|
|
112
|
+
*/
|
|
113
|
+
get() {
|
|
114
|
+
return [...this._tenants];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get the total count of tenants
|
|
118
|
+
* @since 1.1.0
|
|
119
|
+
*/
|
|
120
|
+
getTenantsTotalCount() {
|
|
121
|
+
return this._totalCount;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Set tenants data (called internally by the hook)
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
setTenants(tenants) {
|
|
128
|
+
this._tenants = [...tenants];
|
|
129
|
+
this.notifySubscribers();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Set total count (called internally by the hook)
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
setTotalCount(count) {
|
|
136
|
+
this._totalCount = count;
|
|
137
|
+
this.notifySubscribers();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Update state from a response
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
updateFromResponse(response) {
|
|
144
|
+
this._tenants = [...response.items];
|
|
145
|
+
this._totalCount = response.totalCount;
|
|
146
|
+
this.notifySubscribers();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Reset the state to initial values
|
|
150
|
+
*/
|
|
151
|
+
reset() {
|
|
152
|
+
this._tenants = [];
|
|
153
|
+
this._totalCount = 0;
|
|
154
|
+
this.notifySubscribers();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Subscribe to state changes
|
|
158
|
+
* @param callback Function to call when state changes
|
|
159
|
+
* @returns Unsubscribe function
|
|
160
|
+
*/
|
|
161
|
+
subscribe(callback) {
|
|
162
|
+
this._subscribers.add(callback);
|
|
163
|
+
return () => {
|
|
164
|
+
this._subscribers.delete(callback);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
notifySubscribers() {
|
|
168
|
+
this._subscribers.forEach((callback) => callback());
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var _stateInstance = null;
|
|
172
|
+
function getTenantManagementStateService() {
|
|
173
|
+
if (!_stateInstance) {
|
|
174
|
+
_stateInstance = new TenantManagementStateService();
|
|
175
|
+
}
|
|
176
|
+
return _stateInstance;
|
|
177
|
+
}
|
|
178
|
+
|
|
102
179
|
// src/hooks/useTenantManagement.ts
|
|
103
180
|
import { useState, useCallback, useMemo } from "react";
|
|
104
181
|
import { useRestService } from "@abpjs/core";
|
|
@@ -262,6 +339,15 @@ function useTenantManagement() {
|
|
|
262
339
|
},
|
|
263
340
|
[service]
|
|
264
341
|
);
|
|
342
|
+
const onSharedDatabaseChange = useCallback((value) => {
|
|
343
|
+
setUseSharedDatabase(value);
|
|
344
|
+
if (value) {
|
|
345
|
+
setDefaultConnectionString("");
|
|
346
|
+
}
|
|
347
|
+
}, []);
|
|
348
|
+
const isDisabledSaveButton = useMemo(() => {
|
|
349
|
+
return !useSharedDatabase && !defaultConnectionString.trim();
|
|
350
|
+
}, [useSharedDatabase, defaultConnectionString]);
|
|
265
351
|
const reset = useCallback(() => {
|
|
266
352
|
setTenants([]);
|
|
267
353
|
setTotalCount(0);
|
|
@@ -281,6 +367,7 @@ function useTenantManagement() {
|
|
|
281
367
|
useSharedDatabase,
|
|
282
368
|
sortKey,
|
|
283
369
|
sortOrder,
|
|
370
|
+
isDisabledSaveButton,
|
|
284
371
|
fetchTenants,
|
|
285
372
|
fetchTenantById,
|
|
286
373
|
createTenant,
|
|
@@ -294,6 +381,7 @@ function useTenantManagement() {
|
|
|
294
381
|
setDefaultConnectionString,
|
|
295
382
|
setSortKey,
|
|
296
383
|
setSortOrder,
|
|
384
|
+
onSharedDatabaseChange,
|
|
297
385
|
reset
|
|
298
386
|
};
|
|
299
387
|
}
|
|
@@ -590,5 +678,7 @@ export {
|
|
|
590
678
|
TENANT_MANAGEMENT_ROUTE_PATHS,
|
|
591
679
|
TenantManagementModal,
|
|
592
680
|
TenantManagementService,
|
|
681
|
+
TenantManagementStateService,
|
|
682
|
+
getTenantManagementStateService,
|
|
593
683
|
useTenantManagement
|
|
594
684
|
};
|
package/dist/models/index.d.ts
CHANGED
package/dist/services/index.d.ts
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant Management State Service
|
|
3
|
+
* Translated from @abp/ng.tenant-management v1.1.0
|
|
4
|
+
*
|
|
5
|
+
* This service provides state management for tenant management,
|
|
6
|
+
* equivalent to the Angular NGXS TenantManagementState selectors.
|
|
7
|
+
*/
|
|
8
|
+
import type { ABP } from '@abpjs/core';
|
|
9
|
+
import type { TenantManagement } from '../models';
|
|
10
|
+
/**
|
|
11
|
+
* State service for managing tenant management state.
|
|
12
|
+
* Provides methods equivalent to Angular's NGXS state selectors.
|
|
13
|
+
*
|
|
14
|
+
* @since 1.1.0
|
|
15
|
+
*/
|
|
16
|
+
export declare class TenantManagementStateService {
|
|
17
|
+
private _tenants;
|
|
18
|
+
private _totalCount;
|
|
19
|
+
private _subscribers;
|
|
20
|
+
/**
|
|
21
|
+
* Get all tenants
|
|
22
|
+
* Equivalent to Angular's TenantManagementState selector
|
|
23
|
+
*/
|
|
24
|
+
get(): ABP.BasicItem[];
|
|
25
|
+
/**
|
|
26
|
+
* Get the total count of tenants
|
|
27
|
+
* @since 1.1.0
|
|
28
|
+
*/
|
|
29
|
+
getTenantsTotalCount(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Set tenants data (called internally by the hook)
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
setTenants(tenants: ABP.BasicItem[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Set total count (called internally by the hook)
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
setTotalCount(count: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Update state from a response
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
updateFromResponse(response: TenantManagement.Response): void;
|
|
45
|
+
/**
|
|
46
|
+
* Reset the state to initial values
|
|
47
|
+
*/
|
|
48
|
+
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Subscribe to state changes
|
|
51
|
+
* @param callback Function to call when state changes
|
|
52
|
+
* @returns Unsubscribe function
|
|
53
|
+
*/
|
|
54
|
+
subscribe(callback: () => void): () => void;
|
|
55
|
+
private notifySubscribers;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the singleton instance of TenantManagementStateService
|
|
59
|
+
* @since 1.1.0
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTenantManagementStateService(): TenantManagementStateService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/tenant-management",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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": "1.1.0",
|
|
27
|
+
"@abpjs/theme-shared": "1.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@abp/ng.tenant-management": "1.
|
|
30
|
+
"@abp/ng.tenant-management": "1.1.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",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "https://github.com/abpjs/abp-react"
|
|
51
|
+
"url": "https://github.com/abpjs/abp-react",
|
|
52
|
+
"directory": "packages/tenant-management"
|
|
52
53
|
},
|
|
53
54
|
"homepage": "https://docs.abpjs.io/docs/packages/tenant-management/overview",
|
|
54
55
|
"bugs": {
|