Skip to content

Commit

Permalink
Hide the linked section if no links exist. Also hide the entire secti…
Browse files Browse the repository at this point in the history
…on if no providers exist

Signed-off-by: MTRNord <[email protected]>
  • Loading branch information
MTRNord committed Nov 8, 2024
1 parent 407a721 commit d32ab17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"label": "Password"
},
"title": "Your account",
"unlinked_upstreams": "Unlinked Upstream Providers"
"available_upstreams": "Available Upstream Providers"
},
"add_email_form": {
"email_denied_error": "The entered email is not allowed by the server policy",
Expand Down
38 changes: 23 additions & 15 deletions frontend/src/components/UserProfile/UpstreamProviderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,19 @@ const UpstreamProviderList: React.FC<{}> = () => {
update({ requestPolicy: "network-only" });
}, [update]);

const linkedUpstreams = links.edges.filter((edge) =>
edge.node.upstreamOauth2LinksForUser.some(
(link) => link.provider.id === edge.node.id,
),
);

if (links.totalCount === 0) {
return <></>;
}

return (
<>
<H5>{t("frontend.account.unlinked_upstreams")}</H5>
<H5>{t("frontend.account.available_upstreams")}</H5>
{links.edges
.filter(
(edge) =>
Expand All @@ -92,20 +102,18 @@ const UpstreamProviderList: React.FC<{}> = () => {
key={edge.cursor}
/>
))}
<H5>{t("frontend.account.linked_upstreams")}</H5>
{links.edges
.filter((edge) =>
edge.node.upstreamOauth2LinksForUser.some(
(link) => link.provider.id === edge.node.id,
),
)
.map((edge) => (
<UnlinkUpstreamProvider
upstreamProvider={edge.node}
onUnlinked={onUnlinked}
key={edge.cursor}
/>
))}
{linkedUpstreams.length > 0 && (
<>
<H5>{t("frontend.account.linked_upstreams")}</H5>
{linkedUpstreams.map((edge) => (
<UnlinkUpstreamProvider
upstreamProvider={edge.node}
onUnlinked={onUnlinked}
key={edge.cursor}
/>
))}
</>
)}
<PaginationControls
autoHide
count={links.totalCount ?? 0}
Expand Down

0 comments on commit d32ab17

Please sign in to comment.