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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
GitImportStep,
GitOpsTab,
GitSettingsTab,
} from "../../enums";
} from "../../constants/enums";
import type {
GitSingleArtifactAPIResponsesReduxState,
GitSingleArtifactUIReduxState,
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/git/components/QuickActions/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import QuickActions from ".";
import { GitSettingsTab } from "git/enums";
import { GitSettingsTab } from "../../constants/enums";
import { GitSyncModalTab } from "entities/GitSync";
import { theme } from "constants/DefaultTheme";
import { ThemeProvider } from "styled-components";
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/git/components/QuickActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { GitSyncModalTab } from "entities/GitSync";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import type { GitMetadata, GitStatus } from "../../types";
import { getPullBtnStatus } from "./helpers";
import { GitSettingsTab } from "../../enums";
import { GitSettingsTab } from "../../constants/enums";
import ConnectButton from "./ConnectButton";
import QuickActionButton from "./QuickActionButton";
import AutocommitStatusbar from "./AutocommitStatusbar";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ export enum GitSettingsTab {
General = "General",
Branch = "Branch",
}

export enum AutocommitStatus {
IN_PROGRESS = "IN_PROGRESS",
LOCKED = "LOCKED",
PUBLISHED = "PUBLISHED",
IDLE = "IDLE",
NOT_REQUIRED = "NOT_REQUIRED",
NON_GIT_APP = "NON_GIT_APP",
}
17 changes: 17 additions & 0 deletions app/client/src/git/requests/checkoutBranchRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { AxiosResponse } from "axios";
import type {
CheckoutBranchRequestParams,
CheckoutBranchResponse,
} from "./checkoutBranchRequest.types";
import { GIT_BASE_URL } from "./constants";
import Api from "api/Api";

export default async function checkoutBranchRequest(
branchedApplicationId: string,
params: CheckoutBranchRequestParams,
): Promise<AxiosResponse<CheckoutBranchResponse>> {
return Api.get(
`${GIT_BASE_URL}/checkout-branch/app/${branchedApplicationId}`,
params,
);
}
8 changes: 8 additions & 0 deletions app/client/src/git/requests/checkoutBranchRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface CheckoutBranchRequestParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are doing one api per file so why segregate further having types.ts? wouldn't it incur more context switching?

Copy link
Contributor Author

@brayn003 brayn003 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid circular dependencies.
In case of types in the same file, if I import the response type in say the redux store file. This will happen -
redux store file <- git api file <- request lib file <- redux store file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request lib file <- redux store file
Can you give me a reference to this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Store is used in request interceptor for determining branch and environment to be included in headers

branchName: string;
}

export interface CheckoutBranchResponse {
id: string; // applicationId
baseId: string; // baseApplicationId
}
17 changes: 17 additions & 0 deletions app/client/src/git/requests/commitRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Api from "api/Api";
import type {
CommitRequestParams,
CommitResponse,
} from "./commitRequest.types";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";

export default async function commitRequest(
branchedApplicationId: string,
params: CommitRequestParams,
): Promise<AxiosResponse<CommitResponse>> {
return Api.post(
`${GIT_BASE_URL}/commit/app/${branchedApplicationId}`,
params,
);
}
6 changes: 6 additions & 0 deletions app/client/src/git/requests/commitRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface CommitRequestParams {
commitMessage: string;
doPush: boolean;
}

export type CommitResponse = string;
14 changes: 14 additions & 0 deletions app/client/src/git/requests/connectRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type {
ConnectRequestParams,
ConnectResponse,
} from "./connectRequest.types";
import type { AxiosResponse } from "axios";

export default async function connectRequest(
baseApplicationId: string,
params: ConnectRequestParams,
): Promise<AxiosResponse<ConnectResponse>> {
return Api.post(`${GIT_BASE_URL}/connect/app/${baseApplicationId}`, params);
}
24 changes: 24 additions & 0 deletions app/client/src/git/requests/connectRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export interface ConnectRequestParams {
remoteUrl: string;
gitProfile?: {
authorName: string;
authorEmail: string;
useDefaultProfile?: boolean;
};
}

export interface ConnectResponse {
id: string;
baseId: string;
gitApplicationMetadata: {
branchName: string;
browserSupportedRemoteUrl: string;
defaultApplicationId: string;
defaultArtifactId: string;
defaultBranchName: string;
isRepoPrivate: boolean;
lastCommitedAt: string;
remoteUrl: string;
repoName: string;
};
}
2 changes: 2 additions & 0 deletions app/client/src/git/requests/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const GIT_BASE_URL = "/v1/git";
export const APPLICATION_BASE_URL = "/v1/applications";
17 changes: 17 additions & 0 deletions app/client/src/git/requests/createBranchRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { AxiosResponse } from "axios";
import type {
CreateBranchRequestParams,
CreateBranchResponse,
} from "./createBranchRequest.types";
import { GIT_BASE_URL } from "./constants";
import Api from "api/Api";

export default async function createBranchRequest(
branchedApplicationId: string,
params: CreateBranchRequestParams,
): Promise<AxiosResponse<CreateBranchResponse>> {
return Api.post(
`${GIT_BASE_URL}/create-branch/app/${branchedApplicationId}`,
params,
);
}
8 changes: 8 additions & 0 deletions app/client/src/git/requests/createBranchRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface CreateBranchRequestParams {
branchName: string;
}

export interface CreateBranchResponse {
id: string; // applicationId
baseId: string; // baseApplicationId
}
14 changes: 14 additions & 0 deletions app/client/src/git/requests/deleteBranchRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { AxiosResponse } from "axios";
import type {
DeleteBranchRequestParams,
DeleteBranchResponse,
} from "./deleteBranchRequest.types";
import { GIT_BASE_URL } from "./constants";
import Api from "api/Api";

export default async function deleteBranchRequest(
baseApplicationId: string,
params: DeleteBranchRequestParams,
): Promise<AxiosResponse<DeleteBranchResponse>> {
return Api.delete(`${GIT_BASE_URL}/branch/app/${baseApplicationId}`, params);
}
8 changes: 8 additions & 0 deletions app/client/src/git/requests/deleteBranchRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface DeleteBranchRequestParams {
branchName: string;
}

export interface DeleteBranchResponse {
id: string; // applicationId
baseId: string; // baseApplicationId
}
9 changes: 9 additions & 0 deletions app/client/src/git/requests/discardRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";

export default async function discardRequest(
branchedApplicationId: string,
): Promise<AxiosResponse<void>> {
return Api.put(`${GIT_BASE_URL}/discard/app/${branchedApplicationId}`);
}
10 changes: 10 additions & 0 deletions app/client/src/git/requests/disconnectRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { AxiosResponse } from "axios";
import { GIT_BASE_URL } from "./constants";
import type { DisconnectResponse } from "./disconnectRequest.types";
import Api from "api/Api";

export default async function disconnectRequest(
baseApplicationId: string,
): Promise<AxiosResponse<DisconnectResponse>> {
return Api.post(`${GIT_BASE_URL}/disconnect/app/${baseApplicationId}`);
}
3 changes: 3 additions & 0 deletions app/client/src/git/requests/disconnectRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface DisconnectResponse {
[key: string]: string;
}
12 changes: 12 additions & 0 deletions app/client/src/git/requests/fetchAutocommitProgressRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";
import type { FetchAutocommitProgressResponse } from "./fetchAutocommitProgressRequest.types";

export default async function fetchAutocommitProgressRequest(
baseApplicationId: string,
): Promise<AxiosResponse<FetchAutocommitProgressResponse>> {
return Api.get(
`${GIT_BASE_URL}/auto-commit/progress/app/${baseApplicationId}`,
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { AutocommitStatus } from "../constants/enums";

export interface FetchAutocommitProgressResponse {
autoCommitResponse: AutocommitStatus;
progress: number;
branchName: string;
}
21 changes: 21 additions & 0 deletions app/client/src/git/requests/fetchBranchesRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type {
FetchBranchesRequestParams,
FetchBranchesResponse,
} from "./fetchBranchesRequest.types";
import type { AxiosResponse } from "axios";

export default async function fetchBranchesRequest(
branchedApplicationId: string,
params?: FetchBranchesRequestParams,
): Promise<AxiosResponse<FetchBranchesResponse>> {
const queryParams = {} as FetchBranchesRequestParams;

if (params?.pruneBranches) queryParams.pruneBranches = true;

return Api.get(
`${GIT_BASE_URL}/branch/app/${branchedApplicationId}`,
queryParams,
);
}
11 changes: 11 additions & 0 deletions app/client/src/git/requests/fetchBranchesRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface FetchBranchesRequestParams {
pruneBranches: boolean;
}

interface SingleBranch {
branchName: string;
createdFromLocal: string;
default: boolean;
}

export type FetchBranchesResponse = SingleBranch[];
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchGitMetadataRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";
import type { FetchGitMetadataResponse } from "./fetchGitMetadataRequest.types";

export default async function fetchGitMetadataRequest(
baseApplicationId: string,
): Promise<AxiosResponse<FetchGitMetadataResponse>> {
return Api.get(`${GIT_BASE_URL}/metadata/app/${baseApplicationId}`);
}
15 changes: 15 additions & 0 deletions app/client/src/git/requests/fetchGitMetadataRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface FetchGitMetadataResponse {
branchName: string;
defaultBranchName: string;
remoteUrl: string;
repoName: string;
browserSupportedUrl?: string;
isRepoPrivate?: boolean;
browserSupportedRemoteUrl: string;
defaultApplicationId: string;
isProtectedBranch: boolean;
autoCommitConfig: {
enabled: boolean;
};
isAutoDeploymentEnabled?: boolean;
}
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchGlobalConfigRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";
import type { FetchGlobalConfigResponse } from "./fetchGlobalConfigRequest.types";

export default async function fetchGlobalConfigRequest(): Promise<
AxiosResponse<FetchGlobalConfigResponse>
> {
return Api.get(`${GIT_BASE_URL}/profile/default`);
}
4 changes: 4 additions & 0 deletions app/client/src/git/requests/fetchGlobalConfigRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface FetchGlobalConfigResponse {
authorName: string;
authorEmail: string;
}
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchLocalConfigRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Api from "api/Api";
import type { AxiosResponse } from "axios";
import { GIT_BASE_URL } from "./constants";
import type { FetchLocalConfigResponse } from "./fetchLocalConfigRequest.types";

export default async function fetchLocalConfigRequest(
baseApplicationId: string,
): Promise<AxiosResponse<FetchLocalConfigResponse>> {
return Api.get(`${GIT_BASE_URL}/profile/app/${baseApplicationId}`);
}
5 changes: 5 additions & 0 deletions app/client/src/git/requests/fetchLocalConfigRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface FetchLocalConfigResponse {
authorName: string;
authorEmail: string;
useGlobalProfile: boolean;
}
17 changes: 17 additions & 0 deletions app/client/src/git/requests/fetchMergeStatusRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { AxiosResponse } from "axios";
import type {
FetchMergeStatusRequestParams,
FetchMergeStatusResponse,
} from "./fetchMergeStatusRequest.types";
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";

export default async function fetchMergeStatusRequest(
branchedApplicationId: string,
params: FetchMergeStatusRequestParams,
): Promise<AxiosResponse<FetchMergeStatusResponse>> {
return Api.post(
`${GIT_BASE_URL}/merge/status/app/${branchedApplicationId}`,
params,
);
}
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchMergeStatusRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface FetchMergeStatusRequestParams {
sourceBranch: string;
destinationBranch: string;
}

export interface FetchMergeStatusResponse {
isMergeAble: boolean;
status: string; // merge status
message: string;
}
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchProtectedBranchesRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Api from "api/Api";
import { GIT_BASE_URL } from "./constants";
import type { AxiosResponse } from "axios";
import type { FetchProtectedBranches } from "./fetchProtectedBranchesRequest.types";

export default async function fetchProtectedBranchesRequest(
baseApplicationId: string,
): Promise<AxiosResponse<FetchProtectedBranches>> {
return Api.get(`${GIT_BASE_URL}/branch/app/${baseApplicationId}/protected`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type FetchProtectedBranches = string[];
10 changes: 10 additions & 0 deletions app/client/src/git/requests/fetchSSHKeyRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { AxiosResponse } from "axios";
import type { FetchSSHKeyResponse } from "./fetchSSHKeyRequest.types";
import Api from "api/Api";
import { APPLICATION_BASE_URL } from "./constants";

export default async function fetchSSHKeyRequest(
baseApplicationId: string,
): Promise<AxiosResponse<FetchSSHKeyResponse>> {
return Api.get(`${APPLICATION_BASE_URL}/ssh-keypair/${baseApplicationId}`);
}
6 changes: 6 additions & 0 deletions app/client/src/git/requests/fetchSSHKeyRequest.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface FetchSSHKeyResponse {
publicKey: string;
docUrl: string;
isRegeneratedKey: boolean;
regeneratedKey: boolean;
}
Loading