GithubHelp home page GithubHelp logo

Comments (4)

dosubot avatar dosubot commented on June 29, 2024 2

The issues you are experiencing with saving an alert in Superset and modifying the email recipients of old alerts are likely due to the validation and state management logic in the AlertReportModal component.

  1. Notification Method Highlighted in Red:
    The notification method is highlighted in red because the validation logic checks if all required fields are complete before enabling the save button. Specifically, the validateNotificationSection function checks if the notification settings have the required information, including the recipients. If the recipients are not provided, it marks the section as having errors, which results in the notification method being highlighted in red.

    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);
    };
    
    const checkNotificationSettings = () => {
      if (!notificationSettings.length) {
        return false;
      }
    
      let hasInfo = false;
    
      notificationSettings.forEach(setting => {
        if (!!setting.method && setting.recipients?.length) {
          hasInfo = true;
        }
      });
    
      return hasInfo;
    };
  2. Unable to Modify Email Recipients of Old Alerts:
    The inability to modify email recipients of old alerts created in version 3.1.2 could be due to the way the notification settings are initialized and managed. When an alert is fetched, the notification settings are populated based on the recipients from the resource. If the recipients are not correctly parsed or if the allowed notification methods do not match the existing methods, it could prevent modifications.

    useEffect(() => {
      if (resource) {
        // Add notification settings
        const settings = (resource.recipients || []).map(setting => {
          const config =
            typeof setting.recipient_config_json === 'string'
              ? JSON.parse(setting.recipient_config_json)
              : {};
          return {
            method: setting.type,
            // @ts-ignore: Type not assignable
            recipients: config.target || setting.recipient_config_json,
            options: allowedNotificationMethods,
          };
        });
    
        setNotificationSettings(settings);
        setNotificationAddState(
          settings.length === allowedNotificationMethods.length
            ? 'hidden'
            : 'active',
        );
      }
    }, [resource]);

    Ensure that the allowedNotificationMethods includes the methods used in old alerts and that the recipients are correctly parsed and assigned.

Additionally, the NotificationMethod component handles the rendering and validation of the notification method and recipients. If the recipients are not correctly set or if there are validation errors, the component will highlight the input fields in red.

const onRecipientsChange = (
  event: React.ChangeEvent<HTMLTextAreaElement>,
) => {
  const { target } = event;

  setRecipientValue(target.value);

  if (onUpdate) {
    const updatedSetting = {
      ...setting,
      recipients: target.value,
    };

    onUpdate(index, updatedSetting);
  }
};

To resolve these issues, you need to ensure that all required fields, including the notification method and recipients, are correctly filled out and validated. Additionally, verify that the initialization logic for old alerts correctly parses and assigns the recipients and notification methods [1][2].

To continue talking to Dosu, mention @dosu.

from superset.

akiellor avatar akiellor commented on June 29, 2024

It looks like this has been resolved in this Pull Request. But has not yet been released.

from superset.

Kim-frau avatar Kim-frau commented on June 29, 2024

Great, thanks

from superset.

Kim-frau avatar Kim-frau commented on June 29, 2024

Allready taken care in #28409

from superset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.