-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Topology: Expand/Collapse of Helm Releases
- Loading branch information
1 parent
caee2f6
commit 6ddecb5
Showing
9 changed files
with
190 additions
and
61 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
71 changes: 13 additions & 58 deletions
71
frontend/packages/dev-console/src/components/topology/components/groups/HelmRelease.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
70 changes: 70 additions & 0 deletions
70
frontend/packages/dev-console/src/components/topology/components/groups/HelmReleaseGroup.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,70 @@ | ||
import * as React from 'react'; | ||
import * as classNames from 'classnames'; | ||
import { | ||
Layer, | ||
useHover, | ||
Node, | ||
createSvgIdUrl, | ||
useDragNode, | ||
observer, | ||
useCombineRefs, | ||
} from '@console/topology'; | ||
import NodeShadows, { NODE_SHADOW_FILTER_ID_HOVER, NODE_SHADOW_FILTER_ID } from '../NodeShadows'; | ||
import SvgBoxedText from '../../../svg/SvgBoxedText'; | ||
import { TopologyFilters } from '../../filters/filter-utils'; | ||
import useFilter from '../../filters/useFilter'; | ||
|
||
export type HelmReleaseGroupProps = { | ||
element: Node; | ||
dragging?: boolean; | ||
filters: TopologyFilters; | ||
}; | ||
|
||
const HelmReleaseGroup: React.FC<HelmReleaseGroupProps> = ({ element, dragging, filters }) => { | ||
const [hover, hoverRef] = useHover(); | ||
const { x, y, width, height } = element.getBounds(); | ||
const dragNodeRef = useDragNode()[1]; | ||
const dragLabelRef = useDragNode()[1]; | ||
const refs = useCombineRefs(dragNodeRef, hoverRef); | ||
const filtered = useFilter(filters, { metadata: { name: element.getLabel() } }); | ||
return ( | ||
<g> | ||
<NodeShadows /> | ||
<Layer id={dragging ? undefined : 'groups'}> | ||
<rect | ||
ref={refs} | ||
className="odc-helm-release" | ||
x={x} | ||
y={y} | ||
width={width} | ||
height={height} | ||
rx="5" | ||
ry="5" | ||
filter={createSvgIdUrl( | ||
hover || dragging ? NODE_SHADOW_FILTER_ID_HOVER : NODE_SHADOW_FILTER_ID, | ||
)} | ||
/> | ||
</Layer> | ||
{element.getLabel() && ( | ||
<SvgBoxedText | ||
className={classNames('odc-base-node__label', 'odc-helm-release__label', { | ||
'is-filtered': filtered, | ||
'is-dragging': dragging, | ||
})} | ||
x={x + width / 2} | ||
y={y + height + 20} | ||
paddingX={8} | ||
paddingY={4} | ||
kind="HelmRelease" | ||
truncate={16} | ||
dragRef={dragLabelRef} | ||
typeIconClass="icon-helm" | ||
> | ||
{element.getLabel()} | ||
</SvgBoxedText> | ||
)} | ||
</g> | ||
); | ||
}; | ||
|
||
export default observer(HelmReleaseGroup); |
94 changes: 94 additions & 0 deletions
94
frontend/packages/dev-console/src/components/topology/components/groups/HelmReleaseNode.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,94 @@ | ||
import * as React from 'react'; | ||
import * as classNames from 'classnames'; | ||
import { | ||
useAnchor, | ||
RectAnchor, | ||
useHover, | ||
useSize, | ||
Node, | ||
createSvgIdUrl, | ||
useDragNode, | ||
observer, | ||
useCombineRefs, | ||
} from '@console/topology'; | ||
import NodeShadows, { NODE_SHADOW_FILTER_ID_HOVER, NODE_SHADOW_FILTER_ID } from '../NodeShadows'; | ||
import { TopologyFilters } from '../../filters/filter-utils'; | ||
import useFilter from '../../filters/useFilter'; | ||
import SvgResourceIcon from '../nodes/ResourceIcon'; | ||
import ResourceKindsInfo from '../nodes/ResourceKindsInfo'; | ||
|
||
export type HelmReleaseNodeProps = { | ||
element: Node; | ||
dragging?: boolean; | ||
filters: TopologyFilters; | ||
}; | ||
|
||
const TOP_MARGIN = 20; | ||
const LEFT_MARGIN = 20; | ||
const TEXT_MARGIN = 10; | ||
const RESOURCES_MARGIN = 40; | ||
|
||
const HelmReleaseNode: React.FC<HelmReleaseNodeProps> = ({ element, dragging, filters }) => { | ||
useAnchor((e: Node) => new RectAnchor(e, 4)); | ||
const [hover, hoverRef] = useHover(); | ||
const [labelHover, labelHoverRef] = useHover(); | ||
const dragNodeRef = useDragNode()[1]; | ||
const refs = useCombineRefs<SVGRectElement>(dragNodeRef, hoverRef); | ||
const filtered = useFilter(filters, { metadata: { name: element.getLabel() } }); | ||
const kind = 'HelmRelease'; | ||
const [iconSize, iconRef] = useSize([kind]); | ||
const iconWidth = iconSize ? iconSize.width : 0; | ||
const iconHeight = iconSize ? iconSize.height : 0; | ||
|
||
const rectClasses = classNames('odc-helm-release', { | ||
'is-hover': hover || labelHover, | ||
'is-filtered': filtered, | ||
}); | ||
|
||
const { width, height } = element.getBounds(); | ||
|
||
const title = ( | ||
<g ref={labelHoverRef} className="odc-application-group__node-title"> | ||
<SvgResourceIcon ref={iconRef} x={TOP_MARGIN} y={LEFT_MARGIN} kind={kind} leftJustified /> | ||
<text | ||
x={LEFT_MARGIN + iconWidth + TEXT_MARGIN} | ||
y={TOP_MARGIN + iconHeight} | ||
textAnchor="start" | ||
dy="-0.25em" | ||
> | ||
{element.getLabel()} | ||
</text> | ||
</g> | ||
); | ||
|
||
return ( | ||
<> | ||
<NodeShadows /> | ||
<g ref={hoverRef}> | ||
<rect | ||
ref={refs} | ||
filter={createSvgIdUrl( | ||
hover || labelHover || dragging ? NODE_SHADOW_FILTER_ID_HOVER : NODE_SHADOW_FILTER_ID, | ||
)} | ||
className={rectClasses} | ||
x={0} | ||
y={0} | ||
width={width} | ||
height={height} | ||
rx="5" | ||
ry="5" | ||
/> | ||
</g> | ||
<g> | ||
{title} | ||
<ResourceKindsInfo | ||
groupResources={element.getData().groupResources} | ||
offsetX={LEFT_MARGIN + iconWidth} | ||
offsetY={TOP_MARGIN + iconHeight + RESOURCES_MARGIN} | ||
/> | ||
</g> | ||
</> | ||
); | ||
}; | ||
|
||
export default observer(HelmReleaseNode); |
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
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