Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/webapp/app/presenters/v3/VercelSettingsPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type VercelSettingsResult = {
enabled: boolean;
hasOrgIntegration: boolean;
authInvalid?: boolean;
authError?: string;
connectedProject?: {
id: string;
vercelProjectId: string;
Expand Down Expand Up @@ -52,6 +53,7 @@ export type VercelOnboardingData = {
availableProjects: VercelAvailableProject[];
hasProjectSelected: boolean;
authInvalid?: boolean;
authError?: string;
existingVariables: Record<string, { environments: string[] }>; // Environment slugs (non-archived only)
gitHubAppInstallations: GitHubAppInstallation[];
isGitHubConnected: boolean;
Expand Down Expand Up @@ -98,6 +100,7 @@ export class VercelSettingsPresenter extends BasePresenter {
enabled: true,
hasOrgIntegration: false,
authInvalid: true,
authError: orgIntegrationResult.error instanceof Error ? orgIntegrationResult.error.message : "Failed to fetch organization integration",
connectedProject: undefined,
isGitHubConnected: false,
hasStagingEnvironment: false,
Expand All @@ -116,6 +119,7 @@ export class VercelSettingsPresenter extends BasePresenter {
enabled: true,
hasOrgIntegration: true,
authInvalid: true,
authError: tokenResult.isErr() ? tokenResult.error.message : "Vercel token is invalid",
connectedProject: undefined,
isGitHubConnected: false,
hasStagingEnvironment: false,
Expand Down Expand Up @@ -382,6 +386,7 @@ export class VercelSettingsPresenter extends BasePresenter {
availableProjects: [],
hasProjectSelected: false,
authInvalid: true,
authError: tokenResult.isErr() ? tokenResult.error.message : "Vercel token is invalid",
existingVariables: {},
gitHubAppInstallations,
isGitHubConnected,
Expand All @@ -397,6 +402,7 @@ export class VercelSettingsPresenter extends BasePresenter {
availableProjects: [],
hasProjectSelected: false,
authInvalid: clientResult.error.authInvalid,
authError: clientResult.error.authInvalid ? clientResult.error.message : undefined,
existingVariables: {},
gitHubAppInstallations,
isGitHubConnected,
Expand Down Expand Up @@ -426,6 +432,7 @@ export class VercelSettingsPresenter extends BasePresenter {
availableProjects: [],
hasProjectSelected: false,
authInvalid: availableProjectsResult.error.authInvalid,
authError: availableProjectsResult.error.authInvalid ? availableProjectsResult.error.message : undefined,
existingVariables: {},
gitHubAppInstallations,
isGitHubConnected,
Expand Down Expand Up @@ -472,12 +479,19 @@ export class VercelSettingsPresenter extends BasePresenter {
(sharedEnvVarsResult.isErr() && sharedEnvVarsResult.error.authInvalid);

if (authInvalid) {
const authError =
(customEnvironmentsResult.isErr() && customEnvironmentsResult.error.authInvalid && customEnvironmentsResult.error.message) ||
(projectEnvVarsResult.isErr() && projectEnvVarsResult.error.authInvalid && projectEnvVarsResult.error.message) ||
(sharedEnvVarsResult.isErr() && sharedEnvVarsResult.error.authInvalid && sharedEnvVarsResult.error.message) ||
undefined;

return {
customEnvironments: [],
environmentVariables: [],
availableProjects: availableProjectsResult.value,
hasProjectSelected: true,
authInvalid: true,
authError: authError || undefined,
existingVariables: {},
gitHubAppInstallations,
isGitHubConnected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
}

const authInvalid = onboardingData?.authInvalid || result.authInvalid || false;
const authError = onboardingData?.authError || result.authError;

return typedjson({
...result,
authInvalid,
authError,
onboardingData,
organizationSlug,
projectSlug: projectParam,
Expand Down