@nocobase/plugin-users 0.20.0-alpha.5 → 0.20.0-alpha.6

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.
@@ -1 +1 @@
1
- (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("react-i18next"),require("@nocobase/plugin-acl/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","react-i18next","@nocobase/plugin-acl/client"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-users"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r["react-i18next"],r["@nocobase/plugin-acl"]))})(this,function(r,e,t,l,m,v,g,x){"use strict";var K=Object.defineProperty,E=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var S=(r,e,t)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))N.call(e,t)&&S(r,t,e[t]);if(w)for(var t of w(e))L.call(e,t)&&S(r,t,e[t]);return r},F=(r,e)=>E(r,j(e));var h=(r,e,t)=>new Promise((l,m)=>{var v=u=>{try{x(t.next(u))}catch(A){m(A)}},g=u=>{try{x(t.throw(u))}catch(A){m(A)}},x=u=>u.done?l(u.value):Promise.resolve(u.value).then(v,g);x((t=t.apply(r,e)).next())});const u={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","x-validator":"phone",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"}}}}]},A={type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:u,resourceName:"users",request:{resource:"users",action:"list",params:{pageSize:50,appends:[]}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},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":"Form",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-validator":"phone","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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"UserRolesField"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",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":"Form","x-decorator-props":{useValues:s=>{const o=e.useRecord(),i=e.useRequest(()=>Promise.resolve({data:o}),F(f({},s),{manual:!0})),n=e.useActionContext();return l.useEffect(()=>{n.visible&&i.run()},[n.visible]),i}},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-validator":"phone","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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},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":"Form",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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},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?')}}"},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}}}},D={type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"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-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"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 C(){return g.useTranslation(["users","client"],{nsMode:"fallback"})}const P=()=>{const{t:s}=C();return(v.useField().value||[]).map(i=>t.jsx(m.Tag,{children:v.Schema.compile(i.title,{t:s})},i.name))},b=()=>{var n,c;const s=l.useContext(e.CollectionContext),o=e.useFilterFieldOptions(s.fields),i=e.useResourceActionContext();return e.useFilterFieldProps({options:o,params:((c=(n=i.state)==null?void 0:n.params)==null?void 0:c[0])||i.params,service:i})},T=(s=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",i="abcdefghijklmnopqrstuvwxyz",n="0123456789",c="!#$%^&*-_+=",y=o+i+n+c,p=new Uint32Array(s);crypto.getRandomValues(p);let a="";a+=o.charAt(p[0]%o.length),a+=i.charAt(p[1]%i.length),a+=n.charAt(p[2]%n.length),a+=c.charAt(p[3]%c.length);for(let d=4;d<s;d++){const V=p[d]%y.length;a+=y.charAt(V)}return a=a[0]+a.slice(1).split("").sort(()=>Math.random()-.5).join(""),a},I=()=>{const{t:s}=C(),o=v.useField(),[i,n]=l.useState(!1),c=e.useActionContext();return l.useEffect(()=>{c.visible||o.reset()},[o,c.visible]),t.jsxs(m.Row,{gutter:10,children:[t.jsx(m.Col,{span:18,children:t.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:i,onVisibleChange:n},value:o.value,onChange:y=>o.setValue(y.target.value)})}),t.jsx(m.Col,{span:4,children:t.jsx(m.Button,{onClick:()=>{o.setValue(T()),n(!0)},children:s("Random password")})})]})},U=()=>{const{t:s}=C(),o=e.useSchemaComponentContext();return t.jsx(e.SchemaComponentContext.Provider,{value:F(f({},o),{designable:!1}),children:t.jsx(m.Card,{children:t.jsx(e.SchemaComponent,{schema:A,scope:{t:s,useFilterActionProps:b},components:{UserRolesField:P,PasswordField:I}})})})},R=()=>{const s=e.useAPIClient(),{role:o}=l.useContext(x.RolesManagerContext),i=e.useRecord(),{refresh:n}=e.useResourceActionContext();return{run(){return h(this,null,function*(){yield s.resource("roles.users",o==null?void 0:o.name).remove({values:[i.id]}),n()})}}},k=()=>{const{t:s}=C(),{message:o}=m.App.useApp(),i=e.useAPIClient(),{state:n,setState:c,refresh:y}=e.useResourceActionContext(),{role:p}=l.useContext(x.RolesManagerContext);return{run(){return h(this,null,function*(){const d=n==null?void 0:n.selectedRowKeys;if(!(d!=null&&d.length)){o.warning(s("Please select users"));return}yield i.resource("roles.users",p==null?void 0:p.name).remove({values:d}),c==null||c({selectedRowKeys:[]}),y()})}}},q=s=>{const{role:o}=l.useContext(x.RolesManagerContext);return t.jsx(e.ResourceActionProvider,{collection:u,request:{resource:"users",action:"listExcludeRole",params:{roleName:o==null?void 0:o.name}},children:s.children})},M=()=>{const{t:s}=C(),{role:o}=l.useContext(x.RolesManagerContext),i=e.useRequest({resource:"roles.users",resourceOf:o==null?void 0:o.name,action:"list"},{ready:!!o,refreshDeps:[o]}),n=l.useRef([]),c=(p,a)=>{n.current=a},y=()=>{const p=e.useAPIClient(),{setVisible:a}=e.useActionContext(),{refresh:d}=e.useResourceActionContext();return{run(){return h(this,null,function*(){yield p.resource("roles.users",o==null?void 0:o.name).add({values:n.current.map(B=>B.id)}),n.current=[],a(!1),d()})}}};return t.jsx(e.ResourceActionContext.Provider,{value:f({},i),children:t.jsx(e.CollectionProvider_deprecated,{collection:u,children:t.jsx(e.SchemaComponent,{schema:D,components:{RoleUsersProvider:q},scope:{useBulkRemoveUsers:k,useRemoveUser:R,handleSelectRoleUsers:c,useAddRoleUsers:y,useFilterActionProps:b,t:s}})})})};class O extends e.Plugin{load(){return h(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions",{title:e.tval("Users & Permissions",{ns:"users"}),icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:e.tval("Users"),icon:"UserOutlined",Component:U,aclSnippet:"pm.users"}),this.app.pm.get(x).rolesManager.add("users",{title:e.tval("Users"),Component:M})})}}r.default=O,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@formily/shared"),require("antd"),require("@formily/react"),require("react-i18next"),require("@nocobase/plugin-acl/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@formily/shared","antd","@formily/react","react-i18next","@nocobase/plugin-acl/client"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-users"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r["@formily/shared"],r.antd,r["@formily/react"],r["react-i18next"],r["@nocobase/plugin-acl"]))})(this,function(r,e,t,p,f,d,v,C,a){"use strict";var K=Object.defineProperty,j=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var P=(r,e,t)=>e in r?K(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,g=(r,e)=>{for(var t in e||(e={}))L.call(e,t)&&P(r,t,e[t]);if(S)for(var t of S(e))_.call(e,t)&&P(r,t,e[t]);return r},b=(r,e)=>j(r,N(e));var h=(r,e,t)=>new Promise((p,f)=>{var d=a=>{try{C(t.next(a))}catch(y){f(y)}},v=a=>{try{C(t.throw(a))}catch(y){f(y)}},C=a=>a.done?p(a.value):Promise.resolve(a.value).then(d,v);C((t=t.apply(r,e)).next())});const y={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","x-validator":"phone",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"}}}}]},D={type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:y,resourceName:"users",request:{resource:"users",action:"list",params:{pageSize:50,appends:[]}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete users')}}",content:"{{t('Are you sure you want to delete it?')}}"},icon:"DeleteOutlined"}},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":"Form",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-validator":"phone","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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{nickname:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{username:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{email:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Roles")}}',properties:{roles:{type:"array","x-component":"UserRolesField"}}},column5:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",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":"Form","x-decorator-props":{useValues:i=>{const o=e.useRecord(),n=e.useRequest(()=>Promise.resolve({data:o}),b(g({},i),{manual:!0})),s=e.useActionContext();return p.useEffect(()=>{s.visible&&n.run()},[s.visible]),n}},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-validator":"phone","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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},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":"Form",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-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},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?')}}"},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}}}},T=()=>({type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[f.uid()]:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"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-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"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 A(){return C.useTranslation(["users","client"],{nsMode:"fallback"})}const I=()=>{const{t:i}=A();return(v.useField().value||[]).map(n=>t.jsx(d.Tag,{children:v.Schema.compile(n.title,{t:i})},n.name))},w=()=>{var s,c;const i=p.useContext(e.CollectionContext),o=e.useFilterFieldOptions(i.fields),n=e.useResourceActionContext();return e.useFilterFieldProps({options:o,params:((c=(s=n.state)==null?void 0:s.params)==null?void 0:c[0])||n.params,service:n})},U=(i=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",n="abcdefghijklmnopqrstuvwxyz",s="0123456789",c="!#$%^&*-_+=",x=o+n+s+c,l=new Uint32Array(i);crypto.getRandomValues(l);let u="";u+=o.charAt(l[0]%o.length),u+=n.charAt(l[1]%n.length),u+=s.charAt(l[2]%s.length),u+=c.charAt(l[3]%c.length);for(let m=4;m<i;m++){const F=l[m]%x.length;u+=x.charAt(F)}return u=u[0]+u.slice(1).split("").sort(()=>Math.random()-.5).join(""),u},R=()=>{const{t:i}=A(),o=v.useField(),[n,s]=p.useState(!1),c=e.useActionContext();return p.useEffect(()=>{c.visible||o.reset()},[o,c.visible]),t.jsxs(d.Row,{gutter:10,children:[t.jsx(d.Col,{span:18,children:t.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:n,onVisibleChange:s},value:o.value,onChange:x=>o.setValue(x.target.value),autoComplete:"off"})}),t.jsx(d.Col,{span:4,children:t.jsx(d.Button,{onClick:()=>{o.setValue(U()),s(!0)},children:i("Random password")})})]})},k=()=>{const{t:i}=A(),o=e.useSchemaComponentContext();return t.jsx(e.SchemaComponentContext.Provider,{value:b(g({},o),{designable:!1}),children:t.jsx(d.Card,{children:t.jsx(e.SchemaComponent,{schema:D,scope:{t:i,useFilterActionProps:w},components:{UserRolesField:I,PasswordField:R}})})})},q=()=>{const i=e.useAPIClient(),{role:o}=p.useContext(a.RolesManagerContext),n=e.useRecord(),{refresh:s}=e.useResourceActionContext();return{run(){return h(this,null,function*(){yield i.resource("roles.users",o==null?void 0:o.name).remove({values:[n.id]}),s()})}}},M=()=>{const{t:i}=A(),{message:o}=d.App.useApp(),n=e.useAPIClient(),{state:s,setState:c,refresh:x}=e.useResourceActionContext(),{role:l}=p.useContext(a.RolesManagerContext);return{run(){return h(this,null,function*(){const m=s==null?void 0:s.selectedRowKeys;if(!(m!=null&&m.length)){o.warning(i("Please select users"));return}yield n.resource("roles.users",l==null?void 0:l.name).remove({values:m}),c==null||c({selectedRowKeys:[]}),x()})}}},O=i=>{const{role:o}=p.useContext(a.RolesManagerContext);return t.jsx(e.ResourceActionProvider,{collection:y,request:{resource:"users",action:"listExcludeRole",params:{roleName:o==null?void 0:o.name}},children:i.children})},V=()=>{const{t:i}=A(),{role:o}=p.useContext(a.RolesManagerContext),n=e.useRequest({resource:"roles.users",resourceOf:o==null?void 0:o.name,action:"list"},{ready:!!o});p.useEffect(()=>{n.run()},[o]);const s=p.useRef([]),c=(u,m)=>{s.current=m},x=()=>{const u=e.useAPIClient(),{setVisible:m}=e.useActionContext(),{refresh:F}=e.useResourceActionContext();return{run(){return h(this,null,function*(){yield u.resource("roles.users",o==null?void 0:o.name).add({values:s.current.map(E=>E.id)}),s.current=[],m(!1),F()})}}},l=p.useMemo(()=>T(),[o]);return t.jsx(e.ResourceActionContext.Provider,{value:g({},n),children:t.jsx(e.CollectionProvider_deprecated,{collection:y,children:t.jsx(e.SchemaComponent,{schema:l,components:{RoleUsersProvider:O},scope:{useBulkRemoveUsers:M,useRemoveUser:q,handleSelectRoleUsers:c,useAddRoleUsers:x,useFilterActionProps:w,t:i}})})})};class B extends e.Plugin{load(){return h(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions",{title:e.tval("Users & Permissions",{ns:"users"}),icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:e.tval("Users"),icon:"UserOutlined",Component:k,aclSnippet:"pm.users"}),this.app.pm.get(a).rolesManager.add("users",{title:e.tval("Users"),Component:V})})}}r.default=B,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -162,4 +162,4 @@ export declare const userCollection: {
162
162
  })[];
163
163
  };
164
164
  export declare const usersSchema: ISchema;
165
- export declare const roleUsersSchema: ISchema;
165
+ export declare const getRoleUsersSchema: () => ISchema;
@@ -1,14 +1,15 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
3
  "antd": "5.12.8",
4
- "@nocobase/client": "0.20.0-alpha.5",
4
+ "@nocobase/client": "0.20.0-alpha.6",
5
5
  "@formily/react": "2.3.0",
6
6
  "@formily/core": "2.3.0",
7
- "@nocobase/plugin-acl": "0.20.0-alpha.5",
7
+ "@nocobase/plugin-acl": "0.20.0-alpha.6",
8
8
  "react-i18next": "11.18.6",
9
- "@nocobase/database": "0.20.0-alpha.5",
10
- "@nocobase/server": "0.20.0-alpha.5",
11
- "@nocobase/utils": "0.20.0-alpha.5",
12
- "@nocobase/cache": "0.20.0-alpha.5",
13
- "@nocobase/actions": "0.20.0-alpha.5"
9
+ "@nocobase/database": "0.20.0-alpha.6",
10
+ "@nocobase/server": "0.20.0-alpha.6",
11
+ "@nocobase/utils": "0.20.0-alpha.6",
12
+ "@nocobase/cache": "0.20.0-alpha.6",
13
+ "@formily/shared": "2.3.0",
14
+ "@nocobase/actions": "0.20.0-alpha.6"
14
15
  };
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": "0.20.0-alpha.5",
7
+ "version": "0.20.0-alpha.6",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -24,7 +24,7 @@
24
24
  "@nocobase/test": "0.x",
25
25
  "@nocobase/utils": "0.x"
26
26
  },
27
- "gitHead": "b72d7fdf357a6bc4460ff181644b9014d3dad13b",
27
+ "gitHead": "281767b02ce11f9172fb72e5e53ff98bc80b6eaf",
28
28
  "keywords": [
29
29
  "Users & permissions"
30
30
  ]