mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Disable tools/legend buttons when the workflow has no nodes and is displaying the start screen.
This commit is contained in:
@@ -192,6 +192,30 @@ describe('Visualizer', () => {
|
|||||||
).toHaveBeenCalledWith(8, 9);
|
).toHaveBeenCalledWith(8, 9);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Start Screen shown when no nodes are present', async () => {
|
||||||
|
WorkflowJobTemplatesAPI.readNodes.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
count: 0,
|
||||||
|
results: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<svg>
|
||||||
|
<Visualizer template={template} />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
wrapper.update();
|
||||||
|
expect(wrapper.find('VisualizerStartScreen')).toHaveLength(1);
|
||||||
|
expect(
|
||||||
|
wrapper.find('ActionButton#visualizer-toggle-tools').props().isDisabled
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
wrapper.find('ActionButton#visualizer-toggle-legend').props().isDisabled
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
test('Error shown to user when error thrown fetching workflow nodes', async () => {
|
test('Error shown to user when error thrown fetching workflow nodes', async () => {
|
||||||
WorkflowJobTemplatesAPI.readNodes.mockRejectedValue(new Error());
|
WorkflowJobTemplatesAPI.readNodes.mockRejectedValue(new Error());
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const ActionButton = styled(Button)`
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
ActionButton.displayName = 'ActionButton';
|
||||||
|
|
||||||
function VisualizerToolbar({ i18n, onClose, onSave, template }) {
|
function VisualizerToolbar({ i18n, onClose, onSave, template }) {
|
||||||
const dispatch = useContext(WorkflowDispatchContext);
|
const dispatch = useContext(WorkflowDispatchContext);
|
||||||
@@ -62,7 +63,8 @@ function VisualizerToolbar({ i18n, onClose, onSave, template }) {
|
|||||||
<Tooltip content={i18n._(t`Toggle Legend`)} position="bottom">
|
<Tooltip content={i18n._(t`Toggle Legend`)} position="bottom">
|
||||||
<ActionButton
|
<ActionButton
|
||||||
id="visualizer-toggle-legend"
|
id="visualizer-toggle-legend"
|
||||||
isActive={showLegend}
|
isActive={totalNodes > 0 && showLegend}
|
||||||
|
isDisabled={totalNodes === 0}
|
||||||
onClick={() => dispatch({ type: 'TOGGLE_LEGEND' })}
|
onClick={() => dispatch({ type: 'TOGGLE_LEGEND' })}
|
||||||
variant="plain"
|
variant="plain"
|
||||||
>
|
>
|
||||||
@@ -72,7 +74,8 @@ function VisualizerToolbar({ i18n, onClose, onSave, template }) {
|
|||||||
<Tooltip content={i18n._(t`Toggle Tools`)} position="bottom">
|
<Tooltip content={i18n._(t`Toggle Tools`)} position="bottom">
|
||||||
<ActionButton
|
<ActionButton
|
||||||
id="visualizer-toggle-tools"
|
id="visualizer-toggle-tools"
|
||||||
isActive={showTools}
|
isActive={totalNodes > 0 && showTools}
|
||||||
|
isDisabled={totalNodes === 0}
|
||||||
onClick={() => dispatch({ type: 'TOGGLE_TOOLS' })}
|
onClick={() => dispatch({ type: 'TOGGLE_TOOLS' })}
|
||||||
variant="plain"
|
variant="plain"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user