Skip to content

Commit 77760cd

Browse files
opensearch-trigger-bot[bot]amsiglan
authored andcommitted
Wait for field mapping creation to succeed before detector creation API call (opensearch-project#317) (opensearch-project#327)
* create detector if mapping creation succeeds Signed-off-by: Amardeepsingh Siglani <[email protected]> * updated creation api call sequence Signed-off-by: Amardeepsingh Siglani <[email protected]> Signed-off-by: Amardeepsingh Siglani <[email protected]> (cherry picked from commit 7507594) Co-authored-by: Amardeepsingh Siglani <[email protected]> Signed-off-by: AWSHurneyt <[email protected]>
1 parent 50219e4 commit 77760cd

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

public/pages/CreateDetector/containers/CreateDetector.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,28 @@ export default class CreateDetector extends Component<CreateDetectorProps, Creat
116116
errorNotificationToast(
117117
this.props.notifications,
118118
'create',
119-
'field mappings',
120-
createMappingsRes.error
121-
);
122-
}
123-
124-
const createDetectorRes = await this.props.services.detectorsService.createDetector(detector);
125-
if (createDetectorRes.ok) {
126-
successNotificationToast(
127-
this.props.notifications,
128-
'created',
129-
`detector, "${detector.name}"`
119+
'detector',
120+
'Double check the field mappings and try again.'
130121
);
131-
this.props.history.push(`${ROUTES.DETECTOR_DETAILS}/${createDetectorRes.response._id}`);
132122
} else {
133-
errorNotificationToast(
134-
this.props.notifications,
135-
'create',
136-
'detector',
137-
createDetectorRes.error
123+
const createDetectorRes = await this.props.services.detectorsService.createDetector(
124+
detector
138125
);
126+
if (createDetectorRes.ok) {
127+
successNotificationToast(
128+
this.props.notifications,
129+
'created',
130+
`detector, "${detector.name}"`
131+
);
132+
this.props.history.push(`${ROUTES.DETECTOR_DETAILS}/${createDetectorRes.response._id}`);
133+
} else {
134+
errorNotificationToast(
135+
this.props.notifications,
136+
'create',
137+
'detector',
138+
createDetectorRes.error
139+
);
140+
}
139141
}
140142
} catch (error: any) {
141143
errorNotificationToast(this.props.notifications, 'create', 'detector', error);

public/utils/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const NAME_REGEX = new RegExp(/^[a-zA-Z0-9 _-]{5,50}$/);
1212

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

1717
/**
1818
* Validates a string against NAME_REGEX.

0 commit comments

Comments
 (0)