POC/WIP/Garbage: Rearrange presenting layer of AlertMangement::Alerts
What does this MR do?
I am so overwhelmed by the presentation classes around alerts. I never have any idea where things should live. I would like that to be better.
DISCLAIMER: This MR is very incomplete and broken, but is an idea of a direction we could go in that I think could help.
Proposed architecture:
- A
Gitlab::AlertManagement::Payload::Base
defines an api by which any alert payload content is accessible. Any payload field we expect to interact with (beyond simply displaying it or passing it through to FE), should be defined as part of the base class. - Subclasses of
Payload::Base
define how to access fields from the payload or find corresponding DB records based on the source of the alert (prometheus/generic/etc). - Example use-case: display an alert in the UI. In this scenario, payload attributes should be accessed through the
#parsed_payload
field on anAlertManagement::Alert
. - Example use-case: create a new
AlertManagement::Alert
from an incoming notification. Use thenew_from_payload
class method onAlertMangement::Alert
to instantiate an instance of the class with attributes populated from the payload. - Example use-case: send an email based on an alert. For presentational elements (such as formatting strings), use the
AlertManagement::AlertPresenter
, accessible through the#present
method onAlertManagement::Alert
.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team