fix: not exists data sourec (#3608)
This commit is contained in:
parent
3b30070f2d
commit
44f1ef1416
@ -1,7 +1,7 @@
|
||||
import { RightOutlined } from '@ant-design/icons';
|
||||
import { useApp, useCompile, useDataSourceManager } from '@nocobase/client';
|
||||
import { Breadcrumb, Space, Tag } from 'antd';
|
||||
import React, { useContext } from 'react';
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import { DataSourceContext } from '../DatabaseConnectionProvider';
|
||||
import { NAMESPACE, lang } from '../locale';
|
||||
@ -14,26 +14,30 @@ export const BreadcumbTitle = () => {
|
||||
const dm = useDataSourceManager();
|
||||
const { displayName } = dm.getDataSource(name) || {};
|
||||
const { dataSource } = useContext(DataSourceContext);
|
||||
const { status } = dataSource || dm.getDataSource(name);
|
||||
const option = statusEnum.find((v) => v.value === status);
|
||||
return (
|
||||
<Breadcrumb
|
||||
separator={<RightOutlined />}
|
||||
items={[
|
||||
{ title: <Link to={app.pluginSettingsManager.getRoutePath(NAMESPACE)}>{lang('Data source manager')}</Link> },
|
||||
{
|
||||
title: (
|
||||
<Space>
|
||||
<span>{compile(displayName)}</span>
|
||||
{status && (
|
||||
<Tag key={status} color={option?.color}>
|
||||
{compile(option?.label)}
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
const dataSourceValue = useMemo(() => dataSource || dm.getDataSource(name), [dataSource, name]);
|
||||
const items = useMemo(() => {
|
||||
const status = dataSourceValue?.status;
|
||||
const option = statusEnum.find((v) => v.value === status);
|
||||
const res = [
|
||||
{ title: <Link to={app.pluginSettingsManager.getRoutePath(NAMESPACE)}>{lang('Data source manager')}</Link> },
|
||||
];
|
||||
if (dataSourceValue) {
|
||||
res.push({
|
||||
title: (
|
||||
<Space>
|
||||
<span>{compile(displayName)}</span>
|
||||
{status && (
|
||||
<Tag key={status} color={option?.color}>
|
||||
{compile(option?.label)}
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return res;
|
||||
}, [dataSourceValue]);
|
||||
|
||||
return <Breadcrumb separator={<RightOutlined />} items={items} />;
|
||||
};
|
||||
|
@ -13,14 +13,15 @@ export const ViewDatabaseConnectionAction = () => {
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
!record.enabled &&
|
||||
css`
|
||||
.ant-btn-link {
|
||||
&:hover {
|
||||
color: rgba(0, 0, 0, 0.25) !important;
|
||||
}
|
||||
}
|
||||
`
|
||||
!record.enabled
|
||||
? css`
|
||||
.ant-btn-link {
|
||||
&:hover {
|
||||
color: rgba(0, 0, 0, 0.25) !important;
|
||||
}
|
||||
}
|
||||
`
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Button
|
||||
|
Loading…
Reference in New Issue
Block a user