@@ -15,13 +15,17 @@ import ResourceTreeContext from '@/page/Workspace/context/ResourceTreeContext';
1515import { SearchOutlined } from '@ant-design/icons' ;
1616import { openGlobalSearch } from '@/page/Workspace/SideBar/ResourceTree/const' ;
1717import { isConnectTypeBeFileSystemGroup } from '@/util/connection' ;
18+ import { syncDatasource } from '@/common/network/connection' ;
19+
1820const CustomDropdown = ( {
1921 node,
2022 login,
2123 deleteDataSource,
2224 setCopyDatasourceId,
2325 setEditDatasourceId,
2426 setAddDSVisiable,
27+ userStore,
28+ sync,
2529} ) => {
2630 const [ dropdownVisible , setDropdownVisible ] = useState ( false ) ;
2731 const treeContext = useContext ( ResourceTreeContext ) ;
@@ -38,6 +42,7 @@ const CustomDropdown = ({
3842 setDropdownVisible ( false ) ;
3943 action ( e ) ;
4044 } ;
45+
4146 const menuItems = node . data
4247 ? [
4348 {
@@ -72,7 +77,20 @@ const CustomDropdown = ({
7277 deleteDataSource ( name as string , node . data . id as string ) ;
7378 } ) ,
7479 } ,
75- ]
80+ userStore . isPrivateSpace ( )
81+ ? {
82+ label : formatMessage ( {
83+ id : 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.884084AB' ,
84+ defaultMessage : '同步数据库' ,
85+ } ) ,
86+ key : 'sync' ,
87+ onClick : ( e ) =>
88+ handleMenuClick ( e , ( ) => {
89+ sync ( node . data . id ) ;
90+ } ) ,
91+ }
92+ : null ,
93+ ] ?. filter ( Boolean )
7694 : [ ] ;
7795 const menu = (
7896 < Menu >
@@ -130,6 +148,19 @@ const DataSourceNodeMenu = (props: IProps) => {
130148 copyDatasourceId,
131149 } = props ;
132150 const dataSource = node . data ;
151+
152+ async function sync ( id : number | string ) {
153+ const isSuccess = await syncDatasource ( toInteger ( id ) ) ;
154+ if ( isSuccess ) {
155+ message . success (
156+ formatMessage ( {
157+ id : 'odc.Datasource.Info.SynchronizationSucceeded' ,
158+ defaultMessage : '同步成功' ,
159+ } ) , //同步成功
160+ ) ;
161+ }
162+ }
163+
133164 return (
134165 < >
135166 < Popover
@@ -153,6 +184,8 @@ const DataSourceNodeMenu = (props: IProps) => {
153184 setCopyDatasourceId = { setCopyDatasourceId }
154185 setEditDatasourceId = { setEditDatasourceId }
155186 setAddDSVisiable = { setAddDSVisiable }
187+ userStore = { userStore }
188+ sync = { sync }
156189 />
157190 < div
158191 className = { classNames ( treeStyles . envTip , {
@@ -223,6 +256,13 @@ const DataSourceNodeMenu = (props: IProps) => {
223256 defaultMessage : '删除' ,
224257 } ) }
225258 </ Action . Link >
259+
260+ < Action . Link onClick = { ( ) => sync ( dataSource . id ) } key = { 'sync' } >
261+ { formatMessage ( {
262+ id : 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.884084AB' ,
263+ defaultMessage : '同步数据库' ,
264+ } ) }
265+ </ Action . Link >
226266 </ Action . Group >
227267 ) }
228268 </ div >
0 commit comments