mirror of
https://github.com/ansible/awx.git
synced 2026-03-27 05:45:02 -02:30
Merge pull request #5788 from marshmalien/5693-inv-host-sparkline
Fix host details and list sparkline links Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
@@ -40,6 +40,8 @@ function HostDetail({ host, i18n, onUpdateHost }) {
|
|||||||
const [toggleLoading, setToggleLoading] = useState(false);
|
const [toggleLoading, setToggleLoading] = useState(false);
|
||||||
const [toggleError, setToggleError] = useState(false);
|
const [toggleError, setToggleError] = useState(false);
|
||||||
|
|
||||||
|
const recentPlaybookJobs = recent_jobs.map(job => ({ ...job, type: 'job' }));
|
||||||
|
|
||||||
const handleHostToggle = async () => {
|
const handleHostToggle = async () => {
|
||||||
setToggleLoading(true);
|
setToggleLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -107,7 +109,7 @@ function HostDetail({ host, i18n, onUpdateHost }) {
|
|||||||
<Detail label={i18n._(t`Name`)} value={name} />
|
<Detail label={i18n._(t`Name`)} value={name} />
|
||||||
<Detail
|
<Detail
|
||||||
css="display: flex; flex: 1;"
|
css="display: flex; flex: 1;"
|
||||||
value={<Sparkline jobs={recent_jobs} />}
|
value={<Sparkline jobs={recentPlaybookJobs} />}
|
||||||
label={i18n._(t`Activity`)}
|
label={i18n._(t`Activity`)}
|
||||||
/>
|
/>
|
||||||
<Detail label={i18n._(t`Description`)} value={description} />
|
<Detail label={i18n._(t`Description`)} value={description} />
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ describe('<HostDetail />', () => {
|
|||||||
user_capabilities: {
|
user_capabilities: {
|
||||||
edit: true,
|
edit: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const mockHosts = [
|
|||||||
delete: true,
|
delete: true,
|
||||||
update: true,
|
update: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,7 @@ const mockHosts = [
|
|||||||
delete: true,
|
delete: true,
|
||||||
update: true,
|
update: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -50,6 +52,14 @@ const mockHosts = [
|
|||||||
id: 1,
|
id: 1,
|
||||||
name: 'inv 1',
|
name: 'inv 1',
|
||||||
},
|
},
|
||||||
|
recent_jobs: [
|
||||||
|
{
|
||||||
|
id: 123,
|
||||||
|
name: 'Bibbity Bop',
|
||||||
|
status: 'success',
|
||||||
|
finished: '2020-01-27T19:40:36.208728Z',
|
||||||
|
},
|
||||||
|
],
|
||||||
user_capabilities: {
|
user_capabilities: {
|
||||||
delete: false,
|
delete: false,
|
||||||
update: false,
|
update: false,
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ class HostListItem extends React.Component {
|
|||||||
toggleLoading,
|
toggleLoading,
|
||||||
i18n,
|
i18n,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
const recentPlaybookJobs = host.summary_fields.recent_jobs.map(job => ({
|
||||||
|
...job,
|
||||||
|
type: 'job',
|
||||||
|
}));
|
||||||
|
|
||||||
const labelId = `check-action-${host.id}`;
|
const labelId = `check-action-${host.id}`;
|
||||||
return (
|
return (
|
||||||
<DataListItem key={host.id} aria-labelledby={labelId} id={`${host.id}`}>
|
<DataListItem key={host.id} aria-labelledby={labelId} id={`${host.id}`}>
|
||||||
@@ -57,7 +63,7 @@ class HostListItem extends React.Component {
|
|||||||
</Link>
|
</Link>
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell key="recentJobs">
|
<DataListCell key="recentJobs">
|
||||||
<Sparkline jobs={host.summary_fields.recent_jobs} />
|
<Sparkline jobs={recentPlaybookJobs} />
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell key="inventory">
|
<DataListCell key="inventory">
|
||||||
{host.summary_fields.inventory && (
|
{host.summary_fields.inventory && (
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const mockHost = {
|
|||||||
user_capabilities: {
|
user_capabilities: {
|
||||||
edit: true,
|
edit: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ function InventoryHostItem(props) {
|
|||||||
toggleLoading,
|
toggleLoading,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const recentPlaybookJobs = host.summary_fields.recent_jobs.map(job => ({
|
||||||
|
...job,
|
||||||
|
type: 'job',
|
||||||
|
}));
|
||||||
|
|
||||||
const labelId = `check-action-${host.id}`;
|
const labelId = `check-action-${host.id}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -52,7 +57,7 @@ function InventoryHostItem(props) {
|
|||||||
</Link>
|
</Link>
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<DataListCell key="recentJobs">
|
<DataListCell key="recentJobs">
|
||||||
<Sparkline jobs={host.summary_fields.recent_jobs} />
|
<Sparkline jobs={recentPlaybookJobs} />
|
||||||
</DataListCell>,
|
</DataListCell>,
|
||||||
<ActionButtonCell lastcolumn="true" key="action">
|
<ActionButtonCell lastcolumn="true" key="action">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@@ -69,13 +74,14 @@ function InventoryHostItem(props) {
|
|||||||
labelOff={i18n._(t`Off`)}
|
labelOff={i18n._(t`Off`)}
|
||||||
isChecked={host.enabled}
|
isChecked={host.enabled}
|
||||||
isDisabled={
|
isDisabled={
|
||||||
toggleLoading || !host.summary_fields.user_capabilities.edit
|
toggleLoading ||
|
||||||
|
!host.summary_fields.user_capabilities?.edit
|
||||||
}
|
}
|
||||||
onChange={() => toggleHost(host)}
|
onChange={() => toggleHost(host)}
|
||||||
aria-label={i18n._(t`Toggle host`)}
|
aria-label={i18n._(t`Toggle host`)}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{host.summary_fields.user_capabilities.edit && (
|
{host.summary_fields.user_capabilities?.edit && (
|
||||||
<Tooltip content={i18n._(t`Edit Host`)} position="top">
|
<Tooltip content={i18n._(t`Edit Host`)} position="top">
|
||||||
<ListActionButton
|
<ListActionButton
|
||||||
variant="plain"
|
variant="plain"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const mockHost = {
|
|||||||
user_capabilities: {
|
user_capabilities: {
|
||||||
edit: true,
|
edit: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ const mockHosts = [
|
|||||||
delete: true,
|
delete: true,
|
||||||
update: true,
|
update: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,7 @@ const mockHosts = [
|
|||||||
delete: true,
|
delete: true,
|
||||||
update: true,
|
update: true,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,6 +60,7 @@ const mockHosts = [
|
|||||||
delete: false,
|
delete: false,
|
||||||
update: false,
|
update: false,
|
||||||
},
|
},
|
||||||
|
recent_jobs: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user