Make tracker pattern displayName read-only
The displayName field was always predictable from pattern + matchType and allowing edits added unnecessary complexity. Remove displayName from UpdateTrackerPatternInput across all surfaces (GraphQL, MCP, CLI, n8n) and make the frontend show it as non-editable text. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -48,7 +48,6 @@ type updateResponse struct {
|
||||
|
||||
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
var (
|
||||
flagDisplayName string
|
||||
flagDescription string
|
||||
flagMaxAge int
|
||||
flagExcluded bool
|
||||
@@ -79,9 +78,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
|
||||
input := map[string]any{"trackerPatternId": args[0]}
|
||||
|
||||
if cmd.Flags().Changed("display-name") {
|
||||
input["displayName"] = flagDisplayName
|
||||
}
|
||||
if cmd.Flags().Changed("description") {
|
||||
input["description"] = flagDescription
|
||||
}
|
||||
@@ -113,7 +109,6 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().StringVar(&flagDisplayName, "display-name", "", "Display name")
|
||||
cmd.Flags().StringVar(&flagDescription, "description", "", "Description")
|
||||
cmd.Flags().IntVar(&flagMaxAge, "max-age-seconds", 0, "Maximum age in seconds")
|
||||
cmd.Flags().BoolVar(&flagExcluded, "excluded", false, "Exclude pattern from consent banner")
|
||||
|
||||
@@ -149,7 +149,6 @@ type (
|
||||
|
||||
UpdateTrackerPatternRequest struct {
|
||||
TrackerPatternID gid.GID
|
||||
DisplayName *string
|
||||
MaxAgeSeconds **int
|
||||
Description *string
|
||||
Excluded *bool
|
||||
@@ -357,9 +356,6 @@ func (r *UpdateTrackerPatternRequest) Validate() error {
|
||||
v := validator.New()
|
||||
|
||||
v.Check(r.TrackerPatternID, "tracker_pattern_id", validator.Required(), validator.GID(coredata.TrackerPatternEntityType))
|
||||
if r.DisplayName != nil {
|
||||
v.Check(*r.DisplayName, "display_name", validator.Required(), validator.SafeTextNoNewLine(255))
|
||||
}
|
||||
if r.Description != nil {
|
||||
v.Check(*r.Description, "description", validator.SafeText(1000))
|
||||
}
|
||||
@@ -2258,20 +2254,16 @@ func (s *Service) UpdateTrackerPattern(
|
||||
return fmt.Errorf("cannot load tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
displayNameChanged := req.DisplayName != nil && *req.DisplayName != pattern.DisplayName
|
||||
maxAgeChanged := req.MaxAgeSeconds != nil && !ptrEqual(*req.MaxAgeSeconds, pattern.MaxAgeSeconds)
|
||||
descChanged := req.Description != nil && *req.Description != pattern.Description
|
||||
excludedChanged := req.Excluded != nil && *req.Excluded != pattern.Excluded
|
||||
|
||||
if !displayNameChanged && !maxAgeChanged && !descChanged && !excludedChanged {
|
||||
if !maxAgeChanged && !descChanged && !excludedChanged {
|
||||
return nil
|
||||
}
|
||||
|
||||
staysExcluded := pattern.Excluded && (req.Excluded == nil || *req.Excluded)
|
||||
|
||||
if req.DisplayName != nil {
|
||||
pattern.DisplayName = *req.DisplayName
|
||||
}
|
||||
if req.MaxAgeSeconds != nil {
|
||||
pattern.MaxAgeSeconds = *req.MaxAgeSeconds
|
||||
}
|
||||
|
||||
@@ -823,7 +823,6 @@ func (r *mutationResolver) UpdateTrackerPattern(ctx context.Context, input types
|
||||
scope,
|
||||
cookiebanner.UpdateTrackerPatternRequest{
|
||||
TrackerPatternID: input.TrackerPatternID,
|
||||
DisplayName: input.DisplayName,
|
||||
MaxAgeSeconds: gqlutils.UnwrapOmittable(input.MaxAgeSeconds),
|
||||
Description: input.Description,
|
||||
Excluded: input.Excluded,
|
||||
|
||||
@@ -517,7 +517,6 @@ input CreateTrackerPatternInput {
|
||||
|
||||
input UpdateTrackerPatternInput {
|
||||
trackerPatternId: ID!
|
||||
displayName: String
|
||||
maxAgeSeconds: Int @goField(omittable: true)
|
||||
description: String
|
||||
excluded: Boolean
|
||||
|
||||
@@ -4917,9 +4917,6 @@ func (r *Resolver) UpdateTrackerPatternTool(ctx context.Context, req *mcp.CallTo
|
||||
r.MustAuthorize(ctx, input.ID, probo.ActionTrackerPatternUpdate)
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
updateReq := cookiebanner.UpdateTrackerPatternRequest{TrackerPatternID: input.ID}
|
||||
if v := UnwrapOmittable(input.DisplayName); v != nil && *v != nil {
|
||||
updateReq.DisplayName = *v
|
||||
}
|
||||
if input.MaxAgeSeconds.IsSet() {
|
||||
val, _ := input.MaxAgeSeconds.Value()
|
||||
updateReq.MaxAgeSeconds = &val
|
||||
|
||||
@@ -10012,11 +10012,6 @@ components:
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
display_name:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
go.probo.inc/mcpgen/omittable: true
|
||||
max_age_seconds:
|
||||
type:
|
||||
- integer
|
||||
|
||||
Reference in New Issue
Block a user