Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.12k stars 890 forks source link

[v7] Remove noty dependency in favor of a sweetalert2 fork - streamline notifications in core #5570

Open pxpm opened 2 months ago

pxpm commented 2 months ago

In https://github.com/Laravel-Backpack/community-forum/discussions/1090 we were trying to address the fact that it's not possible to change the backpack core notifications. If you as a developer would prefer to use swal instead of noty of the other way around there isn't a single file (where notifications are triggered) that you didn't had to change to cater your needs.

Doing a little research on the issue I've uncovered some more things that highlight the fact that notifications in Backpack are a little bit all over the place and are not very consistent. You have the ability to trigger a noty from php Alert:: but not a sweetalert for eg.

Regarding the dependencies this issue intends to remove noty and sweetalert (v1) in favor of adding sweertalert2 (or a fork of it because of the russian issue). We now use a deprecated beta version of noty and a deprecated version of sweetalert (v1) soo yeah.

We should look at this as the opportunity to make backpack core notifications "easily" configurable for the 90% use cases. the 10% should still have the ability to create a blade file with their own notifications and use the same api to trigger them.

zachweix commented 1 month ago

I second this suggestion. In theory most of the functionality is easy enough to handle merging this all into one blade file, or perhaps 2 files - one to update all the alerts from JavaScript and local storage into a workable array, and then another to actually display the alerts. Once this is being done, I assume we should allow users to add more info than just type and text?

Has anyone started working on this, maybe I can try to look at this one day until someone else is able to come along?

pxpm commented 1 month ago

Hey @zachweix thanks for the input 🙏

We haven't started working on this, no. Actually we talked about this a few days ago, and I know @tabacitu had been doing some research about this subject.

I think it wouldn't be wise to start working on this just now, until we are certain of what, and how this issue will be addressed. Be assured that when we decide how to proceed we will update this issue, and maybe then if you want to give it a shot, I'd say to go ahead 👍 thanks for helping out.

Cheers

zachweix commented 1 month ago

Sounds good, thanks. It took me a while to figure out how to make a notification like Noty in sweetalert2, so I just want to put it here for posterity (partially for my sake 🙂)

const Toast = Swal.mixin({
  toast: true,
  position: "top-end",
  showConfirmButton: false,
  timer: 3000,
  timerProgressBar: true,
  didOpen: (toast) => {
    toast.onmouseenter = Swal.stopTimer;
    toast.onmouseleave = Swal.resumeTimer;
  }
});
Toast.fire({
  icon: "success",
  title: "Signed in successfully"
});