# What this PR does
Introduces a new class,
`apps.grafana_plugin.ui_url_builder.UIURLBuilder`, which is responsible
for... building UI URLs (😄). The class mainly does two things:
- it will decide if the URL should point to `grafana-oncall-app` or
`grafana-irm-app` based on the value of
`organization.is_grafana_irm_enabled` (**NOTE**: this value isn't yet
being set + defaults to `False`; logic for setting this value will be
done in a subsequent PR)
- Adds `enum`s, `OnCallPage` and `IncidentPage` to DRYify hardcoded UI
URLs (in case we decide to change these slightly in the near future)
## 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] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
show up in the autogenerated release notes.
20 lines
778 B
Python
20 lines
778 B
Python
from rest_framework import serializers
|
|
|
|
from apps.oss_installation.models import CloudConnector, CloudUserIdentity
|
|
from apps.oss_installation.utils import cloud_user_identity_status
|
|
from apps.user_management.models import User
|
|
|
|
|
|
class CloudUserSerializer(serializers.ModelSerializer):
|
|
cloud_data = serializers.SerializerMethodField()
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = ["cloud_data"]
|
|
|
|
def get_cloud_data(self, obj: User):
|
|
connector = CloudConnector.objects.filter().first()
|
|
cloud_user_identity = CloudUserIdentity.objects.filter(email=obj.email).first()
|
|
status, link = cloud_user_identity_status(obj.organization, connector, cloud_user_identity)
|
|
cloud_data = {"status": status, "link": link}
|
|
return cloud_data
|