-
Notifications
You must be signed in to change notification settings - Fork 97
Fixes #38991 - Add chained task dependencies in the UI #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adamruzicka
merged 5 commits into
theforeman:master
from
ianballou:chaining-dependencies
Feb 26, 2026
+341
−1
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
946f415
Fixes #38991 - Add chained task dependencies in the UI
ianballou a9fb32e
Refs #38991 - use PF5 table on dependency tab
ianballou b270e11
Refs #38991 - model dependency task data in rabl
ianballou d7fe308
Refs #38991 - create chain() foreman-tasks method
ianballou fb98b0e
Refs #38991 - chain() now accepts Task objects
ianballou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
app/views/foreman_tasks/api/tasks/dependency_summary.json.rabl
This file contains hidden or 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,4 @@ | ||
| object @task | ||
|
|
||
| attributes :id, :action, :state, :result | ||
| node(:humanized) { @task.humanized[:action] } |
This file contains hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
| require 'foreman_tasks_test_helper' | ||
|
|
||
| module ForemanTasks | ||
| class ChainingTest < ActiveSupport::TestCase | ||
| include ForemanTasks::TestHelpers::WithInThreadExecutor | ||
|
|
||
| before do | ||
| User.current = User.where(:login => 'apiadmin').first | ||
| end | ||
|
|
||
| it 'creates a scheduled task chained to a prerequisite execution plan' do | ||
| prerequisite_plan = ForemanTasks.dynflow.world.plan(Support::DummyDynflowAction) | ||
|
|
||
| task = ForemanTasks.chain(prerequisite_plan.id, Support::DummyDynflowAction) | ||
|
|
||
| assert_kind_of ForemanTasks::Task::DynflowTask, task | ||
| assert_predicate task, :scheduled? | ||
|
|
||
| dependencies = ForemanTasks.dynflow.world.persistence.find_execution_plan_dependencies(task.execution_plan.id) | ||
| assert_includes dependencies, prerequisite_plan.id | ||
| end | ||
|
|
||
| it 'accepts multiple prerequisite execution plans' do | ||
| prerequisite_plan_1 = ForemanTasks.dynflow.world.plan(Support::DummyDynflowAction) | ||
| prerequisite_plan_2 = ForemanTasks.dynflow.world.plan(Support::DummyDynflowAction) | ||
|
|
||
| task = ForemanTasks.chain([prerequisite_plan_1.id, prerequisite_plan_2.id], Support::DummyDynflowAction) | ||
|
|
||
| dependencies = ForemanTasks.dynflow.world.persistence.find_execution_plan_dependencies(task.execution_plan.id) | ||
| assert_includes dependencies, prerequisite_plan_1.id | ||
| assert_includes dependencies, prerequisite_plan_2.id | ||
| end | ||
| end | ||
| end | ||
|
|
||
ianballou marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
93 changes: 93 additions & 0 deletions
93
webpack/ForemanTasks/Components/TaskDetails/Components/Dependencies.js
This file contains hidden or 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,93 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { | ||
| Alert, | ||
| AlertVariant, | ||
| Grid, | ||
| GridItem, | ||
| Title, | ||
| } from '@patternfly/react-core'; | ||
| import { Table, Thead, Tbody, Tr, Th, Td } from '@patternfly/react-table'; | ||
| import { translate as __ } from 'foremanReact/common/I18n'; | ||
|
|
||
| const DependencyTable = ({ title, tasks }) => { | ||
| const tableId = title.toLowerCase().replace(/\s+/g, '-'); | ||
| return ( | ||
| <div> | ||
| <Title headingLevel="h4" size="md" ouiaId={`${tableId}-title`}> | ||
| {title} | ||
| </Title> | ||
| {tasks.length === 0 ? ( | ||
| <p className="text-muted">{__('None')}</p> | ||
| ) : ( | ||
| <Table aria-label={title} variant="compact" ouiaId={`${tableId}-table`}> | ||
| <Thead> | ||
| <Tr ouiaId={`${tableId}-table-header`}> | ||
| <Th width={50}>{__('Action')}</Th> | ||
| <Th width={25}>{__('State')}</Th> | ||
| <Th width={25}>{__('Result')}</Th> | ||
| </Tr> | ||
| </Thead> | ||
| <Tbody> | ||
| {tasks.map(task => ( | ||
| <Tr key={task.id} ouiaId={`${tableId}-table-row-${task.id}`}> | ||
| <Td> | ||
| <a href={`/foreman_tasks/tasks/${task.id}`}> | ||
| {task.humanized || task.action} | ||
| </a> | ||
| </Td> | ||
| <Td>{task.state}</Td> | ||
| <Td>{task.result}</Td> | ||
| </Tr> | ||
| ))} | ||
| </Tbody> | ||
| </Table> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| DependencyTable.propTypes = { | ||
| title: PropTypes.string.isRequired, | ||
| tasks: PropTypes.array, | ||
| }; | ||
|
|
||
| DependencyTable.defaultProps = { | ||
| tasks: [], | ||
| }; | ||
|
|
||
| const Dependencies = ({ dependsOn, blocks }) => ( | ||
| <div> | ||
| <Alert | ||
| variant={AlertVariant.info} | ||
| isInline | ||
| title={__('Task dependencies')} | ||
| ouiaId="task-dependencies-info-alert" | ||
| > | ||
| {__( | ||
| 'This task may have dependencies on other tasks or may be blocking other tasks from executing. Dependencies are established through task chaining relationships.' | ||
ianballou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| )} | ||
| </Alert> | ||
| <br /> | ||
| <Grid hasGutter> | ||
| <GridItem span={6}> | ||
| <DependencyTable title={__('Depends on')} tasks={dependsOn} /> | ||
| </GridItem> | ||
| <GridItem span={6}> | ||
| <DependencyTable title={__('Blocks')} tasks={blocks} /> | ||
| </GridItem> | ||
| </Grid> | ||
| </div> | ||
| ); | ||
|
|
||
| Dependencies.propTypes = { | ||
| dependsOn: PropTypes.array, | ||
| blocks: PropTypes.array, | ||
| }; | ||
|
|
||
| Dependencies.defaultProps = { | ||
| dependsOn: [], | ||
| blocks: [], | ||
| }; | ||
|
|
||
| export default Dependencies; | ||
92 changes: 92 additions & 0 deletions
92
webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Dependencies.test.js
This file contains hidden or 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,92 @@ | ||
| import React from 'react'; | ||
| import { mount } from 'enzyme'; | ||
| import Dependencies from '../Dependencies'; | ||
|
|
||
| describe('Dependencies', () => { | ||
| it('should render with no dependencies', () => { | ||
| const wrapper = mount(<Dependencies dependsOn={[]} blocks={[]} />); | ||
| expect(wrapper.find('Alert')).toHaveLength(1); | ||
| expect(wrapper.find('DependencyTable')).toHaveLength(2); | ||
| expect(wrapper.find('Table')).toHaveLength(0); | ||
| expect(wrapper.text()).toContain('None'); | ||
| }); | ||
|
|
||
| it('should render with depends_on dependencies', () => { | ||
| const dependsOn = [ | ||
| { | ||
| id: '123', | ||
| action: 'Actions::FooBar', | ||
| humanized: 'Foo Bar Action', | ||
| state: 'stopped', | ||
| result: 'success', | ||
| }, | ||
| { | ||
| id: '456', | ||
| action: 'Actions::BazQux', | ||
| humanized: 'Baz Qux Action', | ||
| state: 'running', | ||
| result: 'pending', | ||
| }, | ||
| ]; | ||
| const wrapper = mount(<Dependencies dependsOn={dependsOn} blocks={[]} />); | ||
| expect(wrapper.find('Table')).toHaveLength(1); | ||
| expect(wrapper.find('Tbody').find('Tr')).toHaveLength(2); | ||
| expect(wrapper.text()).toContain('Foo Bar Action'); | ||
| expect(wrapper.text()).toContain('Baz Qux Action'); | ||
| expect(wrapper.text()).toContain('stopped'); | ||
| expect(wrapper.text()).toContain('success'); | ||
| }); | ||
|
|
||
| it('should render with blocks dependencies', () => { | ||
| const blocks = [ | ||
| { | ||
| id: '789', | ||
| action: 'Actions::Test', | ||
| humanized: 'Test Action', | ||
| state: 'paused', | ||
| result: 'warning', | ||
| }, | ||
| ]; | ||
| const wrapper = mount(<Dependencies dependsOn={[]} blocks={blocks} />); | ||
| expect(wrapper.find('Table')).toHaveLength(1); | ||
| expect(wrapper.find('Tbody').find('Tr')).toHaveLength(1); | ||
| expect(wrapper.text()).toContain('Test Action'); | ||
| expect(wrapper.text()).toContain('paused'); | ||
| expect(wrapper.text()).toContain('warning'); | ||
| }); | ||
|
|
||
| it('should render with both dependency types', () => { | ||
| const dependsOn = [ | ||
| { | ||
| id: '123', | ||
| action: 'Actions::Foo', | ||
| humanized: 'Foo Action', | ||
| state: 'stopped', | ||
| result: 'success', | ||
| }, | ||
| ]; | ||
| const blocks = [ | ||
| { | ||
| id: '456', | ||
| action: 'Actions::Bar', | ||
| humanized: 'Bar Action', | ||
| state: 'running', | ||
| result: 'pending', | ||
| }, | ||
| { | ||
| id: '789', | ||
| action: 'Actions::Baz', | ||
| humanized: 'Baz Action', | ||
| state: 'stopped', | ||
| result: 'error', | ||
| }, | ||
| ]; | ||
| const wrapper = mount( | ||
| <Dependencies dependsOn={dependsOn} blocks={blocks} /> | ||
| ); | ||
| expect(wrapper.find('Table')).toHaveLength(2); | ||
| expect(wrapper.text()).toContain('Foo Action'); | ||
| expect(wrapper.text()).toContain('Bar Action'); | ||
| expect(wrapper.text()).toContain('Baz Action'); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.