Skip to content

Commit

Permalink
Remote form: warn about signed_only enabled & missing requirements fo…
Browse files Browse the repository at this point in the history
…r Galaxy remote (#4392) (#4407)

Issue: AAH-2748

also related to #4385 and thus AAH-2360

(cherry picked from commit cc0048c)

Co-authored-by: Martin Hradil <mhradil@redhat.com>
  • Loading branch information
patchback[bot] and himdel committed Oct 16, 2023
1 parent 6fd77fc commit a6707ef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES/2748.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remote form: warn about signed_only enabled & missing requirements for Galaxy remote
49 changes: 38 additions & 11 deletions src/components/repositories/remote-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Trans, t } from '@lingui/macro';
import { CodeEditor, Language } from '@patternfly/react-code-editor';
import {
ActionGroup,
Alert,
Button,
Checkbox,
ExpandableSection,
Expand All @@ -16,7 +17,7 @@ import {
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 from 'react';
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';
Expand Down Expand Up @@ -113,6 +114,10 @@ export class RemoteForm extends React.Component<IProps, IState> {
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
Expand Down Expand Up @@ -147,14 +152,15 @@ export class RemoteForm extends React.Component<IProps, IState> {
if (showMain) {
return (
<>
{this.renderForm(
requiredFields,
disabledFields,
<ActionGroup key='actions'>
{save}
{cancel}
</ActionGroup>,
)}
{this.renderForm(requiredFields, disabledFields, {
extra: (
<ActionGroup key='actions'>
{save}
{cancel}
</ActionGroup>
),
isCommunityRemote,
})}
</>
);
}
Expand All @@ -167,12 +173,19 @@ export class RemoteForm extends React.Component<IProps, IState> {
onClose={() => closeModal()}
actions={[save, cancel]}
>
{this.renderForm(requiredFields, disabledFields)}
{this.renderForm(requiredFields, disabledFields, { isCommunityRemote })}
</Modal>
);
}

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;
Expand Down Expand Up @@ -266,6 +279,13 @@ export class RemoteForm extends React.Component<IProps, IState> {
name={t`Signed only`}
label={t`Download only signed collections`}
>
{isCommunityRemote && this.props.remote.signed_only ? (
<Alert
isInline
variant='warning'
title={t`Community content will never be synced if this setting is enabled`}
/>
) : null}
<Switch
id='signed_only'
isChecked={!!remote.signed_only}
Expand Down Expand Up @@ -343,6 +363,13 @@ export class RemoteForm extends React.Component<IProps, IState> {
validated={this.toError(!('requirements_file' in errorMessages))}
helperTextInvalid={errorMessages['requirements_file']}
>
{isCommunityRemote && !this.props.remote.requirements_file ? (
<Alert
isInline
variant='warning'
title={t`YAML requirements are required to sync from Galaxy`}
/>
) : null}
<Flex>
<FlexItem grow={{ default: 'grow' }}>
<FileUpload
Expand Down

0 comments on commit a6707ef

Please sign in to comment.