Rename API token mentions to access token

This commit is contained in:
x032205
2025-06-12 20:36:34 -04:00
parent f515cc83d7
commit 3f2de2c5ef
6 changed files with 29 additions and 29 deletions
@@ -27,8 +27,8 @@ import {
} from "@app/hooks/api/auth/queries";
import { MfaMethod } from "@app/hooks/api/auth/types";
import { fetchOrganizations } from "@app/hooks/api/organization/queries";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { isLoggedIn } from "@app/hooks/api/reactQuery";
import { ProjectType } from "@app/hooks/api/workspace/types";
// eslint-disable-next-line new-cap
const client = new jsrp.client();
@@ -21,11 +21,11 @@ import {
GenericAppConnectionsFields
} from "./GenericAppConnectionFields";
type ApiTokenForm = z.infer<typeof apiTokenSchema>;
type AccessTokenForm = z.infer<typeof accessTokenSchema>;
type Props = {
appConnection?: TAzureDevOpsConnection;
onSubmit: (formData: ApiTokenForm) => Promise<void>;
onSubmit: (formData: AccessTokenForm) => Promise<void>;
};
// Base schema with common fields
@@ -41,7 +41,7 @@ const oauthSchema = baseSchema.extend({
orgName: z.string().trim().min(1, "Organization name is required")
});
const apiTokenSchema = baseSchema.extend({
const accessTokenSchema = baseSchema.extend({
method: z.literal(AzureDevOpsConnectionMethod.AccessToken),
credentials: z.object({
accessToken: z.string().trim().min(1, "Access Token is required"),
@@ -50,7 +50,7 @@ const apiTokenSchema = baseSchema.extend({
});
// Union schema
const formSchema = z.discriminatedUnion("method", [oauthSchema, apiTokenSchema]);
const formSchema = z.discriminatedUnion("method", [oauthSchema, accessTokenSchema]);
type FormData = z.infer<typeof formSchema>;
@@ -230,7 +230,7 @@ export const AzureDevOpsConnectionForm = ({ appConnection, onSubmit }: Props) =>
</>
)}
{/* API Token-specific fields */}
{/* Access Token-specific fields */}
{selectedMethod === AzureDevOpsConnectionMethod.AccessToken && (
<>
<Controller
@@ -48,14 +48,14 @@ type OAuthCredentials = Extract<
TAzureDevOpsConnection,
{ method: AzureDevOpsConnectionMethod.OAuth }
>["credentials"];
type ApiTokenCredentials = Extract<
type AccessTokenCredentials = Extract<
TAzureDevOpsConnection,
{ method: AzureDevOpsConnectionMethod.AccessToken }
>["credentials"];
type AzureDevOpsFormData = BaseFormData &
Pick<TAzureDevOpsConnection, "name" | "method" | "description"> &
(Pick<OAuthCredentials, "tenantId" | "orgName"> | Pick<ApiTokenCredentials, "orgName">);
(Pick<OAuthCredentials, "tenantId" | "orgName"> | Pick<AccessTokenCredentials, "orgName">);
type FormDataMap = {
[AppConnection.GitHub]: GithubFormData & { app: AppConnection.GitHub };
@@ -287,7 +287,7 @@ export const OAuthCallbackPage = () => {
try {
if (!("tenantId" in formData)) {
throw new Error("Expected OAuth form data but got API token data");
throw new Error("Expected OAuth form data but got access token data");
}
if (connectionId) {