Skip to content

Commit

Permalink
Merge pull request patternfly#125 from jeff-phillips-18/node-details-…
Browse files Browse the repository at this point in the history
…scale

fix: reduce node details when at low scale
  • Loading branch information
jeff-phillips-18 authored Dec 13, 2023
2 parents bf94564 + e18751c commit 4f416c8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/demo-app-ts/src/components/DemoFinallyNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Layer,
ScaleDetailsLevel,
TOP_LAYER,
useDetailsLevel,
useHover,
WithContextMenuProps,
WithSelectionProps
Expand All @@ -19,7 +18,7 @@ type DemoFinallyNodeProps = {

const DemoFinallyNode: React.FunctionComponent<DemoFinallyNodeProps> = ({ ...props }) => {
const [hover, hoverRef] = useHover();
const detailsLevel = useDetailsLevel();
const detailsLevel = props.element.getGraph().getDetailsLevel();

return (
<Layer id={detailsLevel !== ScaleDetailsLevel.high && hover ? TOP_LAYER : DEFAULT_LAYER}>
Expand Down
3 changes: 1 addition & 2 deletions packages/demo-app-ts/src/components/DemoTaskNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ScaleDetailsLevel,
TaskNode,
TOP_LAYER,
useDetailsLevel,
useHover,
WhenDecorator,
WithContextMenuProps,
Expand All @@ -33,7 +32,7 @@ const DemoTaskNode: React.FunctionComponent<DemoTaskNodeProps> = ({
const nodeElement = element as Node;
const data = element.getData();
const [hover, hoverRef] = useHover();
const detailsLevel = useDetailsLevel();
const detailsLevel = element.getGraph().getDetailsLevel();

const passedData = React.useMemo(() => {
const newData = { ...data };
Expand Down
3 changes: 1 addition & 2 deletions packages/demo-app-ts/src/components/StyleGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@patternfly/react-topology';
import AlternateIcon from '@patternfly/react-icons/dist/esm/icons/regions-icon';
import DefaultIcon from '@patternfly/react-icons/dist/esm/icons/builder-image-icon';
import useDetailsLevel from '@patternfly/react-topology/dist/esm/hooks/useDetailsLevel';

const ICON_PADDING = 20;

Expand Down Expand Up @@ -43,7 +42,7 @@ const StyleGroup: React.FunctionComponent<StyleGroupProps> = ({
}) => {
const groupElement = element as Node;
const data = element.getData();
const detailsLevel = useDetailsLevel();
const detailsLevel = element.getGraph().getDetailsLevel();

const getTypeIcon = (dataType?: DataTypes): any => {
switch (dataType) {
Expand Down
3 changes: 1 addition & 2 deletions packages/demo-app-ts/src/components/StyleNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-i
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
import PauseCircle from '@patternfly/react-icons/dist/esm/icons/pause-circle-icon';
import Thumbtack from '@patternfly/react-icons/dist/esm/icons/thumbtack-icon';
import useDetailsLevel from '@patternfly/react-topology/dist/esm/hooks/useDetailsLevel';
import { SVGIconProps } from '@patternfly/react-icons/dist/esm/createIcon';

export enum DataTypes {
Expand Down Expand Up @@ -134,7 +133,7 @@ const StyleNode: React.FunctionComponent<StyleNodeProps> = ({
}) => {
const nodeElement = element as Node;
const data = element.getData();
const detailsLevel = useDetailsLevel();
const detailsLevel = element.getGraph().getDetailsLevel();
const [hover, hoverRef] = useHover();

const passedData = React.useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/demo-app-ts/src/utils/useDemoPipelineNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export const useDemoPipelineNodes = (
taskIconTooltip: showIcons ? 'Environment' : undefined,
showContextMenu,
columnGroup: TASK_STATUSES.length % STATUS_PER_ROW + 1,
showStatusState: false,
showStatusState: true,
leadIcon: <ExternalLinkAltIcon width={16} height={16} />,
};

Expand Down
3 changes: 1 addition & 2 deletions packages/module/src/pipelines/components/nodes/TaskNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import NodeShadows, {
} from '../../../components/nodes/NodeShadows';
import LabelBadge from '../../../components/nodes/labels/LabelBadge';
import LabelIcon from '../../../components/nodes/labels/LabelIcon';
import useDetailsLevel from '../../../hooks/useDetailsLevel';
import { useScaleNode } from '../../../hooks';

const STATUS_ICON_SIZE = 16;
Expand Down Expand Up @@ -169,7 +168,7 @@ const TaskNodeInner: React.FC<TaskNodeInnerProps> = observer(({
const badgeLabelTriggerRef = React.useRef();
const [actionSize, actionRef] = useSize([actionIcon, paddingX]);
const [contextSize, contextRef] = useSize([onContextMenu, paddingX]);
const detailsLevel = useDetailsLevel();
const detailsLevel = element.getGraph().getDetailsLevel();

if (badgePopoverProps) {
// eslint-disable-next-line no-console
Expand Down

0 comments on commit 4f416c8

Please sign in to comment.