-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some EIPs provide a `disabled` property to ignore them during the runtime. This commit adds a quick access to that property, so users can easily enable/disable nodes in the canvas. In addition to that, the step is grayed out when disabled. fix: #758 fix: #699
- Loading branch information
Showing
25 changed files
with
181 additions
and
15 deletions.
There are no files selected for viewing
36 changes: 26 additions & 10 deletions
36
packages/ui/src/components/Visualization/Custom/CustomNode.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 |
---|---|---|
@@ -1,12 +1,28 @@ | ||
/* stylelint-disable-next-line selector-class-pattern */ | ||
.custom-node__image { | ||
display: flex; | ||
flex-flow: column; | ||
align-items: center; | ||
height: 100%; | ||
justify-content: center; | ||
|
||
img { | ||
max-height: 80%; | ||
.custom-node { | ||
&__image { | ||
display: flex; | ||
flex-flow: column; | ||
align-items: center; | ||
height: 100%; | ||
justify-content: center; | ||
|
||
img { | ||
max-height: 80%; | ||
max-width: 95%; | ||
} | ||
} | ||
|
||
&[data-disabled='true'] &__image { | ||
filter: grayscale(100%); | ||
} | ||
|
||
&--disabled { | ||
--pf-topology__node_decorator--Color: var(--pf-v5-global--BackgroundColor--dark-200); | ||
} | ||
} | ||
|
||
/* stylelint-disable-next-line selector-class-pattern */ | ||
.custom-node__label--disabled { | ||
font-style: italic; | ||
text-decoration: line-through; | ||
} |
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
39 changes: 39 additions & 0 deletions
39
packages/ui/src/components/Visualization/Custom/ItemDisableStep.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,39 @@ | ||
import { BanIcon, CheckIcon } from '@patternfly/react-icons'; | ||
import { ContextMenuItem } from '@patternfly/react-topology'; | ||
import { FunctionComponent, PropsWithChildren, useCallback, useContext } from 'react'; | ||
import { IDataTestID } from '../../../models'; | ||
import { IVisualizationNode } from '../../../models/visualization/base-visual-entity'; | ||
import { EntitiesContext } from '../../../providers/entities.provider'; | ||
import { setValue } from '../../../utils/set-value'; | ||
|
||
interface ItemDisableStepProps extends PropsWithChildren<IDataTestID> { | ||
vizNode: IVisualizationNode; | ||
} | ||
|
||
export const ItemDisableStep: FunctionComponent<ItemDisableStepProps> = (props) => { | ||
const entitiesContext = useContext(EntitiesContext); | ||
|
||
const isDisabled = !!props.vizNode.getComponentSchema()?.definition?.disabled; | ||
|
||
const onToggleDisableNode = useCallback(() => { | ||
const newModel = props.vizNode.getComponentSchema()?.definition || {}; | ||
setValue(newModel, 'disabled', !isDisabled); | ||
props.vizNode.updateModel(newModel); | ||
|
||
entitiesContext?.updateEntitiesFromCamelResource(); | ||
}, [entitiesContext, isDisabled, props.vizNode]); | ||
|
||
return ( | ||
<ContextMenuItem onClick={onToggleDisableNode} data-testid={props['data-testid']}> | ||
{isDisabled ? ( | ||
<> | ||
<CheckIcon /> Enable | ||
</> | ||
) : ( | ||
<> | ||
<BanIcon /> Disable | ||
</> | ||
)} | ||
</ContextMenuItem> | ||
); | ||
}; |
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
Oops, something went wrong.