Skip to content

Commit 3121b87

Browse files
yezaoshu蚂蚁代码服务
authored andcommitted
PullRequest: 874 feat: support sync datasourcr in private space
Merge branch 'feat/syncdb of git@code.alipay.com:oceanbase/oceanbase-developer-center.git into dev-4.3.4 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/874 Reviewed-by: 晓康 <xxk268858@oceanbase.com> * feat: support sync datasourcr in private space
1 parent d1fa701 commit 3121b87

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

src/page/Workspace/SideBar/ResourceTree/TreeNodeMenu/dataSource.tsx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ import ResourceTreeContext from '@/page/Workspace/context/ResourceTreeContext';
1515
import { SearchOutlined } from '@ant-design/icons';
1616
import { openGlobalSearch } from '@/page/Workspace/SideBar/ResourceTree/const';
1717
import { isConnectTypeBeFileSystemGroup } from '@/util/connection';
18+
import { syncDatasource } from '@/common/network/connection';
19+
1820
const 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

Comments
 (0)