-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #30633 - Stopped chart doesnt count cancelled
- Loading branch information
Showing
18 changed files
with
1,379 additions
and
1,491 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
4 changes: 4 additions & 0 deletions
4
...Dashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.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
53 changes: 53 additions & 0 deletions
53
...ponents/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js
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,53 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
import { Icon, Button, OverlayTrigger, Tooltip } from 'patternfly-react'; | ||
import { translate as __ } from 'foremanReact/common/I18n'; | ||
import { | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS, | ||
} from '../../../../TasksDashboardConstants'; | ||
import { queryPropType } from '../../../../TasksDashboardPropTypes'; | ||
|
||
const tooltip = ( | ||
<Tooltip id="stopped-tooltip"> | ||
{__('Other includes all stopped tasks that are cancelled or pending')} | ||
</Tooltip> | ||
); | ||
|
||
export const OtherInfo = ({ updateQuery, otherCount, query }) => { | ||
const { OTHER } = TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS; | ||
const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES; | ||
const active = query.state === STOPPED && query.result === OTHER; | ||
return ( | ||
<span className={classNames(active && 'other-active')}> | ||
<OverlayTrigger | ||
overlay={tooltip} | ||
trigger={['hover', 'focus']} | ||
placement="bottom" | ||
> | ||
<span> | ||
<Icon type="pf" name="info" /> | ||
<span>{__('Other:')} </span> | ||
</span> | ||
</OverlayTrigger> | ||
<Button | ||
bsStyle="link" | ||
onClick={() => | ||
updateQuery({ | ||
state: STOPPED, | ||
result: OTHER, | ||
}) | ||
} | ||
> | ||
{otherCount} | ||
</Button> | ||
</span> | ||
); | ||
}; | ||
OtherInfo.propTypes = { | ||
updateQuery: PropTypes.func.isRequired, | ||
otherCount: PropTypes.number.isRequired, | ||
query: queryPropType.isRequired, | ||
}; |
14 changes: 14 additions & 0 deletions
14
...ts/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js
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,14 @@ | ||
import { testComponentSnapshotsWithFixtures } from '@theforeman/test'; | ||
|
||
import { OtherInfo } from './OtherInfo'; | ||
|
||
const fixtures = { | ||
render: { | ||
updateQuery: jest.fn, | ||
otherCount: 7, | ||
query: { state: 'STOPPED', result: 'OTHER' }, | ||
}, | ||
}; | ||
|
||
describe('OtherInfo', () => | ||
testComponentSnapshotsWithFixtures(OtherInfo, fixtures)); |
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
35 changes: 1 addition & 34 deletions
35
...sDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js
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,48 +1,15 @@ | ||
import { testComponentSnapshotsWithFixtures } from '@theforeman/test'; | ||
import { | ||
TASKS_DASHBOARD_AVAILABLE_TIMES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS, | ||
} from '../../../../TasksDashboardConstants'; | ||
import { TASKS_DASHBOARD_AVAILABLE_QUERY_STATES } from '../../../../TasksDashboardConstants'; | ||
import StoppedTasksCard from './StoppedTasksCard'; | ||
|
||
const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES; | ||
const { LAST } = TASKS_DASHBOARD_AVAILABLE_QUERY_MODES; | ||
const { WEEK } = TASKS_DASHBOARD_AVAILABLE_TIMES; | ||
|
||
const fixtures = { | ||
'render with minimal props': {}, | ||
'render with props': { | ||
data: { | ||
error: { total: 9, last: 1 }, | ||
warning: { total: 8, last: 2 }, | ||
success: { total: 7, last: 3 }, | ||
}, | ||
time: WEEK, | ||
}, | ||
'render selected': { | ||
query: { state: STOPPED }, | ||
}, | ||
}; | ||
|
||
Object.values(TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS).forEach(result => { | ||
fixtures[`render ${result}-total selected`] = { | ||
query: { | ||
state: STOPPED, | ||
result, | ||
}, | ||
}; | ||
fixtures[`render ${result}-last selected`] = { | ||
time: WEEK, | ||
query: { | ||
state: STOPPED, | ||
result, | ||
mode: LAST, | ||
time: WEEK, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('StoppedTasksCard', () => | ||
testComponentSnapshotsWithFixtures(StoppedTasksCard, fixtures)); |
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
54 changes: 54 additions & 0 deletions
54
...board/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js
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,54 @@ | ||
import { testComponentSnapshotsWithFixtures } from '@theforeman/test'; | ||
|
||
import { StoppedTable } from './StoppedTasksCardTable'; | ||
import { | ||
TASKS_DASHBOARD_AVAILABLE_TIMES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, | ||
TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS, | ||
} from '../../../../TasksDashboardConstants'; | ||
|
||
const { STOPPED } = TASKS_DASHBOARD_AVAILABLE_QUERY_STATES; | ||
const { LAST } = TASKS_DASHBOARD_AVAILABLE_QUERY_MODES; | ||
const { WEEK } = TASKS_DASHBOARD_AVAILABLE_TIMES; | ||
const data = { | ||
error: { total: 9, last: 1 }, | ||
warning: { total: 8, last: 2 }, | ||
success: { total: 7, last: 3 }, | ||
}; | ||
const fixtures = { | ||
'render with props': { | ||
data, | ||
time: WEEK, | ||
query: {}, | ||
updateQuery: jest.fn(), | ||
}, | ||
}; | ||
|
||
Object.values(TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS) | ||
.filter(result => result !== TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS.OTHER) | ||
.forEach(result => { | ||
fixtures[`render ${result}-total selected`] = { | ||
query: { | ||
state: STOPPED, | ||
result, | ||
}, | ||
updateQuery: jest.fn(), | ||
data, | ||
time: WEEK, | ||
}; | ||
fixtures[`render ${result}-last selected`] = { | ||
time: WEEK, | ||
query: { | ||
state: STOPPED, | ||
result, | ||
mode: LAST, | ||
time: WEEK, | ||
}, | ||
updateQuery: jest.fn(), | ||
data, | ||
}; | ||
}); | ||
|
||
describe('StoppedTable', () => | ||
testComponentSnapshotsWithFixtures(StoppedTable, fixtures)); |
Oops, something went wrong.