Skip to content

Conversation

stveit
Copy link
Contributor

@stveit stveit commented May 26, 2025

Scope and purpose

Fixes #1194.

Adds a page with information from an incident that kinda simulates what a real ticket could look like on a ticket site (very basic page). DummyPlugin will return a URL to this page when you use the "Create ticket" function.

Example of the basic page (uses a ticket html file that already existed):
image

The url has the format /incidents/fake_ticket/<pk>/. I'll happily take suggestions for URL names and such, or potentially other ways to generate a page like this. I kinda just went with the "fake" naming scheme, but maybe it should be called something else. Maybe /incidents/dummy_ticket/<pk>/ instead?

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this results in changes to the database model: Updated the ER diagram

@stveit stveit self-assigned this May 26, 2025
@stveit stveit changed the title Add page with data to dummy plugin Add "fake" ticket page that DummyPlugin links to when autocreating tickets May 26, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2025

Codecov Report

Attention: Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.93%. Comparing base (4fc7811) to head (c83949f).

Files with missing lines Patch % Lines
src/argus/htmx/incident/views.py 54.54% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1488      +/-   ##
==========================================
- Coverage   78.97%   78.93%   -0.04%     
==========================================
  Files         120      120              
  Lines        5294     5308      +14     
==========================================
+ Hits         4181     4190       +9     
- Misses       1113     1118       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stveit stveit force-pushed the add-page-with-data-to-dummy-plugin branch from bd50714 to ed7a5a5 Compare May 28, 2025 07:22
@stveit stveit force-pushed the add-page-with-data-to-dummy-plugin branch from ed7a5a5 to c83949f Compare May 28, 2025 07:59
Copy link

@stveit stveit marked this pull request as ready for review May 28, 2025 10:02
@johannaengland
Copy link
Contributor

"Demo ticket" might be another option for showing that it is not a real ticket

@johannaengland johannaengland requested a review from a team May 30, 2025 07:12
Copy link
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to see an additional test along the lines that the dummy plugin returns a valid url and that the result of following that url is a site containing some details of the incident

Comment on lines 10 to +13
from django.utils.timezone import now as tznow
from django.urls import reverse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from django.utils.timezone import now as tznow
from django.urls import reverse
from django.urls import reverse
from django.utils.timezone import now as tznow

Comment on lines 20 to +25
from argus.incident.ticket.utils import get_ticket_plugin_path
from argus.incident.ticket.base import TicketPluginException
from argus.incident.serializers import IncidentSerializer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from argus.incident.ticket.utils import get_ticket_plugin_path
from argus.incident.ticket.base import TicketPluginException
from argus.incident.serializers import IncidentSerializer
from argus.incident.serializers import IncidentSerializer
from argus.incident.ticket.utils import get_ticket_plugin_path
from argus.incident.ticket.base import TicketPluginException

Comment on lines +269 to +274
context = IncidentSerializer(incident).data
argus_url = urljoin(
getattr(settings, "FRONTEND_URL", ""),
reverse("htmx:incident-detail", kwargs={"pk": pk}),
)
context["argus_url"] = argus_url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could use

def serialize_incident_for_ticket_autocreation(incident: Incident, actor: User):
serialized_incident = IncidentSerializer(incident).data
# TODO: ensure argus_url ends with "/" on HTMx frontend
serialized_incident["argus_url"] = urljoin(
getattr(settings, "FRONTEND_URL", ""),
f"incidents/{incident.pk}",
)
serialized_incident["user"] = actor.get_full_name()
return serialized_incident
for this

Comment on lines +106 to +109
url = urljoin(
getattr(settings, "FRONTEND_URL", ""),
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move this into the create function, just to keep the concern of "creating a ticket" separate for demonstration purposes on how to write a ticket plugin

Comment on lines +106 to +109
url = urljoin(
getattr(settings, "FRONTEND_URL", ""),
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns the link to the incident detail page, not the fake ticket system page

Suggested change
url = urljoin(
getattr(settings, "FRONTEND_URL", ""),
reverse("htmx:incident-detail", kwargs={"pk": serialized_incident["pk"]}),
)
url = reverse("htmx:fake-ticket", kwargs={"pk": serialized_incident["pk"]})

@hmpf
Copy link
Contributor

hmpf commented Jun 13, 2025

I will hand-check this when I can, no merging or approves before that.

@hmpf hmpf added frontend Affects frontend ticket system Affects the ticket system blocked Another thing/issue has to be resolved before tackling this labels Jun 13, 2025
@hmpf hmpf self-requested a review July 10, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Another thing/issue has to be resolved before tackling this frontend Affects frontend ticket system Affects the ticket system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ticket-plugin: Make a plugin that pops up a new page with the data that would be used to make the ticket

4 participants