OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Can't submit the SMS provider settings form without empty provider but can't set Twilio until I submit the form

Open barthamark opened this issue 1 year ago • 6 comments

Describe the bug

After enabling the SMS Notifications feature I wanted to set Twilio as the default provider. For that, first, I needed to enable it on the same form where the default provider is needed to be set. However, I can't save it without selecting any provider. It can be worked around if there an option selected until I save the form and Twilio is enabled, then select Twilio, however, if there's nothing in there (e.g., in production), then there is no way to save the form. Locally, the "Log" is an option, but in prod, there's nothing in the list.

Orchard Core version

2.0.2

To Reproduce

  1. Enable "SMS Notifications"
  2. Go to Configuration > Settings > SMS
  3. Notice that Twilio is no in the Default Provider list, and nothing is selected.
  4. Go to Twilio tab.
  5. Enable Twilio and fill the form.
  6. Click Save.
  7. See validation error that Default Provider is not selected.

Expected behavior

Maybe the Default Provider shouldn't be a mandatory field? Or some JS code that adds Twilio to the list right after checking the Enable Twilio checkbox?

Workaround

  • If there is at least one other item in the Default Provider list, then select that. After enabling Twilio, replace it with that.
  • If there is no other, then create a temporary one from code like this, and do the same as above:
public class DummySmsProvider : ISmsProvider
{
    private readonly IStringLocalizer<DummySmsProvider> T;

    public LocalizedString Name => T["Dummy SMS Provider"];

    public DummySmsProvider(IStringLocalizer<DummySmsProvider> localizer) => T = localizer;

    public Task<SmsResult> SendAsync(SmsMessage message) => throw new System.NotImplementedException();
}

services.AddSmsProvider<DummySmsProvider>(nameof(DummySmsProvider));

barthamark avatar Nov 25 '24 13:11 barthamark

There's a 'LogSmsProvider OOB, that could be used or set Twillio by default

hishamco avatar Nov 25 '24 15:11 hishamco

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Dec 12 '24 18:12 github-actions[bot]

@barthamark anything to add here?

hishamco avatar Apr 07 '25 07:04 hishamco

I don't have anything to add here, I'd say it's still a good idea to fix it even if the LogSmsProvider is still there (which is not the case in some cases).

barthamark avatar Apr 07 '25 14:04 barthamark

What's your proposed fix?

hishamco avatar Apr 07 '25 17:04 hishamco

My proposed fix is what I wrote to the expected behavior. Somehow either separate the form pages and their validation. I want to be able to save the form on the Twilio tab with the Enable switch set to ON without setting any provider on the first tab (obviously, my next step would be to set that to Twilio). Or just not make the provider a required field.

barthamark avatar Apr 12 '25 08:04 barthamark