@nocobase/plugin-data-source-manager 1.4.10 → 1.4.11

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.
@@ -48,7 +48,7 @@
48
48
  color: rgba(0, 0, 0, 0.25) !important;
49
49
  }
50
50
  }
51
- `,children:a.jsx(v.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:()=>{t(tf(e))},role:"button","aria-label":`${e==null?void 0:e.key}-Configure`,children:o("Configure")})})},nf=()=>{const{t:e}=j.useTranslation(),t=r.usePlugin(ie),o=[...t.types.keys()].map(g=>{const f=t.types.get(g);return{value:g,label:e(f==null?void 0:f.label)}}).concat([{value:"main",label:e("Main")}]),n=r.useDataSourceManager(),i=d.useRef([]);d.useEffect(()=>()=>{n.getDataSources().forEach(g=>{i.current.includes(g.key)&&g.reload()})},[i]);const s=d.useCallback(g=>{n.removeDataSources(g)},[n]),c=d.useCallback(g=>{n.addDataSource(ht,g),i.current=[...i.current,g.key]},[]),l=()=>{const g=r.useResourceActionContext();return{onClick(){return D(this,null,function*(){var w,T;const b=(w=g==null?void 0:g.data)==null?void 0:w.data.filter($=>$.status!=="loaded");if(b!=null&&b.length){const $=n.getDataSources(),x=b.map(h=>h.key),m=$.filter(h=>x.includes(h.key));yield Promise.all(m.map(h=>h.reload()))}(T=g==null?void 0:g.refresh)==null||T.call(g)})}}},y=()=>{const{refresh:g}=r.useResourceActionContext(),{resource:f}=r.useResourceContext(),{key:b}=r.useRecord();return{run(){return D(this,null,function*(){yield f.destroy({filterByTk:b}),s([b]),g()})}}},u=g=>{const{key:f}=r.useRecord();g.visible=f!=="main"};return a.jsx(v.Card,{bordered:!1,children:a.jsx(r.SchemaComponent,{components:{CreateDatabaseConnectAction:Ry,EditDatabaseConnectionAction:ef,ViewDatabaseConnectionAction:of},scope:{useNewId:g=>`${g}${V.uid()}`,types:o,useRefreshActionProps:l,useDestroyAction:y,dataSourceDeleteCallback:s,dataSourceCreateCallback:c,useIsAbleDelete:u},schema:cn})})},qo=e=>_.Schema.compile(e,{t:r.i18n.t}),rf={type:"object",properties:{block1:{type:"void","x-collection":"collections","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"collections",filterTargetKey:"name",targetKey:"name",sortable:!0,fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{ t("Collection display name") }}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Collection name") }}',type:"string","x-component":"Input",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'}},{type:"string",name:"template",interface:"input",uiSchema:{title:'{{ t("Collection Template") }}',type:"string","x-component":"Input"}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}},{type:"hasMany",name:"inherits",interface:"select",uiSchema:{title:'{{ t("Inherits") }}',type:"string","x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input"}}]},dragSort:!0,request:{resource:"collections",action:"list",params:{pageSize:50,sort:"sort",filter:{"hidden.$isFalsy":!0},appends:["category"]}}},properties:{tabs:{type:"void","x-component":"ConfigurationTabs"}}}}},Go={type:"object",properties:{[V.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button",isBulk:!0}},create:{type:"void",title:'{{ t("Create collection") }}',"x-component":"AddCollection","x-component-props":{type:"primary"}}}},[V.uid()]:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=r.useAPIClient(),{t}=j.useTranslation();return{move(n,i){return D(this,null,function*(){yield e.resource("collections").move({sourceId:n.name,targetId:i.name}),v.message.success(t("Saved successfully"),.2)})}}}},properties:{column1:{type:"void",title:'{{t("Collection display name")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{"x-component":Tt,"x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Collection template")}}',properties:{template:{"x-component":r.CollectionTemplateTag,"x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-visible":"categoryVisible",title:'{{t("Collection category")}}',properties:{category:{"x-component":r.CollectionCategory,"x-read-pretty":!0}}},column5:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{"x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column6:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("Configure fields") }}',"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{destroyOnClose:!0,width:"70%"},"x-reactions":e=>{const t=e.path.segments[1],o=e.path.segments[0],n=e.form.getValuesIn(`${o}.${t}`);n&&(e.title=`${qo(n.title)} - ${qo('{{ t("Configure fields") }}')}`)},properties:{collectionFieldSchema:{type:"void","x-component":"CollectionFields"}}}}},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"EditCollection","x-component-props":{role:"button","aria-label":'{{ "edit-button-" + $record.name }}',type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button","aria-label":'{{ "delete-button-" + $record.name }}',type:"primary",className:"nb-action-link"}}}}}}}}}},af={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateCategry }}",style:{marginLeft:"8px"}}}}}}}}},sf={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},cf=(e,t)=>(o,n)=>{o.loading=!0,e(o,n,t).then(ft.action.bound(i=>{o.dataSource=i,o.loading=!1})).catch(console.error)},lf=()=>{const[e,t]=d.useState([]);return[e,t]},uf=()=>{const e=r.useRecord(),t=_.useForm();return{run(){return D(this,null,function*(){var i,s,c;const n=(c=(s=(i=t.values)==null?void 0:i.children)==null?void 0:s.slice)==null?void 0:c.call(s);t.setValuesIn("children",n.filter(l=>l.name!==e.name))})}}},pf=()=>({run(){return D(this,null,function*(){})}}),df=()=>{const e=r.useRecord(),{getCollectionFields:t}=r.useCollectionManager_deprecated();return e.__parent&&e.__parent.interface==="subTable"?d.useContext(r.DataSourceContext_deprecated).dataSource:t(e.collectionName||e.name)},mf=e=>`${e||""}${V.uid()}`,yf=()=>{const{t:e}=j.useTranslation(),{interfaces:t,getCollections:o,getCollection:n}=r.useCollectionManager_deprecated(),{data:{database:i}}=r.useCurrentAppInfo(),s=d.useContext(r.CollectionCategoriesContext),c=r.useAPIClient(),l=c.resource("dbViews"),y=r.useCompile();_.useForm();const u=r.useApp(),g=(x,m,h)=>D(this,null,function*(){var E;const{targetScope:p}=m,C=((E=x.props)==null?void 0:E.name)==="inherits";return o().filter(I=>{var F;if(h!=null&&h.includes(I.template)||I.autoCreate&&I.isThrough||C&&I.template==="view"||x.props.name==="target"&&Array.isArray(I.filterTargetKey)&&I.filterTargetKey.length>1)return!1;const B=!(p!=null&&p.template)||p.template.includes(I.template),S=!(p!=null&&p[(F=x.props)==null?void 0:F.name])||p[x.props.name].includes(I.name);return B&&S}).map(I=>({label:y(I.title),value:I.name}))}),f=()=>D(this,null,function*(){return s.data.map(x=>({label:y(x.name),value:x.id}))}),b=()=>D(this,null,function*(){return l.list().then(({data:x})=>{var m;return(m=x==null?void 0:x.data)==null?void 0:m.map(h=>{const p=h.schema;return{label:p?`${p}.${y(h.name)}`:h.name,value:p?`${p}_${h.name}`:h.name}})})}),w=x=>D(this,null,function*(){const{name:m,fields:h}=x.form.values,{fields:p}=n(m)||{};return Promise.resolve({data:p||h}).then(({data:C})=>{var P;return(P=C.filter(E=>E.interface?!!u.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(E.interface).titleUsable:!1))==null?void 0:P.map(E=>{var I;return{label:y((I=E.uiSchema)==null?void 0:I.title)||E.name,value:E.name}})})}),T=()=>D(this,null,function*(){return c.resource("storages").list().then(({data:x})=>{var m;return(m=x==null?void 0:x.data)==null?void 0:m.map(h=>({label:e(y(h.title)),value:h.name}))})}),$=d.useContext(r.SchemaComponentContext);return a.jsx(r.SchemaComponentContext.Provider,{value:K(A({},$),{designable:!1}),children:a.jsx(r.SchemaComponent,{schema:rf,components:{AddSubFieldAction:r.AddSubFieldAction,EditSubFieldAction:r.EditSubFieldAction,FieldSummary:r.FieldSummary,TemplateSummay:r.TemplateSummary,CollectionFields:At},scope:{loadFilterTargetKeys:w,useDestroySubField:uf,useBulkDestroySubField:pf,useSelectedRowKeys:lf,useAsyncDataSource:cf,loadCollections:g,loadCategories:f,loadDBViews:b,loadStorages:T,useCurrentFields:df,useNewId:mf,useCancelAction:r.useCancelAction,interfaces:t,enableInherits:(i==null?void 0:i.dialect)==="postgres",isPG:(i==null?void 0:i.dialect)==="postgres",getPickerFormat:oe.getPickerFormat}})})};function ff(e){const{attributes:t,listeners:o,setNodeRef:n}=J.useDraggable({id:e.id,data:e.data});return a.jsx("div",K(A(A({ref:n},o),t),{children:a.jsx("div",{children:e.children})}))}function gf(e){const{isOver:t,setNodeRef:o}=J.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return a.jsx("div",{ref:o,style:n,children:e.children})}const hf=_.observer(({item:e})=>a.jsx(gf,{id:e.id.toString(),data:e,children:a.jsx("div",{children:a.jsx(ff,{id:e.id.toString(),data:e,children:a.jsx(Uo,{item:e})})})}),{displayName:"TabTitle"}),Uo=({item:e})=>{const{t}=j.useTranslation(),o=r.useCompile();return a.jsxs(v.Space,{children:[a.jsx(v.Badge,{color:e.color}),t(o(e.name))]})},Cf=_.observer(e=>{const[t,o]=d.useState(null),{refresh:n}=d.useContext(r.CollectionCategoriesContext),{refresh:i}=r.useResourceActionContext(),s=r.useAPIClient(),c=g=>D(this,null,function*(){const{active:f,over:b}=g;setTimeout(()=>{o(null)}),b&&b.id!==f.id&&(yield s.resource("collectionCategories").move({sourceId:f.id,targetId:b.id}),yield n(),yield i())});function l(g){var f;o((f=g.active)==null?void 0:f.data.current)}const y=J.useSensor(J.MouseSensor,{activationConstraint:{distance:10}}),u=J.useSensors(y);return a.jsxs(J.DndContext,{sensors:u,onDragEnd:c,onDragStart:l,children:[e.children,a.jsx(J.DragOverlay,{children:t?a.jsx("span",{style:{whiteSpace:"nowrap"},children:a.jsx(Uo,{item:t})}):null})]})},{displayName:"DndProvider"}),vf=()=>{const{t:e}=j.useTranslation(),{data:t,refresh:o}=d.useContext(r.CollectionCategoriesContext),{refresh:n,run:i,defaultRequest:s,setState:c}=r.useResourceActionContext(),[l,y]=d.useState({tab:"all"}),[u,g]=d.useState(l.tab),f=r.useCompile(),b=r.useAPIClient(),{modal:w}=v.App.useApp(),T=d.useMemo(()=>{if(!t)return[];const p=t.sort((C,P)=>P.sort-C.sort).concat().map(C=>K(A({},C),{schema:Go}));return!p.find(C=>C.id==="all")&&p.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Go}),p},[t]);d.useEffect(()=>{l.tab!=="all"&&$(l.tab)},[]);const $=p=>{var C;if(y({tab:p}),g(V.uid()),p!=="all"){const E={$and:[(C=s==null?void 0:s.params)==null?void 0:C.filter,{"category.id":p}]};i({filter:E}),c==null||c({category:[+p],params:[{filter:E}]})}else i(),c==null||c({category:[],params:[]})},x=p=>{w.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>D(this,null,function*(){yield b.resource("collectionCategories").destroy({filter:{id:p}}),p===+l.tab&&y({tab:"all"}),yield o(),yield n()})})},m=()=>D(this,null,function*(){return t.map(p=>({label:e(f(p.name)),value:p.id}))}),h=Y.memoize(p=>({items:[{key:"edit",label:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{[V.uid()]:{"x-component":"EditCategory","x-component-props":{item:p}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>x(p.id)}]}));return t?a.jsx(Cf,{children:a.jsx(v.Tabs,{addIcon:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:$,defaultActiveKey:l.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:T.map(p=>({label:p.id!=="all"?a.jsx("div",{"data-no-dnd":"true",children:a.jsx(hf,{item:p})}):f(p.name),key:String(p.id),closable:p.closable,closeIcon:a.jsx(v.Dropdown,{menu:h(p),children:a.jsx(Q.MenuOutlined,{role:"button","aria-label":f(p.name),style:{padding:8,margin:"-8px"}})}),children:a.jsx(v.Card,{bordered:!1,children:a.jsx(r.SchemaComponentOptions,{components:{CollectionFields:At},inherit:!0,scope:{loadCategories:m,categoryVisible:p.id==="all",categoryId:p.id},children:a.jsx(_.RecursionField,{name:u,schema:p.schema,onlyRenderProperties:!0})})})}))})}):null},bf=()=>{const e=_.useForm(),t=r.useActionContext(),{refresh:o}=d.useContext(r.CollectionCategoriesContext),n=r.useAPIClient();return{run(){return D(this,null,function*(){yield e.submit();const s=Y.cloneDeep(e.values);yield n.resource("collectionCategories").create({values:A({},s)}),t.setVisible(!1),yield e.reset(),yield o()})}}},xf=e=>a.jsx(zo,A({},e)),zo=e=>{const{scope:t,getContainer:o,children:n}=e,[i,s]=d.useState(!1),{t:c}=j.useTranslation();return a.jsxs(r.ActionContextProvider,{value:{visible:i,setVisible:s},children:[a.jsx("div",{onClick:()=>s(!0),title:c("Add category"),children:n||a.jsx(Q.PlusOutlined,{})}),a.jsx(r.SchemaComponent,{schema:af,components:{CollectionCategory:r.CollectionCategory,CollectionTemplateTag:r.CollectionTemplateTag},scope:A({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useCreateCategry:bf},t)})]})},Sf=()=>{const e=_.useForm(),t=r.useActionContext(),{refresh:o}=d.useContext(r.CollectionCategoriesContext),{refresh:n}=r.useResourceActionContext(),i=r.useAPIClient(),{id:s}=r.useRecord();return{run(){return D(this,null,function*(){yield e.submit();const l=Y.cloneDeep(e.values);yield i.resource("collectionCategories").update({filter:{id:s},values:A({},l)}),t.setVisible(!1),yield e.reset(),yield o(),yield n()})}}},Af=e=>{const t=r.useRecord(),o=r.useRequest(()=>Promise.resolve({data:Y.cloneDeep(t)}),K(A({},e),{manual:!0})),n=r.useActionContext();return d.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},$f=e=>a.jsx(Ho,A({},e)),Ho=e=>{const{scope:t,getContainer:o,item:n,children:i}=e,[s,c]=d.useState(!1),l=r.useCompile();return a.jsx(r.RecordProvider,{record:n,children:a.jsxs(r.ActionContextProvider,{value:{visible:s,setVisible:c},children:[a.jsx(a.Fragment,{children:i||a.jsx("span",{onClick:()=>c(!0),children:l('{{ t("Edit category") }}')})}),a.jsx(r.SchemaComponent,{schema:sf,scope:A({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useEditCategry:Sf,useValuesFromRecord:Af},t)})]})})};Ce.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const Tf={type:"object",properties:{[V.uid()]:{"x-component":"ConfigurationTable"}}},Ff=()=>a.jsx(r.SchemaComponent,{schema:Tf,components:{CollectionCategoriesProvider:r.CollectionCategoriesProvider,ConfigurationTable:yf,ConfigurationTabs:vf,AddFieldAction:r.AddFieldAction,AddCollectionField:r.AddCollectionField,AddCollection:r.AddCollection,AddCollectionAction:r.AddCollectionAction,AddCategoryAction:zo,AddCategory:xf,EditCollection:r.EditCollection,EditCollectionAction:r.EditCollectionAction,DeleteCollection:r.DeleteCollection,DeleteCollectionAction:r.DeleteCollectionAction,EditFieldAction:r.EditFieldAction,EditCollectionField:r.EditCollectionField,OverridingCollectionField:r.OverridingCollectionField,OverridingFieldAction:r.OverridingFieldAction,ViewCollectionField:r.ViewCollectionField,ViewFieldAction:r.ViewFieldAction,EditCategory:$f,EditCategoryAction:Ho,SyncFieldsAction:r.SyncFieldsAction,SyncFieldsActionCom:r.SyncFieldsActionCom,SyncSQLFieldsAction:r.SyncSQLFieldsAction}}),Se=d.createContext(null);Se.displayName="PermissionContext";const wf=e=>{const t=r.useAPIClient(),o=r.useRecord(),{t:n}=j.useTranslation(),i=d.useContext(Ae),{snippets:s}=i;s==null||s.forEach(y=>{i[y]=!0});const[c,l]=d.useState(i);return d.useEffect(()=>{l(i)},[i]),a.jsx(Se.Provider,{value:{currentDataSource:o,currentRecord:c,update:(y,u)=>D(this,null,function*(){yield t.request({url:`dataSources/${o.key}/roles:update`,data:u.values,method:"post",params:{filterByTk:u.values.roleName}}),l(A(A({},c),u.values)),v.message.success(n("Saved successfully"))})},children:e.children})},_f=e=>{const t=d.useContext(Ae),o=r.useRecord();return a.jsx(r.RecordContext_deprecated.Provider,{value:A({},t),children:a.jsx(r.SchemaComponentOptions,{scope:{dataSourceKey:o.key},children:e.children})})},Pf=e=>{const t=r.useRecord(),{visible:o}=r.useActionContext(),{currentDataSource:n}=d.useContext(Se),i=r.useRequest({resource:"roles.dataSourceResources",resourceOf:t.roleName,action:"get",params:{appends:["actions","actions.scope"],filterByTk:t.name,filter:{dataSourceKey:n.key,name:t.name}}},K(A({},e),{manual:!0}));return d.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}o&&i.run()},[o,t.exists]),i},Df=()=>{const e=_.useForm(),t=r.useAPIClient(),o=r.useRecord(),n=r.useActionContext(),{refresh:i}=r.useResourceActionContext(),{currentDataSource:s}=d.useContext(Se);return{run(){return D(this,null,function*(){yield t.resource("roles.dataSourceResources",o.roleName)[o.exists?"update":"create"]({filterByTk:o.name,filter:{dataSourceKey:s.key,name:o.name},values:K(A({},e.values),{name:o.name,dataSourceKey:s.key})}),n.setVisible(!1),i()})}}},If={type:"void","x-decorator":"RoleRecordProvider",properties:{block:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"dataSourcesCollections",targetKey:"name",filterTargetKey:"name",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Collection display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Collection name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Resource type")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Collection")}}',value:"collection",color:"green"},{label:'{{t("Association")}}',value:"association",color:"blue"}]}},{type:"string",name:"usingConfig",interface:"input",uiSchema:{title:'{{t("Permission policy")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Individual")}}',value:"resourceAction",color:"orange"},{label:'{{t("General")}}',value:"strategy",color:"default"}]}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}}]},association:{sourceKey:"name",targetKey:"name"},resourceName:"roles.dataSourcesCollections",request:{resource:"roles.dataSourcesCollections",action:"list",params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:"{{dataSourceKey}}"},sort:["sort"],appends:["fields"]}}},properties:{[V.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table1:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column0:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{usingConfig:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:Pf},title:'{{t("Configure permission")}}',properties:{usingActionsConfig:{title:'{{t("Permission policy")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:!1,enum:[{value:!1,label:'{{t("General")}}'},{value:!0,label:'{{t("Individual")}}'}],"x-reactions":{target:"actions",fulfill:{state:{hidden:"{{!$self.value}}"}}}},actions:{"x-component":"RolesResourcesActions","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:Df}}}}}}}}}}}}}}}}}},Wo={name:"dataSources",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"number","x-component":"Input",required:!0}}]},Of=(e={})=>({type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Wo,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,showAnonymous:!0,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Wo},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"PermissionProvider",title:'{{t("Configure permissions")}}',properties:{tabs1:{type:"void","x-component":"Tabs","x-component-props":{},properties:A({tab1:{type:"void",title:'{{t("General action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{role:{"x-component":"RoleConfigure"}}},tab2:{type:"void",title:'{{t("Action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{roleCollectionsSchema:If}}},e)}}}}}}}}}}}}}}}),pt=d.createContext([]);pt.displayName="AvailableActionsContext";const Mf=e=>{const{data:t,loading:o}=r.useRequest({resource:"availableActions",action:"list"});return o?a.jsx(v.Spin,{}):a.jsx(pt.Provider,{value:t==null?void 0:t.data,children:e.children})},Qo=()=>d.useContext(pt),kf=()=>{const e=r.useRecord(),t=r.usePlugin(ie);return a.jsx("div",{children:a.jsx(r.SchemaComponentContext.Provider,{value:{designable:!1},children:a.jsx(Mf,{children:a.jsx(r.SchemaComponent,{schema:Of(t.getExtendedTabs()),components:{SettingCenterPermissionProvider:r.SettingCenterPermissionProvider,PermissionProvider:wf},scope:{dataSourceKey:e.key}})})})})},Ef=()=>{const{update:e}=d.useContext(Se),{t}=j.useTranslation(),{key:o}=r.useRecord();return a.jsx(r.SchemaComponent,{schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:n=>{const i=r.useAPIClient(),s=d.useContext(Ae);return r.useRequest(()=>i.resource(`dataSources/${o}/roles`).get({filterByTk:s.name}).then(c=>{var y,u;const l=(y=c==null?void 0:c.data)==null?void 0:y.data;return(u=l.snippets)==null||u.forEach(g=>{l[g]=!0}),{data:l}}),n)},effects(){Ce.onFieldChange("*",(n,i)=>D(this,null,function*(){i.modified&&(yield e(n,i))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},jf=tn.createStyles(({css:e})=>e`
51
+ `,children:a.jsx(v.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:()=>{t(tf(e))},role:"button","aria-label":`${e==null?void 0:e.key}-Configure`,children:o("Configure")})})},nf=()=>{const{t:e}=j.useTranslation(),t=r.usePlugin(ie),o=[...t.types.keys()].map(g=>{const f=t.types.get(g);return{value:g,label:e(f==null?void 0:f.label)}}).concat([{value:"main",label:e("Main")}]),n=r.useDataSourceManager(),i=d.useRef([]);d.useEffect(()=>()=>{n.getDataSources().forEach(g=>{i.current.includes(g.key)&&g.reload()})},[i]);const s=d.useCallback(g=>{n.removeDataSources(g)},[n]),c=d.useCallback(g=>{n.addDataSource(ht,g),i.current=[...i.current,g.key]},[]),l=()=>{const g=r.useResourceActionContext();return{onClick(){return D(this,null,function*(){var w,T;const b=(w=g==null?void 0:g.data)==null?void 0:w.data.filter($=>$.status!=="loaded");if(b!=null&&b.length){const $=n.getDataSources(),x=b.map(h=>h.key),m=$.filter(h=>x.includes(h.key));yield Promise.all(m.map(h=>h.reload()))}(T=g==null?void 0:g.refresh)==null||T.call(g)})}}},y=()=>{const{refresh:g}=r.useResourceActionContext(),{resource:f}=r.useResourceContext(),{key:b}=r.useRecord();return{run(){return D(this,null,function*(){yield f.destroy({filterByTk:b}),s([b]),g()})}}},u=g=>{const{key:f}=r.useRecord();g.visible=f!=="main"};return a.jsx(v.Card,{bordered:!1,children:a.jsx(r.SchemaComponent,{components:{CreateDatabaseConnectAction:Ry,EditDatabaseConnectionAction:ef,ViewDatabaseConnectionAction:of},scope:{useNewId:g=>`${g}${V.uid()}`,types:o,useRefreshActionProps:l,useDestroyAction:y,dataSourceDeleteCallback:s,dataSourceCreateCallback:c,useIsAbleDelete:u},schema:cn})})},qo=e=>_.Schema.compile(e,{t:r.i18n.t}),rf={type:"object",properties:{block1:{type:"void","x-collection":"collections","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"collections",filterTargetKey:"name",targetKey:"name",sortable:!0,fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{ t("Collection display name") }}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Collection name") }}',type:"string","x-component":"Input",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'}},{type:"string",name:"template",interface:"input",uiSchema:{title:'{{ t("Collection Template") }}',type:"string","x-component":"Input"}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}},{type:"hasMany",name:"inherits",interface:"select",uiSchema:{title:'{{ t("Inherits") }}',type:"string","x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input"}}]},dragSort:!0,request:{resource:"collections",action:"list",params:{pageSize:50,sort:"sort",filter:{"hidden.$isFalsy":!0},appends:["category"]}}},properties:{tabs:{type:"void","x-component":"ConfigurationTabs"}}}}},Go={type:"object",properties:{[V.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button",isBulk:!0}},create:{type:"void",title:'{{ t("Create collection") }}',"x-component":"AddCollection","x-component-props":{type:"primary"}}}},[V.uid()]:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=r.useAPIClient(),{t}=j.useTranslation();return{move(n,i){return D(this,null,function*(){yield e.resource("collections").move({sourceId:n.name,targetId:i.name}),v.message.success(t("Saved successfully"),.2)})}}}},properties:{column1:{type:"void",title:'{{t("Collection display name")}}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{"x-component":Tt,"x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Collection template")}}',properties:{template:{"x-component":r.CollectionTemplateTag,"x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-visible":"categoryVisible",title:'{{t("Collection category")}}',properties:{category:{"x-component":r.CollectionCategory,"x-read-pretty":!0}}},column5:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{"x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column6:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("Configure fields") }}',"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{destroyOnClose:!0,width:"70%"},"x-reactions":e=>{const t=e.path.segments[1],o=e.path.segments[0],n=e.form.getValuesIn(`${o}.${t}`);n&&(e.title=`${qo(n.title)} - ${qo('{{ t("Configure fields") }}')}`)},properties:{collectionFieldSchema:{type:"void","x-component":"CollectionFields"}}}}},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"EditCollection","x-component-props":{role:"button","aria-label":'{{ "edit-button-" + $record.name }}',type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button","aria-label":'{{ "delete-button-" + $record.name }}',type:"primary",className:"nb-action-link"}}}}}}}}}},af={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateCategry }}",style:{marginLeft:"8px"}}}}}}}}},sf={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},cf=(e,t)=>(o,n)=>{o.loading=!0,e(o,n,t).then(ft.action.bound(i=>{o.dataSource=i,o.loading=!1})).catch(console.error)},lf=()=>{const[e,t]=d.useState([]);return[e,t]},uf=()=>{const e=r.useRecord(),t=_.useForm();return{run(){return D(this,null,function*(){var i,s,c;const n=(c=(s=(i=t.values)==null?void 0:i.children)==null?void 0:s.slice)==null?void 0:c.call(s);t.setValuesIn("children",n.filter(l=>l.name!==e.name))})}}},pf=()=>({run(){return D(this,null,function*(){})}}),df=()=>{const e=r.useRecord(),{getCollectionFields:t}=r.useCollectionManager_deprecated();return e.__parent&&e.__parent.interface==="subTable"?d.useContext(r.DataSourceContext_deprecated).dataSource:t(e.collectionName||e.name)},mf=e=>`${e||""}${V.uid()}`,yf=()=>{const{t:e}=j.useTranslation(),{interfaces:t,getCollections:o,getCollection:n}=r.useCollectionManager_deprecated(),{data:{database:i}}=r.useCurrentAppInfo(),s=d.useContext(r.CollectionCategoriesContext),c=r.useAPIClient(),l=c.resource("dbViews"),y=r.useCompile();_.useForm();const u=r.useApp(),g=(x,m,h)=>D(this,null,function*(){var E;const{targetScope:p}=m,C=((E=x.props)==null?void 0:E.name)==="inherits";return o().filter(I=>{var F;if(h!=null&&h.includes(I.template)||I.autoCreate&&I.isThrough||C&&I.template==="view"||x.props.name==="target"&&Array.isArray(I.filterTargetKey)&&I.filterTargetKey.length>1)return!1;const B=!(p!=null&&p.template)||p.template.includes(I.template),S=!(p!=null&&p[(F=x.props)==null?void 0:F.name])||p[x.props.name].includes(I.name);return B&&S}).map(I=>({label:y(I.title),value:I.name}))}),f=()=>D(this,null,function*(){return s.data.map(x=>({label:y(x.name),value:x.id}))}),b=()=>D(this,null,function*(){return l.list().then(({data:x})=>{var m;return(m=x==null?void 0:x.data)==null?void 0:m.map(h=>{const p=h.schema;return{label:p?`${p}.${y(h.name)}`:h.name,value:p?`${p}@${h.name}`:h.name}})})}),w=x=>D(this,null,function*(){const{name:m,fields:h}=x.form.values,{fields:p}=n(m)||{};return Promise.resolve({data:p||h}).then(({data:C})=>{var P;return(P=C.filter(E=>E.interface?!!u.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(E.interface).titleUsable:!1))==null?void 0:P.map(E=>{var I;return{label:y((I=E.uiSchema)==null?void 0:I.title)||E.name,value:E.name}})})}),T=()=>D(this,null,function*(){return c.resource("storages").list().then(({data:x})=>{var m;return(m=x==null?void 0:x.data)==null?void 0:m.map(h=>({label:e(y(h.title)),value:h.name}))})}),$=d.useContext(r.SchemaComponentContext);return a.jsx(r.SchemaComponentContext.Provider,{value:K(A({},$),{designable:!1}),children:a.jsx(r.SchemaComponent,{schema:rf,components:{AddSubFieldAction:r.AddSubFieldAction,EditSubFieldAction:r.EditSubFieldAction,FieldSummary:r.FieldSummary,TemplateSummay:r.TemplateSummary,CollectionFields:At},scope:{loadFilterTargetKeys:w,useDestroySubField:uf,useBulkDestroySubField:pf,useSelectedRowKeys:lf,useAsyncDataSource:cf,loadCollections:g,loadCategories:f,loadDBViews:b,loadStorages:T,useCurrentFields:df,useNewId:mf,useCancelAction:r.useCancelAction,interfaces:t,enableInherits:(i==null?void 0:i.dialect)==="postgres",isPG:(i==null?void 0:i.dialect)==="postgres",getPickerFormat:oe.getPickerFormat}})})};function ff(e){const{attributes:t,listeners:o,setNodeRef:n}=J.useDraggable({id:e.id,data:e.data});return a.jsx("div",K(A(A({ref:n},o),t),{children:a.jsx("div",{children:e.children})}))}function gf(e){const{isOver:t,setNodeRef:o}=J.useDroppable({id:e.id,data:e.data}),n=t?{color:"green"}:void 0;return a.jsx("div",{ref:o,style:n,children:e.children})}const hf=_.observer(({item:e})=>a.jsx(gf,{id:e.id.toString(),data:e,children:a.jsx("div",{children:a.jsx(ff,{id:e.id.toString(),data:e,children:a.jsx(Uo,{item:e})})})}),{displayName:"TabTitle"}),Uo=({item:e})=>{const{t}=j.useTranslation(),o=r.useCompile();return a.jsxs(v.Space,{children:[a.jsx(v.Badge,{color:e.color}),t(o(e.name))]})},Cf=_.observer(e=>{const[t,o]=d.useState(null),{refresh:n}=d.useContext(r.CollectionCategoriesContext),{refresh:i}=r.useResourceActionContext(),s=r.useAPIClient(),c=g=>D(this,null,function*(){const{active:f,over:b}=g;setTimeout(()=>{o(null)}),b&&b.id!==f.id&&(yield s.resource("collectionCategories").move({sourceId:f.id,targetId:b.id}),yield n(),yield i())});function l(g){var f;o((f=g.active)==null?void 0:f.data.current)}const y=J.useSensor(J.MouseSensor,{activationConstraint:{distance:10}}),u=J.useSensors(y);return a.jsxs(J.DndContext,{sensors:u,onDragEnd:c,onDragStart:l,children:[e.children,a.jsx(J.DragOverlay,{children:t?a.jsx("span",{style:{whiteSpace:"nowrap"},children:a.jsx(Uo,{item:t})}):null})]})},{displayName:"DndProvider"}),vf=()=>{const{t:e}=j.useTranslation(),{data:t,refresh:o}=d.useContext(r.CollectionCategoriesContext),{refresh:n,run:i,defaultRequest:s,setState:c}=r.useResourceActionContext(),[l,y]=d.useState({tab:"all"}),[u,g]=d.useState(l.tab),f=r.useCompile(),b=r.useAPIClient(),{modal:w}=v.App.useApp(),T=d.useMemo(()=>{if(!t)return[];const p=t.sort((C,P)=>P.sort-C.sort).concat().map(C=>K(A({},C),{schema:Go}));return!p.find(C=>C.id==="all")&&p.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Go}),p},[t]);d.useEffect(()=>{l.tab!=="all"&&$(l.tab)},[]);const $=p=>{var C;if(y({tab:p}),g(V.uid()),p!=="all"){const E={$and:[(C=s==null?void 0:s.params)==null?void 0:C.filter,{"category.id":p}]};i({filter:E}),c==null||c({category:[+p],params:[{filter:E}]})}else i(),c==null||c({category:[],params:[]})},x=p=>{w.confirm({title:f("{{t('Delete category')}}"),content:f("{{t('Are you sure you want to delete it?')}}"),onOk:()=>D(this,null,function*(){yield b.resource("collectionCategories").destroy({filter:{id:p}}),p===+l.tab&&y({tab:"all"}),yield o(),yield n()})})},m=()=>D(this,null,function*(){return t.map(p=>({label:e(f(p.name)),value:p.id}))}),h=Y.memoize(p=>({items:[{key:"edit",label:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{[V.uid()]:{"x-component":"EditCategory","x-component-props":{item:p}}}}})},{key:"delete",label:f("{{t('Delete category')}}"),onClick:()=>x(p.id)}]}));return t?a.jsx(Cf,{children:a.jsx(v.Tabs,{addIcon:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:$,defaultActiveKey:l.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:T.map(p=>({label:p.id!=="all"?a.jsx("div",{"data-no-dnd":"true",children:a.jsx(hf,{item:p})}):f(p.name),key:String(p.id),closable:p.closable,closeIcon:a.jsx(v.Dropdown,{menu:h(p),children:a.jsx(Q.MenuOutlined,{role:"button","aria-label":f(p.name),style:{padding:8,margin:"-8px"}})}),children:a.jsx(v.Card,{bordered:!1,children:a.jsx(r.SchemaComponentOptions,{components:{CollectionFields:At},inherit:!0,scope:{loadCategories:m,categoryVisible:p.id==="all",categoryId:p.id},children:a.jsx(_.RecursionField,{name:u,schema:p.schema,onlyRenderProperties:!0})})})}))})}):null},bf=()=>{const e=_.useForm(),t=r.useActionContext(),{refresh:o}=d.useContext(r.CollectionCategoriesContext),n=r.useAPIClient();return{run(){return D(this,null,function*(){yield e.submit();const s=Y.cloneDeep(e.values);yield n.resource("collectionCategories").create({values:A({},s)}),t.setVisible(!1),yield e.reset(),yield o()})}}},xf=e=>a.jsx(zo,A({},e)),zo=e=>{const{scope:t,getContainer:o,children:n}=e,[i,s]=d.useState(!1),{t:c}=j.useTranslation();return a.jsxs(r.ActionContextProvider,{value:{visible:i,setVisible:s},children:[a.jsx("div",{onClick:()=>s(!0),title:c("Add category"),children:n||a.jsx(Q.PlusOutlined,{})}),a.jsx(r.SchemaComponent,{schema:af,components:{CollectionCategory:r.CollectionCategory,CollectionTemplateTag:r.CollectionTemplateTag},scope:A({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useCreateCategry:bf},t)})]})},Sf=()=>{const e=_.useForm(),t=r.useActionContext(),{refresh:o}=d.useContext(r.CollectionCategoriesContext),{refresh:n}=r.useResourceActionContext(),i=r.useAPIClient(),{id:s}=r.useRecord();return{run(){return D(this,null,function*(){yield e.submit();const l=Y.cloneDeep(e.values);yield i.resource("collectionCategories").update({filter:{id:s},values:A({},l)}),t.setVisible(!1),yield e.reset(),yield o(),yield n()})}}},Af=e=>{const t=r.useRecord(),o=r.useRequest(()=>Promise.resolve({data:Y.cloneDeep(t)}),K(A({},e),{manual:!0})),n=r.useActionContext();return d.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},$f=e=>a.jsx(Ho,A({},e)),Ho=e=>{const{scope:t,getContainer:o,item:n,children:i}=e,[s,c]=d.useState(!1),l=r.useCompile();return a.jsx(r.RecordProvider,{record:n,children:a.jsxs(r.ActionContextProvider,{value:{visible:s,setVisible:c},children:[a.jsx(a.Fragment,{children:i||a.jsx("span",{onClick:()=>c(!0),children:l('{{ t("Edit category") }}')})}),a.jsx(r.SchemaComponent,{schema:sf,scope:A({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useEditCategry:Sf,useValuesFromRecord:Af},t)})]})})};Ce.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const Tf={type:"object",properties:{[V.uid()]:{"x-component":"ConfigurationTable"}}},Ff=()=>a.jsx(r.SchemaComponent,{schema:Tf,components:{CollectionCategoriesProvider:r.CollectionCategoriesProvider,ConfigurationTable:yf,ConfigurationTabs:vf,AddFieldAction:r.AddFieldAction,AddCollectionField:r.AddCollectionField,AddCollection:r.AddCollection,AddCollectionAction:r.AddCollectionAction,AddCategoryAction:zo,AddCategory:xf,EditCollection:r.EditCollection,EditCollectionAction:r.EditCollectionAction,DeleteCollection:r.DeleteCollection,DeleteCollectionAction:r.DeleteCollectionAction,EditFieldAction:r.EditFieldAction,EditCollectionField:r.EditCollectionField,OverridingCollectionField:r.OverridingCollectionField,OverridingFieldAction:r.OverridingFieldAction,ViewCollectionField:r.ViewCollectionField,ViewFieldAction:r.ViewFieldAction,EditCategory:$f,EditCategoryAction:Ho,SyncFieldsAction:r.SyncFieldsAction,SyncFieldsActionCom:r.SyncFieldsActionCom,SyncSQLFieldsAction:r.SyncSQLFieldsAction}}),Se=d.createContext(null);Se.displayName="PermissionContext";const wf=e=>{const t=r.useAPIClient(),o=r.useRecord(),{t:n}=j.useTranslation(),i=d.useContext(Ae),{snippets:s}=i;s==null||s.forEach(y=>{i[y]=!0});const[c,l]=d.useState(i);return d.useEffect(()=>{l(i)},[i]),a.jsx(Se.Provider,{value:{currentDataSource:o,currentRecord:c,update:(y,u)=>D(this,null,function*(){yield t.request({url:`dataSources/${o.key}/roles:update`,data:u.values,method:"post",params:{filterByTk:u.values.roleName}}),l(A(A({},c),u.values)),v.message.success(n("Saved successfully"))})},children:e.children})},_f=e=>{const t=d.useContext(Ae),o=r.useRecord();return a.jsx(r.RecordContext_deprecated.Provider,{value:A({},t),children:a.jsx(r.SchemaComponentOptions,{scope:{dataSourceKey:o.key},children:e.children})})},Pf=e=>{const t=r.useRecord(),{visible:o}=r.useActionContext(),{currentDataSource:n}=d.useContext(Se),i=r.useRequest({resource:"roles.dataSourceResources",resourceOf:t.roleName,action:"get",params:{appends:["actions","actions.scope"],filterByTk:t.name,filter:{dataSourceKey:n.key,name:t.name}}},K(A({},e),{manual:!0}));return d.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}o&&i.run()},[o,t.exists]),i},Df=()=>{const e=_.useForm(),t=r.useAPIClient(),o=r.useRecord(),n=r.useActionContext(),{refresh:i}=r.useResourceActionContext(),{currentDataSource:s}=d.useContext(Se);return{run(){return D(this,null,function*(){yield t.resource("roles.dataSourceResources",o.roleName)[o.exists?"update":"create"]({filterByTk:o.name,filter:{dataSourceKey:s.key,name:o.name},values:K(A({},e.values),{name:o.name,dataSourceKey:s.key})}),n.setVisible(!1),i()})}}},If={type:"void","x-decorator":"RoleRecordProvider",properties:{block:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"dataSourcesCollections",targetKey:"name",filterTargetKey:"name",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Collection display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Collection name")}}',type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"input",uiSchema:{title:'{{t("Resource type")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Collection")}}',value:"collection",color:"green"},{label:'{{t("Association")}}',value:"association",color:"blue"}]}},{type:"string",name:"usingConfig",interface:"input",uiSchema:{title:'{{t("Permission policy")}}',type:"string","x-component":"Select",enum:[{label:'{{t("Individual")}}',value:"resourceAction",color:"orange"},{label:'{{t("General")}}',value:"strategy",color:"default"}]}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}}]},association:{sourceKey:"name",targetKey:"name"},resourceName:"roles.dataSourcesCollections",request:{resource:"roles.dataSourcesCollections",action:"list",params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:"{{dataSourceKey}}"},sort:["sort"],appends:["fields"]}}},properties:{[V.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table1:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column0:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{usingConfig:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:Pf},title:'{{t("Configure permission")}}',properties:{usingActionsConfig:{title:'{{t("Permission policy")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:!1,enum:[{value:!1,label:'{{t("General")}}'},{value:!0,label:'{{t("Individual")}}'}],"x-reactions":{target:"actions",fulfill:{state:{hidden:"{{!$self.value}}"}}}},actions:{"x-component":"RolesResourcesActions","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:Df}}}}}}}}}}}}}}}}}},Wo={name:"dataSources",filterTargetKey:"name",targetKey:"name",fields:[{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Display name")}}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"number","x-component":"Input",required:!0}}]},Of=(e={})=>({type:"object",properties:{block1:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:Wo,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,showAnonymous:!0,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:Wo},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-decorator":"ACLActionProvider","x-acl-action":"roles:update","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"PermissionProvider",title:'{{t("Configure permissions")}}',properties:{tabs1:{type:"void","x-component":"Tabs","x-component-props":{},properties:A({tab1:{type:"void",title:'{{t("General action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{role:{"x-component":"RoleConfigure"}}},tab2:{type:"void",title:'{{t("Action permissions")}}',"x-component":"Tabs.TabPane","x-component-props":{},properties:{roleCollectionsSchema:If}}},e)}}}}}}}}}}}}}}}),pt=d.createContext([]);pt.displayName="AvailableActionsContext";const Mf=e=>{const{data:t,loading:o}=r.useRequest({resource:"availableActions",action:"list"});return o?a.jsx(v.Spin,{}):a.jsx(pt.Provider,{value:t==null?void 0:t.data,children:e.children})},Qo=()=>d.useContext(pt),kf=()=>{const e=r.useRecord(),t=r.usePlugin(ie);return a.jsx("div",{children:a.jsx(r.SchemaComponentContext.Provider,{value:{designable:!1},children:a.jsx(Mf,{children:a.jsx(r.SchemaComponent,{schema:Of(t.getExtendedTabs()),components:{SettingCenterPermissionProvider:r.SettingCenterPermissionProvider,PermissionProvider:wf},scope:{dataSourceKey:e.key}})})})})},Ef=()=>{const{update:e}=d.useContext(Se),{t}=j.useTranslation(),{key:o}=r.useRecord();return a.jsx(r.SchemaComponent,{schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:n=>{const i=r.useAPIClient(),s=d.useContext(Ae);return r.useRequest(()=>i.resource(`dataSources/${o}/roles`).get({filterByTk:s.name}).then(c=>{var y,u;const l=(y=c==null?void 0:c.data)==null?void 0:y.data;return(u=l.snippets)==null||u.forEach(g=>{l[g]=!0}),{data:l}}),n)},effects(){Ce.onFieldChange("*",(n,i)=>D(this,null,function*(){i.modified&&(yield e(n,i))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},jf=tn.createStyles(({css:e})=>e`
52
52
  .ant-table-cell {
53
53
  > .ant-space-horizontal {
54
54
  .ant-space-item-split:has(+ .ant-space-item:empty) {
@@ -8,13 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.4.10",
11
+ "@nocobase/client": "1.4.11",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-acl": "1.4.10",
14
- "@nocobase/utils": "1.4.10",
15
- "@nocobase/server": "1.4.10",
13
+ "@nocobase/plugin-acl": "1.4.11",
14
+ "@nocobase/utils": "1.4.11",
15
+ "@nocobase/server": "1.4.11",
16
16
  "lodash": "4.17.21",
17
- "@nocobase/data-source-manager": "1.4.10",
17
+ "@nocobase/data-source-manager": "1.4.11",
18
18
  "@ant-design/icons": "5.2.6",
19
19
  "antd": "5.12.8",
20
20
  "react-router-dom": "6.21.0",
@@ -22,10 +22,10 @@ module.exports = {
22
22
  "react-i18next": "11.18.6",
23
23
  "@formily/react": "2.3.0",
24
24
  "@emotion/css": "11.13.0",
25
- "@nocobase/database": "1.4.10",
26
- "@nocobase/acl": "1.4.10",
25
+ "@nocobase/database": "1.4.11",
26
+ "@nocobase/acl": "1.4.11",
27
27
  "sequelize": "6.35.2",
28
- "@nocobase/test": "1.4.10",
28
+ "@nocobase/test": "1.4.11",
29
29
  "@formily/antd-v5": "1.1.9",
30
30
  "@formily/core": "2.3.0",
31
31
  "@formily/reactive": "2.3.0",
@@ -40,11 +40,11 @@ __export(data_sources_collections_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(data_sources_collections_exports);
42
42
  var import_lodash = __toESM(require("lodash"));
43
+ var import_database = require("@nocobase/database");
43
44
  var data_sources_collections_default = {
44
45
  name: "dataSources.collections",
45
46
  actions: {
46
47
  async list(ctx, next) {
47
- var _a, _b;
48
48
  const params = ctx.action.params;
49
49
  const { associatedIndex: dataSourceKey } = params;
50
50
  const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
@@ -67,13 +67,10 @@ var data_sources_collections_default = {
67
67
  if (!dataSource) {
68
68
  throw new Error(`dataSource ${dataSourceKey} not found`);
69
69
  }
70
- const { paginate, filter } = ctx.action.params;
71
- const filterTitle = (_a = import_lodash.default.get(filter, "$and.0.title.$includes")) == null ? void 0 : _a.toLowerCase();
72
- const filterName = (_b = import_lodash.default.get(filter, "$and.0.name.$includes")) == null ? void 0 : _b.toLowerCase();
70
+ const { paginate, filter = {} } = ctx.action.params;
73
71
  const collections = import_lodash.default.sortBy(
74
72
  dataSource.collectionManager.getCollections().filter((collection) => {
75
- var _a2;
76
- return (!filterTitle || ((_a2 = import_lodash.default.get(collection, "options.title")) == null ? void 0 : _a2.toLowerCase().includes(filterTitle))) && (!filterName || collection.options.name.toLowerCase().includes(filterName));
73
+ return (0, import_database.filterMatch)(collection.options, filter);
77
74
  }),
78
75
  "name"
79
76
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
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": "24ae34685506e34f254c44c25eb50e253ea0c2b6"
20
+ "gitHead": "275065a7af0069fc43be71b0231d246146854c7e"
21
21
  }