@nocobase/plugin-users 1.3.22-beta → 1.3.23-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/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","@nocobase/utils/client","react/jsx-runtime","react","@formily/shared","antd","@formily/react","react-i18next","@nocobase/plugin-acl/client"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t["@nocobase/plugin-users"]={},t["@nocobase/client"],t["@nocobase/utils"],t.jsxRuntime,t.react,t["@formily/shared"],t.antd,t["@formily/react"],t["react-i18next"],t["@nocobase/plugin-acl"]))})(this,function(t,e,i,c,p,F,x,A,y,d){"use strict";var N=Object.defineProperty,L=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var T=(t,e,i)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,h=(t,e)=>{for(var i in e||(e={}))z.call(e,i)&&T(t,i,e[i]);if(D)for(var i of D(e))$.call(e,i)&&T(t,i,e[i]);return t},w=(t,e)=>L(t,_(e));var f=(t,e,i)=>new Promise((c,p)=>{var F=y=>{try{A(i.next(y))}catch(d){p(d)}},x=y=>{try{A(i.throw(y))}catch(d){p(d)}},A=y=>y.done?c(y.value):Promise.resolve(y.value).then(F,x);A((i=i.apply(t,e)).next())});const g={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"}}}}]},P={type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:g,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-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"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-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(),r=e.useRequest(()=>Promise.resolve({data:o}),w(h({},s),{manual:!0})),n=e.useActionContext();return p.useEffect(()=>{n.visible&&r.run()},[n.visible]),r}},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-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}}"}}}}}}}}}}}},I=()=>({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-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 v(){return y.useTranslation(["users","client"],{nsMode:"fallback"})}const U=()=>{const{t:s}=v();return(A.useField().value||[]).map(r=>c.jsx(x.Tag,{children:A.Schema.compile(r.title,{t:s})},r.name))},S=()=>{var n,a;const s=p.useContext(e.CollectionContext),o=e.useFilterFieldOptions(s.fields),r=e.useResourceActionContext();return e.useFilterFieldProps({options:o,params:((a=(n=r.state)==null?void 0:n.params)==null?void 0:a[0])||r.params,service:r})},R=(s=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",r="abcdefghijklmnopqrstuvwxyz",n="0123456789",a="!#$%^&*-_+=",C=o+r+n+a,u=new Uint32Array(s);crypto.getRandomValues(u);let l="";l+=o.charAt(u[0]%o.length),l+=r.charAt(u[1]%r.length),l+=n.charAt(u[2]%n.length),l+=a.charAt(u[3]%a.length);for(let m=4;m<s;m++){const b=u[m]%C.length;l+=C.charAt(b)}return l=l[0]+l.slice(1).split("").sort(()=>Math.random()-.5).join(""),l},k=()=>{const{t:s}=v(),o=A.useField(),[r,n]=p.useState(!1),a=e.useActionContext();return p.useEffect(()=>{a.visible||o.reset()},[o,a.visible]),c.jsxs(x.Row,{gutter:10,children:[c.jsx(x.Col,{span:18,children:c.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:r,onVisibleChange:n},value:o.value,onChange:C=>o.setValue(C.target.value),autoComplete:"off"})}),c.jsx(x.Col,{span:4,children:c.jsx(x.Button,{onClick:()=>{o.setValue(R()),n(!0)},children:s("Random password")})})]})},q=()=>{const{t:s}=v(),o=e.useSchemaComponentContext();return c.jsx(e.SchemaComponentContext.Provider,{value:w(h({},o),{designable:!1}),children:c.jsx(x.Card,{children:c.jsx(e.SchemaComponent,{schema:P,scope:{t:s,useFilterActionProps:S},components:{UserRolesField:U,PasswordField:k}})})})},M=()=>{const s=e.useAPIClient(),{role:o}=p.useContext(d.RolesManagerContext),r=e.useRecord(),{refresh:n}=e.useResourceActionContext();return{run(){return f(this,null,function*(){yield s.resource("roles.users",o==null?void 0:o.name).remove({values:[r.id]}),n()})}}},O=()=>{const{t:s}=v(),{message:o}=x.App.useApp(),r=e.useAPIClient(),{state:n,setState:a,refresh:C}=e.useResourceActionContext(),{role:u}=p.useContext(d.RolesManagerContext);return{run(){return f(this,null,function*(){const m=n==null?void 0:n.selectedRowKeys;if(!(m!=null&&m.length)){o.warning(s("Please select users"));return}yield r.resource("roles.users",u==null?void 0:u.name).remove({values:m}),a==null||a({selectedRowKeys:[]}),C()})}}},V=s=>{const{role:o}=p.useContext(d.RolesManagerContext);return c.jsx(e.ResourceActionProvider,{collection:g,request:{resource:"users",action:"listExcludeRole",params:{roleName:o==null?void 0:o.name}},children:s.children})},B=()=>{const{t:s}=v(),{role:o}=p.useContext(d.RolesManagerContext),r=e.useRequest({resource:"roles.users",resourceOf:o==null?void 0:o.name,action:"list"},{ready:!!o});p.useEffect(()=>{r.run()},[o]);const n=p.useRef([]),a=(l,m)=>{n.current=m},C=()=>{const{role:l}=p.useContext(d.RolesManagerContext),m=e.useAPIClient(),{setVisible:b}=e.useActionContext(),{refresh:K}=e.useResourceActionContext();return{run(){return f(this,null,function*(){yield m.resource("roles.users",l==null?void 0:l.name).add({values:n.current.map(j=>j.id)}),n.current=[],b(!1),K()})}}},u=p.useMemo(()=>I(),[o]);return c.jsx(e.ResourceActionContext.Provider,{value:h({},r),children:c.jsx(e.CollectionProvider_deprecated,{collection:g,children:c.jsx(e.SchemaComponent,{schema:u,components:{RoleUsersProvider:V},scope:{useBulkRemoveUsers:O,useRemoveUser:M,handleSelectRoleUsers:a,useAddRoleUsers:C,useFilterActionProps:S,t:s}})})})};class E extends e.Plugin{load(){return f(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions",{title:i.tval("Users & Permissions",{ns:"users"}),icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:i.tval("Users"),icon:"UserOutlined",Component:q,aclSnippet:"pm.users"}),this.app.pm.get(d).rolesManager.add("users",{title:i.tval("Users"),Component:B})})}}t.default=E,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
10
|
+
(function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/client"),require("react/jsx-runtime"),require("react"),require("@formily/shared"),require("react-i18next"),require("antd"),require("@formily/react"),require("@formily/core"),require("@nocobase/plugin-acl/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/utils/client","react/jsx-runtime","react","@formily/shared","react-i18next","antd","@formily/react","@formily/core","@nocobase/plugin-acl/client"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t["@nocobase/plugin-users"]={},t["@nocobase/client"],t["@nocobase/utils"],t.jsxRuntime,t.react,t["@formily/shared"],t["react-i18next"],t.antd,t["@formily/react"],t["@formily/core"],t["@nocobase/plugin-acl"]))})(this,function(t,e,s,m,a,h,b,d,x,v,C){"use strict";var z=Object.defineProperty,H=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var S=(t,e,s)=>e in t?z(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,F=(t,e)=>{for(var s in e||(e={}))G.call(e,s)&&S(t,s,e[s]);if(P)for(var s of P(e))J.call(e,s)&&S(t,s,e[s]);return t},T=(t,e)=>H(t,$(e));var f=(t,e,s)=>new Promise((m,a)=>{var h=x=>{try{d(s.next(x))}catch(v){a(v)}},b=x=>{try{d(s.throw(x))}catch(v){a(v)}},d=x=>x.done?m(x.value):Promise.resolve(x.value).then(h,b);d((s=s.apply(t,e)).next())});const w={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"}}}}]},D={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"}}}}}}}}}}},k=()=>({type:"void",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{[h.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 A(){return b.useTranslation(["users","client"],{nsMode:"fallback"})}const I=(r=10)=>{const o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",i="abcdefghijklmnopqrstuvwxyz",n="0123456789",p="!#$%^&*-_+=",y=o+i+n+p,l=new Uint32Array(r);crypto.getRandomValues(l);let u="";u+=o.charAt(l[0]%o.length),u+=i.charAt(l[1]%i.length),u+=n.charAt(l[2]%n.length),u+=p.charAt(l[3]%p.length);for(let c=4;c<r;c++){const g=l[c]%y.length;u+=y.charAt(g)}return u=u[0]+u.slice(1).split("").sort(()=>Math.random()-.5).join(""),u},R=()=>{const{t:r}=A(),o=x.useField(),[i,n]=a.useState(!1),p=e.useActionContext();return a.useEffect(()=>{p.visible||o.reset()},[o,p.visible]),m.jsxs(d.Row,{gutter:10,children:[m.jsx(d.Col,{span:18,children:m.jsx(e.Password,{checkStrength:!0,visibilityToggle:{visible:i,onVisibleChange:n},value:o.value,onChange:y=>o.setValue(y.target.value),autoComplete:"off"})}),m.jsx(d.Col,{span:4,children:m.jsx(d.Button,{onClick:()=>{o.setValue(I()),n(!0)},children:r("Random password")})})]})},V=()=>{const{setVisible:r}=e.useActionContext();return{type:"default",onClick(){r(!1)}}},q=()=>{const{setVisible:r}=e.useActionContext(),{message:o}=d.App.useApp(),i=x.useForm(),n=e.useDataBlockResource(),{runAsync:p}=e.useDataBlockRequest(),{t:y}=A(),l=e.useCollection();return{type:"primary",onClick(){return f(this,null,function*(){yield i.submit();const c=i.values;console.log("values:",c),c[l.filterTargetKey]?yield n.update({values:c,filterByTk:c[l.filterTargetKey]}):yield n.create({values:c}),yield p(),o.success(y("Saved successfully")),r(!1)})}}},U=()=>{const r=e.useCollectionRecordData();return{form:a.useMemo(()=>v.createForm({initialValues:r}),[r])}},M=()=>{const{t:r}=A(),o=e.useSchemaComponentContext();return m.jsx(e.SchemaComponentContext.Provider,{value:T(F({},o),{designable:!1}),children:m.jsx(e.SchemaComponent,{schema:D,scope:{t:r,useCancelActionProps:V,useSubmitActionProps:q,useEditFormProps:U},components:{PasswordField:R}})})},B=()=>{var n,p;const r=a.useContext(e.CollectionContext),o=e.useFilterFieldOptions(r.fields),i=e.useResourceActionContext();return e.useFilterFieldProps({options:o,params:((p=(n=i.state)==null?void 0:n.params)==null?void 0:p[0])||i.params,service:i})},K=()=>{const r=e.useAPIClient(),{role:o}=a.useContext(C.RolesManagerContext),i=e.useRecord(),{refresh:n}=e.useResourceActionContext();return{run(){return f(this,null,function*(){yield r.resource("roles.users",o==null?void 0:o.name).remove({values:[i.id]}),n()})}}},O=()=>{const{t:r}=A(),{message:o}=d.App.useApp(),i=e.useAPIClient(),{state:n,setState:p,refresh:y}=e.useResourceActionContext(),{role:l}=a.useContext(C.RolesManagerContext);return{run(){return f(this,null,function*(){const c=n==null?void 0:n.selectedRowKeys;if(!(c!=null&&c.length)){o.warning(r("Please select users"));return}yield i.resource("roles.users",l==null?void 0:l.name).remove({values:c}),p==null||p({selectedRowKeys:[]}),y()})}}},E=r=>{const{role:o}=a.useContext(C.RolesManagerContext);return m.jsx(e.ResourceActionProvider,{collection:w,request:{resource:"users",action:"listExcludeRole",params:{roleName:o==null?void 0:o.name}},children:r.children})},j=()=>{const{t:r}=A(),{role:o}=a.useContext(C.RolesManagerContext),i=e.useRequest({resource:"roles.users",resourceOf:o==null?void 0:o.name,action:"list"},{ready:!!o});a.useEffect(()=>{i.run()},[o]);const n=a.useRef([]),p=(u,c)=>{n.current=c},y=()=>{const{role:u}=a.useContext(C.RolesManagerContext),c=e.useAPIClient(),{setVisible:g}=e.useActionContext(),{refresh:L}=e.useResourceActionContext();return{run(){return f(this,null,function*(){yield c.resource("roles.users",u==null?void 0:u.name).add({values:n.current.map(_=>_.id)}),n.current=[],g(!1),L()})}}},l=a.useMemo(()=>k(),[o]);return m.jsx(e.ResourceActionContext.Provider,{value:F({},i),children:m.jsx(e.CollectionProvider_deprecated,{collection:w,children:m.jsx(e.SchemaComponent,{schema:l,components:{RoleUsersProvider:E},scope:{useBulkRemoveUsers:O,useRemoveUser:K,handleSelectRoleUsers:p,useAddRoleUsers:y,useFilterActionProps:B,t:r}})})})};class N extends e.Plugin{load(){return f(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions",{title:s.tval("Users & Permissions",{ns:"users"}),icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:s.tval("Users"),icon:"UserOutlined",Component:M,aclSnippet:"pm.users"}),this.app.pm.get(C).rolesManager.add("users",{title:s.tval("Users"),Component:j})})}}t.default=N,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
|
-
"@nocobase/client": "1.3.
|
|
13
|
+
"@nocobase/client": "1.3.23-beta",
|
|
14
14
|
"@formily/react": "2.3.0",
|
|
15
15
|
"@formily/core": "2.3.0",
|
|
16
|
-
"@nocobase/plugin-acl": "1.3.
|
|
17
|
-
"@nocobase/utils": "1.3.
|
|
16
|
+
"@nocobase/plugin-acl": "1.3.23-beta",
|
|
17
|
+
"@nocobase/utils": "1.3.23-beta",
|
|
18
18
|
"react-i18next": "11.18.6",
|
|
19
|
-
"@nocobase/database": "1.3.
|
|
20
|
-
"@nocobase/server": "1.3.
|
|
21
|
-
"@nocobase/cache": "1.3.
|
|
19
|
+
"@nocobase/database": "1.3.23-beta",
|
|
20
|
+
"@nocobase/server": "1.3.23-beta",
|
|
21
|
+
"@nocobase/cache": "1.3.23-beta",
|
|
22
22
|
"@formily/shared": "2.3.0",
|
|
23
|
-
"@nocobase/actions": "1.3.
|
|
23
|
+
"@nocobase/actions": "1.3.23-beta",
|
|
24
24
|
"lodash": "4.17.21"
|
|
25
25
|
};
|
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.3.
|
|
7
|
+
"version": "1.3.23-beta",
|
|
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": "1.x",
|
|
25
25
|
"@nocobase/utils": "1.x"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "a32ecfe2cde9b7696e7eab88a49eadda8ce1fcb7",
|
|
28
28
|
"keywords": [
|
|
29
29
|
"Users & permissions"
|
|
30
30
|
]
|