Commit graph

634 commits

Author SHA1 Message Date
Yulya Artyukhina
2edae70b04
Update wording for mobile push notifications timing choices (#3253)
# What this PR does
Update wording for mobile push notifications timing choices

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-02 11:37:28 +00:00
Joey Orlando
1cbce6f0e4
Merge branch 'main' into dev 2023-11-02 07:21:01 -04:00
Joey Orlando
c3d11b847f
[hotfix] frontend TypeError (#3252) 2023-11-02 07:14:44 -04:00
Innokentii Konstantinov
c8228670cd Update CHANGELOG 2023-11-02 19:06:43 +08:00
Ildar Iskhakov
7fe67c68d0
Update CHANGELOG.md 2023-11-02 17:59:03 +08:00
Michael Derynck
3b02c587f5
Order alert groups by -started_at in internal API (#3240)
# What this PR does
Order alert groups in API by -started_at instead of -pk. This should
result in no visible change for most installations. In the case where
alert groups are being moved/restored between installations this allows
for the display order to be as expected without relying on insertion
order.

Note: Public API is already using -started_at instead of pk and it is
already indexed.

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-01 13:19:21 -06:00
Joey Orlando
c552decb37
Update CHANGELOG.md 2023-10-31 11:21:20 -04:00
Joey Orlando
d568ad6707
few add responders patches (#3220)
# Which issue(s) this PR fixes

Closes https://github.com/grafana/support-escalations/issues/8143

Fix a few minor issues introduced in #3128:

- Fix slow `GET /users` internal API endpoint related to [this
change](https://github.com/grafana/oncall/blob/dev/engine/apps/api/views/user.py#L239)
- Fix slow `GET /teams` internal API endpoint. Introduced a `short`
query parameter that only invokes
`apps.schedules.ical_utils.get_oncall_users_for_multiple_schedules` when
`short=false`.
- Order results from `GET /teams` internal API endpoint by name
(ascending)
- Fix search issue when searching for teams in the add responders popup
window (this was strictly a frontend issue)
- CSS changes to add responders dropdown to fix lonnnggg results list:
  **Before**
<img width="377" alt="Screenshot 2023-10-31 at 10 06 20"
src="https://github.com/grafana/oncall/assets/9406895/246c7c3b-7bea-44a1-afec-a38144c2c2d1">
  **After**
<img width="444" alt="Screenshot 2023-10-31 at 10 48 12"
src="https://github.com/grafana/oncall/assets/9406895/b5602a22-c691-4dc7-bd3d-e4d6b76d04a0">



## Still todo

The `apps.schedules.ical_utils.get_oncall_users_for_multiple_schedules`
method is still very slow when an instance has a lot of users (ex.
`ops`). Ideally we should refactor this method to be more efficient
because we still need to call this method under some circumstances. Ex.
to populate this dropdown when Direct Paging a user (note that it didn't
finish loading here on `ops`):
<img width="1037" alt="Screenshot 2023-10-30 at 18 14 59"
src="https://github.com/grafana/oncall/assets/9406895/9d91a57c-5db8-4ff9-862a-cd3755f52690">



## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-31 11:18:33 -04:00
Matias Bordese
5996141133
Disable updates for API/terraform shifts in internal API (#3224)
Related to https://github.com/grafana/oncall-private/issues/2246
2023-10-31 15:08:07 +00:00
Rares Mardare
d1de4bc54b changelog 2023-10-30 18:12:32 +02:00
Rares Mardare
871860c399
Pagination refactoring/cleanup (#3205)
# What this PR does

- Pagination cleanup so that frontend no longer hardcodes page size
- Moved pagination to the filters store instead for all pages that have
pagination enabled
- Prevent UI triggering polling if window is inactive or if the previous
request didn't complete

## Which issue(s) this PR fixes

#2931 
#2462

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-30 14:20:14 +00:00
Joey Orlando
c78ab58b44
Update CHANGELOG.md 2023-10-30 09:58:34 -04:00
Yulya Artyukhina
76a0643bc5
"Going oncall" notification settings (#3187)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-10-30 13:44:18 +00:00
Joey Orlando
6a78ee6983
fix RBAC authz issue for Slack Alert Group actions (#3213)
Was able to reproduce locally with OnCall RBAC enabled and as a user
with Viewer role:
<img width="701" alt="Screenshot 2023-10-30 at 09 30 52"
src="https://github.com/grafana/oncall/assets/9406895/0050c2b1-2765-4aba-a73e-985f364691ad">

Fixed with the changes introduced in this PR:
<img width="963" alt="Screenshot 2023-10-30 at 09 30 16"
src="https://github.com/grafana/oncall/assets/9406895/02b62f39-01e5-4a13-baaf-db30181eb16a">
<img width="967" alt="Screenshot 2023-10-30 at 09 30 11"
src="https://github.com/grafana/oncall/assets/9406895/c606f6db-8e99-4df4-a3e9-5c9da8feb051">



## Which issue(s) this PR fixes

Closes #3212 

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-30 09:48:54 -04:00
Nelson
c281484f67
add support for datetime on final_shifts API parameters (#3103)
# What this PR does
- Changes the data type from `DateField` to `DateTimeField` on the
`final_shifts` API endpoint
- Accepts either a date or a datetime for the `start_date` and
`end_date` parameters (e.g. 2021-01-01 or 2021-01-01T01:00)
- Datetime granularity is in line with what is configurable on the
schedule i.e. `YYYY-MM-DD hh:mm`
- removes the rounding logic that modifies the query sent on the
database

## Which issue(s) this PR fixes
#3086 

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-10-30 12:00:39 +00:00
Matias Bordese
c4fb620328
Upgrade to django 4.2.6 and other deps updates (#3176) 2023-10-27 18:45:00 +00:00
Joey Orlando
697248dc75
Add responders improvements (#3128)
# What this PR does

https://www.loom.com/share/c5e10b5ec51343d0954c6f41cfd6a5fb

## Summary of backend changes
- Add `AlertReceiveChannel.get_orgs_direct_paging_integrations` method
and `AlertReceiveChannel.is_contactable` property. These are needed to
be able to (optionally) filter down teams, in the `GET /teams` internal
API endpoint
([here](https://github.com/grafana/oncall/pull/3128/files#diff-a4bd76e557f7e11dafb28a52c1034c075028c693b3c12d702d53c07fc6f24c05R55-R63)),
to just teams that have a "contactable" Direct Paging integration
- `engine/apps/alerts/paging.py`
- update these functions to support new UX. In short `direct_paging` no
longer takes a list of `ScheduleNotifications` or an `EscalationChain`
object
  - add `user_is_oncall` helper function
- add `_construct_title` helper function. In short if no `title` is
provided, which is the case for Direct Pages originating from OnCall
(either UI or Slack), then the format is `f"{from_user.username} is
paging <team.name (if team is specified> <comma separated list of
user.usernames> to join escalation"`
- `engine/apps/api/serializers/team.py` - add
`number_of_users_currently_oncall` attribute to response schema
([code](https://github.com/grafana/oncall/pull/3128/files#diff-26af48f796c9e987a76447586dd0f92349783d6ea6a0b6039a2f0f28bd58c2ebR45-R52))
- `engine/apps/api/serializers/user.py` - add `is_currently_oncall`
attribute to response schema
([code](https://github.com/grafana/oncall/pull/3128/files#diff-6744b5544ebb120437af98a996da5ad7d48ee1139a6112c7e3904010ab98f232R157-R162))
- `engine/apps/api/views/team.py` - add support for two new optional
query params `only_include_notifiable_teams` and `include_no_team`
([code](https://github.com/grafana/oncall/pull/3128/files#diff-a4bd76e557f7e11dafb28a52c1034c075028c693b3c12d702d53c07fc6f24c05R55-R70))
- `engine/apps/api/views/user.py`
- in the `GET /users` internal API endpoint, when specifying the
`search` query param now also search on `teams__name`
([code](https://github.com/grafana/oncall/pull/3128/files#diff-30309629484ad28e6fe09816e1bd226226d652ea977b6f3b6775976c729bf4b5R223);
this is a new UX requirement)
- add support for a new optional query param, `is_currently_oncall`, to
allow filtering users based on.. whether they are currently on call or
not
([code](https://github.com/grafana/oncall/pull/3128/files#diff-30309629484ad28e6fe09816e1bd226226d652ea977b6f3b6775976c729bf4b5R272-R282))
- remove `check_availability` endpoint (no longer used with new UX; also
removed references in frontend code)
- `engine/apps/slack/scenarios/paging.py` and
`engine/apps/slack/scenarios/manage_responders.py` - update Slack
workflows to support new UX. Schedules are no longer a concept here.
When creating a new alert group via `/escalate` the user either
specifies a team and/or user(s) (they must specify at least one of the
two and validation is done here to check this). When adding responders
to an existing alert group it's simply a list of users that they can
add, no more schedules.
- add `Organization.slack_is_configured` and
`Organization.telegram_is_configured` properties. These are needed to
support [this new functionality
](https://github.com/grafana/oncall/pull/3128/files#diff-9d96504027309f2bd1e95352bac1433b09b60eb4fafb611b52a6c15ed16cbc48R271-R272)
in the `AlertReceiveChannel` model.

## Summary of frontend changes
- Refactor/rename `EscalationVariants` component to `AddResponders` +
remove `grafana-plugin/src/containers/UserWarningModal` (no longer
needed with new UX)
- Remove `grafana-plugin/src/models/user.ts` as it seemed to be a
duplicate of `grafana-plugin/src/models/user/user.types.ts`

Related to https://github.com/grafana/incident/issues/4278

- Closes #3115
- Closes #3116
- Closes #3117
- Closes #3118 
- Closes #3177 

## TODO
- [x] make frontend changes
- [x] update Slack backend functionality
- [x] update public documentation
- [x] add/update e2e tests

## Post-deploy To-dos
- [ ] update dev/ops/production Slack bots to update `/escalate` command
description (should now say "Direct page a team or user(s)")

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-27 12:12:07 -04:00
Michael Derynck
a1a318c819
Update CHANGELOG.md 2023-10-25 13:52:52 -06:00
Yulya Artyukhina
a3aeb0ecb5
Fix channel filter endpoint (#3192)
# What this PR does
Add filtering term length check for channel filter endpoints

## Which issue(s) this PR fixes

Closes https://github.com/grafana/oncall-private/issues/2114

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-25 12:33:05 +00:00
Michael Derynck
50d3f1b9d5
Update CHANGELOG.md 2023-10-23 16:22:42 -06:00
Matias Bordese
d546d0b7ff
Fix iCal imported schedules related users and next shifts per user (#3178)
Fixes https://github.com/grafana/oncall-private/issues/2212
2023-10-23 22:15:02 +00:00
Michael Derynck
0d22ae7e53
Change functions for access control (#3184)
# What this PR does
Update calls used for access control to match changes in Grafana:
https://github.com/grafana/grafana/pull/76187
https://github.com/grafana/grafana/pull/76237

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-23 15:58:45 -06:00
Yulya Artyukhina
c0318b55c0
Permissions for labels (#3173)
# What this PR does
Adds check for basic role permissions on get/create/update labels

## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/2194

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-23 11:03:51 +00:00
Vadim Stepanov
2179e7a1c9
Resolution note source mobile app (#3174)
# What this PR does

Fixes https://github.com/grafana/oncall/issues/2320

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-20 15:22:45 +01:00
Rares Mardare
79d1b0a77e
Added mechanism to discard older network requests (#3172)
# What this PR does

- Added mechanism to prevent concurrency conflicts when multiple network
requests are fired and the order of resolving is reversed. This resulted
in flickering the results data, thus showing discrepancy between the
filters (e.g. the search input) and the table data.

Within `RemoteFilters` and `UsersFilters` we're setting an ID for each
network result, and whenever we get to hit the store, we'll compare that
ID with the latest generated ID, thus if they match, we're all good, if
they don't, that means that network request should be discarded and its
data shouldn't be passed to the store.

This was implemented for:
- Users page
- Schedules page
(and more to come)

Fixes https://github.com/grafana/oncall-private/issues/2108
2023-10-20 13:11:32 +00:00
Yulya Artyukhina
24f4969f61
Add labels implementation for integration (#3014)
# What this PR does
Adds labels implementation for integrations:
- ability to create/update labels on creating/updating integration
- ability to associate labels to integrations
- cache for label reprs on OnCall side
- feature flag to enable/disable labels

## Which issue(s) this PR fixes
https://github.com/grafana/oncall-private/issues/2157

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Maxim <maxim.mordasov@grafana.com>
Co-authored-by: Rares Mardare <rares.mardare@grafana.com>
2023-10-20 07:30:11 +00:00
Matias Bordese
bb0bee421e
Update CHANGELOG.md 2023-10-19 14:51:17 -03:00
Matias Bordese
848bd1277f
Handle None role when syncing users from Grafana (#3147)
Fixes https://github.com/grafana/oncall-private/issues/2201
2023-10-19 17:39:08 +00:00
Matias Bordese
a539e3646d
Update shifts public API to improve web shifts support (#3165) 2023-10-19 17:30:12 +00:00
Maxim Mordasov
2d656c50db
Build ‘When I am on-call’ for web UI #2915 (#3100)
# What this PR does

Polish ‘When I am on-call’ feature

## Which issue(s) this PR fixes

[Build ‘When I am on-call’ for web UI
#2915](https://github.com/grafana/oncall/issues/2915)

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-19 09:53:12 +00:00
Matias Bordese
35620028cc
Add user TZ information to next shifts per user endpoint (#3157) 2023-10-18 17:14:56 +00:00
Matias Bordese
5c85ced4a9
Update ical schedule creation/update to trigger final schedule refresh (#3156)
Otherwise iCal schedules only refresh their cached final representation
once a day (via periodic task).
Related to https://github.com/grafana/oncall/issues/3154
2023-10-18 16:41:25 +00:00
Rares Mardare
f23ae99998
Add truncation for content beyond 2 lines and show tooltip with original value if content was truncated (#3123)
# What this PR does

- Removed `MAX_LINE_LENGTH` which was used to truncate Integrations Name
- Added new component `TextEllipsisTooltip` that determines if its
content was truncated, and if so, it will show a tooltip with the
original value. Integrations Name and Alert Group Name fields inside
tables have been changed so that after filling in 2 lines, the content
gets truncated and a tooltip is shown on hover.

Before

![image](https://github.com/grafana/oncall/assets/40542072/1bdd29f3-5804-45f1-85b1-69657d26c73f)
After

![image](https://github.com/grafana/oncall/assets/40542072/1a68c3ed-5884-431f-8a6f-f8ea1185987c)

As you can see this results in more space being taken for the
integrations name (but no more than what it should take), and the end
result is always truncated after 2 lines. Same applies to the
Integrations

Before

![image](https://github.com/grafana/oncall/assets/40542072/802e9a4f-89b5-461d-9c04-15d7117cdb8b)
After

![image](https://github.com/grafana/oncall/assets/40542072/a0674469-bdcc-4051-9783-9ffc81b8ba31)

The `Don't delete` integration wasn't even showing 100% of its full
width in the before screen, but it shows in the after because now
there's no more limit on the characters.
2023-10-18 11:41:14 +00:00
Michael Derynck
1871106d0a
Update CHANGELOG.md 2023-10-16 15:27:20 -06:00
Michael Derynck
f40e0463d2
Fix inconsistency with API URL returned by plugin status (#3122)
# What this PR does
Change status to return backend URL in the same way (trailing /) that is
used to build URLs throughout by using create_engine_url utility
function.

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-16 17:38:08 +00:00
Matias Bordese
ae85ce3d55
Update plugin role permissions (#3145)
When the direct paging role was
[introduced](https://github.com/grafana/oncall/pull/3107), the OnCaller
role didn't keep the permission to use this feature.
Also, being an OnCaller, makes sense user can update their own
notification settings.

Related https://github.com/grafana/support-escalations/issues/7840.
2023-10-11 17:27:04 +00:00
Vadim Stepanov
579aaade8a
v1.3.43 changelog (#3125) 2023-10-05 15:04:24 +01:00
Vadim Stepanov
1acb7018d0
Improve alert group deletion API (#3124)
# What this PR does

- Invalidate alert group cache on wipe
- Improve public API docs on alert group deletion
- Add / improve tests

## Which issue(s) this PR fixes

Related to https://github.com/grafana/oncall/issues/3051

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-05 14:32:40 +01:00
Vadim Stepanov
a727450d49
Public API: Acknowledge & Resolve actions (#3108)
# What this PR does

Makes it possible to acknowledge/unacknowledge and resolve/unresolve
alert groups via public API, and makes sure these actions are reflected
properly in the alert group timeline.

## Demo

```bash
curl --request POST \
     --header "Authorization: TOKEN" \
     http://localhost:8080/api/v1/alert_groups/IQMHLV8INB24N/resolve
```

<img width="651" alt="Screenshot 2023-10-04 at 16 05 27"
src="https://github.com/grafana/oncall/assets/20116910/d4e66868-0132-4b6b-95c7-8424fced7c0b">

## Which issue(s) this PR fixes

https://github.com/grafana/oncall/issues/3051

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-05 09:46:48 +01:00
Matias Bordese
7d0594a906
Update CHANGELOG.md 2023-10-04 16:01:35 -03:00
Matias Bordese
abc0f17c70
Update schedule filter events endpoint to return additional shift info (#3110)
Related to https://github.com/grafana/oncall-private/issues/2191

This will also allow plugin to get shift name and type from the
filter_events API, without needing to get details for each involved
shift in the user's on-call summary timeline.
2023-10-04 16:47:27 +00:00
Joey Orlando
728ee46b91
Update CHANGELOG.md 2023-10-04 07:57:18 -04:00
Joey Orlando
b0e0f646d8
add new 'Alert Groups Direct Paging' RBAC role (#3107)
# What this PR does

Closes #3095

https://www.loom.com/share/6c1a3e9970814f7c83d5cbd72cb5e6b5

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-03 19:28:26 -04:00
Michael Derynck
d604fa1d06
Fix action/webhook API not accepting empty/null user (#3094)
# What this PR does
Fix update calls made by terraform when user field is empty or not
present.
Should have been part of: https://github.com/grafana/oncall/pull/3053

## Which issue(s) this PR fixes
https://github.com/grafana/terraform-provider-grafana/issues/1025

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-10-03 14:33:05 +00:00
Matias Bordese
29eae9b2c6
Fix slack notification for shift end affected by taken swap (#3092)
Related to https://github.com/grafana/oncall/issues/3096
2023-10-02 12:56:07 +00:00
Ildar Iskhakov
9dc1125d5c
Update CHANGELOG.md 2023-09-28 14:41:15 +08:00
Ildar Iskhakov
51014735aa
WIP: Direct paging improvements (#3064)
# What this PR does
* Create Direct Paging integration (with default route) when team is
created with bulk_update
* Create notification policies when user is created with bulk_update
* If user notification policies are empty change it to Email
* Minor markup and wording improvements
* Add grafana queue to helm chart
* Remove disabled commands for redis helm chart
* Improve Dockerfile caching

## Which issue(s) this PR fixes

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-28 03:57:49 +00:00
Michael Derynck
9126f214eb
Update CHANGELOG.md
Remove repeated entry
2023-09-27 12:51:45 -06:00
Michael Derynck
cfda0c8aaa
Update CHANGELOG.md 2023-09-27 12:43:15 -06:00
Michael Derynck
b5a8b8b168
Add webhook presets (#2996)
# What this PR does
Add a system similar to how we select integrations when creating
webhooks so that the user has a description of what webhookds do and
does not have to write complex templates for common webhook use cases.
Presets allow us to create the contents of the webhooks in code and
define which fields are controlled by the preset. Some specifics:

- Newly created webhooks must choose between Simple, Advanced or another
predefined system
- Simple is always an escalation step and will post the entire payload
to the given URL
- Advanced is the same as no preset which is our current view where all
fields are available
- There are no changes for all existing webhooks with empty preset
fields
- Once a webhook is created with a preset the preset cannot be changed
- Fields in the webhook that are populated by code will give a
validation error if they are modified
- In the public API webhooks with presets are returned for viewing but
cannot be created or modified. This restriction is in place because the
Web UI provides the context for which fields to use with a preset. The
public API is for interacting with webhooks where all fields are
defined.

To define a preset create a file with metadata and an override function.
The metadata drives validation and what to display in the UI. There are
two functions one is connected to the pre_save hook of the Webhook model
for persistent changes, the other replaces parameters at execution time
for ephemeral changes. See the simple and advanced presets as an
example. The file must be listed in settings in
`INSTALLED_WEBHOOK_PRESETS` to be enabled at runtime..

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-09-27 07:22:52 -06:00