Skip to content

Commit

Permalink
remove mysql in ocp mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Nov 7, 2023
1 parent cc258c0 commit ebc3eee
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 50 deletions.
5 changes: 5 additions & 0 deletions src/common/datasource/mysql/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { ConnectType, TaskType } from '@/d.ts';
import { IDataSourceModeConfig } from '../interface';
import MySQLColumnExtra from '../oceanbase/MySQLColumnExtra';
import { haveOCP } from '@/util/env';

const tableConfig = {
enableTableCharsetsAndCollations: true,
Expand Down Expand Up @@ -89,4 +90,8 @@ const items: Record<ConnectType.MYSQL, IDataSourceModeConfig> = {
},
};

if (haveOCP()) {
delete items[ConnectType.MYSQL];
}

export default items;
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const InstanceSelect: React.FC<IProps> = function ({ clusterStore, disabled }) {
const clusterRef = useRef<any>();
const tenantRef = useRef<any>();
const { form } = useContext(DatasourceFormContext);
const type = Form.useWatch('type', form);

useEffect(() => {
clusterStore.loadClusterList();
Expand All @@ -67,26 +68,50 @@ const InstanceSelect: React.FC<IProps> = function ({ clusterStore, disabled }) {
.filter((c) => c.status === 'ONLINE')
.forEach((cluster) => {
const tenants = tenantListMap[cluster.instanceId];

if (cluster.type !== 'CLUSTER') {
const tenantMode = tenantListMap[cluster?.instanceId]?.find(
(t) => t.tenantId === cluster?.instanceId,
)?.tenantMode;
const tenantType = tenantMode === 'MySQL' ? ConnectType.OB_MYSQL : ConnectType.OB_ORACLE;
if (tenantType !== type) {
return;
}
result.push({
value: cluster.instanceId,
label: cluster.instanceName,
isLeaf: true,
});
} else {
const children = tenants
?.map((tenant) => {
const tenantMode = tenantListMap[cluster?.instanceId]?.find(
(t) => t.tenantId === tenant?.tenantId,
)?.tenantMode;
const tenantType =
tenantMode === 'MySQL' ? ConnectType.OB_MYSQL : ConnectType.OB_ORACLE;
if (tenantType !== type) {
return null;
}
return {
value: tenant.tenantId,
label: tenant.tenantName,
};
})
.filter(Boolean);
if (!children?.length) {
return;
}
result.push({
value: cluster.instanceId,
label: cluster.instanceName,
isLeaf: false,
children: tenants?.map((tenant) => ({
value: tenant.tenantId,
label: tenant.tenantName,
})),
children: children,
});
}
});
return result;
}, [clusterList, tenantListMap]);
}, [clusterList, tenantListMap, type]);

return (
<>
Expand Down
46 changes: 24 additions & 22 deletions src/page/Datasource/Datasource/NewDatasourceDrawer/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,30 @@ export default forwardRef<IFormRef, IProps>(function DatasourceForm(
/>
</Form.Item>
) : null}
<Typography>
<Typography.Paragraph>
<Space size={4}>
<span>
{
formatMessage({
id:
'odc.src.page.Datasource.Datasource.NewDatasourceDrawer.Form.DataSourceType',
}) /* 数据源类型: */
}
</span>
<Icon
component={getDataSourceStyleByConnectType(type)?.icon?.component}
style={{
color: getDataSourceStyleByConnectType(type)?.icon?.color,
fontSize: 14,
}}
/>
{ConnectTypeText[type] || ''}
</Space>
</Typography.Paragraph>
</Typography>
{haveOCP() ? null : (
<Typography>
<Typography.Paragraph>
<Space size={4}>
<span>
{
formatMessage({
id:
'odc.src.page.Datasource.Datasource.NewDatasourceDrawer.Form.DataSourceType',
}) /* 数据源类型: */
}
</span>
<Icon
component={getDataSourceStyleByConnectType(type)?.icon?.component}
style={{
color: getDataSourceStyleByConnectType(type)?.icon?.color,
fontSize: 14,
}}
/>
{ConnectTypeText[type] || ''}
</Space>
</Typography.Paragraph>
</Typography>
)}
{/* <DBTypeItem /> */}
<Form.Item
rules={[
Expand Down
48 changes: 25 additions & 23 deletions src/page/Datasource/Datasource/NewDatasourceDrawer/NewButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,32 @@ const NewDatasourceButton: React.FC<{
),
};
});
results.push({
type: 'divider',
});
results = results.concat(
mysqlConnectTypes.map((item) => {
return {
label: ConnectTypeText[item],
key: item,
icon: (
<Icon
component={getDataSourceStyleByConnectType(item)?.icon?.component}
style={{
color: getDataSourceStyleByConnectType(item)?.icon?.color,
fontSize: '16px',
}}
/>
),
};
}),
);
results.push({
type: 'divider',
});
if (mysqlConnectTypes?.length) {
results.push({
type: 'divider',
});
results = results.concat(
mysqlConnectTypes.map((item) => {
return {
label: ConnectTypeText[item],
key: item,
icon: (
<Icon
component={getDataSourceStyleByConnectType(item)?.icon?.component}
style={{
color: getDataSourceStyleByConnectType(item)?.icon?.color,
fontSize: '16px',
}}
/>
),
};
}),
);
}
if (!haveOCP()) {
results.push({
type: 'divider',
});
results = results.concat({
label: formatMessage({
id: 'odc.component.BatchImportButton.BatchImport',
Expand Down

0 comments on commit ebc3eee

Please sign in to comment.