@nocobase/plugin-data-source-manager 1.4.0-alpha.20240918085507 → 1.4.0-alpha.20240923152933
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 +1 -1
- package/dist/externalVersion.js +7 -7
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
`),Kf=(e="main")=>({name:`dataSources/${e}/rolesResourcesScopes`,fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]}),Nf=()=>{const{name:e}=m.useContext(fe),t=r.useFormBlockContext();return m.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},Bf=e=>{const{data:t}=r.useCollectionRecord(),{id:o}=t||{},n=K(A({},e),{disabled:[1,2].includes(o)});return a.jsx(r.Action.Link,A({},n))},Vf=e=>{const{data:t}=r.useCollectionRecord(),{id:o}=t||{},n=K(A(A({},e),r.useDestroyActionProps()),{disabled:[1,2].includes(o)});return a.jsx(r.Action.Link,A({},n))},Lf=e=>{const t=Kf(e);return{type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:t,resource:`dataSources/${e}/rolesResourcesScopes`,action:"list",params:{pageSize:20},useParams(){return{filter:{$or:[{resourceName:m.useContext(fe).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:`dataSources/${e}/rolesResourcesScopes`,collection:t},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":Nf,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":r.withDynamicSchemaProps(o=>a.jsx(r.FlagProvider,{isVariableParsedInOtherContext:!0,children:a.jsx(r.Filter,A({},o))})),"x-use-component-props":()=>{const o=m.useContext(fe);return{options:r.useFilterFieldOptions(o.fields)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":Bf,"x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:`dataSources/${e}/rolesResourcesScopes`,collection:t,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":r.withDynamicSchemaProps(o=>a.jsx(r.FlagProvider,{isVariableParsedInOtherContext:!0,children:a.jsx(r.Filter,A({},o))})),"x-use-component-props":()=>{const o=m.useContext(fe);return{options:r.useFilterFieldOptions(o.fields)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-component":Vf}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}},Yo=m.createContext(null);Yo.displayName="RolesResourcesScopesSelectedRowKeysContext";const qf=e=>{const[t,o]=m.useState([]);return a.jsx(Yo.Provider,{value:[t,o],children:e.children})},Gf=e=>{var i;const t=m.useMemo(()=>Ce.createForm({values:{scope:e.value}}),[]),{key:o}=((i=r.useCollectionRecord())==null?void 0:i.parentRecord.data)||{},n=Lf(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:qf},scope:{onChange(s){var c;(c=e==null?void 0:e.onChange)==null||c.call(e,s)}},schema:n})})},Uf=e=>{var o;const t={};return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{n.name&&(t[n.name]=n,t[n.name].scope=Y.isEmpty(n.scope)?null:n.scope)}),t},fe=m.createContext({});fe.displayName="RoleResourceCollectionContext";const zf=_.connect(e=>{var x,d;const{styles:t}=jf(),o=h=>{const p=h.map(C=>K(A({},C),{scope:Y.isEmpty(C.scope)?null:C.scope}));e.onChange(p)},n=r.useRecord(),i=Qo(),s=n.fields,c=r.useCompile(),{t:l}=j.useTranslation(),y=_.useField(),u=Uf(y.value||[]),g=(h,p)=>{var P;const C=u==null?void 0:u[h];return C?(P=C==null?void 0:C.fields)==null?void 0:P.includes(p):!1},f=i.filter(h=>h.allowConfigureFields),b=s==null?void 0:s.map(h=>{const p=A({},h);for(const C of f)p[C.name]=g(C.name,h.name);return p}),w=h=>{var p;u[h]?delete u[h]:u[h]={name:h,fields:(p=s==null?void 0:s.map)==null?void 0:p.call(s,C=>C.name)},o(Object.values(u))},T=(h,p)=>{u[h]?(u[h].scope=p,o(Object.values(u))):(w(h),u[h].scope=p,o(Object.values(u)))},$={};for(const h of f)$[h.name]=(s==null?void 0:s.length)===((d=(x=u==null?void 0:u[h.name])==null?void 0:x.fields)==null?void 0:d.length);return a.jsx("div",{children:a.jsx(fe.Provider,{value:n,children:a.jsxs(ie.FormLayout,{layout:"vertical",children:[a.jsx(ie.FormItem,{label:l("Action permission"),children:a.jsx(v.Table,{className:t,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:l("Action display name"),render:h=>c(h)},{dataIndex:"onNewRecord",title:l("Action type"),render:h=>h?a.jsx(v.Tag,{color:"green",children:l("Action on new records")}):a.jsx(v.Tag,{color:"geekblue",children:l("Action on existing records")})},{dataIndex:"enabled",title:l("Allow"),render:(h,p)=>a.jsx(v.Checkbox,{checked:h,onChange:()=>{w(p.name)}})},{dataIndex:"scope",title:l("Data scope"),render:(h,p)=>!p.onNewRecord&&a.jsx(Gf,{value:h,onChange:C=>{T(p.name,C)}})}],dataSource:i==null?void 0:i.map(h=>{let p=!1,C=null;return u[h.name]&&(p=!0,h.onNewRecord||(C=u[h.name].scope)),K(A({},h),{enabled:p,scope:C})})})}),a.jsx(ie.FormItem,{label:l("Field permission"),children:a.jsx(v.Table,{className:t,pagination:!1,dataSource:b,columns:[{dataIndex:["uiSchema","title"],title:l("Field display name"),render:(h,p)=>c(h)||p.name},...f.map(h=>{const p=$==null?void 0:$[h.name];return{dataIndex:h.name,title:a.jsxs(a.Fragment,{children:[a.jsx(v.Checkbox,{checked:p,onChange:()=>{var P;const C=u[h.name]||{name:h.name};p?C.fields=[]:C.fields=(P=s==null?void 0:s.map)==null?void 0:P.call(s,E=>E.name),u[h.name]=C,o(Object.values(u))}}),c(h.displayName)]}),render:(C,P)=>a.jsx(v.Checkbox,{checked:C,onChange:()=>{const E=u[h.name]||{name:h.name},I=E.fields||[];if(C){const O=I.indexOf(P.name);I.splice(O,1)}else I.push(P.name);E.fields=I,u[h.name]=E,o(Object.values(u))}})}})]})})]})})})}),Hf=e=>{var o;if(!e)return{};const t={};return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{const[i,s]=n.split(":");t[i]=s||"all"}),t},Jo=e=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const n=e[o];n==="all"?t.push(o):t.push(`${o}:${n}`)}return t},Wf=_.connect(e=>{const{onChange:t}=e,o=Qo(),n=r.useCompile(),{t:i}=j.useTranslation(),s=_.useField(),c=Hf(s.value);return a.jsx("div",{children:a.jsx(v.Table,{size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:i("Action display name"),render:l=>n(l)},{dataIndex:"onNewRecord",title:i("Action type"),render:l=>l?a.jsx(v.Tag,{color:"green",children:i("Action on new records")}):a.jsx(v.Tag,{color:"geekblue",children:i("Action on existing records")})},{dataIndex:"enabled",title:i("Allow"),render:(l,y)=>a.jsx(v.Checkbox,{checked:l,onChange:u=>{l?delete c[y.name]:c[y.name]="all",t(Jo(c))}})},{dataIndex:"scope",title:i("Data scope"),render:(l,y)=>!y.onNewRecord&&a.jsx(v.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:l,options:[{label:i("All records"),value:"all"},{label:i("Own records"),value:"own"}],onChange:u=>{c[y.name]=u,t(Jo(c))}})}],dataSource:o==null?void 0:o.map(l=>{let y="all",u=!1;return c[l.name]&&(u=!0,y=c[l.name]),K(A({},l),{enabled:u,scope:y})})})})}),Qf={type:"object",properties:{[V.uid()]:{"x-component":"DataSourceTable"}}},Ae=m.createContext({});Ae.displayName="CurrentRolesContext";const Yf=({role:e})=>a.jsx(v.Card,{"data-testid":"acl-pane-card",bordered:!1,children:a.jsx(Ae.Provider,{value:e,children:a.jsx(r.SchemaComponent,{components:{MenuConfigure:r.MenuConfigure,RoleConfigure:Ef,RolesResourcesActions:zf,DataSourceTable:kf,StrategyActions:Wf,SettingsCenterConfigure:r.SettingsCenterConfigure,SettingCenterProvider:r.SettingCenterProvider,ResourceActionProvider:r.ResourceActionProvider,RoleRecordProvider:_f},schema:Qf})})});class se extends r.Plugin{constructor(){super(...arguments);yt(this,"types",new Map);yt(this,"extendedTabs",{})}getExtendedTabs(){return this.extendedTabs}registerPermissionTab(o){this.extendedTabs[ge.uid()]=o}load(){return D(this,null,function*(){this.app.pm.get(H).settingsUI.addPermissionsTab(({t:o,TabLayout:n,role:i})=>({key:"dataSource",label:o("Data sources"),children:a.jsx(n,{children:a.jsx(Yf,{role:i})})})),this.app.use(sn),this.app.pluginSettingsManager.add(N,{title:`{{t("Data sources", { ns: "${N}" })}}`,icon:"ClusterOutlined",showTabs:!1,aclSnippet:"pm.data-source-manager*"}),this.app.pluginSettingsManager.add(`${N}.list`,{title:`{{t("Data sources", { ns: "${N}" })}}`,Component:nf,sort:1,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${N}/:name`,{title:a.jsx(bt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${N}/main`,{title:a.jsx(bt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${N}/main.collections`,{title:`{{t("Collections", { ns: "${N}" })}}`,Component:Ff,topLevelName:`${N}/main`,pluginKey:N,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${N}/:name.collections`,{title:`{{t("Collections", { ns: "${N}" })}}`,Component:Xy,topLevelName:`${N}/:name`,pluginKey:N,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.dataSourceManager.addDataSources(this.getThirdDataSource.bind(this),ht)})}setDataSources(){return D(this,null,function*(){var n;const o=yield this.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1}});return(n=o==null?void 0:o.data)==null?void 0:n.data})}getThirdDataSource(){return D(this,null,function*(){var n;const o=yield this.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1,appends:["collections"]}});return(n=o==null?void 0:o.data)==null?void 0:n.data})}registerType(o,n){this.types.set(o,n)}}M.PluginDataSourceManagerClient=se,M.default=se,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
59
|
+
`),Kf=(e="main")=>({name:`dataSources/${e}/rolesResourcesScopes`,fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Scope name")}}',type:"string","x-component":"Input",required:!0}}]}),Nf=()=>{const{name:e}=m.useContext(fe),t=r.useFormBlockContext();return m.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},Bf=e=>{const{data:t}=r.useCollectionRecord(),{id:o}=t||{},n=K(A({},e),{disabled:[1,2].includes(o)});return a.jsx(r.Action.Link,A({},n))},Vf=e=>{const{data:t}=r.useCollectionRecord(),{id:o}=t||{},n=K(A(A({},e),r.useDestroyActionProps()),{disabled:[1,2].includes(o)});return a.jsx(r.Action.Link,A({},n))},Lf=e=>{const t=Kf(e);return{type:"object",properties:{scope:{"x-component":"RecordPicker","x-component-props":{size:"small",fieldNames:{label:"name",value:"id"},multiple:!1,association:{target:"rolesResourcesScopes"},onChange:"{{ onChange }}"},properties:{selector:{type:"void",title:'{{ t("Select record") }}',"x-component":"RecordPicker.Selector","x-component-props":{className:"nb-record-picker-selector"},properties:{tableBlock:{type:"void","x-decorator":"TableSelectorProvider","x-decorator-props":{collection:t,resource:`dataSources/${e}/rolesResourcesScopes`,action:"list",params:{pageSize:20},useParams(){return{filter:{$or:[{resourceName:m.useContext(fe).name},{resourceName:null}]}}},rowKey:"id"},"x-component":"BlockItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{create:{type:"void",title:'{{ t("Add new") }}',"x-action":"create","x-component":"Action","x-component-props":{icon:"PlusOutlined",openMode:"drawer",type:"primary"},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:`dataSources/${e}/rolesResourcesScopes`,collection:t},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":Nf,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":r.withDynamicSchemaProps(o=>a.jsx(r.FlagProvider,{isVariableParsedInOtherContext:!0,children:a.jsx(r.Filter,A({},o))})),"x-use-component-props":()=>{const o=m.useContext(fe);return{options:r.useFilterFieldOptions(o.fields)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}}},value:{type:"array","x-component":"TableV2.Selector","x-use-component-props":"useTableSelectorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-component":"TableV2.Column",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{edit:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-component":Bf,"x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"nb-action-popup"},properties:{formBlock:{type:"void","x-decorator":"FormBlockProvider","x-decorator-props":{resource:`dataSources/${e}/rolesResourcesScopes`,collection:t,action:"get",useParams:"{{ useParamsFromRecord }}"},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps",properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":r.withDynamicSchemaProps(o=>a.jsx(r.FlagProvider,{isVariableParsedInOtherContext:!0,children:a.jsx(r.Filter,A({},o))})),"x-use-component-props":()=>{const o=m.useContext(fe);return{options:r.useFilterFieldOptions(o.fields)}},"x-component-props":{dynamicComponent:r.VariableInput}},actions:{type:"void","x-component":"ActionBar","x-component-props":{layout:"one-column",style:{marginTop:24}},properties:{update:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}},destroy:{title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-component":Vf}}}}}}}}},footer:{"x-component":"Action.Container.Footer","x-component-props":{},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"usePickActionProps","x-component-props":{type:"primary",htmlType:"submit"}}}}}}}}}}}}},Yo=m.createContext(null);Yo.displayName="RolesResourcesScopesSelectedRowKeysContext";const qf=e=>{const[t,o]=m.useState([]);return a.jsx(Yo.Provider,{value:[t,o],children:e.children})},Gf=e=>{var i;const t=m.useMemo(()=>Ce.createForm({values:{scope:e.value}}),[]),{key:o}=((i=r.useCollectionRecord())==null?void 0:i.parentRecord.data)||{},n=Lf(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:qf},scope:{onChange(s){var c;(c=e==null?void 0:e.onChange)==null||c.call(e,s)}},schema:n})})},Uf=e=>{var o;const t={};return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{n.name&&(t[n.name]=n,t[n.name].scope=Y.isEmpty(n.scope)?null:n.scope)}),t},fe=m.createContext({});fe.displayName="RoleResourceCollectionContext";const zf=_.connect(e=>{var x,d;const{styles:t}=jf(),o=h=>{const p=h.map(C=>K(A({},C),{scope:Y.isEmpty(C.scope)?null:C.scope}));e.onChange(p)},n=r.useRecord(),i=Qo(),s=n.fields,c=r.useCompile(),{t:l}=j.useTranslation(),y=_.useField(),u=Uf(y.value||[]),g=(h,p)=>{var P;const C=u==null?void 0:u[h];return C?(P=C==null?void 0:C.fields)==null?void 0:P.includes(p):!1},f=i.filter(h=>h.allowConfigureFields),b=s==null?void 0:s.map(h=>{const p=A({},h);for(const C of f)p[C.name]=g(C.name,h.name);return p}),w=h=>{var p;u[h]?delete u[h]:u[h]={name:h,fields:(p=s==null?void 0:s.map)==null?void 0:p.call(s,C=>C.name)},o(Object.values(u))},T=(h,p)=>{u[h]?(u[h].scope=p,o(Object.values(u))):(w(h),u[h].scope=p,o(Object.values(u)))},$={};for(const h of f)$[h.name]=(s==null?void 0:s.length)===((d=(x=u==null?void 0:u[h.name])==null?void 0:x.fields)==null?void 0:d.length);return a.jsx("div",{children:a.jsx(fe.Provider,{value:n,children:a.jsxs(ie.FormLayout,{layout:"vertical",children:[a.jsx(ie.FormItem,{label:l("Action permission"),children:a.jsx(v.Table,{className:t,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:l("Action display name"),render:h=>c(h)},{dataIndex:"onNewRecord",title:l("Action type"),render:h=>h?a.jsx(v.Tag,{color:"green",children:l("Action on new records")}):a.jsx(v.Tag,{color:"geekblue",children:l("Action on existing records")})},{dataIndex:"enabled",title:l("Allow"),render:(h,p)=>a.jsx(v.Checkbox,{checked:h,onChange:()=>{w(p.name)}})},{dataIndex:"scope",title:l("Data scope"),render:(h,p)=>!p.onNewRecord&&a.jsx(Gf,{value:h,onChange:C=>{T(p.name,C)}})}],dataSource:i==null?void 0:i.map(h=>{let p=!1,C=null;return u[h.name]&&(p=!0,h.onNewRecord||(C=u[h.name].scope)),K(A({},h),{enabled:p,scope:C})})})}),a.jsx(ie.FormItem,{label:l("Field permission"),children:a.jsx(v.Table,{className:t,pagination:!1,dataSource:b,columns:[{dataIndex:["uiSchema","title"],title:l("Field display name"),render:(h,p)=>c(h)||p.name},...f.map(h=>{const p=$==null?void 0:$[h.name];return{dataIndex:h.name,title:a.jsxs(a.Fragment,{children:[a.jsx(v.Checkbox,{checked:p,onChange:()=>{var P;const C=u[h.name]||{name:h.name};p?C.fields=[]:C.fields=(P=s==null?void 0:s.map)==null?void 0:P.call(s,E=>E.name),u[h.name]=C,o(Object.values(u))}}),c(h.displayName)]}),render:(C,P)=>a.jsx(v.Checkbox,{checked:C,onChange:()=>{const E=u[h.name]||{name:h.name},I=E.fields||[];if(C){const O=I.indexOf(P.name);I.splice(O,1)}else I.push(P.name);E.fields=I,u[h.name]=E,o(Object.values(u))}})}})]})})]})})})}),Hf=e=>{var o;if(!e)return{};const t={};return(o=e==null?void 0:e.forEach)==null||o.call(e,n=>{const[i,s]=n.split(":");t[i]=s||"all"}),t},Jo=e=>{const t=[];for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const n=e[o];n==="all"?t.push(o):t.push(`${o}:${n}`)}return t},Wf=_.connect(e=>{const{onChange:t}=e,o=Qo(),n=r.useCompile(),{t:i}=j.useTranslation(),s=_.useField(),c=Hf(s.value);return a.jsx("div",{children:a.jsx(v.Table,{size:"small",pagination:!1,rowKey:"name",columns:[{dataIndex:"displayName",title:i("Action display name"),render:l=>n(l)},{dataIndex:"onNewRecord",title:i("Action type"),render:l=>l?a.jsx(v.Tag,{color:"green",children:i("Action on new records")}):a.jsx(v.Tag,{color:"geekblue",children:i("Action on existing records")})},{dataIndex:"enabled",title:i("Allow"),render:(l,y)=>a.jsx(v.Checkbox,{checked:l,onChange:u=>{l?delete c[y.name]:c[y.name]="all",t(Jo(c))}})},{dataIndex:"scope",title:i("Data scope"),render:(l,y)=>!y.onNewRecord&&a.jsx(v.Select,{"data-testid":"select-data-scope",popupMatchSelectWidth:!1,size:"small",value:l,options:[{label:i("All records"),value:"all"},{label:i("Own records"),value:"own"}],onChange:u=>{c[y.name]=u,t(Jo(c))}})}],dataSource:o==null?void 0:o.map(l=>{let y="all",u=!1;return c[l.name]&&(u=!0,y=c[l.name]),K(A({},l),{enabled:u,scope:y})})})})}),Qf={type:"object",properties:{[V.uid()]:{"x-component":"DataSourceTable"}}},Ae=m.createContext({});Ae.displayName="CurrentRolesContext";const Yf=({role:e})=>a.jsx(v.Card,{"data-testid":"acl-pane-card",bordered:!1,children:a.jsx(Ae.Provider,{value:e,children:a.jsx(r.SchemaComponent,{components:{MenuConfigure:r.MenuConfigure,RoleConfigure:Ef,RolesResourcesActions:zf,DataSourceTable:kf,StrategyActions:Wf,SettingsCenterConfigure:r.SettingsCenterConfigure,SettingCenterProvider:r.SettingCenterProvider,ResourceActionProvider:r.ResourceActionProvider,RoleRecordProvider:_f},schema:Qf})})});class se extends r.Plugin{constructor(){super(...arguments);yt(this,"types",new Map);yt(this,"extendedTabs",{})}getExtendedTabs(){return this.extendedTabs}registerPermissionTab(o){this.extendedTabs[ge.uid()]=o}load(){return D(this,null,function*(){this.app.pm.get(H).settingsUI.addPermissionsTab(({t:o,TabLayout:n,activeRole:i})=>({key:"dataSource",label:o("Data sources"),children:a.jsx(n,{children:a.jsx(Yf,{role:i})})})),this.app.use(sn),this.app.pluginSettingsManager.add(N,{title:`{{t("Data sources", { ns: "${N}" })}}`,icon:"ClusterOutlined",showTabs:!1,aclSnippet:"pm.data-source-manager*"}),this.app.pluginSettingsManager.add(`${N}.list`,{title:`{{t("Data sources", { ns: "${N}" })}}`,Component:nf,sort:1,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${N}/:name`,{title:a.jsx(bt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${N}/main`,{title:a.jsx(bt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${N}/main.collections`,{title:`{{t("Collections", { ns: "${N}" })}}`,Component:Ff,topLevelName:`${N}/main`,pluginKey:N,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${N}/:name.collections`,{title:`{{t("Collections", { ns: "${N}" })}}`,Component:Xy,topLevelName:`${N}/:name`,pluginKey:N,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.dataSourceManager.addDataSources(this.getThirdDataSource.bind(this),ht)})}setDataSources(){return D(this,null,function*(){var n;const o=yield this.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1}});return(n=o==null?void 0:o.data)==null?void 0:n.data})}getThirdDataSource(){return D(this,null,function*(){var n;const o=yield this.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1,appends:["collections"]}});return(n=o==null?void 0:o.data)==null?void 0:n.data})}registerType(o,n){this.types.set(o,n)}}M.PluginDataSourceManagerClient=se,M.default=se,Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
11
|
+
"@nocobase/client": "1.4.0-alpha.20240923152933",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/plugin-acl": "1.4.0-alpha.
|
|
14
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
15
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/plugin-acl": "1.4.0-alpha.20240923152933",
|
|
14
|
+
"@nocobase/utils": "1.4.0-alpha.20240923152933",
|
|
15
|
+
"@nocobase/server": "1.4.0-alpha.20240923152933",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
18
18
|
"antd": "5.12.8",
|
|
@@ -21,10 +21,10 @@ module.exports = {
|
|
|
21
21
|
"react-i18next": "11.18.6",
|
|
22
22
|
"@formily/react": "2.3.0",
|
|
23
23
|
"@emotion/css": "11.13.0",
|
|
24
|
-
"@nocobase/database": "1.4.0-alpha.
|
|
25
|
-
"@nocobase/acl": "1.4.0-alpha.
|
|
24
|
+
"@nocobase/database": "1.4.0-alpha.20240923152933",
|
|
25
|
+
"@nocobase/acl": "1.4.0-alpha.20240923152933",
|
|
26
26
|
"sequelize": "6.35.2",
|
|
27
|
-
"@nocobase/test": "1.4.0-alpha.
|
|
27
|
+
"@nocobase/test": "1.4.0-alpha.20240923152933",
|
|
28
28
|
"@formily/antd-v5": "1.1.9",
|
|
29
29
|
"@formily/core": "2.3.0",
|
|
30
30
|
"@formily/reactive": "2.3.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-data-source-manager",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.20240923152933",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"displayName": "Data source manager",
|
|
6
6
|
"displayName.zh-CN": "数据源管理",
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"keywords": [
|
|
18
18
|
"Data model tools"
|
|
19
19
|
],
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "bd1a83a7040a63619a3d39c5b67048fa97a49f5a"
|
|
21
21
|
}
|