@tachybase/module-data-source 0.23.35 → 0.23.41

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.
@@ -45,7 +45,7 @@
45
45
  overflow-x: auto;
46
46
  overflow-y: hidden;
47
47
  }
48
- `,children:a.jsx(S.Table,{showHeader:!1,loading:e==null?void 0:e.loading,columns:Zy,dataSource:d,pagination:!1,expandable:{expandedRowRender:_,expandedRowKeys:D},onExpand:(M,V)=>{let H=[];M?H=D.concat([V.key]):H=D.filter(G=>G!==V.key),E(H)}})})},{displayName:"CollectionFieldsTableArray"}),Yy=()=>{var t;const e=r.useAsyncData();return[(t=e==null?void 0:e.state)==null?void 0:t.selectedRowKeys,o=>{var n;return(n=e==null?void 0:e.setState)==null?void 0:n.call(e,{selectedRowKeys:o})}]},Ry=(e,t)=>{const{request:o,dataSource:n}=t,s=r.useRequest(o(t),K(F({},e),{manual:!0}));return o?(s.run(),s):Promise.resolve({data:n})},ef=C.observer(e=>{const{rowKey:t="id",useDataSource:o=Ry,useSelectedRowKeys:n=Yy}=e,s=C.useField(),i=C.useFieldSchema(),l=f.useMemo(()=>C.createForm(),[]),p=C.useAttach(l.createArrayField(K(F({},s.props),{basePath:""}))),u=o({uid:i["x-uid"],onSuccess(c){l.setValues({[i.name]:c==null?void 0:c.data})}},e);return a.jsx(r.AsyncDataProvider,{value:u,children:a.jsx(C.FormContext.Provider,{value:l,children:a.jsx(C.FieldContext.Provider,{value:p,children:a.jsx(Xy,K(F({},e),{rowKey:t,loading:u==null?void 0:u.loading,useSelectedRowKeys:n,pagination:!1}))})})})},{displayName:"CollectionFieldsTable"});function tf(e){const{attributes:t,listeners:o,setNodeRef:n}=Z.useDraggable({id:e.id,data:e.data});return a.jsx("div",K(F(F({ref:n},o),t),{children:a.jsx("div",{children:e.children})}))}function of(e){const{isOver:t,setNodeRef:o}=Z.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 nf=C.observer(({item:e})=>a.jsx(of,{id:e.id.toString(),data:e,children:a.jsx("div",{children:a.jsx(tf,{id:e.id.toString(),data:e,children:a.jsx(Oo,{item:e})})})}),{displayName:"TabTitle"}),Oo=({item:e})=>{const{t}=j.useTranslation(),o=r.useCompile();return a.jsxs(S.Space,{children:[a.jsx(S.Badge,{color:e.color}),t(o(e.name))]})},rf=C.observer(e=>{const[t,o]=f.useState(null),{refresh:n}=f.useContext(r.CollectionCategroriesContext),{refresh:s}=r.useResourceActionContext(),i=r.useAPIClient(),l=g=>I(this,null,function*(){const{active:m,over:v}=g;setTimeout(()=>{o(null)}),v&&v.id!==m.id&&(yield i.resource("collectionCategories").move({sourceId:m.id,targetId:v.id}),yield n(),yield s())});function p(g){var m;o((m=g.active)==null?void 0:m.data.current)}const u=Z.useSensor(Z.MouseSensor,{activationConstraint:{distance:10}}),c=Z.useSensors(u);return a.jsxs(Z.DndContext,{sensors:c,onDragEnd:l,onDragStart:p,children:[e.children,a.jsx(Z.DragOverlay,{children:t?a.jsx("span",{style:{whiteSpace:"nowrap"},children:a.jsx(Oo,{item:t})}):null})]})},{displayName:"DndProvider"}),af=()=>{const{t:e}=j.useTranslation(),{data:t,refresh:o}=f.useContext(r.CollectionCategroriesContext),{refresh:n,run:s,defaultRequest:i,setState:l}=r.useResourceActionContext(),[p,u]=f.useState({tab:"all"}),[c,g]=f.useState(p.tab),m=r.useCompile(),v=r.useAPIClient(),{modal:x}=S.App.useApp(),P=f.useMemo(()=>{if(!t)return[];const d=t.sort((A,D)=>D.sort-A.sort).concat().map(A=>K(F({},A),{schema:Io}));return!d.find(A=>A.id==="all")&&d.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Io}),d},[t]);f.useEffect(()=>{p.tab!=="all"&&w(p.tab)},[]);const w=d=>{var A;if(u({tab:d}),g(C.uid()),d!=="all"){const E={$and:[(A=i==null?void 0:i.params)==null?void 0:A.filter,{"category.id":d}]};s({filter:E}),l==null||l({category:[+d],params:[{filter:E}]})}else s(),l==null||l({category:[],params:[]})},h=d=>{x.confirm({title:m("{{t('Delete category')}}"),content:m("{{t('Are you sure you want to delete it?')}}"),onOk:()=>I(this,null,function*(){yield v.resource("collectionCategories").destroy({filter:{id:d}}),d===+p.tab&&u({tab:"all"}),yield o(),yield n()})})},b=()=>I(this,null,function*(){return t.map(d=>({label:e(m(d.name)),value:d.id}))}),y=Q.memoize(d=>({items:[{key:"edit",label:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{[C.uid()]:{"x-component":"EditCategory","x-component-props":{item:d}}}}})},{key:"delete",label:m("{{t('Delete category')}}"),onClick:()=>h(d.id)}]}));return t?a.jsx(rf,{children:a.jsx(S.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:w,defaultActiveKey:p.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:P.map(d=>({label:d.id!=="all"?a.jsx("div",{"data-no-dnd":"true",children:a.jsx(nf,{item:d})}):m(d.name),key:String(d.id),closable:d.closable,closeIcon:a.jsx(S.Dropdown,{menu:y(d),children:a.jsx(J.MenuOutlined,{role:"button","aria-label":m(d.name),style:{padding:8,margin:"-8px"}})}),children:a.jsx(S.Card,{bordered:!1,children:a.jsx(r.SchemaComponentOptions,{components:{CollectionFields:_o},inherit:!0,scope:{loadCategories:b,categoryVisible:d.id==="all",categoryId:d.id},children:a.jsx(C.RecursionField,{name:c,schema:d.schema,onlyRenderProperties:!0})})})}))})}):null},sf=()=>{const e=C.useForm(),t=r.useActionContext(),{refresh:o}=f.useContext(r.CollectionCategroriesContext),n=r.useAPIClient();return{run(){return I(this,null,function*(){yield e.submit();const i=Q.cloneDeep(e.values);yield n.resource("collectionCategories").create({values:F({},i)}),t.setVisible(!1),yield e.reset(),yield o()})}}},lf=e=>a.jsx(Eo,F({},e)),Eo=e=>{const{scope:t,getContainer:o,children:n}=e,[s,i]=f.useState(!1),{t:l}=j.useTranslation();return a.jsxs(r.ActionContextProvider,{value:{visible:s,setVisible:i},children:[a.jsx("div",{onClick:()=>i(!0),title:l("Add category"),children:n||a.jsx(J.PlusOutlined,{})}),a.jsx(r.SchemaComponent,{schema:jy,components:{CollectionCategory:r.CollectionCategory,CollectionTemplateTag:r.CollectionTemplateTag},scope:F({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useCreateCategry:sf},t)})]})},cf=()=>{const e=C.useForm(),t=r.useActionContext(),{refresh:o}=f.useContext(r.CollectionCategroriesContext),{refresh:n}=r.useResourceActionContext(),s=r.useAPIClient(),{id:i}=r.useRecord();return{run(){return I(this,null,function*(){yield e.submit();const p=Q.cloneDeep(e.values);yield s.resource("collectionCategories").update({filter:{id:i},values:F({},p)}),t.setVisible(!1),yield e.reset(),yield o(),yield n()})}}},pf=e=>{const t=r.useRecord(),o=r.useRequest(()=>Promise.resolve({data:Q.cloneDeep(t)}),K(F({},e),{manual:!0})),n=r.useActionContext();return f.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},uf=e=>a.jsx(ko,F({},e)),ko=e=>{const{scope:t,getContainer:o,item:n,children:s}=e,[i,l]=f.useState(!1),p=r.useCompile();return a.jsx(r.RecordProvider,{record:n,children:a.jsxs(r.ActionContextProvider,{value:{visible:i,setVisible:l},children:[a.jsx(a.Fragment,{children:s||a.jsx("span",{onClick:()=>l(!0),children:p('{{ t("Edit category") }}')})}),a.jsx(r.SchemaComponent,{schema:Ky,scope:F({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useEditCategry:cf,useValuesFromRecord:pf},t)})]})})};C.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const df={type:"object",properties:{[C.uid()]:{"x-component":"ConfigurationTable"}}},mf=()=>a.jsx(r.SchemaComponent,{schema:df,components:{CollectionCategroriesProvider:r.CollectionCategroriesProvider,ConfigurationTable:Uy,ConfigurationTabs:af,AddFieldAction:r.AddFieldAction,AddCollectionField:r.AddCollectionField,AddCollection:r.AddCollection,AddCollectionAction:r.AddCollectionAction,AddCategoryAction:Eo,AddCategory:lf,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:uf,EditCategoryAction:ko,SyncFieldsAction:r.SyncFieldsAction,SyncFieldsActionCom:r.SyncFieldsActionCom,SyncSQLFieldsAction:r.SyncSQLFieldsAction}}),he=f.createContext(null);he.displayName="PermissionContext";const yf=e=>{const t=r.useAPIClient(),o=r.useRecord(),{t:n}=j.useTranslation(),s=f.useContext(be),{snippets:i}=s;i==null||i.forEach(u=>{s[u]=!0});const[l,p]=f.useState(s);return f.useEffect(()=>{p(s)},[s]),a.jsx(he.Provider,{value:{currentDataSource:o,currentRecord:l,update:(u,c)=>I(this,null,function*(){yield t.request({url:`dataSources/${o.key}/roles:update`,data:c.values,method:"post",params:{filterByTk:c.values.roleName}}),p(F(F({},l),c.values)),S.message.success(n("Saved successfully"))})},children:e.children})},ff=e=>{const t=f.useContext(be),o=r.useRecord();return a.jsx(r.RecordContext_deprecated.Provider,{value:F({},t),children:a.jsx(r.SchemaComponentOptions,{scope:{dataSourceKey:o.key},children:e.children})})},gf=r.withDynamicSchemaProps(e=>{const h=e,{showIndex:t,dragSort:o,rowKey:n,fieldNames:s,collection:i,service:l}=h,p=Ee(h,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),u=C.useField(),c=r.useTableBlockParams(e),g=C.useFieldSchema(),{treeTable:m}=(g==null?void 0:g["x-decorator-props"])||{},[v,x]=f.useState(!!s);let P="children";if(i!=null&&i.tree&&m!==!1){const b=i.fields.find(y=>y.treeChildren);b&&(P=b.name),c.tree=!0}const w=f.useMemo(()=>C.createForm(),[m]);return a.jsx(r.SchemaComponentOptions,{scope:{treeTable:m},children:a.jsx(C.FormContext.Provider,{value:w,children:a.jsx(r.BlockProvider,K(F({name:e.name||"table"},e),{params:c,runWhenParamsChanged:!0,children:a.jsx(r.FixedBlockWrapper,{children:a.jsx(r.TableBlockContext.Provider,{value:K(F({},p),{field:u,service:l,params:c,showIndex:t,dragSort:o,rowKey:n,expandFlag:v,childrenColumnName:P,setExpandFlag:()=>x(!v)}),children:a.jsx(r.RenderChildrenWithAssociationFilter,F({},e))})})}))})})}),vf=e=>{const t=r.useCollectionRecordData(),{visible:o}=r.useActionContext(),{currentDataSource:n}=f.useContext(he),s=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(F({},e),{manual:!0}));return f.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}o&&s.run()},[o,t.exists]),s},Cf={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:{}}]},hf={type:"void","x-decorator":"RoleRecordProvider",properties:{block:{type:"void","x-decorator":"RoleCollectionTableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleCollectionServiceProps",properties:{[C.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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table1:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{column0:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{usingConfig:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.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:vf},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-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSaveRoleResourceAction"}}}}}}}}}}}}}}}}},bf=e=>{const{uid:t}=e,o=r.useCollectionRecordData(),n=o.name,s=r.useRequest({resource:"roles.dataSourcesCollections",action:"list",resourceOf:n,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:o.key},sort:["sort"],appends:["fields"]}},{uid:t});return F({service:s,collection:Cf,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:o.key},sort:["sort"],appends:["fields"]}},e)},xf=()=>{var n,s;const e=f.useContext(r.CollectionContext),t=r.useFilterFieldOptions(e.fields),{service:o}=r.useTableBlockContext();return r.useFilterFieldProps({options:t,params:((s=(n=o.state)==null?void 0:n.params)==null?void 0:s[0])||o.params,service:o})},Sf={type:"void",properties:{block1:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:{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}}]},action:"list",params:{pageSize:50,showAnonymous:!0,appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.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:{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:hf}}}}}}}}}}}}}}}}}},Af=()=>{const e=C.useForm(),t=r.useAPIClient(),o=r.useCollectionRecordData(),n=r.useActionContext(),{service:s}=r.useTableBlockContext(),{currentDataSource:i}=f.useContext(he);return{onClick(){return I(this,null,function*(){yield t.resource("roles.dataSourceResources",o.roleName)[o.exists?"update":"create"]({filterByTk:o.name,filter:{dataSourceKey:i.key,name:o.name},values:K(F({},e.values),{name:o.name,dataSourceKey:i.key})}),n.setVisible(!1),s==null||s.refresh()})}}},st=f.createContext([]);st.displayName="AvailableActionsContext";const $f=e=>{const{data:t,loading:o}=r.useRequest({resource:"availableActions",action:"list"});return o?a.jsx(S.Spin,{}):a.jsx(st.Provider,{value:t==null?void 0:t.data,children:e.children})},Mo=()=>f.useContext(st),Tf=()=>{const e=r.useRecord();return a.jsx("div",{children:a.jsx(r.SchemaComponentContext.Provider,{value:{designable:!1},children:a.jsx($f,{children:a.jsx(r.SchemaComponent,{schema:Sf,components:{SettingCenterPermissionProvider:r.SettingCenterPermissionProvider,PermissionProvider:yf,RoleCollectionTableBlockProvider:gf},scope:{dataSourceKey:e.key,useSaveRoleResourceAction:Af,useFilterActionProps:xf,useRoleCollectionServiceProps:bf}})})})})},Ff=()=>{const{update:e}=f.useContext(he),{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 s=r.useAPIClient(),i=f.useContext(be);return r.useRequest(()=>s.resource(`dataSources/${o}/roles`).get({filterByTk:i.name}).then(l=>{var u,c;const p=(u=l==null?void 0:l.data)==null?void 0:u.data;return(c=p.snippets)==null||c.forEach(g=>{p[g]=!0}),{data:p}}),n)},effects(){C.onFieldChange("*",(n,s)=>I(this,null,function*(){s.modified&&(yield e(n,s))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},wf=(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}}]}),_f=()=>{const{name:e}=f.useContext(me),t=r.useFormBlockContext();return f.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},Pf=e=>{const t=wf(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:"tb-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:f.useContext(me).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:"tb-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":_f,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=f.useContext(me);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:"tb-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=f.useContext(me);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"}}}}}}}}}}}}},jo=f.createContext(null);jo.displayName="RolesResourcesScopesSelectedRowKeysContext";const Df=e=>{const[t,o]=f.useState([]);return a.jsx(jo.Provider,{value:[t,o],children:e.children})},If=e=>{const t=f.useMemo(()=>C.createForm({values:{scope:e.value}}),[]),{key:o}=r.useRecord(),n=Pf(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Df},scope:{onChange(s){var i;(i=e==null?void 0:e.onChange)==null||i.call(e,s)}},schema:n})})},Of=r.createStyles(({css:e})=>e`
48
+ `,children:a.jsx(S.Table,{showHeader:!1,loading:e==null?void 0:e.loading,columns:Zy,dataSource:d,pagination:!1,expandable:{expandedRowRender:_,expandedRowKeys:D},onExpand:(M,V)=>{let H=[];M?H=D.concat([V.key]):H=D.filter(G=>G!==V.key),E(H)}})})},{displayName:"CollectionFieldsTableArray"}),Yy=()=>{var t;const e=r.useAsyncData();return[(t=e==null?void 0:e.state)==null?void 0:t.selectedRowKeys,o=>{var n;return(n=e==null?void 0:e.setState)==null?void 0:n.call(e,{selectedRowKeys:o})}]},Ry=(e,t)=>{const{request:o,dataSource:n}=t,s=r.useRequest(o(t),K(F({},e),{manual:!0}));return o?(s.run(),s):Promise.resolve({data:n})},ef=C.observer(e=>{const{rowKey:t="id",useDataSource:o=Ry,useSelectedRowKeys:n=Yy}=e,s=C.useField(),i=C.useFieldSchema(),l=f.useMemo(()=>C.createForm(),[]),p=C.useAttach(l.createArrayField(K(F({},s.props),{basePath:""}))),u=o({uid:i["x-uid"],onSuccess(c){l.setValues({[i.name]:c==null?void 0:c.data})}},e);return a.jsx(r.AsyncDataProvider,{value:u,children:a.jsx(C.FormContext.Provider,{value:l,children:a.jsx(C.FieldContext.Provider,{value:p,children:a.jsx(Xy,K(F({},e),{rowKey:t,loading:u==null?void 0:u.loading,useSelectedRowKeys:n,pagination:!1}))})})})},{displayName:"CollectionFieldsTable"});function tf(e){const{attributes:t,listeners:o,setNodeRef:n}=Z.useDraggable({id:e.id,data:e.data});return a.jsx("div",K(F(F({ref:n},o),t),{children:a.jsx("div",{children:e.children})}))}function of(e){const{isOver:t,setNodeRef:o}=Z.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 nf=C.observer(({item:e})=>a.jsx(of,{id:e.id.toString(),data:e,children:a.jsx("div",{children:a.jsx(tf,{id:e.id.toString(),data:e,children:a.jsx(Oo,{item:e})})})}),{displayName:"TabTitle"}),Oo=({item:e})=>{const{t}=j.useTranslation(),o=r.useCompile();return a.jsxs(S.Space,{children:[a.jsx(S.Badge,{color:e.color}),t(o(e.name))]})},rf=C.observer(e=>{const[t,o]=f.useState(null),{refresh:n}=f.useContext(r.CollectionCategroriesContext),{refresh:s}=r.useResourceActionContext(),i=r.useAPIClient(),l=g=>I(this,null,function*(){const{active:m,over:v}=g;setTimeout(()=>{o(null)}),v&&v.id!==m.id&&(yield i.resource("collectionCategories").move({sourceId:m.id,targetId:v.id}),yield n(),yield s())});function p(g){var m;o((m=g.active)==null?void 0:m.data.current)}const u=Z.useSensor(Z.MouseSensor,{activationConstraint:{distance:10}}),c=Z.useSensors(u);return a.jsxs(Z.DndContext,{sensors:c,onDragEnd:l,onDragStart:p,children:[e.children,a.jsx(Z.DragOverlay,{children:t?a.jsx("span",{style:{whiteSpace:"nowrap"},children:a.jsx(Oo,{item:t})}):null})]})},{displayName:"DndProvider"}),af=()=>{const{t:e}=j.useTranslation(),{data:t,refresh:o}=f.useContext(r.CollectionCategroriesContext),{refresh:n,run:s,defaultRequest:i,setState:l}=r.useResourceActionContext(),[p,u]=f.useState({tab:"all"}),[c,g]=f.useState(p.tab),m=r.useCompile(),v=r.useAPIClient(),{modal:x}=S.App.useApp(),P=f.useMemo(()=>{if(!t)return[];const d=t.sort((A,D)=>D.sort-A.sort).concat().map(A=>K(F({},A),{schema:Io}));return!d.find(A=>A.id==="all")&&d.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Io}),d},[t]);f.useEffect(()=>{p.tab!=="all"&&w(p.tab)},[]);const w=d=>{var A;if(u({tab:d}),g(C.uid()),d!=="all"){const E={$and:[(A=i==null?void 0:i.params)==null?void 0:A.filter,{"category.id":d}]};s({filter:E}),l==null||l({category:[+d],params:[{filter:E}]})}else s(),l==null||l({category:[],params:[]})},h=d=>{x.confirm({title:m("{{t('Delete category')}}"),content:m("{{t('Are you sure you want to delete it?')}}"),onOk:()=>I(this,null,function*(){yield v.resource("collectionCategories").destroy({filter:{id:d}}),d===+p.tab&&u({tab:"all"}),yield o(),yield n()})})},b=()=>I(this,null,function*(){return t.map(d=>({label:e(m(d.name)),value:d.id}))}),y=Q.memoize(d=>({items:[{key:"edit",label:a.jsx(r.SchemaComponent,{schema:{type:"void",properties:{[C.uid()]:{"x-component":"EditCategory","x-component-props":{item:d}}}}})},{key:"delete",label:m("{{t('Delete category')}}"),onClick:()=>h(d.id)}]}));return t?a.jsx(rf,{children:a.jsx(S.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:w,defaultActiveKey:p.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:P.map(d=>({label:d.id!=="all"?a.jsx("div",{"data-no-dnd":"true",children:a.jsx(nf,{item:d})}):m(d.name),key:String(d.id),closable:d.closable,closeIcon:a.jsx(S.Dropdown,{menu:y(d),children:a.jsx(J.MenuOutlined,{role:"button","aria-label":m(d.name),style:{padding:8,margin:"-8px"}})}),children:a.jsx(S.Card,{bordered:!1,children:a.jsx(r.SchemaComponentOptions,{components:{CollectionFields:_o},inherit:!0,scope:{loadCategories:b,categoryVisible:d.id==="all",categoryId:d.id},children:a.jsx(C.RecursionField,{name:c,schema:d.schema,onlyRenderProperties:!0})})})}))})}):null},sf=()=>{const e=C.useForm(),t=r.useActionContext(),{refresh:o}=f.useContext(r.CollectionCategroriesContext),n=r.useAPIClient();return{run(){return I(this,null,function*(){yield e.submit();const i=Q.cloneDeep(e.values);yield n.resource("collectionCategories").create({values:F({},i)}),t.setVisible(!1),yield e.reset(),yield o()})}}},lf=e=>a.jsx(Eo,F({},e)),Eo=e=>{const{scope:t,getContainer:o,children:n}=e,[s,i]=f.useState(!1),{t:l}=j.useTranslation();return a.jsxs(r.ActionContextProvider,{value:{visible:s,setVisible:i},children:[a.jsx("div",{onClick:()=>i(!0),title:l("Add category"),children:n||a.jsx(J.PlusOutlined,{})}),a.jsx(r.SchemaComponent,{schema:jy,components:{CollectionCategory:r.CollectionCategory,CollectionTemplateTag:r.CollectionTemplateTag},scope:F({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useCreateCategry:sf},t)})]})},cf=()=>{const e=C.useForm(),t=r.useActionContext(),{refresh:o}=f.useContext(r.CollectionCategroriesContext),{refresh:n}=r.useResourceActionContext(),s=r.useAPIClient(),{id:i}=r.useRecord();return{run(){return I(this,null,function*(){yield e.submit();const p=Q.cloneDeep(e.values);yield s.resource("collectionCategories").update({filter:{id:i},values:F({},p)}),t.setVisible(!1),yield e.reset(),yield o(),yield n()})}}},pf=e=>{const t=r.useRecord(),o=r.useRequest(()=>Promise.resolve({data:Q.cloneDeep(t)}),K(F({},e),{manual:!0})),n=r.useActionContext();return f.useEffect(()=>{n.visible&&o.run()},[n.visible]),o},uf=e=>a.jsx(ko,F({},e)),ko=e=>{const{scope:t,getContainer:o,item:n,children:s}=e,[i,l]=f.useState(!1),p=r.useCompile();return a.jsx(r.RecordProvider,{record:n,children:a.jsxs(r.ActionContextProvider,{value:{visible:i,setVisible:l},children:[a.jsx(a.Fragment,{children:s||a.jsx("span",{onClick:()=>l(!0),children:p('{{ t("Edit category") }}')})}),a.jsx(r.SchemaComponent,{schema:Ky,scope:F({getContainer:o,useCancelAction:r.useCancelAction,createOnly:!0,useEditCategry:cf,useValuesFromRecord:pf},t)})]})})};C.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const df={type:"object",properties:{[C.uid()]:{"x-component":"ConfigurationTable"}}},mf=()=>a.jsx(r.SchemaComponent,{schema:df,components:{CollectionCategroriesProvider:r.CollectionCategroriesProvider,ConfigurationTable:Uy,ConfigurationTabs:af,AddFieldAction:r.AddFieldAction,AddCollectionField:r.AddCollectionField,AddCollection:r.AddCollection,AddCollectionAction:r.AddCollectionAction,AddCategoryAction:Eo,AddCategory:lf,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:uf,EditCategoryAction:ko,SyncFieldsAction:r.SyncFieldsAction,SyncFieldsActionCom:r.SyncFieldsActionCom,SyncSQLFieldsAction:r.SyncSQLFieldsAction}}),he=f.createContext(null);he.displayName="PermissionContext";const yf=e=>{const t=r.useAPIClient(),o=r.useRecord(),{t:n}=j.useTranslation(),s=f.useContext(be),{snippets:i}=s;i==null||i.forEach(u=>{s[u]=!0});const[l,p]=f.useState(s);return f.useEffect(()=>{p(s)},[s]),a.jsx(he.Provider,{value:{currentDataSource:o,currentRecord:l,update:(u,c)=>I(this,null,function*(){yield t.request({url:`dataSources/${o.key}/roles:update`,data:c.values,method:"post",params:{filterByTk:c.values.roleName}}),p(F(F({},l),c.values)),S.message.success(n("Saved successfully"))})},children:e.children})},ff=e=>{const t=f.useContext(be),o=r.useRecord();return a.jsx(r.RecordContext_deprecated.Provider,{value:F({},t),children:a.jsx(r.SchemaComponentOptions,{scope:{dataSourceKey:o.key},children:e.children})})},gf=r.withDynamicSchemaProps(e=>{const h=e,{showIndex:t,dragSort:o,rowKey:n,fieldNames:s,collection:i,service:l}=h,p=Ee(h,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),u=C.useField(),c=r.useTableBlockParams(e),g=C.useFieldSchema(),{treeTable:m}=(g==null?void 0:g["x-decorator-props"])||{},[v,x]=f.useState(!!s);let P="children";if(i!=null&&i.tree&&m!==!1){const b=i.fields.find(y=>y.treeChildren);b&&(P=b.name),c.tree=!0}const w=f.useMemo(()=>C.createForm(),[m]);return a.jsx(r.SchemaComponentOptions,{scope:{treeTable:m},children:a.jsx(C.FormContext.Provider,{value:w,children:a.jsx(r.BlockProvider,K(F({name:e.name||"table"},e),{params:c,runWhenParamsChanged:!0,children:a.jsx(r.FixedBlockWrapper,{children:a.jsx(r.TableBlockContext.Provider,{value:K(F({},p),{field:u,service:l,params:c,showIndex:t,dragSort:o,rowKey:n,expandFlag:v,childrenColumnName:P,setExpandFlag:()=>x(!v)}),children:a.jsx(r.RenderChildrenWithAssociationFilter,F({},e))})})}))})})}),vf=e=>{const t=r.useCollectionRecordData(),{visible:o}=r.useActionContext(),{currentDataSource:n}=f.useContext(he),s=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(F({},e),{manual:!0}));return f.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}o&&s.run()},[o,t.exists]),s},Cf={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:{}}]},hf={type:"void","x-decorator":"RoleRecordProvider",properties:{block:{type:"void","x-decorator":"RoleCollectionTableBlockProvider","x-component":"CardItem","x-use-decorator-props":"useRoleCollectionServiceProps",properties:{[C.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":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table1:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{column0:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{usingConfig:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.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:vf},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-use-component-props":"useCancelActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSaveRoleResourceAction"}}}}}}}}}}}}}}}}},bf=e=>{const{uid:t}=e,o=r.useCollectionRecordData(),n=o.name,s=r.useRequest({resource:"roles.dataSourcesCollections",action:"list",resourceOf:n,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:o.key},sort:["sort"],appends:["fields"]}},{uid:t});return F({service:s,collection:Cf,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:o.key},sort:["sort"],appends:["fields"]}},e)},xf=()=>{var n,s;const e=f.useContext(r.CollectionContext),t=r.useFilterFieldOptions(e.fields),{service:o}=r.useTableBlockContext();return r.useFilterFieldProps({options:t,params:((s=(n=o.state)==null?void 0:n.params)==null?void 0:s[0])||o.params,service:o})},Sf={type:"void",properties:{block1:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:{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}}]},action:"list",params:{pageSize:50,showAnonymous:!0,appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"}},properties:{column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column4:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.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-reactions":e=>{e.visible=e.record.status==="loaded"},"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:{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:hf}}}}}}}}}}}}}}}}}},Af=()=>{const e=C.useForm(),t=r.useAPIClient(),o=r.useCollectionRecordData(),n=r.useActionContext(),{service:s}=r.useTableBlockContext(),{currentDataSource:i}=f.useContext(he);return{onClick(){return I(this,null,function*(){yield t.resource("roles.dataSourceResources",o.roleName)[o.exists?"update":"create"]({filterByTk:o.name,filter:{dataSourceKey:i.key,name:o.name},values:K(F({},e.values),{name:o.name,dataSourceKey:i.key})}),n.setVisible(!1),s==null||s.refresh()})}}},st=f.createContext([]);st.displayName="AvailableActionsContext";const $f=e=>{const{data:t,loading:o}=r.useRequest({resource:"availableActions",action:"list"});return o?a.jsx(S.Spin,{}):a.jsx(st.Provider,{value:t==null?void 0:t.data,children:e.children})},Mo=()=>f.useContext(st),Tf=()=>{const e=r.useRecord();return a.jsx("div",{children:a.jsx(r.SchemaComponentContext.Provider,{value:{designable:!1},children:a.jsx($f,{children:a.jsx(r.SchemaComponent,{schema:Sf,components:{SettingCenterPermissionProvider:r.SettingCenterPermissionProvider,PermissionProvider:yf,RoleCollectionTableBlockProvider:gf},scope:{dataSourceKey:e.key,useSaveRoleResourceAction:Af,useFilterActionProps:xf,useRoleCollectionServiceProps:bf}})})})})},Ff=()=>{const{update:e}=f.useContext(he),{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 s=r.useAPIClient(),i=f.useContext(be);return r.useRequest(()=>s.resource(`dataSources/${o}/roles`).get({filterByTk:i.name}).then(l=>{var u,c;const p=(u=l==null?void 0:l.data)==null?void 0:u.data;return(c=p.snippets)==null||c.forEach(g=>{p[g]=!0}),{data:p}}),n)},effects(){C.onFieldChange("*",(n,s)=>I(this,null,function*(){s.modified&&(yield e(n,s))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},wf=(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}}]}),_f=()=>{const{name:e}=f.useContext(me),t=r.useFormBlockContext();return f.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},Pf=e=>{const t=wf(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:"tb-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:f.useContext(me).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:"tb-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":_f,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=f.useContext(me);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:"tb-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=f.useContext(me);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"}}}}}}}}}}}}},jo=f.createContext(null);jo.displayName="RolesResourcesScopesSelectedRowKeysContext";const Df=e=>{const[t,o]=f.useState([]);return a.jsx(jo.Provider,{value:[t,o],children:e.children})},If=e=>{const t=f.useMemo(()=>C.createForm({values:{scope:e.value}}),[]),{key:o}=r.useRecord(),n=Pf(o);return a.jsx(r.FormProvider,{form:t,children:a.jsx(r.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Df},scope:{onChange(s){var i;(i=e==null?void 0:e.onChange)==null||i.call(e,s)}},schema:n})})},Of=r.createStyles(({css:e})=>e`
49
49
  .ant-table-cell {
50
50
  > .ant-space-horizontal {
51
51
  .ant-space-item-split:has(+ .ant-space-item:empty) {
@@ -1,19 +1,19 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "0.23.35",
4
- "@tachybase/server": "0.23.35",
3
+ "@tachybase/client": "0.23.41",
4
+ "@tachybase/server": "0.23.41",
5
5
  "lodash": "4.17.21",
6
6
  "@ant-design/icons": "5.5.2",
7
7
  "antd": "5.22.5",
8
8
  "react-router-dom": "6.28.1",
9
- "@tachybase/schema": "0.23.35",
9
+ "@tachybase/schema": "0.23.41",
10
10
  "react-i18next": "15.2.0",
11
- "@tachybase/database": "0.23.35",
12
- "@tachybase/utils": "0.23.35",
13
- "@tachybase/module-acl": "0.23.35",
14
- "@tachybase/acl": "0.23.35",
11
+ "@tachybase/database": "0.23.41",
12
+ "@tachybase/utils": "0.23.41",
13
+ "@tachybase/module-acl": "0.23.41",
14
+ "@tachybase/acl": "0.23.41",
15
15
  "sequelize": "6.37.5",
16
- "@tachybase/components": "0.23.35",
16
+ "@tachybase/components": "0.23.41",
17
17
  "@dnd-kit/core": "6.3.1",
18
18
  "ahooks": "3.8.4"
19
19
  };
@@ -55,6 +55,15 @@ var data_sources_default = (0, import_database.defineCollection)({
55
55
  name: "fixed",
56
56
  defaultValue: false
57
57
  },
58
+ {
59
+ type: "belongsToMany",
60
+ name: "roles",
61
+ target: "roles",
62
+ foreignKey: "dataSourceKey",
63
+ otherKey: "roleName",
64
+ targetKey: "name",
65
+ through: "dataSourcesRoles"
66
+ },
58
67
  {
59
68
  type: "hasMany",
60
69
  name: "collections",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-data-source",
3
3
  "displayName": "Data source manager",
4
- "version": "0.23.35",
4
+ "version": "0.23.41",
5
5
  "description": "Manage data sources, including the built-in Master database, external databases, APIs, etc.",
6
6
  "keywords": [
7
7
  "Data model tools"
@@ -18,16 +18,16 @@
18
18
  "react-i18next": "^15.2.0",
19
19
  "react-router-dom": "6.28.1",
20
20
  "sequelize": "^6.37.5",
21
- "@tachybase/components": "0.23.35",
22
- "@tachybase/schema": "0.23.35"
21
+ "@tachybase/components": "0.23.41",
22
+ "@tachybase/schema": "0.23.41"
23
23
  },
24
24
  "peerDependencies": {
25
- "@tachybase/acl": "0.23.35",
26
- "@tachybase/client": "0.23.35",
27
- "@tachybase/server": "0.23.35",
28
- "@tachybase/test": "0.23.35",
29
- "@tachybase/utils": "0.23.35",
30
- "@tachybase/database": "0.23.35"
25
+ "@tachybase/acl": "0.23.41",
26
+ "@tachybase/database": "0.23.41",
27
+ "@tachybase/test": "0.23.41",
28
+ "@tachybase/client": "0.23.41",
29
+ "@tachybase/utils": "0.23.41",
30
+ "@tachybase/server": "0.23.41"
31
31
  },
32
32
  "description.zh-CN": "管理数据源,包括内置的 Master 数据库,外部的数据库、API。",
33
33
  "displayName.zh-CN": "数据源管理",