@nocobase/plugin-users 1.4.21 → 1.4.23

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.
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("@formily/core"),require("@emotion/css"),require("@formily/shared"),require("react-i18next"),require("@nocobase/plugin-acl/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/utils/client","react/jsx-runtime","react","antd","@formily/react","@formily/core","@emotion/css","@formily/shared","react-i18next","@nocobase/plugin-acl/client"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-users"]={},r["@nocobase/client"],r["@nocobase/utils"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r["@formily/core"],r["@emotion/css"],r["@formily/shared"],r["react-i18next"],r["@nocobase/plugin-acl"]))})(this,function(r,e,p,a,u,x,C,A,y,b,D,h){"use strict";var W=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var k=(r,e,p)=>e in r?W(r,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):r[e]=p,g=(r,e)=>{for(var p in e||(e={}))Z.call(e,p)&&k(r,p,e[p]);if(T)for(var p of T(e))ee.call(e,p)&&k(r,p,e[p]);return r},w=(r,e)=>X(r,Y(e));var v=(r,e,p)=>new Promise((a,u)=>{var x=y=>{try{A(p.next(y))}catch(b){u(b)}},C=y=>{try{A(p.throw(y))}catch(b){u(b)}},A=y=>y.done?a(y.value):Promise.resolve(y.value).then(x,C);A((p=p.apply(r,e)).next())});const P={name:"users",fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0},interface:"id"},{interface:"input",type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"username",unique:!0,uiSchema:{type:"string",title:'{{t("Username")}}',"x-component":"Input","x-validator":{username:!0},required:!0}},{interface:"email",type:"string",name:"email",unique:!0,uiSchema:{type:"string",title:'{{t("Email")}}',"x-component":"Input","x-validator":"email",required:!0}},{interface:"phone",type:"string",name:"phone",unique:!0,uiSchema:{type:"string",title:'{{t("Phone")}}',"x-component":"Input",required:!0}},{interface:"password",type:"password",name:"password",hidden:!0,uiSchema:{type:"string",title:'{{t("Password")}}',"x-component":"Password"}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",foreignKey:"userId",otherKey:"roleName",onDelete:"CASCADE",sourceKey:"id",targetKey:"name",through:"rolesUsers",uiSchema:{type:"array",title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}}]},I={type:"object",properties:{block1:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{dataSource:"main",rowKey:"id",collection:"users",action:"list",params:{pageSize:20}},"x-use-decorator-props":"useTableBlockDecoratorProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"},"x-use-component-props":"useBulkDestroyActionProps"},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add user")}}',properties:{nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-decorator":"FormItem",required:!1},password:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},roles:{"x-component":"CollectionField","x-collection-field":"users.roles","x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},"x-use-component-props":"useTableBlockProps",properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"CollectionField","x-component-props":{mode:"Tag",enableLink:!1,ellipsis:!0},"x-read-pretty":!0,"x-collection-field":"users.roles"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column","x-decorator":"TableV2.Column.ActionBar",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit profile")}}',"x-decorator":"ACLActionProvider","x-acl-action":"users:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",title:'{{t("Edit profile")}}',properties:{nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-decorator":"FormItem",required:!1},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"users.roles"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}},changePassword:{type:"void",title:'{{t("Change password")}}',"x-decorator":"ACLActionProvider","x-acl-action":"users:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",title:'{{t("Change password")}}',properties:{password:{"x-component":"CollectionField","x-component-props":{component:"PasswordField"},"x-decorator":"FormItem",required:!0},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"users:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-use-component-props":"useDestroyActionProps"}}}}}}}}}}},U={type:"object","x-decorator":"UsersSettingsProvider",properties:{usersSettings:{type:"void","x-component":"CardItem","x-decorator":"UsersSettingsProvider",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{enableEditProfile:{type:"string","x-component":"Checkbox","x-decorator":"FormItem",default:!0,"x-content":'{{t("Allow edit profile")}}'},enableChangePassword:{type:"string","x-component":"Checkbox","x-decorator":"FormItem",default:!0,"x-content":'{{t("Allow change password")}}'}}},footer:{type:"void","x-component":"div","x-component-props":{style:{float:"right"}},properties:{submit:{title:"Submit","x-component":"Action","x-use-component-props":"useSubmitActionProps"}}}}}}},q=()=>({type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[b.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},actions:{type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-component-props":{icon:"MinusOutlined",confirm:{title:"{{t('Remove')}}",content:"{{t('Are you sure you want to remove these users?')}}"},style:{marginRight:8},useAction:"{{ useBulkRemoveUsers }}"}},create:{type:"void",title:'{{t("Add users")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add users")}}',properties:{resource:{type:"void","x-decorator":"FormItem","x-component":"RoleUsersProvider",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox",onChange:"{{ handleSelectRoleUsers }}"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useAddRoleUsers }}"}}}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void",title:'{{t("Username")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void",title:'{{t("Nickname")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{remove:{type:"void",title:'{{ t("Remove") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Remove user')}}",content:"{{t('Are you sure you want to remove it?')}}"},useAction:"{{ useRemoveUser }}"}}}}}}}}}});function f(){return D.useTranslation(["users","client"],{nsMode:"fallback"})}const V=(t=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",s="0123456789",l="!#$%^&*-_+=",m=o+n+s+l,c=new Uint32Array(t);crypto.getRandomValues(c);let d="";d+=o.charAt(c[0]%o.length),d+=n.charAt(c[1]%n.length),d+=s.charAt(c[2]%s.length),d+=l.charAt(c[3]%l.length);for(let i=4;i<t;i++){const F=c[i]%m.length;d+=m.charAt(F)}return d=d[0]+d.slice(1).split("").sort(()=>Math.random()-.5).join(""),d},M=()=>{const{t}=f(),o=C.useField(),[n,s]=u.useState(!1),l=e.useActionContext();return u.useEffect(()=>{l.visible||o.reset()},[o,l.visible]),a.jsxs(x.Row,{gutter:10,children:[a.jsx(x.Col,{span:18,children:a.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:n,onVisibleChange:s},value:o.value,onChange:m=>o.setValue(m.target.value),autoComplete:"off"})}),a.jsx(x.Col,{span:4,children:a.jsx(x.Button,{onClick:()=>{o.setValue(V()),s(!0)},children:t("Random password")})})]})},R=()=>{const{setVisible:t}=e.useActionContext(),o=C.useForm();return{type:"default",onClick(){t(!1),o.reset()}}},B=()=>{const{setVisible:t}=e.useActionContext(),{message:o}=x.App.useApp(),n=C.useForm(),s=e.useDataBlockResource(),{refresh:l}=e.useDataBlockRequest(),{t:m}=f(),c=e.useCollection();return{type:"primary",onClick(){return v(this,null,function*(){yield n.submit();const i=n.values;i[c.filterTargetKey]?yield s.update({values:i,filterByTk:i[c.filterTargetKey]}):yield s.create({values:i}),l(),o.success(m("Saved successfully")),t(!1),n.reset()})}}},E=()=>{const t=e.useCollectionRecordData();return{form:u.useMemo(()=>A.createForm({initialValues:t}),[t])}},K=()=>{const{t}=f(),o=e.useSchemaComponentContext();return a.jsx(e.SchemaComponentContext.Provider,{value:w(g({},o),{designable:!1}),children:a.jsx(e.SchemaComponent,{schema:I,scope:{t,useCancelActionProps:R,useSubmitActionProps:B,useEditFormProps:E},components:{PasswordField:M}})})},S=u.createContext({}),O=t=>{const o=e.useRequest({url:"systemSettings:get/1"});return a.jsx(S.Provider,{value:o,children:t.children})},j=()=>{const{t}=f(),o=e.useSchemaComponentContext(),n=C.useForm(),s=()=>{var i;const m=u.useContext(S),{enableChangePassword:c,enableEditProfile:d}=((i=m==null?void 0:m.data)==null?void 0:i.data)||{};return u.useEffect(()=>{n==null||n.setValues({enableChangePassword:c!==!1,enableEditProfile:d!==!1})},[m]),{form:n}},l=()=>{const m=e.useAPIClient(),c=C.useForm();return{type:"primary",onClick(){return v(this,null,function*(){yield c.submit();const i=c.values;yield m.request({url:"systemSettings:update/1",data:i,method:"POST"}),x.message.success(t("Saved successfully")),window.location.reload()})}}};return a.jsx(e.SchemaComponentContext.Provider,{value:w(g({},o),{designable:!1}),children:a.jsx(e.SchemaComponent,{schema:U,scope:{t,useFormBlockProps:s,useSubmitActionProps:l},components:{UsersSettingsProvider:O}})})},N=()=>{const{t}=f();return a.jsx(x.Tabs,{defaultActiveKey:"usersManager",type:"card",className:y.css`
10
+ (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("@formily/core"),require("@emotion/css"),require("@formily/shared"),require("react-i18next"),require("@nocobase/plugin-acl/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/utils/client","react/jsx-runtime","react","antd","@formily/react","@formily/core","@emotion/css","@formily/shared","react-i18next","@nocobase/plugin-acl/client"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-users"]={},r["@nocobase/client"],r["@nocobase/utils"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r["@formily/core"],r["@emotion/css"],r["@formily/shared"],r["react-i18next"],r["@nocobase/plugin-acl"]))})(this,function(r,e,p,a,u,x,C,A,y,b,D,h){"use strict";var W=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var k=(r,e,p)=>e in r?W(r,e,{enumerable:!0,configurable:!0,writable:!0,value:p}):r[e]=p,g=(r,e)=>{for(var p in e||(e={}))Z.call(e,p)&&k(r,p,e[p]);if(T)for(var p of T(e))ee.call(e,p)&&k(r,p,e[p]);return r},w=(r,e)=>X(r,Y(e));var v=(r,e,p)=>new Promise((a,u)=>{var x=y=>{try{A(p.next(y))}catch(b){u(b)}},C=y=>{try{A(p.throw(y))}catch(b){u(b)}},A=y=>y.done?a(y.value):Promise.resolve(y.value).then(x,C);A((p=p.apply(r,e)).next())});const P={name:"users",fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,uiSchema:{type:"number",title:'{{t("ID")}}',"x-component":"InputNumber","x-read-pretty":!0},interface:"id"},{interface:"input",type:"string",name:"nickname",uiSchema:{type:"string",title:'{{t("Nickname")}}',"x-component":"Input"}},{interface:"input",type:"string",name:"username",unique:!0,uiSchema:{type:"string",title:'{{t("Username")}}',"x-component":"Input","x-validator":{username:!0},required:!0}},{interface:"email",type:"string",name:"email",unique:!0,uiSchema:{type:"string",title:'{{t("Email")}}',"x-component":"Input","x-validator":"email",required:!0}},{interface:"phone",type:"string",name:"phone",unique:!0,uiSchema:{type:"string",title:'{{t("Phone")}}',"x-component":"Input",required:!0}},{interface:"password",type:"password",name:"password",hidden:!0,uiSchema:{type:"string",title:'{{t("Password")}}',"x-component":"Password"}},{interface:"m2m",type:"belongsToMany",name:"roles",target:"roles",foreignKey:"userId",otherKey:"roleName",onDelete:"CASCADE",sourceKey:"id",targetKey:"name",through:"rolesUsers",uiSchema:{type:"array",title:'{{t("Roles")}}',"x-component":"AssociationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"name"}}}}]},I={type:"object",properties:{block1:{type:"void","x-component":"CardItem","x-component-props":{heightMode:"fullHeight"},"x-decorator":"TableBlockProvider","x-decorator-props":{dataSource:"main",rowKey:"id",collection:"users",action:"list",params:{pageSize:20}},"x-use-decorator-props":"useTableBlockDecoratorProps",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--nb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"},"x-use-component-props":"useBulkDestroyActionProps"},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add user")}}',properties:{nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-decorator":"FormItem",required:!1},password:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{autoComplete:"new-password"},required:!0},roles:{"x-component":"CollectionField","x-collection-field":"users.roles","x-decorator":"FormItem"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},"x-use-component-props":"useTableBlockProps",properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"CollectionField","x-component-props":{mode:"Tag",enableLink:!1,ellipsis:!0},"x-read-pretty":!0,"x-collection-field":"users.roles"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column","x-decorator":"TableV2.Column.ActionBar",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit profile")}}',"x-decorator":"ACLActionProvider","x-acl-action":"users:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",title:'{{t("Edit profile")}}',properties:{nickname:{"x-component":"CollectionField","x-decorator":"FormItem"},username:{"x-component":"CollectionField","x-decorator":"FormItem"},email:{title:'{{t("Email")}}',"x-component":"Input","x-validator":"email","x-decorator":"FormItem",required:!1},phone:{title:'{{t("Phone")}}',"x-component":"Input","x-decorator":"FormItem",required:!1},roles:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"users.roles"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}},changePassword:{type:"void",title:'{{t("Change password")}}',"x-decorator":"ACLActionProvider","x-acl-action":"users:update","x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",title:'{{t("Change password")}}',properties:{password:{"x-component":"CollectionField","x-component-props":{component:"PasswordField"},"x-decorator":"FormItem",required:!0},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-acl-action":"users:destroy","x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-use-component-props":"useDestroyActionProps"}}}}}}}}}}},U={type:"object","x-decorator":"UsersSettingsProvider",properties:{usersSettings:{type:"void","x-component":"CardItem","x-decorator":"UsersSettingsProvider",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{enableEditProfile:{type:"string","x-component":"Checkbox","x-decorator":"FormItem",default:!0,"x-content":'{{t("Allow edit profile")}}'},enableChangePassword:{type:"string","x-component":"Checkbox","x-decorator":"FormItem",default:!0,"x-content":'{{t("Allow change password")}}'}}},footer:{type:"void","x-component":"div","x-component-props":{style:{float:"right"}},properties:{submit:{title:"Submit","x-component":"Action","x-use-component-props":"useSubmitActionProps"}}}}}}},q=()=>({type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[b.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},actions:{type:"void","x-component":"Space",properties:{remove:{type:"void",title:'{{t("Remove")}}',"x-component":"Action","x-component-props":{icon:"MinusOutlined",confirm:{title:"{{t('Remove')}}",content:"{{t('Are you sure you want to remove these users?')}}"},style:{marginRight:8},useAction:"{{ useBulkRemoveUsers }}"}},create:{type:"void",title:'{{t("Add users")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2",title:'{{t("Add users")}}',properties:{resource:{type:"void","x-decorator":"FormItem","x-component":"RoleUsersProvider",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{username:{$includes:""}},{nickname:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox",onChange:"{{ handleSelectRoleUsers }}"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},phone:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{phone:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},email:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}}}}}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useAddRoleUsers }}"}}}}}}}}}}}},table:{type:"void","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{username:{type:"void",title:'{{t("Username")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},nickname:{type:"void",title:'{{t("Nickname")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{remove:{type:"void",title:'{{ t("Remove") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Remove user')}}",content:"{{t('Are you sure you want to remove it?')}}"},useAction:"{{ useRemoveUser }}"}}}}}}}}}});function f(){return D.useTranslation(["users","client"],{nsMode:"fallback"})}const V=(t=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",s="0123456789",l="!#$%^&*-_+=",m=o+n+s+l,c=new Uint32Array(t);crypto.getRandomValues(c);let d="";d+=o.charAt(c[0]%o.length),d+=n.charAt(c[1]%n.length),d+=s.charAt(c[2]%s.length),d+=l.charAt(c[3]%l.length);for(let i=4;i<t;i++){const F=c[i]%m.length;d+=m.charAt(F)}return d=d[0]+d.slice(1).split("").sort(()=>Math.random()-.5).join(""),d},M=()=>{const{t}=f(),o=C.useField(),[n,s]=u.useState(!1),l=e.useActionContext();return u.useEffect(()=>{l.visible||o.reset()},[o,l.visible]),a.jsxs(x.Row,{gutter:10,children:[a.jsx(x.Col,{span:18,children:a.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:n,onVisibleChange:s},value:o.value,onChange:m=>o.setValue(m.target.value),autoComplete:"new-password"})}),a.jsx(x.Col,{span:4,children:a.jsx(x.Button,{onClick:()=>{o.setValue(V()),s(!0)},children:t("Random password")})})]})},R=()=>{const{setVisible:t}=e.useActionContext(),o=C.useForm();return{type:"default",onClick(){t(!1),o.reset()}}},B=()=>{const{setVisible:t}=e.useActionContext(),{message:o}=x.App.useApp(),n=C.useForm(),s=e.useDataBlockResource(),{refresh:l}=e.useDataBlockRequest(),{t:m}=f(),c=e.useCollection();return{type:"primary",onClick(){return v(this,null,function*(){yield n.submit();const i=n.values;i[c.filterTargetKey]?yield s.update({values:i,filterByTk:i[c.filterTargetKey]}):yield s.create({values:i}),l(),o.success(m("Saved successfully")),t(!1),n.reset()})}}},E=()=>{const t=e.useCollectionRecordData();return{form:u.useMemo(()=>A.createForm({initialValues:t}),[t])}},K=()=>{const{t}=f(),o=e.useSchemaComponentContext();return a.jsx(e.SchemaComponentContext.Provider,{value:w(g({},o),{designable:!1}),children:a.jsx(e.SchemaComponent,{schema:I,scope:{t,useCancelActionProps:R,useSubmitActionProps:B,useEditFormProps:E},components:{PasswordField:M}})})},S=u.createContext({}),O=t=>{const o=e.useRequest({url:"systemSettings:get/1"});return a.jsx(S.Provider,{value:o,children:t.children})},j=()=>{const{t}=f(),o=e.useSchemaComponentContext(),n=C.useForm(),s=()=>{var i;const m=u.useContext(S),{enableChangePassword:c,enableEditProfile:d}=((i=m==null?void 0:m.data)==null?void 0:i.data)||{};return u.useEffect(()=>{n==null||n.setValues({enableChangePassword:c!==!1,enableEditProfile:d!==!1})},[m]),{form:n}},l=()=>{const m=e.useAPIClient(),c=C.useForm();return{type:"primary",onClick(){return v(this,null,function*(){yield c.submit();const i=c.values;yield m.request({url:"systemSettings:update/1",data:i,method:"POST"}),x.message.success(t("Saved successfully")),window.location.reload()})}}};return a.jsx(e.SchemaComponentContext.Provider,{value:w(g({},o),{designable:!1}),children:a.jsx(e.SchemaComponent,{schema:U,scope:{t,useFormBlockProps:s,useSubmitActionProps:l},components:{UsersSettingsProvider:O}})})},N=()=>{const{t}=f();return a.jsx(x.Tabs,{defaultActiveKey:"usersManager",type:"card",className:y.css`
11
11
  .ant-tabs-nav {
12
12
  margin-bottom: 0px;
13
13
  }
@@ -10,17 +10,17 @@
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
12
  "antd": "5.12.8",
13
- "@nocobase/client": "1.4.21",
13
+ "@nocobase/client": "1.4.23",
14
14
  "@formily/react": "2.3.0",
15
15
  "@formily/core": "2.3.0",
16
- "@nocobase/plugin-acl": "1.4.21",
16
+ "@nocobase/plugin-acl": "1.4.23",
17
17
  "@emotion/css": "11.13.0",
18
- "@nocobase/utils": "1.4.21",
18
+ "@nocobase/utils": "1.4.23",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/database": "1.4.21",
21
- "@nocobase/server": "1.4.21",
22
- "@nocobase/plugin-user-data-sync": "1.4.21",
20
+ "@nocobase/database": "1.4.23",
21
+ "@nocobase/server": "1.4.23",
22
+ "@nocobase/plugin-user-data-sync": "1.4.23",
23
23
  "lodash": "4.17.21",
24
24
  "@formily/shared": "2.3.2",
25
- "@nocobase/actions": "1.4.21"
25
+ "@nocobase/actions": "1.4.23"
26
26
  };
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.4.21",
7
+ "version": "1.4.23",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -25,7 +25,7 @@
25
25
  "@nocobase/test": "1.x",
26
26
  "@nocobase/utils": "1.x"
27
27
  },
28
- "gitHead": "923b7d163381e85ce7ffefd14d24936d9dcd3caa",
28
+ "gitHead": "1e87e75a9c3b1efb0426b0690589f988a6d4aedc",
29
29
  "keywords": [
30
30
  "Users & permissions"
31
31
  ]