Hello and thanks for your work on this module!

I'm looking for an alert system to be used internally, only on the admin side. We use Bootstrap Theme as our admin theme. We have some requirements that are (understandably) outside of the scope of this module -- the ability to have multiple alerts, for example - but we're interested in possibly implementing this as a more lightweight solution until we get that built out. We've also been looking at Site Alert, but it doesn't yet have a stable release and I have yet to hear back on whether there are plans for one. It also needs some modification to work well with Bootstrap.

One thing that we need, and that I think makes sense to include with this module, is to make the alert stay hidden for the duration of the session once it is dismissed. You have already built in the option to dismiss them, which is awesome, yet they come back on the next page load, which isn't really what one would expect. Is this something you would consider implementing? I already have a patch prepared for 7.x, and will also work on one for 8.x if there's interest.

Another thing we would like very much is to have another permission for viewing the site alerts, but I will open another issue for that. :)

I'll attach the patch for review shortly. Cheers -

Comments

othermachines created an issue. See original summary.

othermachines’s picture

Status: Active » Needs review
StatusFileSize
new4.27 KB

What this patch does:

* Saves a random key when the configuration form is saved;
* If 'dismiss' feature is enabled, saves key to a cookie when '.close' element is clicked,
* On every page load, saved key is checked against the cookie (if set). If no match, alert is loaded.

If updating the module from a previous version, a default key '123' will be automatically applied until the next time the configuration form is saved. So it should "just work".

Thanks -

labboy0276’s picture

OK

So I had a moment to check this out. Good job and thanks for doing this. I noticed one flaw that when you go to the /user login page it adds it back, but whatever, no big deal I will leave it as is. I added your code to D7 and will push that up now.

If you wouldn't mind making a d8 version for this, that would be great. Please us the dev version. If not, I will try and do this within a month.

othermachines’s picture

@labboy0276 - Sorry, I didn't realize you'd edited your comment to ask if I'd make the change for D8 (I just read the original note that was emailed out to me). I'll put it on my task list but it might be a week or two.

othermachines’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
StatusFileSize
new6.38 KB

Patch for D8. Sorry it took a bit longer than anticipated to get to this. I cobbled it together pretty quickly so hope you don't mind giving it a good once-over. Cheers -

othermachines’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev

Oops - I meant to explain this bit:

     $page_top['bootstrap_site_alert'] = [
-      '#markup' => $alert,
+      '#type' => 'inline_template',
+      '#template' => $alert,
       '#weight' => 1000,
     ];

This was a bit of a hack because I wasn't able to get the <button> tag to output at all. There may well be a better type to use for this purpose.

othermachines’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Uh, weird. I have no idea why that switched versions. Switching back...

labboy0276’s picture

Status: Needs review » Fixed

Great, good job, I tested it real quick and it seems to be good.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.