@nocobase/plugin-data-source-manager 0.21.0-alpha.7 → 0.21.0-alpha.8

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.
@@ -47,4 +47,4 @@
47
47
  }
48
48
  }
49
49
  }
50
- `),Pf=(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}}]}),Df=()=>{const{name:e}=d.useContext(de),t=r.useFormBlockContext();return d.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},If=e=>{const t=Pf(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:d.useContext(de).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":Df,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const o=d.useContext(de);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":"Action.Link","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":"Filter","x-use-component-props":()=>{const o=d.useContext(de);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":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},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"}}}}}}}}}}}}},Uo=d.createContext(null);Uo.displayName="RolesResourcesScopesSelectedRowKeysContext";const Of=e=>{const[t,o]=d.useState([]);return a.jsx(Uo.Provider,{value:[t,o],children:e.children})},Mf=e=>{const t=d.useMemo(()=>me.createForm({values:{scope:e.value}}),[]),{key:o}=r.useRecord(),n=If(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Of},scope:{onChange(s){var i;(i=e==null?void 0:e.onChange)==null||i.call(e,s)}},schema:n})})},jf=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=J.isEmpty(n.scope)?null:n.scope)}),t},de=d.createContext({});de.displayName="RoleResourceCollectionContext";const Ef=T.connect(e=>{var b,h;const{styles:t}=_f(),o=f=>{const m=f.map(v=>N(A({},v),{scope:J.isEmpty(v.scope)?null:v.scope}));e.onChange(m)},n=r.useRecord(),s=qo(),i=n.fields,c=r.useCompile(),{t:l}=V.useTranslation(),p=T.useField(),u=jf(p.value||[]),y=(f,m)=>{var F;const v=u==null?void 0:u[f];return v?(F=v==null?void 0:v.fields)==null?void 0:F.includes(m):!1},g=s.filter(f=>f.allowConfigureFields),C=i==null?void 0:i.map(f=>{const m=A({},f);for(const v of g)m[v.name]=y(v.name,f.name);return m}),I=f=>{var m;u[f]?delete u[f]:u[f]={name:f,fields:(m=i==null?void 0:i.map)==null?void 0:m.call(i,v=>v.name)},o(Object.values(u))},$=(f,m)=>{u[f]?(u[f].scope=m,o(Object.values(u))):(I(f),u[f].scope=m,o(Object.values(u)))},S={};for(const f of g)S[f.name]=(i==null?void 0:i.length)===((h=(b=u==null?void 0:u[f.name])==null?void 0:b.fields)==null?void 0:h.length);return a.jsx("div",{children:a.jsx(de.Provider,{value:n,children:a.jsxs(re.FormLayout,{layout:"vertical",children:[a.jsx(re.FormItem,{label:l("Action permission"),children:a.jsx(x.Table,{className:t,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:l("Action display name"),render:f=>c(f)},{dataIndex:"onNewRecord",title:l("Action type"),render:f=>f?a.jsx(x.Tag,{color:"green",children:l("Action on new records")}):a.jsx(x.Tag,{color:"geekblue",children:l("Action on existing records")})},{dataIndex:"enabled",title:l("Allow"),render:(f,m)=>a.jsx(x.Checkbox,{checked:f,onChange:()=>{I(m.name)}})},{dataIndex:"scope",title:l("Data scope"),render:(f,m)=>!m.onNewRecord&&a.jsx(Mf,{value:f,onChange:v=>{$(m.name,v)}})}],dataSource:s==null?void 0:s.map(f=>{let m=!1,v=null;return u[f.name]&&(m=!0,f.onNewRecord||(v=u[f.name].scope)),N(A({},f),{enabled:m,scope:v})})})}),a.jsx(re.FormItem,{label:l("Field permission"),children:a.jsx(x.Table,{className:t,pagination:!1,dataSource:C,columns:[{dataIndex:["uiSchema","title"],title:l("Field display name"),render:(f,m)=>c(f)||m.name},...g.map(f=>{const m=S==null?void 0:S[f.name];return{dataIndex:f.name,title:a.jsxs(a.Fragment,{children:[a.jsx(x.Checkbox,{checked:m,onChange:()=>{var F;const v=u[f.name]||{name:f.name};m?v.fields=[]:v.fields=(F=i==null?void 0:i.map)==null?void 0:F.call(i,M=>M.name),u[f.name]=v,o(Object.values(u))}}),c(f.displayName)]}),render:(v,F)=>a.jsx(x.Checkbox,{checked:v,onChange:()=>{const M=u[f.name]||{name:f.name},O=M.fields||[];if(v){const k=O.indexOf(F.name);O.splice(k,1)}else O.push(F.name);M.fields=O,u[f.name]=M,o(Object.values(u))}})}})]})})]})})})}),kf={type:"object",properties:{[B.uid()]:{"x-component":"DataSourceTable"}}},ve=d.createContext({});ve.displayName="CurrentRolesContext";const Kf=({role:e})=>a.jsx(x.Card,{"data-testid":"acl-pane-card",bordered:!1,children:a.jsx(ve.Provider,{value:e,children:a.jsx(r.SchemaComponent,{components:{MenuConfigure:r.MenuConfigure,RoleConfigure:Tf,RolesResourcesActions:Ef,DataSourceTable:$f,StrategyActions:wf,SettingsCenterConfigure:r.SettingsCenterConfigure,SettingCenterProvider:r.SettingCenterProvider,ResourceActionProvider:r.ResourceActionProvider,RoleRecordProvider:Cf},schema:kf})})});class be extends r.Plugin{constructor(){super(...arguments);Wo(this,"types",new Map)}load(){return D(this,null,function*(){this.app.addComponents({DataSourcePermissionManager:Kf}),this.app.use(Xo),this.app.pluginSettingsManager.add(E,{title:`{{t("Data sources", { ns: "${E}" })}}`,icon:"ClusterOutlined",showTabs:!1,aclSnippet:"pm.database-connections.manager"}),this.app.pluginSettingsManager.add(`${E}.list`,{title:`{{t("Data sources", { ns: "${E}" })}}`,Component:qy,sort:1}),this.app.pluginSettingsManager.add(`${E}/:name`,{title:a.jsx(gt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100}),this.app.pluginSettingsManager.add(`${E}/main`,{title:a.jsx(gt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100}),this.app.pluginSettingsManager.add(`${E}/main.collections`,{title:`{{t("Collections", { ns: "${E}" })}}`,Component:gf,topLevelName:`${E}/main`,pluginKey:E}),this.app.pluginSettingsManager.add(`${E}/:name.collections`,{title:`{{t("Collections", { ns: "${E}" })}}`,Component:Ky,topLevelName:`${E}/:name`,pluginKey:E}),this.app.dataSourceManager.addDataSources(this.getThirdDataSource.bind(this),mt)})}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)}}j.PluginDataSourceManagerClient=be,j.default=be,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
50
+ `),Pf=(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}}]}),Df=()=>{const{name:e}=d.useContext(de),t=r.useFormBlockContext();return d.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},If=e=>{const t=Pf(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:d.useContext(de).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":Df,properties:{name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},scope:{type:"object",title:'{{t("Data scope")}}',name:"filter","x-decorator":"FormItem","x-component":"Filter","x-use-component-props":()=>{const o=d.useContext(de);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":"Action.Link","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":"Filter","x-use-component-props":()=>{const o=d.useContext(de);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":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}}}},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"}}}}}}}}}}}}},Uo=d.createContext(null);Uo.displayName="RolesResourcesScopesSelectedRowKeysContext";const Of=e=>{const[t,o]=d.useState([]);return a.jsx(Uo.Provider,{value:[t,o],children:e.children})},Mf=e=>{const t=d.useMemo(()=>me.createForm({values:{scope:e.value}}),[]),{key:o}=r.useRecord(),n=If(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Of},scope:{onChange(s){var i;(i=e==null?void 0:e.onChange)==null||i.call(e,s)}},schema:n})})},jf=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=J.isEmpty(n.scope)?null:n.scope)}),t},de=d.createContext({});de.displayName="RoleResourceCollectionContext";const Ef=T.connect(e=>{var b,h;const{styles:t}=_f(),o=f=>{const m=f.map(v=>N(A({},v),{scope:J.isEmpty(v.scope)?null:v.scope}));e.onChange(m)},n=r.useRecord(),s=qo(),i=n.fields,c=r.useCompile(),{t:l}=V.useTranslation(),p=T.useField(),u=jf(p.value||[]),y=(f,m)=>{var F;const v=u==null?void 0:u[f];return v?(F=v==null?void 0:v.fields)==null?void 0:F.includes(m):!1},g=s.filter(f=>f.allowConfigureFields),C=i==null?void 0:i.map(f=>{const m=A({},f);for(const v of g)m[v.name]=y(v.name,f.name);return m}),I=f=>{var m;u[f]?delete u[f]:u[f]={name:f,fields:(m=i==null?void 0:i.map)==null?void 0:m.call(i,v=>v.name)},o(Object.values(u))},$=(f,m)=>{u[f]?(u[f].scope=m,o(Object.values(u))):(I(f),u[f].scope=m,o(Object.values(u)))},S={};for(const f of g)S[f.name]=(i==null?void 0:i.length)===((h=(b=u==null?void 0:u[f.name])==null?void 0:b.fields)==null?void 0:h.length);return a.jsx("div",{children:a.jsx(de.Provider,{value:n,children:a.jsxs(re.FormLayout,{layout:"vertical",children:[a.jsx(re.FormItem,{label:l("Action permission"),children:a.jsx(x.Table,{className:t,size:"small",pagination:!1,columns:[{dataIndex:"displayName",title:l("Action display name"),render:f=>c(f)},{dataIndex:"onNewRecord",title:l("Action type"),render:f=>f?a.jsx(x.Tag,{color:"green",children:l("Action on new records")}):a.jsx(x.Tag,{color:"geekblue",children:l("Action on existing records")})},{dataIndex:"enabled",title:l("Allow"),render:(f,m)=>a.jsx(x.Checkbox,{checked:f,onChange:()=>{I(m.name)}})},{dataIndex:"scope",title:l("Data scope"),render:(f,m)=>!m.onNewRecord&&a.jsx(Mf,{value:f,onChange:v=>{$(m.name,v)}})}],dataSource:s==null?void 0:s.map(f=>{let m=!1,v=null;return u[f.name]&&(m=!0,f.onNewRecord||(v=u[f.name].scope)),N(A({},f),{enabled:m,scope:v})})})}),a.jsx(re.FormItem,{label:l("Field permission"),children:a.jsx(x.Table,{className:t,pagination:!1,dataSource:C,columns:[{dataIndex:["uiSchema","title"],title:l("Field display name"),render:(f,m)=>c(f)||m.name},...g.map(f=>{const m=S==null?void 0:S[f.name];return{dataIndex:f.name,title:a.jsxs(a.Fragment,{children:[a.jsx(x.Checkbox,{checked:m,onChange:()=>{var F;const v=u[f.name]||{name:f.name};m?v.fields=[]:v.fields=(F=i==null?void 0:i.map)==null?void 0:F.call(i,M=>M.name),u[f.name]=v,o(Object.values(u))}}),c(f.displayName)]}),render:(v,F)=>a.jsx(x.Checkbox,{checked:v,onChange:()=>{const M=u[f.name]||{name:f.name},O=M.fields||[];if(v){const k=O.indexOf(F.name);O.splice(k,1)}else O.push(F.name);M.fields=O,u[f.name]=M,o(Object.values(u))}})}})]})})]})})})}),kf={type:"object",properties:{[B.uid()]:{"x-component":"DataSourceTable"}}},ve=d.createContext({});ve.displayName="CurrentRolesContext";const Kf=({role:e})=>a.jsx(x.Card,{"data-testid":"acl-pane-card",bordered:!1,children:a.jsx(ve.Provider,{value:e,children:a.jsx(r.SchemaComponent,{components:{MenuConfigure:r.MenuConfigure,RoleConfigure:Tf,RolesResourcesActions:Ef,DataSourceTable:$f,StrategyActions:wf,SettingsCenterConfigure:r.SettingsCenterConfigure,SettingCenterProvider:r.SettingCenterProvider,ResourceActionProvider:r.ResourceActionProvider,RoleRecordProvider:Cf},schema:kf})})});class be extends r.Plugin{constructor(){super(...arguments);Wo(this,"types",new Map)}load(){return D(this,null,function*(){this.app.addComponents({DataSourcePermissionManager:Kf}),this.app.use(Xo),this.app.pluginSettingsManager.add(E,{title:`{{t("Data sources", { ns: "${E}" })}}`,icon:"ClusterOutlined",showTabs:!1,aclSnippet:"pm.data-source-manager*"}),this.app.pluginSettingsManager.add(`${E}.list`,{title:`{{t("Data sources", { ns: "${E}" })}}`,Component:qy,sort:1,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${E}/:name`,{title:a.jsx(gt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),this.app.pluginSettingsManager.add(`${E}/main`,{title:a.jsx(gt,{}),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${E}/main.collections`,{title:`{{t("Collections", { ns: "${E}" })}}`,Component:gf,topLevelName:`${E}/main`,pluginKey:E,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.pluginSettingsManager.add(`${E}/:name.collections`,{title:`{{t("Collections", { ns: "${E}" })}}`,Component:Ky,topLevelName:`${E}/:name`,pluginKey:E,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),this.app.dataSourceManager.addDataSources(this.getThirdDataSource.bind(this),mt)})}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)}}j.PluginDataSourceManagerClient=be,j.default=be,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.21.0-alpha.7",
2
+ "@nocobase/client": "0.21.0-alpha.8",
3
3
  "react": "18.2.0",
4
- "@nocobase/server": "0.21.0-alpha.7",
4
+ "@nocobase/server": "0.21.0-alpha.8",
5
5
  "lodash": "4.17.21",
6
6
  "@ant-design/icons": "5.2.6",
7
7
  "antd": "5.12.8",
@@ -10,10 +10,10 @@ module.exports = {
10
10
  "react-i18next": "11.18.6",
11
11
  "@formily/react": "2.3.0",
12
12
  "@emotion/css": "11.11.2",
13
- "@nocobase/database": "0.21.0-alpha.7",
14
- "@nocobase/utils": "0.21.0-alpha.7",
15
- "@nocobase/plugin-acl": "0.21.0-alpha.7",
16
- "@nocobase/acl": "0.21.0-alpha.7",
13
+ "@nocobase/database": "0.21.0-alpha.8",
14
+ "@nocobase/utils": "0.21.0-alpha.8",
15
+ "@nocobase/plugin-acl": "0.21.0-alpha.8",
16
+ "@nocobase/acl": "0.21.0-alpha.8",
17
17
  "sequelize": "6.35.2",
18
18
  "@formily/antd-v5": "1.1.9",
19
19
  "@formily/core": "2.3.0",
@@ -0,0 +1,6 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ on: string;
4
+ appVersion: string;
5
+ up(): Promise<void>;
6
+ }
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var update_snippet_name_exports = {};
19
+ __export(update_snippet_name_exports, {
20
+ default: () => update_snippet_name_default
21
+ });
22
+ module.exports = __toCommonJS(update_snippet_name_exports);
23
+ var import_server = require("@nocobase/server");
24
+ class update_snippet_name_default extends import_server.Migration {
25
+ on = "afterLoad";
26
+ // 'beforeLoad' or 'afterLoad'
27
+ appVersion = "<0.21.0-alpha.8";
28
+ async up() {
29
+ const roles = await this.db.getRepository("roles").find();
30
+ for (const role of roles) {
31
+ const snippets = await role.get("snippets");
32
+ let roleNeedsUpdate = false;
33
+ for (let i = 0; i < snippets.length; i++) {
34
+ if (snippets[i].includes("pm.database-connections.manager")) {
35
+ snippets[i] = snippets[i].replace("pm.database-connections.manager", "pm.data-source-manager");
36
+ roleNeedsUpdate = true;
37
+ }
38
+ }
39
+ if (roleNeedsUpdate) {
40
+ await this.db.getRepository("roles").update({
41
+ filter: {
42
+ name: role.get("name")
43
+ },
44
+ values: {
45
+ snippets: JSON.parse(JSON.stringify(snippets))
46
+ }
47
+ });
48
+ }
49
+ }
50
+ }
51
+ }
@@ -131,6 +131,9 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
131
131
  dataPath = "body.data";
132
132
  }
133
133
  const items = import_lodash.default.get(ctx, dataPath);
134
+ if (!Array.isArray(items)) {
135
+ return;
136
+ }
134
137
  import_lodash.default.set(
135
138
  ctx,
136
139
  dataPath,
@@ -343,6 +346,16 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
343
346
  acl: dataSource.acl,
344
347
  transaction
345
348
  });
349
+ await this.app.db.getRepository("roles").update({
350
+ filter: {
351
+ name: model.get("roleName")
352
+ },
353
+ values: {
354
+ strategy: model.get("strategy")
355
+ },
356
+ hooks: false,
357
+ transaction
358
+ });
346
359
  });
347
360
  this.app.on("acl:writeResources", async ({ roleName, transaction }) => {
348
361
  const dataSource = this.app.dataSourceManager.dataSources.get("main");
@@ -398,17 +411,12 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
398
411
  }
399
412
  });
400
413
  this.app.acl.registerSnippet({
401
- name: `pm.${this.name}`,
414
+ name: `pm.data-source-manager`,
402
415
  actions: [
403
416
  "dataSources:*",
404
417
  "dataSources.collections:*",
405
418
  "dataSourcesCollections.fields:*",
406
- "roles.dataSourceResources",
407
- "collections:*",
408
- "collections.fields:*",
409
- "dbViews:*",
410
- "collectionCategories:*",
411
- "sqlCollection:*"
419
+ "roles.dataSourceResources"
412
420
  ]
413
421
  });
414
422
  this.app.acl.allow("dataSources", "listEnabled", "loggedIn");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "0.21.0-alpha.7",
3
+ "version": "0.21.0-alpha.8",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Data source manager",
6
6
  "displayName.zh-CN": "数据源管理",
@@ -16,5 +16,5 @@
16
16
  "keywords": [
17
17
  "Data model tools"
18
18
  ],
19
- "gitHead": "b1be3993f8aa81173d01bc390aa8e4c5adcc0e2d"
19
+ "gitHead": "bed69485709bc8e268285b50debfc1ebfd7a30c7"
20
20
  }