Skip to content

Commit

Permalink
chore: use label in link/unlink settings nodes (#3977)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Jul 4, 2024
1 parent 020a9de commit 180287a
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050002,
"text": "Link ory",
"text": "Link Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"meta": {
"label": {
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info",
"context": {
"provider": "ory"
"provider": "Ory"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050002,
"text": "Link ory",
"text": "Link Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"meta": {
"label": {
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info",
"context": {
"provider": "ory"
"provider": "Ory"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"meta": {
"label": {
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info",
"context": {
"provider": "ory"
"provider": "Ory"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@
"meta": {
"label": {
"context": {
"provider": "ory"
"provider": "Ory"
},
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@
"meta": {
"label": {
"id": 1050003,
"text": "Unlink ory",
"text": "Unlink Ory",
"type": "info",
"context": {
"provider": "ory"
"provider": "Ory"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions selfservice/strategy/oidc/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"github.com/ory/kratos/ui/node"
)

func NewLinkNode(provider string) *node.Node {
return node.NewInputField("link", provider, node.OpenIDConnectGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoSelfServiceSettingsUpdateLinkOIDC(provider))
func NewLinkNode(providerID, providerLabel string) *node.Node {
return node.NewInputField("link", providerID, node.OpenIDConnectGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoSelfServiceSettingsUpdateLinkOIDC(providerLabel))
}

func NewUnlinkNode(provider string) *node.Node {
return node.NewInputField("unlink", provider, node.OpenIDConnectGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoSelfServiceSettingsUpdateUnlinkOIDC(provider))
func NewUnlinkNode(providerID, providerLabel string) *node.Node {
return node.NewInputField("unlink", providerID, node.OpenIDConnectGroup, node.InputAttributeTypeSubmit).WithMetaLabel(text.NewInfoSelfServiceSettingsUpdateUnlinkOIDC(providerLabel))
}
5 changes: 3 additions & 2 deletions selfservice/strategy/oidc/strategy_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/ory/x/sqlxx"
"github.com/ory/x/stringsx"

"github.com/tidwall/sjson"

Expand Down Expand Up @@ -173,7 +174,7 @@ func (s *Strategy) PopulateSettingsMethod(r *http.Request, id *identity.Identity
if l.Config().OrganizationID != "" {
continue
}
sr.UI.GetNodes().Append(NewLinkNode(l.Config().ID))
sr.UI.GetNodes().Append(NewLinkNode(l.Config().ID, stringsx.Coalesce(l.Config().Label, l.Config().ID)))
}

count, err := s.d.IdentityManager().CountActiveFirstFactorCredentials(r.Context(), confidential)
Expand All @@ -185,7 +186,7 @@ func (s *Strategy) PopulateSettingsMethod(r *http.Request, id *identity.Identity
// This means that we're able to remove a connection because it is the last configured credential. If it is
// removed, the identity is no longer able to sign in.
for _, l := range linked {
sr.UI.GetNodes().Append(NewUnlinkNode(l.Config().ID))
sr.UI.GetNodes().Append(NewUnlinkNode(l.Config().ID, stringsx.Coalesce(l.Config().Label, l.Config().ID)))
}
}

Expand Down
Loading

0 comments on commit 180287a

Please sign in to comment.