Skip to content

Geo Primary Verification API: Expose verification state as name instead of integer value

Show verification state name instead of integer enum value

Problem

Currently, the verification_state field displays an integer enum value, which is not user-friendly and makes it difficult to understand the actual verification status.

Solution

Update the verification_state field to display the status name instead of the integer enum value. The status name will be derived from the verification_state_object, with the 'verification_' prefix removed for cleaner presentation.

Implementation Guide

  1. Apply the provided patch to ee/lib/api/entities/admin/model.rb
Index: ee/lib/api/entities/admin/model.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/lib/api/entities/admin/model.rb b/ee/lib/api/entities/admin/model.rb
--- a/ee/lib/api/entities/admin/model.rb	(revision c695bb2ccad1d7fa8af3689550f9f467ad816167)
+++ b/ee/lib/api/entities/admin/model.rb	(date 1760670882868)
@@ -34,10 +34,15 @@
           if: ->(model) { verification_enabled?(model) } do
           expose :verification_checksum, as: :checksum
           expose :verified_at, as: :last_checksum
-          expose :verification_state, as: :checksum_state
           expose :verification_retry_count, as: :checksum_retry_count
           expose :verification_retry_at, as: :checksum_retry_at
           expose :verification_failure, as: :checksum_failure
+
+          expose :verification_state, as: :checksum_state do |model|
+            return nil unless model.respond_to?(:verification_state_object)
+
+            model.verification_state_object.verification_state_name.to_s.gsub('verification_', '')
+          end
         end
 
         private

Note: This is based off ee/app/graphql/types/geo/registry_type.rb but we can also create a helper method to derive the name to DRY the implementation.


Description was generated using AI

Edited by 🤖 GitLab Bot 🤖