@tachybase/module-data-source 1.3.18 → 1.3.20

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:c.jsx(T.Table,{showHeader:!1,loading:e==null?void 0:e.loading,columns:pu,dataSource:y,pagination:!1,expandable:{expandedRowRender:P,expandedRowKeys:D},onExpand:(q,E)=>{let R=[];q?R=D.concat([E.key]):R=D.filter(L=>L!==E.key),O(R)}})})},{displayName:"CollectionFieldsTableArray"}),fu=()=>{var t;const e=s.useAsyncData();return[(t=e==null?void 0:e.state)==null?void 0:t.selectedRowKeys,r=>{var o;return(o=e==null?void 0:e.setState)==null?void 0:o.call(e,{selectedRowKeys:r})}]},yu=(e,t)=>{const{request:r,dataSource:o}=t,n=s.useRequest(r(t),B(I({},e),{manual:!0}));return r?(n.run(),n):Promise.resolve({data:o})},hu=C.observer(e=>{const{rowKey:t="id",useDataSource:r=yu,useSelectedRowKeys:o=fu}=e,n=C.useField(),a=C.useFieldSchema(),i=g.useMemo(()=>C.createForm(),[]),l=C.useAttach(i.createArrayField(B(I({},n.props),{basePath:""}))),p=r({uid:a["x-uid"],onSuccess(u){i.setValues({[a.name]:u==null?void 0:u.data})}},e);return c.jsx(s.AsyncDataProvider,{value:p,children:c.jsx(C.FormContext.Provider,{value:i,children:c.jsx(C.FieldContext.Provider,{value:l,children:c.jsx(mu,B(I({},e),{rowKey:t,loading:p==null?void 0:p.loading,useSelectedRowKeys:o,pagination:!1}))})})})},{displayName:"CollectionFieldsTable"});function gu(e){const{attributes:t,listeners:r,setNodeRef:o}=Z.useDraggable({id:e.id,data:e.data});return c.jsx("div",B(I(I({ref:o},r),t),{children:c.jsx("div",{children:e.children})}))}function vu(e){const{isOver:t,setNodeRef:r}=Z.useDroppable({id:e.id,data:e.data}),o=t?{color:"green"}:void 0;return c.jsx("div",{ref:r,style:o,children:e.children})}const Cu=C.observer(({item:e})=>c.jsx(vu,{id:e.id.toString(),data:e,children:c.jsx("div",{children:c.jsx(gu,{id:e.id.toString(),data:e,children:c.jsx(zs,{item:e})})})}),{displayName:"TabTitle"}),zs=({item:e})=>{const{t}=$.useTranslation(),r=s.useCompile();return c.jsxs(T.Space,{children:[c.jsx(T.Badge,{color:e.color}),t(r(e.name))]})},bu=C.observer(e=>{const[t,r]=g.useState(null),{refresh:o}=g.useContext(s.CollectionCategroriesContext),{refresh:n}=s.useResourceActionContext(),a=s.useAPIClient(),i=m=>M(null,null,function*(){const{active:d,over:h}=m;setTimeout(()=>{r(null)}),h&&h.id!==d.id&&(yield a.resource("collectionCategories").move({sourceId:d.id,targetId:h.id}),yield o(),yield n())});function l(m){var d;r((d=m.active)==null?void 0:d.data.current)}const p=Z.useSensor(Z.MouseSensor,{activationConstraint:{distance:10}}),u=Z.useSensors(p);return c.jsxs(Z.DndContext,{sensors:u,onDragEnd:i,onDragStart:l,children:[e.children,c.jsx(Z.DragOverlay,{children:t?c.jsx("span",{style:{whiteSpace:"nowrap"},children:c.jsx(zs,{item:t})}):null})]})},{displayName:"DndProvider"}),xu=()=>{const{t:e}=$.useTranslation(),{data:t,refresh:r}=g.useContext(s.CollectionCategroriesContext),{refresh:o,run:n,defaultRequest:a,setState:i}=s.useResourceActionContext(),[l,p]=g.useState({tab:"all"}),[u,m]=g.useState(l.tab),d=s.useCompile(),h=s.useAPIClient(),{modal:b}=T.App.useApp(),F=g.useMemo(()=>{if(!t)return[];const y=t.sort((S,D)=>D.sort-S.sort).concat().map(S=>B(I({},S),{schema:Us}));return!y.find(S=>S.id==="all")&&y.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Us}),y},[t]);g.useEffect(()=>{l.tab!=="all"&&w(l.tab)},[]);const w=y=>{var S;if(p({tab:y}),m(C.uid()),y!=="all"){const O={$and:[(S=a==null?void 0:a.params)==null?void 0:S.filter,{"category.id":y}]};n({filter:O}),i==null||i({category:[+y],params:[{filter:O}]})}else n(),i==null||i({category:[],params:[]})},v=y=>{b.confirm({title:d("{{t('Delete category')}}"),content:d("{{t('Are you sure you want to delete it?')}}"),onOk:()=>M(null,null,function*(){yield h.resource("collectionCategories").destroy({filter:{id:y}}),y===+l.tab&&p({tab:"all"}),yield r(),yield o()})})},x=()=>M(null,null,function*(){return t.map(y=>({label:e(d(y.name)),value:y.id}))}),f=W.memoize(y=>({items:[{key:"edit",label:c.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[C.uid()]:{"x-component":"EditCategory","x-component-props":{item:y}}}}})},{key:"delete",label:d("{{t('Delete category')}}"),onClick:()=>v(y.id)}]}));return t?c.jsx(bu,{children:c.jsx(T.Tabs,{addIcon:c.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:w,defaultActiveKey:l.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:F.map(y=>({label:y.id!=="all"?c.jsx("div",{"data-no-dnd":"true",children:c.jsx(Cu,{item:y})}):d(y.name),key:String(y.id),closable:y.closable,closeIcon:c.jsx(T.Dropdown,{menu:f(y),children:c.jsx(X.MenuOutlined,{role:"button","aria-label":d(y.name),style:{padding:8,margin:"-8px"}})}),children:c.jsx(T.Card,{bordered:!1,children:c.jsx(s.SchemaComponentOptions,{components:{CollectionFields:Ls},inherit:!0,scope:{loadCategories:x,categoryVisible:y.id==="all",categoryId:y.id},children:c.jsx(C.RecursionField,{name:u,schema:y.schema,onlyRenderProperties:!0})})})}))})}):null},Su=()=>{const e=C.useForm(),t=s.useActionContext(),{refresh:r}=g.useContext(s.CollectionCategroriesContext),o=s.useAPIClient();return{run(){return M(this,null,function*(){yield e.submit();const a=W.cloneDeep(e.values);yield o.resource("collectionCategories").create({values:I({},a)}),t.setVisible(!1),yield e.reset(),yield r()})}}},Au=e=>c.jsx(Hs,I({},e)),Hs=e=>{const{scope:t,getContainer:r,children:o}=e,[n,a]=g.useState(!1),{t:i}=$.useTranslation();return c.jsxs(s.ActionContextProvider,{value:{visible:n,setVisible:a},children:[c.jsx("div",{onClick:()=>a(!0),title:i("Add category"),children:o||c.jsx(X.PlusOutlined,{})}),c.jsx(s.SchemaComponent,{schema:Xl,components:{CollectionCategory:s.CollectionCategory,CollectionTemplateTag:s.CollectionTemplateTag},scope:I({getContainer:r,useCancelAction:s.useCancelAction,createOnly:!0,useCreateCategry:Su},t)})]})},_u=()=>{const e=C.useForm(),t=s.useActionContext(),{refresh:r}=g.useContext(s.CollectionCategroriesContext),{refresh:o}=s.useResourceActionContext(),n=s.useAPIClient(),{id:a}=s.useRecord();return{run(){return M(this,null,function*(){yield e.submit();const l=W.cloneDeep(e.values);yield n.resource("collectionCategories").update({filter:{id:a},values:I({},l)}),t.setVisible(!1),yield e.reset(),yield r(),yield o()})}}},Tu=e=>{const t=s.useRecord(),r=s.useRequest(()=>Promise.resolve({data:W.cloneDeep(t)}),B(I({},e),{manual:!0})),o=s.useActionContext();return g.useEffect(()=>{o.visible&&r.run()},[o.visible]),r},Fu=e=>c.jsx(Ws,I({},e)),Ws=e=>{const{scope:t,getContainer:r,item:o,children:n}=e,[a,i]=g.useState(!1),l=s.useCompile();return c.jsx(s.RecordProvider,{record:o,children:c.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:i},children:[c.jsx(c.Fragment,{children:n||c.jsx("span",{onClick:()=>i(!0),children:l('{{ t("Edit category") }}')})}),c.jsx(s.SchemaComponent,{schema:Yl,scope:I({getContainer:r,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:_u,useValuesFromRecord:Tu},t)})]})})};C.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const wu={type:"object",properties:{[C.uid()]:{"x-component":"ConfigurationTable"}}},qu=()=>c.jsx(s.SchemaComponent,{schema:wu,components:{CollectionCategroriesProvider:s.CollectionCategroriesProvider,ConfigurationTable:su,ConfigurationTabs:xu,AddFieldAction:s.AddFieldAction,AddCollectionField:s.AddCollectionField,AddCollection:s.AddCollection,AddCollectionAction:s.AddCollectionAction,AddCategoryAction:Hs,AddCategory:Au,EditCollection:s.EditCollection,EditCollectionAction:s.EditCollectionAction,DeleteCollection:s.DeleteCollection,DeleteCollectionAction:s.DeleteCollectionAction,EditFieldAction:s.EditFieldAction,EditCollectionField:s.EditCollectionField,OverridingCollectionField:s.OverridingCollectionField,OverridingFieldAction:s.OverridingFieldAction,ViewCollectionField:s.ViewCollectionField,ViewFieldAction:s.ViewFieldAction,EditCategory:Fu,EditCategoryAction:Ws,SyncFieldsAction:s.SyncFieldsAction,SyncFieldsActionCom:s.SyncFieldsActionCom,SyncSQLFieldsAction:s.SyncSQLFieldsAction}}),Se=g.createContext(null);Se.displayName="PermissionContext";const Pu=e=>{const t=s.useAPIClient(),r=s.useRecord(),{t:o}=$.useTranslation(),n=g.useContext(Ae),{snippets:a}=n;a==null||a.forEach(p=>{n[p]=!0});const[i,l]=g.useState(n);return g.useEffect(()=>{l(n)},[n]),c.jsx(Se.Provider,{value:{currentDataSource:r,currentRecord:i,update:(p,u)=>M(null,null,function*(){yield t.request({url:`dataSources/${r.key}/roles:update`,data:u.values,method:"post",params:{filterByTk:u.values.roleName}}),l(I(I({},i),u.values)),T.message.success(o("Saved successfully"))})},children:e.children})},Iu=e=>{const t=g.useContext(Ae),r=s.useRecord();return c.jsx(s.RecordContext_deprecated.Provider,{value:I({},t),children:c.jsx(s.SchemaComponentOptions,{scope:{dataSourceKey:r.key},children:e.children})})},Du=s.withDynamicSchemaProps(e=>{const v=e,{showIndex:t,dragSort:r,rowKey:o,fieldNames:n,collection:a,service:i}=v,l=Ke(v,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),p=C.useField(),u=s.useTableBlockParams(e),m=C.useFieldSchema(),{treeTable:d}=(m==null?void 0:m["x-decorator-props"])||{},[h,b]=g.useState(!!n);let F="children";if(a!=null&&a.tree&&d!==!1){const x=a.fields.find(f=>f.treeChildren);x&&(F=x.name),u.tree=!0}const w=g.useMemo(()=>C.createForm(),[d]);return c.jsx(s.SchemaComponentOptions,{scope:{treeTable:d},children:c.jsx(C.FormContext.Provider,{value:w,children:c.jsx(s.BlockProvider,B(I({name:e.name||"table"},e),{params:u,runWhenParamsChanged:!0,children:c.jsx(s.FixedBlockWrapper,{children:c.jsx(s.TableBlockContext.Provider,{value:B(I({},l),{field:p,service:i,params:u,showIndex:t,dragSort:r,rowKey:o,expandFlag:h,childrenColumnName:F,setExpandFlag:()=>b(!h)}),children:c.jsx(s.RenderChildrenWithAssociationFilter,I({},e))})})}))})})}),Ou=e=>{const t=s.useCollectionRecordData(),{visible:r}=s.useActionContext(),{currentDataSource:o}=g.useContext(Se),n=s.useRequest({resource:"roles.dataSourceResources",resourceOf:t.roleName,action:"get",params:{appends:["actions","actions.scope"],filterByTk:t.name,filter:{dataSourceKey:o.key,name:t.name}}},B(I({},e),{manual:!0}));return g.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}r&&n.run()},[r,t.exists]),n},ku={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:{}}]},Mu={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:Ou},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"}}}}}}}}}}}}}}}}},Eu=e=>{const{uid:t}=e,r=s.useRecord(),o=r==null?void 0:r.name,n=s.useCollectionRecordData(),a=s.useRequest({resource:"roles.dataSourcesCollections",action:"list",resourceOf:o,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:n.key},sort:["sort"],appends:["fields"]}},{uid:t});return I({service:a,collection:ku,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:r.key},sort:["sort"],appends:["fields"]}},e)},ju=()=>{var o,n;const e=g.useContext(s.CollectionContext),t=s.useFilterFieldOptions(e.fields),{service:r}=s.useTableBlockContext();return s.useFilterFieldProps({options:t,params:((n=(o=r.state)==null?void 0:o.params)==null?void 0:n[0])||r.params,service:r})},Ku={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:Mu}}}}}}}}}}}}}}}}}},$u=()=>{const e=C.useForm(),t=s.useAPIClient(),r=s.useCollectionRecordData(),o=s.useActionContext(),{service:n}=s.useTableBlockContext(),{currentDataSource:a}=g.useContext(Se);return{onClick(){return M(this,null,function*(){yield t.resource("roles.dataSourceResources",r.roleName)[r.exists?"update":"create"]({filterByTk:r.name,filter:{dataSourceKey:a.key,name:r.name},values:B(I({},e.values),{name:r.name,dataSourceKey:a.key})}),o.setVisible(!1),n==null||n.refresh()})}}},ko=g.createContext([]);ko.displayName="AvailableActionsContext";const Bu=e=>{const{data:t,loading:r}=s.useRequest({resource:"availableActions",action:"list"});return r?c.jsx(T.Spin,{}):c.jsx(ko.Provider,{value:t==null?void 0:t.data,children:e.children})},Js=()=>g.useContext(ko),Vu=()=>{const e=s.useRecord();return c.jsx("div",{children:c.jsx(s.SchemaComponentContext.Provider,{value:{designable:!1},children:c.jsx(Bu,{children:c.jsx(s.SchemaComponent,{schema:Ku,components:{SettingCenterPermissionProvider:s.SettingCenterPermissionProvider,PermissionProvider:Pu,RoleCollectionTableBlockProvider:Du},scope:{dataSourceKey:e.key,useSaveRoleResourceAction:$u,useFilterActionProps:ju,useRoleCollectionServiceProps:Eu}})})})})},Nu=()=>{const{update:e}=g.useContext(Se),{t}=$.useTranslation(),{key:r}=s.useRecord();return c.jsx(s.SchemaComponent,{schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:o=>{const n=s.useAPIClient(),a=g.useContext(Ae);return s.useRequest(()=>n.resource(`dataSources/${r}/roles`).get({filterByTk:a.name}).then(i=>{var p,u;const l=(p=i==null?void 0:i.data)==null?void 0:p.data;return(u=l.snippets)==null||u.forEach(m=>{l[m]=!0}),{data:l}}),o)},effects(){C.onFieldChange("*",(o,n)=>M(null,null,function*(){n.modified&&(yield e(o,n))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},Lu=(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}}]}),Ru=()=>{const{name:e}=g.useContext(pe),t=s.useFormBlockContext();return g.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[t.form,e]),{form:t.form}},Gu=e=>{const t=Lu(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:g.useContext(pe).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:s.OpenMode.DRAWER_MODE,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":Ru,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 r=g.useContext(pe);return{options:s.useFilterFieldOptions(r.fields)}},"x-component-props":{dynamicComponent:s.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:s.OpenMode.DRAWER_MODE,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 r=g.useContext(pe);return{options:s.useFilterFieldOptions(r.fields)}},"x-component-props":{dynamicComponent:s.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"}}}}}}}}}}}}},Qs=g.createContext(null);Qs.displayName="RolesResourcesScopesSelectedRowKeysContext";const Uu=e=>{const[t,r]=g.useState([]);return c.jsx(Qs.Provider,{value:[t,r],children:e.children})},zu=e=>{const t=g.useMemo(()=>C.createForm({values:{scope:e.value}}),[]),{key:r}=s.useRecord(),o=Gu(r);return c.jsx(s.FormProvider,{form:t,children:c.jsx(s.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Uu},scope:{onChange(n){var a;(a=e==null?void 0:e.onChange)==null||a.call(e,n)}},schema:o})})},Hu=s.createStyles(({css:e})=>e`
48
+ `,children:c.jsx(T.Table,{showHeader:!1,loading:e==null?void 0:e.loading,columns:pu,dataSource:y,pagination:!1,expandable:{expandedRowRender:P,expandedRowKeys:D},onExpand:(q,E)=>{let R=[];q?R=D.concat([E.key]):R=D.filter(L=>L!==E.key),O(R)}})})},{displayName:"CollectionFieldsTableArray"}),fu=()=>{var t;const e=s.useAsyncData();return[(t=e==null?void 0:e.state)==null?void 0:t.selectedRowKeys,r=>{var o;return(o=e==null?void 0:e.setState)==null?void 0:o.call(e,{selectedRowKeys:r})}]},yu=(e,t)=>{const{request:r,dataSource:o}=t,n=s.useRequest(r(t),B(I({},e),{manual:!0}));return r?(n.run(),n):Promise.resolve({data:o})},hu=C.observer(e=>{const{rowKey:t="id",useDataSource:r=yu,useSelectedRowKeys:o=fu}=e,n=C.useField(),a=C.useFieldSchema(),i=g.useMemo(()=>C.createForm(),[]),l=C.useAttach(i.createArrayField(B(I({},n.props),{basePath:""}))),p=r({uid:a["x-uid"],onSuccess(u){i.setValues({[a.name]:u==null?void 0:u.data})}},e);return c.jsx(s.AsyncDataProvider,{value:p,children:c.jsx(C.FormContext.Provider,{value:i,children:c.jsx(C.FieldContext.Provider,{value:l,children:c.jsx(mu,B(I({},e),{rowKey:t,loading:p==null?void 0:p.loading,useSelectedRowKeys:o,pagination:!1}))})})})},{displayName:"CollectionFieldsTable"});function gu(e){const{attributes:t,listeners:r,setNodeRef:o}=Z.useDraggable({id:e.id,data:e.data});return c.jsx("div",B(I(I({ref:o},r),t),{children:c.jsx("div",{children:e.children})}))}function vu(e){const{isOver:t,setNodeRef:r}=Z.useDroppable({id:e.id,data:e.data}),o=t?{color:"green"}:void 0;return c.jsx("div",{ref:r,style:o,children:e.children})}const Cu=C.observer(({item:e})=>c.jsx(vu,{id:e.id.toString(),data:e,children:c.jsx("div",{children:c.jsx(gu,{id:e.id.toString(),data:e,children:c.jsx(zs,{item:e})})})}),{displayName:"TabTitle"}),zs=({item:e})=>{const{t}=$.useTranslation(),r=s.useCompile();return c.jsxs(T.Space,{children:[c.jsx(T.Badge,{color:e.color}),t(r(e.name))]})},bu=C.observer(e=>{const[t,r]=g.useState(null),{refresh:o}=g.useContext(s.CollectionCategroriesContext),{refresh:n}=s.useResourceActionContext(),a=s.useAPIClient(),i=m=>M(null,null,function*(){const{active:d,over:h}=m;setTimeout(()=>{r(null)}),h&&h.id!==d.id&&(yield a.resource("collectionCategories").move({sourceId:d.id,targetId:h.id}),yield o(),yield n())});function l(m){var d;r((d=m.active)==null?void 0:d.data.current)}const p=Z.useSensor(Z.MouseSensor,{activationConstraint:{distance:10}}),u=Z.useSensors(p);return c.jsxs(Z.DndContext,{sensors:u,onDragEnd:i,onDragStart:l,children:[e.children,c.jsx(Z.DragOverlay,{children:t?c.jsx("span",{style:{whiteSpace:"nowrap"},children:c.jsx(zs,{item:t})}):null})]})},{displayName:"DndProvider"}),xu=()=>{const{t:e}=$.useTranslation(),{data:t,refresh:r}=g.useContext(s.CollectionCategroriesContext),{refresh:o,run:n,defaultRequest:a,setState:i}=s.useResourceActionContext(),[l,p]=g.useState({tab:"all"}),[u,m]=g.useState(l.tab),d=s.useCompile(),h=s.useAPIClient(),{modal:b}=T.App.useApp(),F=g.useMemo(()=>{if(!t)return[];const y=t.sort((S,D)=>D.sort-S.sort).concat().map(S=>B(I({},S),{schema:Us}));return!y.find(S=>S.id==="all")&&y.unshift({name:'{{t("All collections")}}',id:"all",sort:0,closable:!1,schema:Us}),y},[t]);g.useEffect(()=>{l.tab!=="all"&&w(l.tab)},[]);const w=y=>{var S;if(p({tab:y}),m(C.uid()),y!=="all"){const O={$and:[(S=a==null?void 0:a.params)==null?void 0:S.filter,{"category.id":y}]};n({filter:O}),i==null||i({category:[+y],params:[{filter:O}]})}else n(),i==null||i({category:[],params:[]})},v=y=>{b.confirm({title:d("{{t('Delete category')}}"),content:d("{{t('Are you sure you want to delete it?')}}"),onOk:()=>M(null,null,function*(){yield h.resource("collectionCategories").destroy({filter:{id:y}}),y===+l.tab&&p({tab:"all"}),yield r(),yield o()})})},x=()=>M(null,null,function*(){return t.map(y=>({label:e(d(y.name)),value:y.id}))}),f=W.memoize(y=>({items:[{key:"edit",label:c.jsx(s.SchemaComponent,{schema:{type:"void",properties:{[C.uid()]:{"x-component":"EditCategory","x-component-props":{item:y}}}}})},{key:"delete",label:d("{{t('Delete category')}}"),onClick:()=>v(y.id)}]}));return t?c.jsx(bu,{children:c.jsx(T.Tabs,{addIcon:c.jsx(s.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:w,defaultActiveKey:l.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:F.map(y=>({label:y.id!=="all"?c.jsx("div",{"data-no-dnd":"true",children:c.jsx(Cu,{item:y})}):d(y.name),key:String(y.id),closable:y.closable,closeIcon:c.jsx(T.Dropdown,{menu:f(y),children:c.jsx(X.MenuOutlined,{role:"button","aria-label":d(y.name),style:{padding:8,margin:"-8px"}})}),children:c.jsx(T.Card,{bordered:!1,children:c.jsx(s.SchemaComponentOptions,{components:{CollectionFields:Ls},inherit:!0,scope:{loadCategories:x,categoryVisible:y.id==="all",categoryId:y.id},children:c.jsx(C.RecursionField,{name:u,schema:y.schema,onlyRenderProperties:!0})})})}))})}):null},Su=()=>{const e=C.useForm(),t=s.useActionContext(),{refresh:r}=g.useContext(s.CollectionCategroriesContext),o=s.useAPIClient();return{run(){return M(this,null,function*(){yield e.submit();const a=W.cloneDeep(e.values);yield o.resource("collectionCategories").create({values:I({},a)}),t.setVisible(!1),yield e.reset(),yield r()})}}},Au=e=>c.jsx(Hs,I({},e)),Hs=e=>{const{scope:t,getContainer:r,children:o}=e,[n,a]=g.useState(!1),{t:i}=$.useTranslation();return c.jsxs(s.ActionContextProvider,{value:{visible:n,setVisible:a},children:[c.jsx("div",{onClick:()=>a(!0),title:i("Add category"),children:o||c.jsx(X.PlusOutlined,{})}),c.jsx(s.SchemaComponent,{schema:Xl,components:{CollectionCategory:s.CollectionCategory,CollectionTemplateTag:s.CollectionTemplateTag},scope:I({getContainer:r,useCancelAction:s.useCancelAction,createOnly:!0,useCreateCategry:Su},t)})]})},_u=()=>{const e=C.useForm(),t=s.useActionContext(),{refresh:r}=g.useContext(s.CollectionCategroriesContext),{refresh:o}=s.useResourceActionContext(),n=s.useAPIClient(),{id:a}=s.useRecord();return{run(){return M(this,null,function*(){yield e.submit();const l=W.cloneDeep(e.values);yield n.resource("collectionCategories").update({filter:{id:a},values:I({},l)}),t.setVisible(!1),yield e.reset(),yield r(),yield o()})}}},Tu=e=>{const t=s.useRecord(),r=s.useRequest(()=>Promise.resolve({data:W.cloneDeep(t)}),B(I({},e),{manual:!0})),o=s.useActionContext();return g.useEffect(()=>{o.visible&&r.run()},[o.visible]),r},Fu=e=>c.jsx(Ws,I({},e)),Ws=e=>{const{scope:t,getContainer:r,item:o,children:n}=e,[a,i]=g.useState(!1),l=s.useCompile();return c.jsx(s.RecordProvider,{record:o,children:c.jsxs(s.ActionContextProvider,{value:{visible:a,setVisible:i},children:[c.jsx(c.Fragment,{children:n||c.jsx("span",{onClick:()=>i(!0),children:l('{{ t("Edit category") }}')})}),c.jsx(s.SchemaComponent,{schema:Yl,scope:I({getContainer:r,useCancelAction:s.useCancelAction,createOnly:!0,useEditCategry:_u,useValuesFromRecord:Tu},t)})]})})};C.registerValidateFormats({uid:/^[a-zA-Z][a-zA-Z0-9_-]*$/});const wu={type:"object",properties:{[C.uid()]:{"x-component":"ConfigurationTable"}}},qu=()=>c.jsx(s.SchemaComponent,{schema:wu,components:{CollectionCategroriesProvider:s.CollectionCategroriesProvider,ConfigurationTable:su,ConfigurationTabs:xu,AddFieldAction:s.AddFieldAction,AddCollectionField:s.AddCollectionField,AddCollection:s.AddCollection,AddCollectionAction:s.AddCollectionAction,AddCategoryAction:Hs,AddCategory:Au,EditCollection:s.EditCollection,EditCollectionAction:s.EditCollectionAction,DeleteCollection:s.DeleteCollection,DeleteCollectionAction:s.DeleteCollectionAction,EditFieldAction:s.EditFieldAction,EditCollectionField:s.EditCollectionField,OverridingCollectionField:s.OverridingCollectionField,OverridingFieldAction:s.OverridingFieldAction,ViewCollectionField:s.ViewCollectionField,ViewFieldAction:s.ViewFieldAction,EditCategory:Fu,EditCategoryAction:Ws,SyncFieldsAction:s.SyncFieldsAction,SyncFieldsActionCom:s.SyncFieldsActionCom,SyncSQLFieldsAction:s.SyncSQLFieldsAction}}),Se=g.createContext(null);Se.displayName="PermissionContext";const Pu=e=>{const t=s.useAPIClient(),r=s.useRecord(),{t:o}=$.useTranslation(),n=g.useContext(Ae),{snippets:a}=n;a==null||a.forEach(p=>{n[p]=!0});const[i,l]=g.useState(n);return g.useEffect(()=>{l(n)},[n]),c.jsx(Se.Provider,{value:{currentDataSource:r,currentRecord:i,update:(p,u)=>M(null,null,function*(){yield t.request({url:`dataSources/${r.key}/roles:update`,data:u.values,method:"post",params:{filterByTk:u.values.roleName}}),l(I(I({},i),u.values)),T.message.success(o("Saved successfully"))})},children:e.children})},Iu=e=>{const t=g.useContext(Ae),r=s.useRecord();return c.jsx(s.RecordContext_deprecated.Provider,{value:I({},t),children:c.jsx(s.SchemaComponentOptions,{scope:{dataSourceKey:r.key},children:e.children})})},Du=s.withDynamicSchemaProps(e=>{const v=e,{showIndex:t,dragSort:r,rowKey:o,fieldNames:n,collection:a,service:i}=v,l=Ke(v,["showIndex","dragSort","rowKey","fieldNames","collection","service"]),p=C.useField(),u=s.useTableBlockParams(e),m=C.useFieldSchema(),{treeTable:d}=(m==null?void 0:m["x-decorator-props"])||{},[h,b]=g.useState(!!n);let F="children";if(a!=null&&a.tree&&d!==!1){const x=a.fields.find(f=>f.treeChildren);x&&(F=x.name),u.tree=!0}const w=g.useMemo(()=>C.createForm(),[d]);return c.jsx(s.SchemaComponentOptions,{scope:{treeTable:d},children:c.jsx(C.FormContext.Provider,{value:w,children:c.jsx(s.BlockProvider,B(I({name:e.name||"table"},e),{params:u,runWhenParamsChanged:!0,children:c.jsx(s.FixedBlockWrapper,{children:c.jsx(s.TableBlockContext.Provider,{value:B(I({},l),{field:p,service:i,params:u,showIndex:t,dragSort:r,rowKey:o,expandFlag:h,childrenColumnName:F,setExpandFlag:()=>b(!h)}),children:c.jsx(s.RenderChildrenWithAssociationFilter,I({},e))})})}))})})}),Ou=e=>{const t=s.useCollectionRecordData(),{visible:r}=s.useActionContext(),{currentDataSource:o}=g.useContext(Se),n=s.useRequest({resource:"roles.dataSourceResources",resourceOf:t.roleName,action:"get",params:{appends:["actions","actions.scope"],filterByTk:t.name,filter:{dataSourceKey:o.key,name:t.name}}},B(I({},e),{manual:!0}));return g.useEffect(()=>{if(!t.exists){e.onSuccess({data:{}});return}r&&n.run()},[r,t.exists]),n},ku={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:{}}]},Mu={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:Ou},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"}}}}}}}}}}}}}}}}},Eu=e=>{const{uid:t}=e,r=s.useRecord(),o=r==null?void 0:r.name,n=s.useCollectionRecordData(),a=s.useRequest({resource:"roles.dataSourcesCollections",action:"list",resourceOf:o,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:n.key},sort:["sort"],appends:["fields"]}},{uid:t});return I({service:a,collection:ku,params:{pageSize:20,filter:{hidden:{$isFalsy:!0},dataSourceKey:r.key},sort:["sort"],appends:["fields"]}},e)},ju=()=>{var o,n;const e=g.useContext(s.CollectionContext),t=s.useFilterFieldOptions(e.fields),{service:r}=s.useTableBlockContext();return s.useFilterFieldProps({options:t,params:((n=(o=r.state)==null?void 0:o.params)==null?void 0:n[0])||r.params,service:r})},Ku={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:Mu}}}}}}}}}}}}}}}}}},$u=()=>{const e=C.useForm(),t=s.useAPIClient(),r=s.useCollectionRecordData(),o=s.useActionContext(),{service:n}=s.useTableBlockContext(),{currentDataSource:a}=g.useContext(Se);return{onClick(){return M(this,null,function*(){yield t.resource("roles.dataSourceResources",r.roleName)[r.exists?"update":"create"]({filterByTk:r.name,filter:{dataSourceKey:a.key,name:r.name},values:B(I({},e.values),{name:r.name,dataSourceKey:a.key})}),o.setVisible(!1),n==null||n.refresh()})}}},ko=g.createContext([]);ko.displayName="AvailableActionsContext";const Bu=e=>{const{data:t,loading:r}=s.useRequest({resource:"availableActions",action:"list"});return r?c.jsx(T.Spin,{}):c.jsx(ko.Provider,{value:t==null?void 0:t.data,children:e.children})},Js=()=>g.useContext(ko),Vu=()=>{const e=s.useRecord();return c.jsx("div",{children:c.jsx(s.SchemaComponentContext.Provider,{value:{designable:!1},children:c.jsx(Bu,{children:c.jsx(s.SchemaComponent,{schema:Ku,components:{SettingCenterPermissionProvider:s.SettingCenterPermissionProvider,PermissionProvider:Pu,RoleCollectionTableBlockProvider:Du},scope:{dataSourceKey:e.key,useSaveRoleResourceAction:$u,useFilterActionProps:ju,useRoleCollectionServiceProps:Eu}})})})})},Nu=()=>{const{update:e}=g.useContext(Se),{t}=$.useTranslation(),{key:r}=s.useRecord();return c.jsx(s.SchemaComponent,{schema:{type:"void",name:"form","x-component":"Form","x-component-props":{useValues:o=>{const n=s.useAPIClient(),a=g.useContext(Ae);return s.useRequest(()=>n.resource(`dataSources/${r}/roles`).get({filterByTk:a.name}).then(i=>{var p,u;const l=(p=i==null?void 0:i.data)==null?void 0:p.data;return(u=l.snippets)==null||u.forEach(m=>{l[m]=!0}),{data:l}}),o)},effects(){C.onFieldChange("*",(o,n)=>M(null,null,function*(){n.modified&&(yield e(o,n))}))}},properties:{"strategy.actions":{description:t("All collections use general action permissions by default; permission configured individually will override the default one."),"x-component":"StrategyActions"}}}})},Lu=(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}}]}),Ru=()=>{const{name:e}=g.useContext(pe),t=s.useFormBlockContext();return g.useEffect(()=>{t.form.setInitialValues({resourceName:e})},[e]),{form:t.form}},Gu=e=>{const t=Lu(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:g.useContext(pe).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":Ru,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 r=g.useContext(pe);return{options:s.useFilterFieldOptions(r.fields)}},"x-component-props":{dynamicComponent:s.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 r=g.useContext(pe);return{options:s.useFilterFieldOptions(r.fields)}},"x-component-props":{dynamicComponent:s.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"}}}}}}}}}}}}},Qs=g.createContext(null);Qs.displayName="RolesResourcesScopesSelectedRowKeysContext";const Uu=e=>{const[t,r]=g.useState([]);return c.jsx(Qs.Provider,{value:[t,r],children:e.children})},zu=e=>{const t=g.useMemo(()=>C.createForm({values:{scope:e.value}}),[]),{key:r}=s.useRecord(),o=Gu(r);return c.jsx(s.FormProvider,{form:t,children:c.jsx(s.SchemaComponent,{components:{RolesResourcesScopesSelectedRowKeysProvider:Uu},scope:{onChange(n){var a;(a=e==null?void 0:e.onChange)==null||a.call(e,n)}},schema:o})})},Hu=s.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": "1.3.18",
4
- "@tachybase/server": "1.3.18",
3
+ "@tachybase/client": "1.3.20",
4
+ "@tachybase/server": "1.3.20",
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": "1.3.18",
9
+ "@tachybase/schema": "1.3.20",
10
10
  "react-i18next": "15.2.0",
11
- "@tachybase/database": "1.3.18",
12
- "@tachybase/utils": "1.3.18",
13
- "@tachybase/module-acl": "1.3.18",
14
- "@tachybase/acl": "1.3.18",
11
+ "@tachybase/database": "1.3.20",
12
+ "@tachybase/utils": "1.3.20",
13
+ "@tachybase/module-acl": "1.3.20",
14
+ "@tachybase/acl": "1.3.20",
15
15
  "sequelize": "6.37.5",
16
- "@tachybase/components": "1.3.18",
16
+ "@tachybase/components": "1.3.20",
17
17
  "@dnd-kit/core": "6.3.1",
18
18
  "ahooks": "3.9.0"
19
19
  };
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": "1.3.18",
4
+ "version": "1.3.20",
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,17 +18,17 @@
18
18
  "react-i18next": "^15.2.0",
19
19
  "react-router-dom": "6.28.1",
20
20
  "sequelize": "^6.37.5",
21
- "@tachybase/components": "1.3.18",
22
- "@tachybase/schema": "1.3.18"
21
+ "@tachybase/components": "1.3.20",
22
+ "@tachybase/schema": "1.3.20"
23
23
  },
24
24
  "peerDependencies": {
25
- "@tachybase/acl": "1.3.18",
26
- "@tachybase/client": "1.3.18",
27
- "@tachybase/database": "1.3.18",
28
- "@tachybase/module-acl": "1.3.18",
29
- "@tachybase/server": "1.3.18",
30
- "@tachybase/test": "1.3.18",
31
- "@tachybase/utils": "1.3.18"
25
+ "@tachybase/acl": "1.3.20",
26
+ "@tachybase/client": "1.3.20",
27
+ "@tachybase/server": "1.3.20",
28
+ "@tachybase/module-acl": "1.3.20",
29
+ "@tachybase/database": "1.3.20",
30
+ "@tachybase/test": "1.3.20",
31
+ "@tachybase/utils": "1.3.20"
32
32
  },
33
33
  "description.zh-CN": "管理数据源,包括内置的 Master 数据库,外部的数据库、API。",
34
34
  "displayName.zh-CN": "数据源管理",