mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Add custom host toggle tooltip for smart inventory hosts
This commit is contained in:
@@ -8,7 +8,18 @@ import ErrorDetail from '../ErrorDetail';
|
|||||||
import useRequest from '../../util/useRequest';
|
import useRequest from '../../util/useRequest';
|
||||||
import { HostsAPI } from '../../api';
|
import { HostsAPI } from '../../api';
|
||||||
|
|
||||||
function HostToggle({ host, isDisabled = false, onToggle, className, i18n }) {
|
function HostToggle({
|
||||||
|
i18n,
|
||||||
|
className,
|
||||||
|
host,
|
||||||
|
isDisabled = false,
|
||||||
|
onToggle,
|
||||||
|
tooltip = i18n._(
|
||||||
|
t`Indicates if a host is available and should be included in running
|
||||||
|
jobs. For hosts that are part of an external inventory, this may be
|
||||||
|
reset by the inventory sync process.`
|
||||||
|
),
|
||||||
|
}) {
|
||||||
const [isEnabled, setIsEnabled] = useState(host.enabled);
|
const [isEnabled, setIsEnabled] = useState(host.enabled);
|
||||||
const [showError, setShowError] = useState(false);
|
const [showError, setShowError] = useState(false);
|
||||||
|
|
||||||
@@ -39,14 +50,7 @@ function HostToggle({ host, isDisabled = false, onToggle, className, i18n }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<Tooltip
|
<Tooltip content={tooltip} position="top">
|
||||||
content={i18n._(
|
|
||||||
t`Indicates if a host is available and should be included in running
|
|
||||||
jobs. For hosts that are part of an external inventory, this may be
|
|
||||||
reset by the inventory sync process.`
|
|
||||||
)}
|
|
||||||
position="top"
|
|
||||||
>
|
|
||||||
<Switch
|
<Switch
|
||||||
className={className}
|
className={className}
|
||||||
css="display: inline-flex;"
|
css="display: inline-flex;"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { string, bool, func } from 'prop-types';
|
import { string, bool, func } from 'prop-types';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t, Trans } from '@lingui/macro';
|
||||||
import 'styled-components/macro';
|
import 'styled-components/macro';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -67,7 +67,19 @@ function SmartInventoryHostListItem({
|
|||||||
aria-labelledby={labelId}
|
aria-labelledby={labelId}
|
||||||
id={labelId}
|
id={labelId}
|
||||||
>
|
>
|
||||||
<HostToggle isDisabled host={host} />
|
<HostToggle
|
||||||
|
isDisabled
|
||||||
|
host={host}
|
||||||
|
tooltip={
|
||||||
|
<Trans>
|
||||||
|
<b>Smart inventory hosts are read-only.</b>
|
||||||
|
<br />
|
||||||
|
Toggle indicates if a host is available and should be included
|
||||||
|
in running jobs. For hosts that are part of an external
|
||||||
|
inventory, this may be reset by the inventory sync process.
|
||||||
|
</Trans>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</DataListAction>
|
</DataListAction>
|
||||||
</DataListItemRow>
|
</DataListItemRow>
|
||||||
</DataListItem>
|
</DataListItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user