forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui) Add structured properties support in the UI (datahub-project…
- Loading branch information
1 parent
f83a2fa
commit a78c689
Showing
45 changed files
with
1,772 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
datahub-web-react/src/app/entity/shared/components/styled/EntityIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { useEntityRegistry } from '../../../../useEntityRegistry'; | ||
import { PlatformIcon } from '../../../../search/filters/utils'; | ||
import { Entity } from '../../../../../types.generated'; | ||
import { IconStyleType } from '../../../Entity'; | ||
import { ANTD_GRAY } from '../../constants'; | ||
|
||
interface Props { | ||
entity: Entity; | ||
size?: number; | ||
} | ||
|
||
export default function EntityIcon({ entity, size = 14 }: Props) { | ||
const entityRegistry = useEntityRegistry(); | ||
const genericEntityProps = entityRegistry.getGenericEntityProperties(entity.type, entity); | ||
const logoUrl = genericEntityProps?.platform?.properties?.logoUrl; | ||
const icon = logoUrl ? ( | ||
<PlatformIcon src={logoUrl} size={size} /> | ||
) : ( | ||
entityRegistry.getIcon(entity.type, size, IconStyleType.ACCENT, ANTD_GRAY[9]) | ||
); | ||
|
||
return <>{icon}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
datahub-web-react/src/app/entity/shared/containers/profile/sidebar/ProfileSidebar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { ProfileSidebarResizer } from './ProfileSidebarResizer'; | ||
import { EntitySidebar } from './EntitySidebar'; | ||
import { EntitySidebarSection } from '../../../types'; | ||
|
||
export const MAX_SIDEBAR_WIDTH = 800; | ||
export const MIN_SIDEBAR_WIDTH = 200; | ||
|
||
const Sidebar = styled.div<{ $width: number; backgroundColor?: string }>` | ||
max-height: 100%; | ||
position: relative; | ||
width: ${(props) => props.$width}px; | ||
min-width: ${(props) => props.$width}px; | ||
${(props) => props.backgroundColor && `background-color: ${props.backgroundColor};`} | ||
`; | ||
|
||
const ScrollWrapper = styled.div` | ||
overflow: auto; | ||
max-height: 100%; | ||
padding: 0 20px 20px 20px; | ||
`; | ||
|
||
const DEFAULT_SIDEBAR_SECTION = { | ||
visible: (_, _1) => true, | ||
}; | ||
|
||
interface Props { | ||
sidebarSections: EntitySidebarSection[]; | ||
backgroundColor?: string; | ||
topSection?: EntitySidebarSection; | ||
alignLeft?: boolean; | ||
} | ||
|
||
export default function ProfileSidebar({ sidebarSections, backgroundColor, topSection, alignLeft }: Props) { | ||
const sideBarSectionsWithDefaults = sidebarSections.map((sidebarSection) => ({ | ||
...sidebarSection, | ||
display: { ...DEFAULT_SIDEBAR_SECTION, ...sidebarSection.display }, | ||
})); | ||
|
||
const [sidebarWidth, setSidebarWidth] = useState(window.innerWidth * 0.25); | ||
|
||
if (alignLeft) { | ||
return ( | ||
<> | ||
<Sidebar $width={sidebarWidth} backgroundColor={backgroundColor} id="entity-profile-sidebar"> | ||
<ScrollWrapper> | ||
<EntitySidebar sidebarSections={sideBarSectionsWithDefaults} topSection={topSection} /> | ||
</ScrollWrapper> | ||
</Sidebar> | ||
<ProfileSidebarResizer | ||
setSidePanelWidth={(width) => | ||
setSidebarWidth(Math.min(Math.max(width, MIN_SIDEBAR_WIDTH), MAX_SIDEBAR_WIDTH)) | ||
} | ||
initialSize={sidebarWidth} | ||
isSidebarOnLeft | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<ProfileSidebarResizer | ||
setSidePanelWidth={(width) => | ||
setSidebarWidth(Math.min(Math.max(width, MIN_SIDEBAR_WIDTH), MAX_SIDEBAR_WIDTH)) | ||
} | ||
initialSize={sidebarWidth} | ||
/> | ||
<Sidebar $width={sidebarWidth} backgroundColor={backgroundColor} id="entity-profile-sidebar"> | ||
<ScrollWrapper> | ||
<EntitySidebar sidebarSections={sideBarSectionsWithDefaults} topSection={topSection} /> | ||
</ScrollWrapper> | ||
</Sidebar> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.