Skip to content

Commit

Permalink
Fix UI peers_from_control_nodes (ansible#14858)
Browse files Browse the repository at this point in the history
* Fix UI peers_from_control_nodes

Fixes bug where peers_from_control_node was
greyed out in UI.

Additional changes:
- Make edit instance button only show for instances
with managed = False
- Make remove instance button only show for instances
with managed = False
- InstanceList selectable only for instances with
managed = False

---------

Signed-off-by: Seth Foster <[email protected]>
  • Loading branch information
fosterseth authored and djyasin committed Sep 11, 2024
1 parent c9d4366 commit 3dcfb91
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 40 deletions.
64 changes: 29 additions & 35 deletions awx/ui/src/screens/Instances/InstanceDetail/InstanceDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,33 +209,31 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
<Detail label={t`Node Type`} value={instance.node_type} />
<Detail label={t`Host`} value={instance.ip_address} />
<Detail label={t`Listener Port`} value={instance.listener_port} />
{(isExecutionNode || isHopNode || !isManaged) && (
<>
{instance.related?.install_bundle && (
<Detail
label={t`Install Bundle`}
value={
<Tooltip content={t`Click to download bundle`}>
<Button
component="a"
isSmall
href={`${instance.related?.install_bundle}`}
target="_blank"
variant="secondary"
dataCy="install-bundle-download-button"
rel="noopener noreferrer"
>
<DownloadIcon />
</Button>
</Tooltip>
}
/>
)}
<Detail
label={t`Peers from control nodes`}
value={instance.peers_from_control_nodes ? t`On` : t`Off`}
/>
</>
{!isManaged && instance.related?.install_bundle && (
<Detail
label={t`Install Bundle`}
value={
<Tooltip content={t`Click to download bundle`}>
<Button
component="a"
isSmall
href={`${instance.related?.install_bundle}`}
target="_blank"
variant="secondary"
dataCy="install-bundle-download-button"
rel="noopener noreferrer"
>
<DownloadIcon />
</Button>
</Tooltip>
}
/>
)}
{(isExecutionNode || isHopNode) && (
<Detail
label={t`Peers from control nodes`}
value={instance.peers_from_control_nodes ? t`On` : t`Off`}
/>
)}
{!isHopNode && (
<>
Expand Down Expand Up @@ -341,9 +339,8 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
)}
</DetailList>
<CardActionsRow>
{config?.me?.is_superuser &&
isK8s &&
(isExecutionNode || isHopNode || !isManaged) && (
{config?.me?.is_superuser && isK8s && !isManaged && (
<>
<Button
ouiaId="instance-detail-edit-button"
aria-label={t`edit`}
Expand All @@ -352,17 +349,14 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
>
{t`Edit`}
</Button>
)}
{config?.me?.is_superuser &&
isK8s &&
(isExecutionNode || isHopNode || !isManaged) && (
<RemoveInstanceButton
dataCy="remove-instance-button"
itemsToRemove={[instance]}
isK8s={isK8s}
onRemove={removeInstances}
/>
)}
</>
)}
{isExecutionNode && (
<Tooltip content={t`Run a health check on the instance`}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ function InstanceListItem({
);

const isHopNode = instance.node_type === 'hop';
const isExecutionNode = instance.node_type === 'execution';
const isManaged = instance.managed;

return (
Expand All @@ -140,7 +139,7 @@ function InstanceListItem({
rowIndex,
isSelected,
onSelect,
disable: !(isExecutionNode || isHopNode || isManaged),
disable: isManaged,
}}
dataLabel={t`Selected`}
/>
Expand Down
5 changes: 2 additions & 3 deletions awx/ui/src/screens/Instances/Shared/InstanceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const INSTANCE_TYPES = [
{ id: 'hop', name: t`Hop` },
];

function InstanceFormFields({ isEdit, instance }) {
function InstanceFormFields({ isEdit }) {
const [instanceTypeField, instanceTypeMeta, instanceTypeHelpers] = useField({
name: 'node_type',
validate: required(t`Set a value for this field`),
Expand Down Expand Up @@ -98,7 +98,6 @@ function InstanceFormFields({ isEdit, instance }) {
name="peers_from_control_nodes"
label={t`Peers from control nodes`}
tooltip={t`If enabled, control nodes will peer to this instance automatically. If disabled, instance will be connected only to associated peers.`}
isDisabled={parseInt(instance.listener_port, 10) < 1024 || true}
/>
</FormGroup>
</>
Expand Down Expand Up @@ -139,7 +138,7 @@ function InstanceForm({
{(formik) => (
<Form autoComplete="off" onSubmit={formik.handleSubmit}>
<FormColumnLayout>
<InstanceFormFields isEdit={isEdit} instance={instance} />
<InstanceFormFields isEdit={isEdit} />
<FormSubmitError error={submitError} />
<FormActionGroup
onCancel={handleCancel}
Expand Down

0 comments on commit 3dcfb91

Please sign in to comment.