mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-26 09:26:22 +00:00
feat(glossary) Add empty state for the Business Glossary home page (#5217)
This commit is contained in:
parent
77f94cd349
commit
4c33f2d733
@ -10,6 +10,7 @@ import GlossaryEntitiesList from './GlossaryEntitiesList';
|
||||
import GlossaryBrowser from './GlossaryBrowser/GlossaryBrowser';
|
||||
import GlossarySearch from './GlossarySearch';
|
||||
import { ProfileSidebarResizer } from '../entity/shared/containers/profile/sidebar/ProfileSidebarResizer';
|
||||
import EmptyGlossarySection from './EmptyGlossarySection';
|
||||
|
||||
export const HeaderWrapper = styled(TabToolbar)`
|
||||
padding: 15px 45px 10px 24px;
|
||||
@ -44,6 +45,8 @@ function BusinessGlossaryPage() {
|
||||
const terms = termsData?.getRootGlossaryTerms?.terms;
|
||||
const nodes = nodesData?.getRootGlossaryNodes?.nodes;
|
||||
|
||||
const hasTermsOrNodes = !!nodes?.length || !!terms?.length;
|
||||
|
||||
return (
|
||||
<SearchablePage>
|
||||
<GlossaryWrapper>
|
||||
@ -68,7 +71,10 @@ function BusinessGlossaryPage() {
|
||||
refetchForNodes={refetchForNodes}
|
||||
/>
|
||||
</HeaderWrapper>
|
||||
<GlossaryEntitiesList nodes={nodes || []} terms={terms || []} />
|
||||
{hasTermsOrNodes && <GlossaryEntitiesList nodes={nodes || []} terms={terms || []} />}
|
||||
{!hasTermsOrNodes && (
|
||||
<EmptyGlossarySection refetchForTerms={refetchForTerms} refetchForNodes={refetchForNodes} />
|
||||
)}
|
||||
</MainContentWrapper>
|
||||
</GlossaryWrapper>
|
||||
</SearchablePage>
|
||||
|
||||
69
datahub-web-react/src/app/glossary/EmptyGlossarySection.tsx
Normal file
69
datahub-web-react/src/app/glossary/EmptyGlossarySection.tsx
Normal file
@ -0,0 +1,69 @@
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import { Button, Empty, Typography } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import styled from 'styled-components/macro';
|
||||
import { EntityType } from '../../types.generated';
|
||||
import CreateGlossaryEntityModal from '../entity/shared/EntityDropdown/CreateGlossaryEntityModal';
|
||||
|
||||
const StyledEmpty = styled(Empty)`
|
||||
padding: 80px 40px;
|
||||
.ant-empty-footer {
|
||||
.ant-btn:not(:last-child) {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const StyledButton = styled(Button)`
|
||||
margin-right: 8px;
|
||||
`;
|
||||
|
||||
interface Props {
|
||||
refetchForTerms?: () => void;
|
||||
refetchForNodes?: () => void;
|
||||
}
|
||||
|
||||
function EmptyGlossarySection(props: Props) {
|
||||
const { refetchForTerms, refetchForNodes } = props;
|
||||
|
||||
const [isCreateTermModalVisible, setIsCreateTermModalVisible] = useState(false);
|
||||
const [isCreateNodeModalVisible, setIsCreateNodeModalVisible] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledEmpty
|
||||
description={
|
||||
<>
|
||||
<Typography.Title level={4}>Empty Glossary</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
Create Terms and Term Groups to organize data assets using a shared vocabulary.
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<StyledButton onClick={() => setIsCreateTermModalVisible(true)}>
|
||||
<PlusOutlined /> Add Term
|
||||
</StyledButton>
|
||||
<StyledButton onClick={() => setIsCreateNodeModalVisible(true)}>
|
||||
<PlusOutlined /> Add Term Group
|
||||
</StyledButton>
|
||||
</StyledEmpty>
|
||||
{isCreateTermModalVisible && (
|
||||
<CreateGlossaryEntityModal
|
||||
entityType={EntityType.GlossaryTerm}
|
||||
onClose={() => setIsCreateTermModalVisible(false)}
|
||||
refetchData={refetchForTerms}
|
||||
/>
|
||||
)}
|
||||
{isCreateNodeModalVisible && (
|
||||
<CreateGlossaryEntityModal
|
||||
entityType={EntityType.GlossaryNode}
|
||||
onClose={() => setIsCreateNodeModalVisible(false)}
|
||||
refetchData={refetchForNodes}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default EmptyGlossarySection;
|
||||
Loading…
x
Reference in New Issue
Block a user