Skip to content

Commit 04feaf4

Browse files
Show tooltip to explain why JWT access token toggle is disabled
ref DEV-2951
2 parents 9becc8f + 9e09d15 commit 04feaf4

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

portal/src/graphql/portal/EditOAuthClientForm.tsx

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
DeleteClientSecretConfirmationDialog,
3333
DeleteClientSecretConfirmationDialogData,
3434
} from "../../components/applications/DeleteClientSecretConfirmationDialog";
35+
import Tooltip from "../../Tooltip";
3536

3637
const MASKED_SECRET = "***************";
3738

@@ -372,13 +373,17 @@ const EditOAuthClientForm: React.VFC<EditOAuthClientFormProps> =
372373
);
373374
}, [clientConfig.x_application_type, showRefreshTokenSettings]);
374375

375-
const alwaysIssueJWTAccessToken = useMemo(
376-
() =>
377-
(["m2m"] as OAuthClientConfig["x_application_type"][]).includes(
378-
clientConfig.x_application_type
379-
),
380-
[clientConfig.x_application_type]
381-
);
376+
const alwaysIssueJWTAccessTokenTooltipMessageID = useMemo(() => {
377+
const map: Map<OAuthClientConfig["x_application_type"], string | null> =
378+
new Map([
379+
["m2m", "EditOAuthClientForm.issue-jwt-access-token.tooltip-m2m"],
380+
]);
381+
return map.get(clientConfig.x_application_type) ?? null;
382+
}, [clientConfig.x_application_type]);
383+
384+
const isIssueJWTAccessTokenToggleDisabled = useMemo(() => {
385+
return alwaysIssueJWTAccessTokenTooltipMessageID != null;
386+
}, [alwaysIssueJWTAccessTokenTooltipMessageID]);
382387

383388
const showApp2AppSettings =
384389
clientConfig.x_application_type === "native" && app2appEnabled;
@@ -823,14 +828,29 @@ const EditOAuthClientForm: React.VFC<EditOAuthClientFormProps> =
823828
}
824829
onChange={onAccessTokenLifetimeChange}
825830
/>
826-
<Toggle
827-
checked={clientConfig.issue_jwt_access_token}
828-
disabled={alwaysIssueJWTAccessToken}
829-
onChange={onIssueJWTAccessTokenChange}
830-
label={renderToString(
831-
"EditOAuthClientForm.issue-jwt-access-token.label"
832-
)}
833-
/>
831+
<div>
832+
<Label
833+
htmlFor="issue-jwt-access-token-toggle"
834+
disabled={isIssueJWTAccessTokenToggleDisabled}
835+
>
836+
{renderToString(
837+
"EditOAuthClientForm.issue-jwt-access-token.label"
838+
)}
839+
</Label>
840+
<Tooltip
841+
tooltipMessageId={
842+
alwaysIssueJWTAccessTokenTooltipMessageID ?? ""
843+
}
844+
isHidden={alwaysIssueJWTAccessTokenTooltipMessageID == null}
845+
>
846+
<Toggle
847+
id="issue-jwt-access-token-toggle"
848+
checked={clientConfig.issue_jwt_access_token}
849+
disabled={isIssueJWTAccessTokenToggleDisabled}
850+
onChange={onIssueJWTAccessTokenChange}
851+
/>
852+
</Tooltip>
853+
</div>
834854
</Widget>
835855
) : null}
836856
{showCookieSettings ? (

portal/src/locale-data/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@
895895
"EditOAuthClientForm.access-token.description": "How frequent the access token should be refreshed. This will affect the timeliness of the information held in the JWT token.",
896896
"EditOAuthClientForm.access-token.description.m2m": "How frequent the access token should be requested again. This will affect the timeliness of the infromation held in the JWT token.",
897897
"EditOAuthClientForm.issue-jwt-access-token.label": "Issue JWT as access token",
898+
"EditOAuthClientForm.issue-jwt-access-token.tooltip-m2m": "Access token must be in JWT format for M2M applications",
898899
"EditOAuthClientForm.endpoints.title": "Endpoints",
899900
"EditOAuthClientForm.authorization-endpoint.label": "Authorization Endpoint",
900901
"EditOAuthClientForm.token-endpoint.label": "Token Endpoint",

0 commit comments

Comments
 (0)