From e2b57ea6af6188cef94aed98d67e77935a8340bb Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 16 Oct 2023 17:59:03 +0200 Subject: [PATCH] Remote form: warn about signed_only enabled & missing requirements for Galaxy remote (#4392) Issue: AAH-2748 also related to #4385 and thus AAH-2360 (cherry picked from commit cc0048ca12d22875ceef2fac16fe8f112b717760) --- CHANGES/2748.bug | 1 + src/components/repositories/remote-form.tsx | 57 +++++++++++++++------ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 CHANGES/2748.bug diff --git a/CHANGES/2748.bug b/CHANGES/2748.bug new file mode 100644 index 0000000000..41a83367a7 --- /dev/null +++ b/CHANGES/2748.bug @@ -0,0 +1 @@ +Remote form: warn about signed_only enabled & missing requirements for Galaxy remote diff --git a/src/components/repositories/remote-form.tsx b/src/components/repositories/remote-form.tsx index e1624bb9e7..86d353733b 100644 --- a/src/components/repositories/remote-form.tsx +++ b/src/components/repositories/remote-form.tsx @@ -2,6 +2,7 @@ import { Trans, t } from '@lingui/macro'; import { CodeEditor, Language } from '@patternfly/react-code-editor'; import { ActionGroup, + Alert, Button, Checkbox, ExpandableSection, @@ -13,12 +14,10 @@ import { Switch, TextInput, } from '@patternfly/react-core'; -import { - DownloadIcon, - ExclamationCircleIcon, - ExclamationTriangleIcon, -} from '@patternfly/react-icons'; -import React from 'react'; +import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon'; +import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; +import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; +import React, { ReactNode } from 'react'; import { RemoteType, WriteOnlyFieldType } from 'src/api'; import { FileUpload, HelperText, WriteOnlyField } from 'src/components'; import { AppContext } from 'src/loaders/app-context'; @@ -115,6 +114,10 @@ export class RemoteForm extends React.Component { const requiredFields = ['name', 'url']; let disabledFields = allowEditName ? [] : ['name']; + const isCommunityRemote = + remoteType === 'ansible-remote' && + remote?.url === 'https://galaxy.ansible.com/api/'; + switch (remoteType) { case 'ansible-remote': // require only name, url; nothing disabled @@ -149,14 +152,15 @@ export class RemoteForm extends React.Component { if (showMain) { return ( <> - {this.renderForm( - requiredFields, - disabledFields, - - {save} - {cancel} - , - )} + {this.renderForm(requiredFields, disabledFields, { + extra: ( + + {save} + {cancel} + + ), + isCommunityRemote, + })} ); } @@ -169,12 +173,19 @@ export class RemoteForm extends React.Component { onClose={() => closeModal()} actions={[save, cancel]} > - {this.renderForm(requiredFields, disabledFields)} + {this.renderForm(requiredFields, disabledFields, { isCommunityRemote })} ); } - private renderForm(requiredFields, disabledFields, extra?) { + private renderForm( + requiredFields, + disabledFields, + { + extra, + isCommunityRemote, + }: { extra?: ReactNode; isCommunityRemote: boolean }, + ) { const { errorMessages, remote, remoteType } = this.props; const { filenames } = this.state; const { collection_signing } = this.context.featureFlags; @@ -268,6 +279,13 @@ export class RemoteForm extends React.Component { name={t`Signed only`} label={t`Download only signed collections`} > + {isCommunityRemote && this.props.remote.signed_only ? ( + + ) : null} { validated={this.toError(!('requirements_file' in errorMessages))} helperTextInvalid={errorMessages['requirements_file']} > + {isCommunityRemote && !this.props.remote.requirements_file ? ( + + ) : null}