You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.6 KiB
60 lines
2.6 KiB
import React, { useEffect, useState } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { Tabs } from 'antd';
|
|
import DatabaseTable from './databasesTable';
|
|
import FilesTable from './filesTable';
|
|
import RestapisTable from './restapisTable';
|
|
import { push } from 'react-router-redux';
|
|
|
|
const MetadataTab = (props) => {
|
|
const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch, params } = props;
|
|
const [activeKey, setActiveKey] = useState(params?.type || 'databases');
|
|
useEffect(() => {
|
|
if (!params?.type)
|
|
setActiveKey('databases');
|
|
}, [resourceCatalogId]);
|
|
|
|
const onTabChange = (key) => {
|
|
setActiveKey(key)
|
|
}
|
|
const onView = (record) => {
|
|
sessionStorage.setItem('jumpSelectedKey', resourceCatalogKey);
|
|
dispatch(push(`/metadataManagement/latestMetadata/detail/${record.id}`));
|
|
}
|
|
return <div>
|
|
<Tabs defaultActiveKey="databases"
|
|
onChange={onTabChange}
|
|
activeKey={activeKey}
|
|
items={[
|
|
{
|
|
label: <span> 库表 </span>,
|
|
key: 'databases'
|
|
},
|
|
{
|
|
label: <span> 文件 </span>,
|
|
key: 'files'
|
|
},
|
|
{
|
|
label: <span> 接口 </span>,
|
|
key: 'restapis'
|
|
}
|
|
]}>
|
|
</Tabs>
|
|
{
|
|
activeKey === 'databases' && resourceCatalogId ? <DatabaseTable params={params} resourceCatalogId={resourceCatalogId}
|
|
resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} setView={onView} /> :
|
|
activeKey === 'files' && resourceCatalogId ? <FilesTable params={params} resourceCatalogId={resourceCatalogId}
|
|
resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} /> :
|
|
activeKey === 'restapis' && resourceCatalogId ? < RestapisTable params={params} resourceCatalogId={resourceCatalogId}
|
|
resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} /> : null
|
|
}
|
|
</div>
|
|
}
|
|
function mapStateToProps(state) {
|
|
const { global, auth } = state;
|
|
return {
|
|
user: auth.user,
|
|
actions: global.actions
|
|
};
|
|
}
|
|
export default connect(mapStateToProps)(MetadataTab)
|