-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Problem
Currently, the frontend hardcodes the admin URL for taxa with a production domain and path:
get adminUrl(): string {
return `https://api.antenna.insectai.org/bereich/main/taxon/${this.id}`
}This causes two issues:
- The URL always points to production, even in development and staging environments
- The path segment varies by environment, and the frontend doesn't have knowledge of these routing rules
Proposed Solution
Move the admin URL logic to the backend, making it the source of truth:
Backend changes (ami/main/api/serializers.py):
- Add an
admin_urlfield (orlinks.admin) to taxon serializers (TaxonSerializer, TaxonListSerializer, TaxonNoParentNestedSerializer) - Compute the URL using environment-specific routing rules
- Example:
class TaxonSerializer(serializers.ModelSerializer):
admin_url = serializers.SerializerMethodField()
def get_admin_url(self, obj):
request = self.context.get('request')
return build_admin_url(request, obj.id)Frontend changes (ui/src/data-services/models/species.ts):
- Consume the
admin_urlfield from the API - Return
undefinedif not provided by the backend - Example:
get adminUrl(): string | undefined {
return this._species.admin_url ?? this._species?.links?.admin ?? undefined
}UI behavior:
- Admin button only shows when
species.adminUrlis truthy andcanUpdateis true - If backend omits the URL for certain environments or roles, button won't appear
References
- Related PR: Taxon details tweaks #1039
- Discussion: Taxon details tweaks #1039 (comment)
- Requested by: @annavik
Metadata
Metadata
Assignees
Labels
No labels