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