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