Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
feat: don't show successful validation for unknown connectors; fixes s…
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb authored and MelissaFlinn committed Jun 10, 2020
1 parent ad46f4f commit fb5c0f3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import './ConnectionDetailsForm.css';

export interface IConnectionDetailsValidationResult {
message: string;
type: 'error' | 'success';
type: 'error' | 'success' | 'info';
}

export interface IConnectionDetailsFormProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ERROR, WARNING } from '../Shared';

export interface IConnectorConfigurationFormValidationResult {
message: string;
type: 'error' | 'success';
type: 'error' | 'success' | 'info';
}

export interface IConnectorConfigurationFormProps {
Expand Down Expand Up @@ -56,14 +56,14 @@ export const ConnectorConfigurationForm: React.FunctionComponent<IConnectorConfi
</StackItem>
<StackItem>
{validationResults &&
validationResults.map((e, idx) => (
<Alert
title={e.message}
key={idx}
isInline={true}
variant={e.type === ERROR ? WARNING : e.type}
/>
))}
validationResults.map((e, idx) => (
<Alert
title={e.message}
key={idx}
isInline={true}
variant={e.type === ERROR ? WARNING : e.type}
/>
))}
</StackItem>
<StackItem>
<Form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"namePlaceholder": "Must enter a connection name...",
"usedByOne": "Used by 1 integration",
"usedByMulti": "Used by integrations {{count}} times",
"validationSuccessful": "{{name}} has been successfully validated",
"validationUnsupported": "{{name}} does not support validation",
"create": {
"unsavedChangesTitle": "Do you really want to cancel?",
"unsavedChangesMessage": "You have not finished creating the connection. If you cancel now you will lose data you already entered. Do you still want to cancel?",
Expand Down
31 changes: 25 additions & 6 deletions app/ui-react/syndesis/src/modules/connections/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Result } from '@syndesis/models';
import { IConnectorConfigurationFormValidationResult } from '@syndesis/ui';
import i18n from '../../i18n';

export function parseValidationResult(
results: Result[],
connectorName: string
) {
export function parseValidationResult(results: Result[], name: string) {
const badValidationResults = results
.filter(s => s.status === 'ERROR')
.map(
Expand All @@ -16,12 +14,33 @@ export function parseValidationResult(
);
const goodValidationResults = [
{
message: `${connectorName} has been successfully validated`,
message: i18n.t('connections:validationSuccessful', { name }),
type: 'success',
} as IConnectorConfigurationFormValidationResult,
];

const unsupportedValidationResults = results
.filter(s => s.status === 'UNSUPPORTED')
.map(s => {
if (
s.errors &&
s.errors.filter(e => e.code === 'unknown-connector').length > 0
) {
return {
message: i18n.t('connections:validationUnsupported', {
name,
}),
type: 'info',
} as IConnectorConfigurationFormValidationResult;
} else {
return {
message: s.errors!.map(e => e.description).join(', \n'),
type: 'info',
} as IConnectorConfigurationFormValidationResult;
}
});
return badValidationResults.length > 0
? badValidationResults
: unsupportedValidationResults.length > 0
? unsupportedValidationResults
: goodValidationResults;
}

0 comments on commit fb5c0f3

Please sign in to comment.