Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for field mapping creation to succeed before detector creation API call #317

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions public/pages/CreateDetector/containers/CreateDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,28 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat
errorNotificationToast(
this.props.notifications,
'create',
'field mappings',
createMappingsRes.error
);
}

const createDetectorRes = await this.props.services.detectorsService.createDetector(detector);
if (createDetectorRes.ok) {
successNotificationToast(
this.props.notifications,
'created',
`detector, "${detector.name}"`
'detector',
'Double check the field mappings and try again.'
);
this.props.history.push(`${ROUTES.DETECTOR_DETAILS}/${createDetectorRes.response._id}`);
} else {
errorNotificationToast(
this.props.notifications,
'create',
'detector',
createDetectorRes.error
const createDetectorRes = await this.props.services.detectorsService.createDetector(
detector
);
if (createDetectorRes.ok) {
successNotificationToast(
this.props.notifications,
'created',
`detector, "${detector.name}"`
);
this.props.history.push(`${ROUTES.DETECTOR_DETAILS}/${createDetectorRes.response._id}`);
} else {
errorNotificationToast(
this.props.notifications,
'create',
'detector',
createDetectorRes.error
);
}
}
} catch (error: any) {
errorNotificationToast(this.props.notifications, 'create', 'detector', error);
Expand Down
2 changes: 1 addition & 1 deletion public/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const NAME_REGEX = new RegExp(/^[a-zA-Z0-9 _-]{5,50}$/);

// This regex pattern support MIN to MAX character limit, capital and lowercase letters,
// numbers 0-9, hyphens, spaces, and underscores.
export const AUTHOR_REGEX = new RegExp(/^[a-zA-Z0-9 _,-]{5,50}$/);
export const AUTHOR_REGEX = new RegExp(/^[a-zA-Z0-9 _,-.]{5,50}$/);

/**
* Validates a string against NAME_REGEX.
Expand Down