-
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.
Add the component and utility for helm release group
initial implementation initial implementation remove styles for selected and fine tune initial implementation align the item to UX designs add tests for utility and update test use fill attribute istead of styles update snapshot add corner radius to helm icon refactor disable dnd for helm release node decrease opacity on filtered items
- Loading branch information
Showing
11 changed files
with
304 additions
and
6 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
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
33 changes: 33 additions & 0 deletions
33
frontend/packages/dev-console/src/components/topology/components/groups/HelmRelease.scss
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,33 @@ | ||
.odc-helm-release { | ||
fill: #e2e2e2; | ||
stroke: #bbbbbb; | ||
stroke-width: 4px; | ||
stroke-dasharray: 9; | ||
cursor: pointer; | ||
|
||
&__label { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.odc-m-filter-active { | ||
.odc-helm-release { | ||
&__label { | ||
opacity: 0.3; | ||
&.is-filtered { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.odc-m-drag-active { | ||
.odc-helm-release { | ||
&__label { | ||
opacity: 0.3; | ||
&.is-dragging { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import * as React from 'react'; | ||
import * as classNames from 'classnames'; | ||
import { connect } from 'react-redux'; | ||
import { | ||
Layer, | ||
useHover, | ||
Node, | ||
createSvgIdUrl, | ||
useDragNode, | ||
observer, | ||
useCombineRefs, | ||
} from '@console/topology'; | ||
import { RootState } from '@console/internal/redux'; | ||
import NodeShadows, { NODE_SHADOW_FILTER_ID_HOVER, NODE_SHADOW_FILTER_ID } from '../NodeShadows'; | ||
import SvgBoxedText from '../../../svg/SvgBoxedText'; | ||
import './HelmRelease.scss'; | ||
import { getTopologyFilters, TopologyFilters } from '../../filters/filter-utils'; | ||
import useFilter from '../../filters/useFilter'; | ||
|
||
export type HelmReleaseProps = { | ||
element: Node; | ||
dragging?: boolean; | ||
filters: TopologyFilters; | ||
}; | ||
|
||
const HelmRelease: React.FC<HelmReleaseProps> = ({ 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} | ||
icon="helm" | ||
> | ||
{element.getLabel()} | ||
</SvgBoxedText> | ||
)} | ||
</g> | ||
); | ||
}; | ||
|
||
const HelmReleaseState = (state: RootState) => ({ | ||
filters: getTopologyFilters(state), | ||
}); | ||
|
||
export default connect(HelmReleaseState)(observer(HelmRelease)); |
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.