Add time-based scheduling to targeted messages

What does this MR do and why?

This MR adds time-based scheduling capabilities to targeted messages, allowing administrators to specify when admin notifications should be displayed to users.

What it does:

  • Adds starts_at and ends_at timestamp columns to the targeted_messages table with a database constraint ensuring start time is before end time
  • Creates a new Vue component (DatetimePicker) that combines date and time selection for the UI
  • Integrates datetime fields into the targeted message form with proper validation
  • Ensures messages can only be scheduled for future dates (not in the past)

Why it's needed: This enables time-bound admin notifications—administrators can now create messages that automatically display during specific time windows rather than being permanently active. For example, you could schedule a maintenance notification to appear only during a scheduled maintenance window, or a promotional message for a specific campaign period.

References

#581707 (closed)

Screenshots or screen recordings

Before After
image.png image.png
image.png image.png

How to set up and validate locally

  1. Run the database migration:
    • bin/rails db:migrate
  2. Access the admin panel:
    • Go to http://localhost:3000/admin/targeted_messages
    • Sign in as an admin user if needed
  3. Create a new targeted message:
    • Click "Add targeted message" button
    • You'll see the form with:
      • Target Type dropdown
      • Starts at field (date + time picker)
      • Ends at field (date + time picker)
      • Upload CSV for namespace IDs
  4. Edit an existing message:
    • Click edit on any targeted message
    • The datetime fields should pre-populate with existing values
    • Modify and save to verify updates work

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #581707 (closed)

Edited by Harsh Sagar

Merge request reports

Loading
Loading