Skip to content

Commit 7c7fd7e

Browse files
committed
Clarify new secret vs secret list
1 parent 64ef328 commit 7c7fd7e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

site/src/pages/DeploySettingsPage/OAuth2AppsSettingsPage/EditOAuth2AppPage.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ const EditOAuth2AppPage: FC = () => {
2222
const navigate = useNavigate();
2323
const { appId } = useParams() as { appId: string };
2424
const queryClient = useQueryClient();
25-
const [newAppSecret, setNewAppSecret] =
25+
// When a new secret is created it is returned with the full secret. This is
26+
// the only time it will be visible. The secret list only returns a truncated
27+
// version of the secret (for differentiation purposes). Once the user
28+
// acknowledges the secret we will clear it from the state.
29+
const [fullNewSecret, setFullNewSecret] =
2630
useState<TypesGen.OAuth2ProviderAppSecretFull>();
2731

2832
const appQuery = useQuery(oauth2ProviderApp(appId));
@@ -62,7 +66,7 @@ const EditOAuth2AppPage: FC = () => {
6266
mutationFn: postOAuth2ProviderAppSecret,
6367
onSuccess: async (secret: TypesGen.OAuth2ProviderAppSecretFull) => {
6468
displaySuccess("Successfully generated OAuth2 client secret");
65-
setNewAppSecret(secret);
69+
setFullNewSecret(secret);
6670
await queryClient.invalidateQueries([oauth2ProviderAppSecretsKey, appId]);
6771
},
6872
onError: () => displayError("Failed to generate OAuth2 client secret"),
@@ -95,8 +99,8 @@ const EditOAuth2AppPage: FC = () => {
9599
createSecret: postSecretMutation.isLoading,
96100
deleteSecret: deleteSecretMutation.isLoading,
97101
}}
98-
newAppSecret={newAppSecret}
99-
dismissNewSecret={() => setNewAppSecret(undefined)}
102+
fullNewSecret={fullNewSecret}
103+
ackFullNewSecret={() => setFullNewSecret(undefined)}
100104
error={
101105
appQuery.error ||
102106
putMutation.error ||

site/src/pages/DeploySettingsPage/OAuth2AppsSettingsPage/EditOAuth2AppPageView.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type EditOAuth2AppProps = {
4444
generateAppSecret: () => void;
4545
deleteAppSecret: (id: string) => void;
4646
secrets?: readonly TypesGen.OAuth2ProviderAppSecret[];
47-
newAppSecret?: TypesGen.OAuth2ProviderAppSecretFull;
48-
dismissNewSecret: () => void;
47+
fullNewSecret?: TypesGen.OAuth2ProviderAppSecretFull;
48+
ackFullNewSecret: () => void;
4949
error?: unknown;
5050
};
5151

@@ -59,8 +59,8 @@ export const EditOAuth2AppPageView: FC<EditOAuth2AppProps> = ({
5959
generateAppSecret,
6060
deleteAppSecret,
6161
secrets,
62-
newAppSecret,
63-
dismissNewSecret,
62+
fullNewSecret,
63+
ackFullNewSecret,
6464
error,
6565
}) => {
6666
const theme = useTheme();
@@ -87,12 +87,12 @@ export const EditOAuth2AppPageView: FC<EditOAuth2AppProps> = ({
8787
</Button>
8888
</Stack>
8989

90-
{newAppSecret && (
90+
{fullNewSecret && (
9191
<ConfirmDialog
9292
hideCancel
93-
open={Boolean(newAppSecret)}
94-
onConfirm={dismissNewSecret}
95-
onClose={dismissNewSecret}
93+
open={Boolean(fullNewSecret)}
94+
onConfirm={ackFullNewSecret}
95+
onClose={ackFullNewSecret}
9696
title="OAuth2 client secret"
9797
confirmText="OK"
9898
description={
@@ -102,7 +102,7 @@ export const EditOAuth2AppPageView: FC<EditOAuth2AppProps> = ({
102102
now; you will not be able to see it again.
103103
</p>
104104
<CodeExample
105-
code={newAppSecret.client_secret_full}
105+
code={fullNewSecret.client_secret_full}
106106
css={{
107107
minHeight: "auto",
108108
userSelect: "all",

0 commit comments

Comments
 (0)