mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 14:39:26 -02:30
Form hardening and node type exclusion
Disabled add/edit/remove for managed nodes Tightened validation on Peers from control nodes
This commit is contained in:
committed by
Seth Foster
parent
f98493aa61
commit
b093c89a84
@@ -183,6 +183,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
}
|
}
|
||||||
const isHopNode = instance.node_type === 'hop';
|
const isHopNode = instance.node_type === 'hop';
|
||||||
const isExecutionNode = instance.node_type === 'execution';
|
const isExecutionNode = instance.node_type === 'execution';
|
||||||
|
const isManaged = instance.managed;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -208,7 +209,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
<Detail label={t`Node Type`} value={instance.node_type} />
|
<Detail label={t`Node Type`} value={instance.node_type} />
|
||||||
<Detail label={t`Host`} value={instance.ip_address} />
|
<Detail label={t`Host`} value={instance.ip_address} />
|
||||||
<Detail label={t`Listener Port`} value={instance.listener_port} />
|
<Detail label={t`Listener Port`} value={instance.listener_port} />
|
||||||
{(isExecutionNode || isHopNode) && (
|
{(isExecutionNode || isHopNode || !isManaged) && (
|
||||||
<>
|
<>
|
||||||
{instance.related?.install_bundle && (
|
{instance.related?.install_bundle && (
|
||||||
<Detail
|
<Detail
|
||||||
@@ -294,7 +295,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
value={instance.capacity_adjustment}
|
value={instance.capacity_adjustment}
|
||||||
onChange={handleChangeValue}
|
onChange={handleChangeValue}
|
||||||
isDisabled={
|
isDisabled={
|
||||||
!config?.me?.is_superuser || !instance.enabled
|
!config?.me?.is_superuser || !instance.enabled || !isManaged
|
||||||
}
|
}
|
||||||
data-cy="slider"
|
data-cy="slider"
|
||||||
/>
|
/>
|
||||||
@@ -338,7 +339,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
)}
|
)}
|
||||||
</DetailList>
|
</DetailList>
|
||||||
<CardActionsRow>
|
<CardActionsRow>
|
||||||
{config?.me?.is_superuser && isK8s && (isExecutionNode || isHopNode) && (
|
{config?.me?.is_superuser && isK8s && (isExecutionNode || isHopNode || !isManaged) && (
|
||||||
<Button
|
<Button
|
||||||
ouiaId="instance-detail-edit-button"
|
ouiaId="instance-detail-edit-button"
|
||||||
aria-label={t`edit`}
|
aria-label={t`edit`}
|
||||||
@@ -350,7 +351,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
)}
|
)}
|
||||||
{config?.me?.is_superuser &&
|
{config?.me?.is_superuser &&
|
||||||
isK8s &&
|
isK8s &&
|
||||||
(isExecutionNode || isHopNode) && (
|
(isExecutionNode || isHopNode || !isManaged) && (
|
||||||
<RemoveInstanceButton
|
<RemoveInstanceButton
|
||||||
dataCy="remove-instance-button"
|
dataCy="remove-instance-button"
|
||||||
itemsToRemove={[instance]}
|
itemsToRemove={[instance]}
|
||||||
@@ -362,7 +363,7 @@ function InstanceDetail({ setBreadcrumb, isK8s }) {
|
|||||||
<Tooltip content={t`Run a health check on the instance`}>
|
<Tooltip content={t`Run a health check on the instance`}>
|
||||||
<Button
|
<Button
|
||||||
isDisabled={
|
isDisabled={
|
||||||
!config?.me?.is_superuser || instance.health_check_pending
|
!config?.me?.is_superuser || instance.health_check_pending || !instance.managed
|
||||||
}
|
}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
ouiaId="health-check-button"
|
ouiaId="health-check-button"
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ function InstanceListItem({
|
|||||||
|
|
||||||
const isHopNode = instance.node_type === 'hop';
|
const isHopNode = instance.node_type === 'hop';
|
||||||
const isExecutionNode = instance.node_type === 'execution';
|
const isExecutionNode = instance.node_type === 'execution';
|
||||||
|
const isManaged = instance.managed;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tr
|
<Tr
|
||||||
@@ -138,7 +140,7 @@ function InstanceListItem({
|
|||||||
rowIndex,
|
rowIndex,
|
||||||
isSelected,
|
isSelected,
|
||||||
onSelect,
|
onSelect,
|
||||||
disable: !(isExecutionNode || isHopNode),
|
disable: !(isExecutionNode || isHopNode || isManaged),
|
||||||
}}
|
}}
|
||||||
dataLabel={t`Selected`}
|
dataLabel={t`Selected`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ function InstancePeerList({ setBreadcrumb }) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (instance.managed) {
|
||||||
|
// no managed nodes
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const host = instances.data.results.filter(
|
const host = instances.data.results.filter(
|
||||||
(obj) => obj.id === receptor.instance
|
(obj) => obj.id === receptor.instance
|
||||||
)[0];
|
)[0];
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const INSTANCE_TYPES = [
|
|||||||
{ id: 'hop', name: t`Hop` },
|
{ id: 'hop', name: t`Hop` },
|
||||||
];
|
];
|
||||||
|
|
||||||
function InstanceFormFields({ isEdit }) {
|
function InstanceFormFields({ isEdit, instance }) {
|
||||||
const [instanceTypeField, instanceTypeMeta, instanceTypeHelpers] = useField({
|
const [instanceTypeField, instanceTypeMeta, instanceTypeHelpers] = useField({
|
||||||
name: 'node_type',
|
name: 'node_type',
|
||||||
validate: required(t`Set a value for this field`),
|
validate: required(t`Set a value for this field`),
|
||||||
@@ -98,6 +98,7 @@ function InstanceFormFields({ isEdit }) {
|
|||||||
name="peers_from_control_nodes"
|
name="peers_from_control_nodes"
|
||||||
label={t`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.`}
|
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>
|
</FormGroup>
|
||||||
</>
|
</>
|
||||||
@@ -138,7 +139,7 @@ function InstanceForm({
|
|||||||
{(formik) => (
|
{(formik) => (
|
||||||
<Form autoComplete="off" onSubmit={formik.handleSubmit}>
|
<Form autoComplete="off" onSubmit={formik.handleSubmit}>
|
||||||
<FormColumnLayout>
|
<FormColumnLayout>
|
||||||
<InstanceFormFields isEdit={isEdit} />
|
<InstanceFormFields isEdit={isEdit} instance={instance}/>
|
||||||
<FormSubmitError error={submitError} />
|
<FormSubmitError error={submitError} />
|
||||||
<FormActionGroup
|
<FormActionGroup
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
|
|||||||
Reference in New Issue
Block a user