@nocobase/plugin-users 1.6.0-alpha.5 → 1.6.0-alpha.7

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.
@@ -0,0 +1,521 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var edit_form_schema_exports = {};
28
+ __export(edit_form_schema_exports, {
29
+ adminProfileCreateFormSchema: () => adminProfileCreateFormSchema,
30
+ adminProfileEditFormSchema: () => adminProfileEditFormSchema,
31
+ userProfileEditFormSchema: () => userProfileEditFormSchema
32
+ });
33
+ module.exports = __toCommonJS(edit_form_schema_exports);
34
+ const adminProfileCreateFormSchema = {
35
+ type: "void",
36
+ "x-uid": "nocobase-admin-profile-create-form",
37
+ properties: {
38
+ form: {
39
+ type: "void",
40
+ "x-decorator": "FormBlockProvider",
41
+ "x-decorator-props": {
42
+ collection: "users",
43
+ dataSource: "main"
44
+ },
45
+ "x-use-decorator-props": "useCreateFormBlockDecoratorProps",
46
+ properties: {
47
+ create: {
48
+ type: "void",
49
+ "x-component": "FormV2",
50
+ "x-use-component-props": "useCreateFormBlockProps",
51
+ properties: {
52
+ grid: {
53
+ type: "void",
54
+ "x-component": "Grid",
55
+ "x-initializer": "form:configureFields",
56
+ properties: {
57
+ nickname: {
58
+ type: "void",
59
+ "x-component": "Grid.Row",
60
+ properties: {
61
+ col: {
62
+ type: "void",
63
+ "x-component": "Grid.Col",
64
+ properties: {
65
+ nickname: {
66
+ type: "string",
67
+ "x-toolbar": "FormItemSchemaToolbar",
68
+ "x-settings": "fieldSettings:FormItem",
69
+ "x-component": "CollectionField",
70
+ "x-decorator": "FormItem",
71
+ "x-component-props": {},
72
+ "x-collection-field": "users.nickname"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ },
78
+ username: {
79
+ type: "void",
80
+ "x-component": "Grid.Row",
81
+ properties: {
82
+ col: {
83
+ type: "void",
84
+ "x-component": "Grid.Col",
85
+ properties: {
86
+ username: {
87
+ type: "string",
88
+ required: true,
89
+ "x-toolbar": "FormItemSchemaToolbar",
90
+ "x-settings": "fieldSettings:FormItem",
91
+ "x-component": "CollectionField",
92
+ "x-decorator": "FormItem",
93
+ "x-component-props": {},
94
+ "x-collection-field": "users.username"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ },
100
+ email: {
101
+ type: "void",
102
+ "x-component": "Grid.Row",
103
+ properties: {
104
+ col: {
105
+ type: "void",
106
+ "x-component": "Grid.Col",
107
+ properties: {
108
+ email: {
109
+ type: "string",
110
+ required: false,
111
+ "x-toolbar": "FormItemSchemaToolbar",
112
+ "x-settings": "fieldSettings:FormItem",
113
+ "x-component": "CollectionField",
114
+ "x-decorator": "FormItem",
115
+ "x-component-props": {},
116
+ "x-collection-field": "users.email"
117
+ }
118
+ }
119
+ }
120
+ }
121
+ },
122
+ phone: {
123
+ type: "void",
124
+ "x-component": "Grid.Row",
125
+ properties: {
126
+ col: {
127
+ type: "void",
128
+ "x-component": "Grid.Col",
129
+ properties: {
130
+ phone: {
131
+ type: "string",
132
+ required: false,
133
+ "x-toolbar": "FormItemSchemaToolbar",
134
+ "x-settings": "fieldSettings:FormItem",
135
+ "x-component": "CollectionField",
136
+ "x-decorator": "FormItem",
137
+ "x-component-props": {},
138
+ "x-collection-field": "users.phone"
139
+ }
140
+ }
141
+ }
142
+ }
143
+ },
144
+ password: {
145
+ type: "void",
146
+ "x-component": "Grid.Row",
147
+ properties: {
148
+ col: {
149
+ type: "void",
150
+ "x-component": "Grid.Col",
151
+ properties: {
152
+ password: {
153
+ type: "string",
154
+ required: true,
155
+ "x-toolbar": "FormItemSchemaToolbar",
156
+ "x-settings": "fieldSettings:FormItem",
157
+ "x-component": "CollectionField",
158
+ "x-decorator": "FormItem",
159
+ "x-component-props": {},
160
+ "x-collection-field": "users.password"
161
+ }
162
+ }
163
+ }
164
+ }
165
+ },
166
+ roles: {
167
+ type: "void",
168
+ "x-component": "Grid.Row",
169
+ properties: {
170
+ col: {
171
+ type: "void",
172
+ "x-component": "Grid.Col",
173
+ properties: {
174
+ roles: {
175
+ type: "string",
176
+ required: false,
177
+ "x-toolbar": "FormItemSchemaToolbar",
178
+ "x-settings": "fieldSettings:FormItem",
179
+ "x-component": "CollectionField",
180
+ "x-decorator": "FormItem",
181
+ "x-component-props": {},
182
+ "x-collection-field": "users.roles"
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+ },
190
+ footer: {
191
+ type: "void",
192
+ "x-component": "Action.Drawer.FootBar",
193
+ properties: {
194
+ cancel: {
195
+ title: '{{ t("Cancel") }}',
196
+ "x-component": "Action",
197
+ "x-use-component-props": "useCancelActionProps"
198
+ },
199
+ submit: {
200
+ title: '{{ t("Submit") }}',
201
+ "x-component": "Action",
202
+ "x-use-component-props": "useCreateActionProps",
203
+ "x-component-props": {
204
+ type: "primary",
205
+ htmlType: "submit"
206
+ }
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ };
216
+ const adminProfileEditFormSchema = {
217
+ type: "void",
218
+ "x-uid": "nocobase-admin-profile-edit-form",
219
+ properties: {
220
+ form: {
221
+ type: "void",
222
+ "x-decorator": "FormBlockProvider",
223
+ "x-decorator-props": {
224
+ collection: "users",
225
+ dataSource: "main",
226
+ action: "get"
227
+ },
228
+ "x-use-decorator-props": "useEditFormBlockDecoratorProps",
229
+ properties: {
230
+ edit: {
231
+ type: "void",
232
+ "x-component": "FormV2",
233
+ "x-use-component-props": "useEditFormBlockProps",
234
+ properties: {
235
+ grid: {
236
+ type: "void",
237
+ "x-component": "Grid",
238
+ "x-initializer": "form:configureFields",
239
+ properties: {
240
+ nickname: {
241
+ type: "void",
242
+ "x-component": "Grid.Row",
243
+ properties: {
244
+ col: {
245
+ type: "void",
246
+ "x-component": "Grid.Col",
247
+ properties: {
248
+ nickname: {
249
+ type: "string",
250
+ "x-toolbar": "FormItemSchemaToolbar",
251
+ "x-settings": "fieldSettings:FormItem",
252
+ "x-component": "CollectionField",
253
+ "x-decorator": "FormItem",
254
+ "x-component-props": {},
255
+ "x-collection-field": "users.nickname"
256
+ }
257
+ }
258
+ }
259
+ }
260
+ },
261
+ username: {
262
+ type: "void",
263
+ "x-component": "Grid.Row",
264
+ properties: {
265
+ col: {
266
+ type: "void",
267
+ "x-component": "Grid.Col",
268
+ properties: {
269
+ username: {
270
+ type: "string",
271
+ required: true,
272
+ "x-toolbar": "FormItemSchemaToolbar",
273
+ "x-settings": "fieldSettings:FormItem",
274
+ "x-component": "CollectionField",
275
+ "x-decorator": "FormItem",
276
+ "x-component-props": {},
277
+ "x-collection-field": "users.username"
278
+ }
279
+ }
280
+ }
281
+ }
282
+ },
283
+ email: {
284
+ type: "void",
285
+ "x-component": "Grid.Row",
286
+ properties: {
287
+ col: {
288
+ type: "void",
289
+ "x-component": "Grid.Col",
290
+ properties: {
291
+ email: {
292
+ type: "string",
293
+ required: false,
294
+ "x-toolbar": "FormItemSchemaToolbar",
295
+ "x-settings": "fieldSettings:FormItem",
296
+ "x-component": "CollectionField",
297
+ "x-decorator": "FormItem",
298
+ "x-component-props": {},
299
+ "x-collection-field": "users.email"
300
+ }
301
+ }
302
+ }
303
+ }
304
+ },
305
+ phone: {
306
+ type: "void",
307
+ "x-component": "Grid.Row",
308
+ properties: {
309
+ col: {
310
+ type: "void",
311
+ "x-component": "Grid.Col",
312
+ properties: {
313
+ phone: {
314
+ type: "string",
315
+ required: false,
316
+ "x-toolbar": "FormItemSchemaToolbar",
317
+ "x-settings": "fieldSettings:FormItem",
318
+ "x-component": "CollectionField",
319
+ "x-decorator": "FormItem",
320
+ "x-component-props": {},
321
+ "x-collection-field": "users.phone"
322
+ }
323
+ }
324
+ }
325
+ }
326
+ },
327
+ roles: {
328
+ type: "void",
329
+ "x-component": "Grid.Row",
330
+ properties: {
331
+ col: {
332
+ type: "void",
333
+ "x-component": "Grid.Col",
334
+ properties: {
335
+ roles: {
336
+ type: "string",
337
+ required: false,
338
+ "x-toolbar": "FormItemSchemaToolbar",
339
+ "x-settings": "fieldSettings:FormItem",
340
+ "x-component": "CollectionField",
341
+ "x-decorator": "FormItem",
342
+ "x-component-props": {},
343
+ "x-collection-field": "users.roles"
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+ },
351
+ footer: {
352
+ type: "void",
353
+ "x-component": "Action.Drawer.FootBar",
354
+ properties: {
355
+ cancel: {
356
+ title: '{{ t("Cancel") }}',
357
+ "x-component": "Action",
358
+ "x-use-component-props": "useCancelActionProps"
359
+ },
360
+ submit: {
361
+ title: '{{ t("Submit") }}',
362
+ "x-component": "Action",
363
+ "x-use-component-props": "useUpdateActionProps",
364
+ "x-component-props": {
365
+ type: "primary",
366
+ htmlType: "submit"
367
+ }
368
+ }
369
+ }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ }
375
+ }
376
+ };
377
+ const userProfileEditFormSchema = {
378
+ type: "void",
379
+ "x-uid": "nocobase-user-profile-edit-form",
380
+ properties: {
381
+ form: {
382
+ type: "void",
383
+ "x-decorator": "FormBlockProvider",
384
+ "x-decorator-props": {
385
+ collection: "users",
386
+ dataSource: "main",
387
+ action: "get"
388
+ },
389
+ "x-use-decorator-props": "useEditFormBlockDecoratorProps",
390
+ properties: {
391
+ edit: {
392
+ type: "void",
393
+ "x-component": "FormV2",
394
+ "x-use-component-props": "useEditFormBlockProps",
395
+ properties: {
396
+ grid: {
397
+ type: "void",
398
+ "x-component": "Grid",
399
+ "x-initializer": "form:configureFields",
400
+ properties: {
401
+ nickname: {
402
+ type: "void",
403
+ "x-component": "Grid.Row",
404
+ properties: {
405
+ col: {
406
+ type: "void",
407
+ "x-component": "Grid.Col",
408
+ properties: {
409
+ nickname: {
410
+ type: "string",
411
+ "x-toolbar": "FormItemSchemaToolbar",
412
+ "x-settings": "fieldSettings:FormItem",
413
+ "x-component": "CollectionField",
414
+ "x-decorator": "FormItem",
415
+ "x-component-props": {},
416
+ "x-collection-field": "users.nickname"
417
+ }
418
+ }
419
+ }
420
+ }
421
+ },
422
+ username: {
423
+ type: "void",
424
+ "x-component": "Grid.Row",
425
+ properties: {
426
+ col: {
427
+ type: "void",
428
+ "x-component": "Grid.Col",
429
+ properties: {
430
+ username: {
431
+ type: "string",
432
+ required: true,
433
+ "x-toolbar": "FormItemSchemaToolbar",
434
+ "x-settings": "fieldSettings:FormItem",
435
+ "x-component": "CollectionField",
436
+ "x-decorator": "FormItem",
437
+ "x-component-props": {},
438
+ "x-collection-field": "users.username"
439
+ }
440
+ }
441
+ }
442
+ }
443
+ },
444
+ email: {
445
+ type: "void",
446
+ "x-component": "Grid.Row",
447
+ properties: {
448
+ col: {
449
+ type: "void",
450
+ "x-component": "Grid.Col",
451
+ properties: {
452
+ email: {
453
+ type: "string",
454
+ required: false,
455
+ "x-toolbar": "FormItemSchemaToolbar",
456
+ "x-settings": "fieldSettings:FormItem",
457
+ "x-component": "CollectionField",
458
+ "x-decorator": "FormItem",
459
+ "x-component-props": {},
460
+ "x-collection-field": "users.email"
461
+ }
462
+ }
463
+ }
464
+ }
465
+ },
466
+ phone: {
467
+ type: "void",
468
+ "x-component": "Grid.Row",
469
+ properties: {
470
+ col: {
471
+ type: "void",
472
+ "x-component": "Grid.Col",
473
+ properties: {
474
+ phone: {
475
+ type: "string",
476
+ required: false,
477
+ "x-toolbar": "FormItemSchemaToolbar",
478
+ "x-settings": "fieldSettings:FormItem",
479
+ "x-component": "CollectionField",
480
+ "x-decorator": "FormItem",
481
+ "x-component-props": {},
482
+ "x-collection-field": "users.phone"
483
+ }
484
+ }
485
+ }
486
+ }
487
+ }
488
+ }
489
+ },
490
+ footer: {
491
+ type: "void",
492
+ "x-component": "Action.Drawer.FootBar",
493
+ properties: {
494
+ cancel: {
495
+ title: '{{ t("Cancel") }}',
496
+ "x-component": "Action",
497
+ "x-use-component-props": "useCancelActionProps"
498
+ },
499
+ submit: {
500
+ title: '{{ t("Submit") }}',
501
+ "x-component": "Action",
502
+ "x-use-component-props": "useUpdateProfileActionProps",
503
+ "x-component-props": {
504
+ type: "primary",
505
+ htmlType: "submit"
506
+ }
507
+ }
508
+ }
509
+ }
510
+ }
511
+ }
512
+ }
513
+ }
514
+ }
515
+ };
516
+ // Annotate the CommonJS export names for ESM import in node:
517
+ 0 && (module.exports = {
518
+ adminProfileCreateFormSchema,
519
+ adminProfileEditFormSchema,
520
+ userProfileEditFormSchema
521
+ });
@@ -6,7 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { Plugin } from '@nocobase/server';
9
+ import { InstallOptions, Plugin } from '@nocobase/server';
10
10
  export default class PluginUsersServer extends Plugin {
11
11
  beforeLoad(): Promise<void>;
12
12
  load(): Promise<void>;
@@ -16,5 +16,7 @@ export default class PluginUsersServer extends Plugin {
16
16
  rootNickname: any;
17
17
  rootUsername: any;
18
18
  };
19
- install(options: any): Promise<void>;
19
+ initUserCollection(options: InstallOptions): Promise<void>;
20
+ initProfileSchema(): Promise<void>;
21
+ install(options: InstallOptions): Promise<void>;
20
22
  }
@@ -45,6 +45,7 @@ var import_utils = require("@nocobase/utils");
45
45
  var actions = __toESM(require("./actions/users"));
46
46
  var import_UserModel = require("./models/UserModel");
47
47
  var import_user_data_sync_resource = require("./user-data-sync-resource");
48
+ var import_edit_form_schema = require("./profile/edit-form-schema");
48
49
  class PluginUsersServer extends import_server.Plugin {
49
50
  async beforeLoad() {
50
51
  this.db.registerModels({
@@ -169,7 +170,7 @@ class PluginUsersServer extends import_server.Plugin {
169
170
  }
170
171
  };
171
172
  });
172
- const loggedInActions = ["updateProfile"];
173
+ const loggedInActions = ["updateProfile", "updateLang"];
173
174
  loggedInActions.forEach((action) => this.app.acl.allow("users", action, "loggedIn"));
174
175
  this.app.acl.registerSnippet({
175
176
  name: `pm.${this.name}`,
@@ -178,16 +179,10 @@ class PluginUsersServer extends import_server.Plugin {
178
179
  const getMetaDataForUpdateProfileAction = async (ctx) => {
179
180
  return {
180
181
  request: {
181
- params: ctx.request.params,
182
- query: ctx.request.query,
183
182
  body: {
184
183
  ...ctx.request.body,
185
184
  password: "******"
186
- },
187
- path: ctx.request.path
188
- },
189
- response: {
190
- body: ctx.body
185
+ }
191
186
  }
192
187
  };
193
188
  };
@@ -220,6 +215,13 @@ class PluginUsersServer extends import_server.Plugin {
220
215
  await Promise.all(values.map((userId) => ctx.app.emitAsync("cache:del:roles", { userId })));
221
216
  }
222
217
  });
218
+ this.app.resourceManager.use(async (ctx, next) => {
219
+ const { resourceName, actionName } = ctx.action;
220
+ if (resourceName === "users" && actionName === "updateProfile") {
221
+ ctx.action.actionName = "update";
222
+ }
223
+ await next();
224
+ });
223
225
  const userDataSyncPlugin = this.app.pm.get("user-data-sync");
224
226
  if (userDataSyncPlugin && userDataSyncPlugin.enabled) {
225
227
  userDataSyncPlugin.resourceManager.registerResource(new import_user_data_sync_resource.UserDataSyncResource(this.db, this.app.logger));
@@ -249,7 +251,7 @@ class PluginUsersServer extends import_server.Plugin {
249
251
  rootUsername
250
252
  };
251
253
  }
252
- async install(options) {
254
+ async initUserCollection(options) {
253
255
  const { rootNickname, rootPassword, rootEmail, rootUsername } = this.getInstallingData(options);
254
256
  const User = this.db.getCollection("users");
255
257
  if (await User.repository.findOne({ filter: { email: rootEmail } })) {
@@ -268,4 +270,17 @@ class PluginUsersServer extends import_server.Plugin {
268
270
  await repo.db2cm("users");
269
271
  }
270
272
  }
273
+ async initProfileSchema() {
274
+ const uiSchemas = this.db.getRepository("uiSchemas");
275
+ if (!uiSchemas) {
276
+ return;
277
+ }
278
+ await uiSchemas.insert(import_edit_form_schema.adminProfileCreateFormSchema);
279
+ await uiSchemas.insert(import_edit_form_schema.adminProfileEditFormSchema);
280
+ await uiSchemas.insert(import_edit_form_schema.userProfileEditFormSchema);
281
+ }
282
+ async install(options) {
283
+ await this.initUserCollection(options);
284
+ await this.initProfileSchema();
285
+ }
271
286
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "用户",
5
5
  "description": "Provides basic user model, as well as created by and updated by fields.",
6
6
  "description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
7
- "version": "1.6.0-alpha.5",
7
+ "version": "1.6.0-alpha.7",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -19,13 +19,14 @@
19
19
  "@nocobase/database": "1.x",
20
20
  "@nocobase/plugin-acl": "1.x",
21
21
  "@nocobase/plugin-auth": "1.x",
22
+ "@nocobase/plugin-ui-schema-storage": "1.x",
22
23
  "@nocobase/plugin-user-data-sync": "1.x",
23
24
  "@nocobase/resourcer": "1.x",
24
25
  "@nocobase/server": "1.x",
25
26
  "@nocobase/test": "1.x",
26
27
  "@nocobase/utils": "1.x"
27
28
  },
28
- "gitHead": "b600efcab7fef54f1456ef079787f0ab4992e249",
29
+ "gitHead": "d9552440f5e3ce2795c9f2f23a1b04f5376a1550",
29
30
  "keywords": [
30
31
  "Users & permissions"
31
32
  ]
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_users=self.webpackChunk_nocobase_plugin_users||[]).push([["554"],{891:function(e,t,n){n.r(t),n.d(t,{UsersManagement:function(){return j}});var r=n("964"),o=n("563"),a=n("505"),u=n("772"),s=n("721"),c=n("156"),i=n.n(c),l=n("888"),f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",r="0123456789",o="!#$%^&*-_+=",a=t+n+r+o,u=new Uint32Array(e);crypto.getRandomValues(u);var s="";s+=t.charAt(u[0]%t.length),s+=n.charAt(u[1]%n.length),s+=r.charAt(u[2]%r.length),s+=o.charAt(u[3]%o.length);for(var c=4;c<e;c++){var i=u[c]%a.length;s+=a.charAt(i)}return s=s[0]+s.slice(1).split("").sort(function(){return Math.random()-.5}).join("")};function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var m=function(){var e,t,n=(0,l.B)().t,r=(0,a.useField)();var o=(e=i().useState(!1),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],u=!0,s=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);u=!0);}catch(e){s=!0,r=e}finally{try{!u&&null!=o.return&&o.return()}finally{if(s)throw r}}return a}}(e,2)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=o[0],b=o[1],v=(0,u.useActionContext)();return(0,c.useEffect)(function(){if(!v.visible)r.reset()},[r,v.visible]),i().createElement(s.Row,{gutter:10},i().createElement(s.Col,{span:18},i().createElement(u.Password,{checkStrength:!0,visibilityToggle:{visible:m,onVisibleChange:b},value:r.value,onChange:function(e){return r.setValue(e.target.value)},autoComplete:"off"})),i().createElement(s.Col,{span:4},i().createElement(s.Button,{onClick:function(){r.setValue(f()),b(!0)}},n("Random password"))))},b=n("241");function v(e,t,n,r,o,a,u){try{var s=e[a](u),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){v(a,r,o,u,s,"next",e)}function s(e){v(a,r,o,u,s,"throw",e)}u(void 0)})}}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function g(e,t){var n,r,o,a,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function w(){var e,t,n=(e=["\n .ant-tabs-nav {\n margin-bottom: 0px;\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return w=function(){return n},n}var C=function(){var e=(0,u.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},P=function(){var e=(0,u.useActionContext)().setVisible,t=s.App.useApp().message,n=(0,a.useForm)(),r=(0,u.useDataBlockResource)(),o=(0,u.useDataBlockRequestGetter)().getDataBlockRequest,c=(0,l.B)().t,i=(0,u.useCollection)();return{type:"primary",onClick:function(){return y(function(){var a,u;return g(this,function(s){switch(s.label){case 0:return[4,n.submit()];case 1:if(s.sent(),!(u=n.values)[i.filterTargetKey])return[3,3];return[4,r.update({values:u,filterByTk:u[i.filterTargetKey]})];case 2:return s.sent(),[3,5];case 3:return[4,r.create({values:u})];case 4:s.sent(),s.label=5;case 5:return[4,null===(a=o())||void 0===a?void 0:a.runAsync()];case 6:return s.sent(),t.success(c("Saved successfully")),e(!1),[2]}})})()}}},S=function(){var e=(0,u.useCollectionRecordData)();return{form:(0,c.useMemo)(function(){return(0,o.createForm)({initialValues:e})},[e])}},O=function(){var e=(0,l.B)().t,t=(0,u.useSchemaComponentContext)();return i().createElement(u.SchemaComponentContext.Provider,{value:d(h({},t),{designable:!1})},i().createElement(u.SchemaComponent,{schema:b.SN,scope:{t:e,useCancelActionProps:C,useSubmitActionProps:P,useEditFormProps:S},components:{PasswordField:m}}))},A=(0,c.createContext)({}),k=function(e){var t=(0,u.useRequest)({url:"systemSettings:get/1"});return i().createElement(A.Provider,{value:t},e.children)},E=function(){var e=(0,l.B)().t,t=(0,u.useSchemaComponentContext)(),n=(0,a.useForm)();return i().createElement(u.SchemaComponentContext.Provider,{value:d(h({},t),{designable:!1})},i().createElement(u.SchemaComponent,{schema:b.eF,scope:{t:e,useFormBlockProps:function(){var e,t=(0,c.useContext)(A),r=(null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.data)||{},o=r.enableChangePassword,a=r.enableEditProfile;return(0,c.useEffect)(function(){null==n||n.setValues({enableChangePassword:!1!==o,enableEditProfile:!1!==a})},[t]),{form:n}},useSubmitActionProps:function(){var t=(0,u.useAPIClient)(),n=(0,a.useForm)();return{type:"primary",onClick:function(){return y(function(){var r;return g(this,function(o){switch(o.label){case 0:return[4,n.submit()];case 1:return o.sent(),r=n.values,[4,t.request({url:"systemSettings:update/1",data:r,method:"POST"})];case 2:return o.sent(),s.message.success(e("Saved successfully")),window.location.reload(),[2]}})})()}}}},components:{UsersSettingsProvider:k}}))},j=function(){var e=(0,l.B)().t;return i().createElement(s.Tabs,{defaultActiveKey:"usersManager",type:"card",className:(0,r.css)(w()),items:[{label:e("Users manager"),key:"usersManager",children:i().createElement(O,null)},{label:e("Settings"),key:"usersSettings",children:i().createElement(E,null)}]})}}}]);