dosubot[bot] commented on issue #28758:
URL: https://github.com/apache/superset/issues/28758#issuecomment-2137098981

   <!-- Greeting -->
   Hey there, @maclynn147! I'm here to help you with any bugs, questions, or 
contributions you have. Let's tackle this issue together!
   
   <!-- Answer -->
   To resolve the issue where the "Add" button remains grayed out even though 
all fields are filled, ensure that all required fields are correctly filled out 
and validated. Here are the key validation checks you need to confirm:
   
   1. **General Section**:
       - Ensure the `name` and `owners` fields are filled.
       ```tsx
       const validateGeneralSection = () => {
           const errors = [];
           if (!currentAlert?.name?.length) {
               errors.push(TRANSLATIONS.NAME_ERROR_TEXT);
           }
           if (!currentAlert?.owners?.length) {
               errors.push(TRANSLATIONS.OWNERS_ERROR_TEXT);
           }
           updateValidationStatus(Sections.General, errors);
       };
       ```
   
   2. **Content Section**:
       - Ensure the `dashboard` or `chart` field is filled based on the content 
type.
       ```tsx
       const validateContentSection = () => {
           const errors = [];
           if (
               !(
                   (contentType === 'dashboard' && !!currentAlert?.dashboard) ||
                   (contentType === 'chart' && !!currentAlert?.chart)
               )
           ) {
               errors.push(TRANSLATIONS.CONTENT_ERROR_TEXT);
           }
           updateValidationStatus(Sections.Content, errors);
       };
       ```
   
   3. **Alert Section**:
       - Ensure the `database`, `sql`, and `validator_config_json` fields are 
filled.
       ```tsx
       const validateAlertSection = () => {
           const errors = [];
           if (!currentAlert?.database) {
               errors.push(TRANSLATIONS.DATABASE_ERROR_TEXT);
           }
           if (!currentAlert?.sql?.length) {
               errors.push(TRANSLATIONS.SQL_ERROR_TEXT);
           }
           if (
               !(
                   (conditionNotNull || 
!!currentAlert?.validator_config_json?.op) &&
                   (conditionNotNull ||
                       currentAlert?.validator_config_json?.threshold !== 
undefined)
               )
           ) {
               errors.push(TRANSLATIONS.ALERT_CONDITION_ERROR_TEXT);
           }
           updateValidationStatus(Sections.Alert, errors);
       };
       ```
   
   4. **Schedule Section**:
       - Ensure the `crontab` and `working_timeout` fields are filled.
       ```tsx
       const validateScheduleSection = () => {
           const errors = [];
           if (!currentAlert?.crontab?.length) {
               errors.push(TRANSLATIONS.CRONTAB_ERROR_TEXT);
           }
           if (!currentAlert?.working_timeout) {
               errors.push(TRANSLATIONS.WORKING_TIMEOUT_ERROR_TEXT);
           }
           updateValidationStatus(Sections.Schedule, errors);
       };
       ```
   
   5. **Notification Section**:
       - Ensure the notification settings are correctly configured.
       ```tsx
       const validateNotificationSection = () => {
           const hasErrors = !checkNotificationSettings();
           const errors = hasErrors ? [TRANSLATIONS.RECIPIENTS_ERROR_TEXT] : [];
           if (emailError) {
               errors.push(TRANSLATIONS.EMAIL_SUBJECT_ERROR_TEXT);
           }
           updateValidationStatus(Sections.Notification, errors);
       };
       ```
   
   6. **Overall Validation**:
       - Call the `validateAll` function to perform all validation checks.
       ```tsx
       const validateAll = () => {
           validateGeneralSection();
           validateContentSection();
           if (!isReport) validateAlertSection();
           validateScheduleSection();
           validateNotificationSection();
       };
       ```
   
   7. **Enforce Validation**:
       - Ensure the `enforceValidation` function is called to update the state 
of the "Add" button.
       ```tsx
       const enforceValidation = () => {
           const sections = [
               Sections.General,
               Sections.Content,
               isReport ? undefined : Sections.Alert,
               Sections.Schedule,
               Sections.Notification,
           ];
   
           const hasErrors = sections.some(
               section => section && validationStatus[section].hasErrors,
           );
           const tooltip = hasErrors ? 
buildErrorTooltipMessage(validationStatus) : '';
           setErrorTooltipMessage(tooltip);
           setDisableSave(hasErrors);
       };
       ```
   
   Additionally, ensure that the translation keys are correctly defined in your 
translation files to avoid missing variable errors in the developer console 
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/features/alerts/AlertReportModal.tsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/translations/messages.pot)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset/translations/en/LC_MESSAGES/messages.po)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   <details open>
   <summary>
   
   #### Details
   </summary>
   
   **About Dosu**
   This response is meant to be useful and save you time. It is **not meant to 
be a precise solution**, but rather a starting point for your own research.
   
   Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is 
irrelevant.
   </details>
   
   *To continue the conversation, mention @dosu.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to