fix(SR export): prevent empty sr description when export (#3173)

This commit is contained in:
dxlin 2023-06-19 10:35:53 -04:00 committed by GitHub
parent 2d8400f9d8
commit d51211f6b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,12 +20,19 @@ export default function createReportDialogPrompt(uiDialogService) {
* @param {string} param0.value - value from input field * @param {string} param0.value - value from input field
*/ */
const _handleFormSubmit = ({ action, value }) => { const _handleFormSubmit = ({ action, value }) => {
uiDialogService.dismiss({ id: dialogId });
switch (action.id) { switch (action.id) {
case 'save': case 'save':
resolve({ action: RESPONSE.CREATE_REPORT, value: value.label }); // Only save if description is not blank otherwise ignore
if (value.label && value.label.trim() !== '') {
resolve({
action: RESPONSE.CREATE_REPORT,
value: value.label.trim(),
});
uiDialogService.dismiss({ id: dialogId });
}
break; break;
case 'cancel': case 'cancel':
uiDialogService.dismiss({ id: dialogId });
resolve({ action: RESPONSE.CANCEL, value: undefined }); resolve({ action: RESPONSE.CANCEL, value: undefined });
break; break;
} }
@ -55,8 +62,8 @@ export default function createReportDialogPrompt(uiDialogService) {
}; };
const onKeyPressHandler = event => { const onKeyPressHandler = event => {
if (event.key === 'Enter') { if (event.key === 'Enter') {
uiDialogService.dismiss({ id: dialogId }); // Trigger form submit
resolve({ action: RESPONSE.CREATE_REPORT, value: value.label }); _handleFormSubmit({ action: { id: 'save' }, value });
} }
}; };
return ( return (