Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1119f65
chore: adding apis for git
Dec 5, 2024
2900b65
fix: review changes
Dec 5, 2024
0d1fa18
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 5, 2024
146238c
fix: fixing enum imports
Dec 5, 2024
e72e02f
chore: changing named export to default export
Dec 6, 2024
54b5d93
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 6, 2024
a1b608b
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 6, 2024
0bb662f
fix: adding saga for commit and connect
Dec 7, 2024
d7e6c79
chore: adding global profile and config redux slice
Dec 7, 2024
02e128b
chore: adding saga for git profile update
Dec 7, 2024
3218b3a
chore: adding fetch branches saga
Dec 7, 2024
f9c4030
chore: adding fetch and update local profile
Dec 7, 2024
adafd14
fix: fixing connectsaga
Dec 7, 2024
488b346
fix: review changes
Dec 8, 2024
942193d
chore: adding branch based sagas
Dec 9, 2024
e9167f2
fix: moving things around
Dec 9, 2024
d024160
chore: adding ctx
Dec 9, 2024
ef34582
chore: expanding context provider and making contextaware comps
Dec 9, 2024
c3d9a31
fix: remove gittest
Dec 9, 2024
fa8c461
chore: adding init sagas
Dec 10, 2024
9b1414e
fix: test fixes
Dec 10, 2024
2de337e
fix: review changes
Dec 10, 2024
40f057e
Merge branch 'chore/git-mod-5' of github.com:appsmithorg/appsmith int…
Dec 10, 2024
826dbf8
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 10, 2024
3a47055
chore: adding autocommit to saga
Dec 10, 2024
ca19474
fix: adding relevant selectors for quick git actions
Dec 10, 2024
3a2a045
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 11, 2024
59f91f4
fix: resolving conflict errors
Dec 11, 2024
e1eb35a
fix: review changes
Dec 11, 2024
3c4a4c2
Merge branch 'chore/git-mod-5' of github.com:appsmithorg/appsmith int…
Dec 11, 2024
fbcf6ae
fix: fixing test cases
Dec 11, 2024
56cbaef
fix: fixing more test cases
Dec 11, 2024
f8545b4
fix: changing AxiosResponse to AxiosPromise
Dec 11, 2024
65e9ea6
fix: fixing build and naming issues
Dec 11, 2024
2b7c3d2
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 11, 2024
f613ae1
fix: remove expect error
Dec 11, 2024
c88bc0b
fix: review changes
Dec 12, 2024
ea1ab49
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
Dec 12, 2024
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
21 changes: 10 additions & 11 deletions app/client/src/git/components/CtxAwareGitQuickActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import useStatusChangeCount from "./hooks/useStatusChangeCount";

function CtxAwareGitQuickActions() {
const {
autocommitEnabled,
autocommitPolling,
discard,
discardLoading,
fetchStatusLoading,
gitConnected,
protectedMode,
pull,
pullError,
pullLoading,
Expand All @@ -17,12 +21,7 @@ function CtxAwareGitQuickActions() {
toggleGitSettingsModal,
} = useGitContext();

const isGitConnected = false;
const isAutocommitEnabled = true;
const isAutocommitPolling = false;
const isConnectPermitted = true;
const isProtectedMode = false;

const connectPermitted = true;
const isPullFailing = !!pullError;
const isStatusClean = status?.isClean ?? false;
const statusBehindCount = status?.behindCount ?? 0;
Expand All @@ -31,13 +30,13 @@ function CtxAwareGitQuickActions() {
return (
<GitQuickActions
discard={discard}
isAutocommitEnabled={isAutocommitEnabled}
isAutocommitPolling={isAutocommitPolling}
isConnectPermitted={isConnectPermitted}
isAutocommitEnabled={autocommitEnabled}
isAutocommitPolling={autocommitPolling}
isConnectPermitted={connectPermitted}
isDiscardLoading={discardLoading}
isFetchStatusLoading={fetchStatusLoading}
isGitConnected={isGitConnected}
isProtectedMode={isProtectedMode}
isGitConnected={gitConnected}
isProtectedMode={protectedMode}
isPullFailing={isPullFailing}
isPullLoading={pullLoading}
isStatusClean={isStatusClean}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ export default function useGitBranches({
};

return {
branches: branchesState?.value ?? null,
branches: branchesState?.value,
fetchBranchesLoading: branchesState?.loading ?? false,
fetchBranchesError: branchesState?.error ?? null,
fetchBranchesError: branchesState?.error,
fetchBranches,
createBranchLoading: createBranchState?.loading ?? false,
createBranchError: createBranchState?.error ?? null,
createBranchError: createBranchState?.error,
createBranch,
deleteBranchLoading: deleteBranchState?.loading ?? false,
deleteBranchError: deleteBranchState?.error ?? null,
deleteBranchError: deleteBranchState?.error,
deleteBranch,
checkoutBranchLoading: checkoutBranchState?.loading ?? false,
checkoutBranchError: checkoutBranchState?.error ?? null,
checkoutBranchError: checkoutBranchState?.error,
checkoutBranch,
toggleGitBranchListPopup,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import useGitOps from "./useGitOps";
import useGitBranches from "./useGitBranches";
import useGitSettings from "./useGitSettings";
import { useMemo } from "react";
import type { UseGitMetadataReturnValue } from "./useGitMetadata";
import useGitMetadata from "./useGitMetadata";

interface UseGitContextValueParams {
artifactType: keyof typeof GitArtifactType;
baseArtifactId: string;
}

export interface GitContextValue
extends UseGitConnectReturnValue,
extends UseGitMetadataReturnValue,
UseGitConnectReturnValue,
UseGitOpsReturnValue,
UseGitSettingsReturnValue,
UseGitBranchesReturnValue {}
Expand All @@ -28,12 +31,14 @@ export default function useGitContextValue({
() => ({ artifactType, baseArtifactId }),
[artifactType, baseArtifactId],
);
const useGitMetadataReturnValue = useGitMetadata(basePayload);
const useGitConnectReturnValue = useGitConnect(basePayload);
const useGitOpsReturnValue = useGitOps(basePayload);
const useGitBranchesReturnValue = useGitBranches(basePayload);
const useGitSettingsReturnValue = useGitSettings(basePayload);

return {
...useGitMetadataReturnValue,
...useGitOpsReturnValue,
...useGitBranchesReturnValue,
...useGitConnectReturnValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { GitArtifactType } from "git/constants/enums";
import type { FetchGitMetadataResponseData } from "git/requests/fetchGitMetadataRequest.types";
import {
selectGitConnected,
selectGitMetadata,
} from "git/store/selectors/gitSingleArtifactSelectors";
import type { GitRootState } from "git/store/types";
import { useMemo } from "react";
import { useSelector } from "react-redux";

interface UseGitMetadataParams {
artifactType: keyof typeof GitArtifactType;
baseArtifactId: string;
}

export interface UseGitMetadataReturnValue {
gitMetadata: FetchGitMetadataResponseData | null;
fetchGitMetadataLoading: boolean;
fetchGitMetadataError: string | null;
gitConnected: boolean;
}

export default function useGitMetadata({
artifactType,
baseArtifactId,
}: UseGitMetadataParams): UseGitMetadataReturnValue {
const basePayload = useMemo(
() => ({ artifactType, baseArtifactId }),
[artifactType, baseArtifactId],
);

const gitMetadataState = useSelector((state: GitRootState) =>
selectGitMetadata(state, basePayload),
);
const gitConnected = useSelector((state: GitRootState) =>
selectGitConnected(state, basePayload),
);

return {
gitMetadata: gitMetadataState.value,
fetchGitMetadataLoading: gitMetadataState.loading ?? false,
fetchGitMetadataError: gitMetadataState.error,
gitConnected: gitConnected ?? false,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ export default function useGitOps({

return {
commitLoading: commitState?.loading ?? false,
commitError: commitState?.error ?? null,
commitError: commitState?.error,
commit,
discardLoading: discardState?.loading ?? false,
discardError: discardState?.error ?? null,
discardError: discardState?.error,
discard,
status: statusState?.value ?? null,
status: statusState?.value,
fetchStatusLoading: statusState?.loading ?? false,
fetchStatusError: statusState?.error ?? null,
fetchStatusError: statusState?.error,
fetchStatus,
mergeLoading: mergeState?.loading ?? false,
mergeError: mergeState?.error ?? null,
mergeError: mergeState?.error,
merge,
mergeStatus: mergeStatusState?.value ?? null,
mergeStatus: mergeStatusState?.value,
fetchMergeStatusLoading: mergeStatusState?.loading ?? false,
fetchMergeStatusError: mergeStatusState?.error ?? null,
fetchMergeStatusError: mergeStatusState?.error,
fetchMergeStatus,
pullLoading: pullState?.loading ?? false,
pullError: pullState?.error ?? null,
pullError: pullState?.error,
pull,
toggleGitOpsModal,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import type { GitArtifactType, GitSettingsTab } from "git/constants/enums";
import type { FetchProtectedBranchesResponseData } from "git/requests/fetchProtectedBranchesRequest.types";
import { gitArtifactActions } from "git/store/gitArtifactSlice";
import {
selectAutocommitEnabled,
selectAutocommitPolling,
selectProtectedBranches,
selectProtectedMode,
} from "git/store/selectors/gitSingleArtifactSelectors";
import type { GitRootState } from "git/store/types";
import { useMemo } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";

interface UseGitSettingsParams {
artifactType: keyof typeof GitArtifactType;
baseArtifactId: string;
}

export interface UseGitSettingsReturnValue {
autocommitEnabled: boolean;
autocommitPolling: boolean;
protectedBranches: FetchProtectedBranchesResponseData | null;
fetchProtectedBranchesLoading: boolean;
fetchProtectedBranchesError: string | null;
fetchProtectedBranches: () => void;
protectedMode: boolean;
toggleGitSettingsModal: (
open: boolean,
tab: keyof typeof GitSettingsTab,
Expand All @@ -25,6 +40,33 @@ export default function useGitSettings({
[artifactType, baseArtifactId],
);

// autocommit
const autocommitEnabled = useSelector((state: GitRootState) =>
selectAutocommitEnabled(state, basePayload),
);

const autocommitPolling = useSelector((state: GitRootState) =>
selectAutocommitPolling(state, basePayload),
);

// branch protection
const protectedBranchesState = useSelector((state: GitRootState) =>
selectProtectedBranches(state, basePayload),
);

const fetchProtectedBranches = () => {
dispatch(
gitArtifactActions.fetchProtectedBranchesInit({
...basePayload,
}),
);
};

const protectedMode = useSelector((state: GitRootState) =>
selectProtectedMode(state, basePayload),
);

// ui
const toggleGitSettingsModal = (
open: boolean,
tab: keyof typeof GitSettingsTab,
Expand All @@ -39,6 +81,13 @@ export default function useGitSettings({
};

return {
autocommitEnabled: autocommitEnabled ?? false,
autocommitPolling: autocommitPolling ?? false,
protectedBranches: protectedBranchesState.value,
fetchProtectedBranchesLoading: protectedBranchesState.loading ?? false,
fetchProtectedBranchesError: protectedBranchesState.error,
fetchProtectedBranches,
protectedMode: protectedMode ?? false,
toggleGitSettingsModal,
};
}
14 changes: 4 additions & 10 deletions app/client/src/git/components/GitContextProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useContext, useEffect } from "react";
import React, { createContext, useContext } from "react";
import type { GitArtifactType } from "git/constants/enums";
import type { GitContextValue } from "./hooks/useGitContextValue";
import useGitContextValue from "./hooks/useGitContextValue";
Expand All @@ -15,24 +15,18 @@ interface GitContextProviderProps {
artifactType: keyof typeof GitArtifactType;
baseArtifactId: string;
children: React.ReactNode;
// extra
// connectPermitted?: boolean;
}

export default function GitContextProvider({
artifactType,
baseArtifactId,
children,
// connectPermitted = true,
}: GitContextProviderProps) {
const contextValue = useGitContextValue({ artifactType, baseArtifactId });

const { fetchBranches } = contextValue;

useEffect(
function gitInitEffect() {
fetchBranches();
},
[fetchBranches],
);

return (
<GitContext.Provider value={contextValue}>{children}</GitContext.Provider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("QuickActionButton", () => {
<QuickActionButton {...defaultProps} />
</ThemeProvider>,
);
const btn = container.getElementsByClassName("t--test-btn")[0];
const btn = container.querySelectorAll(".t--test-btn button")[0];

fireEvent.click(btn);
expect(defaultProps.onClick).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ const SpinnerContainer = styled.div`
padding: 0 10px;
`;

const QuickActionButtonContainer = styled.button<{ disabled?: boolean }>`
const QuickActionButtonContainer = styled.div<{ disabled?: boolean }>`
margin: 0 ${(props) => props.theme.spaces[1]}px;
display: block;
position: relative;
overflow: visible;
cursor: ${({ disabled = false }) => (disabled ? "not-allowed" : "pointer")};
opacity: ${({ disabled = false }) => (disabled ? 0.6 : 1)};
`;

Expand Down Expand Up @@ -57,11 +56,7 @@ function QuickActionButton({
const content = capitalizeFirstLetter(tooltipText);

return (
<QuickActionButtonContainer
className={className}
disabled={disabled}
onClick={onClick}
>
<QuickActionButtonContainer className={className} disabled={disabled}>
{loading ? (
<SpinnerContainer className="t--loader-quick-git-action">
<SpinnerLoader size="md" />
Expand All @@ -73,6 +68,7 @@ function QuickActionButton({
isDisabled={disabled}
isIconButton
kind="tertiary"
onClick={onClick}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we give a data-testid and use? I think with these changes some cypress modifications would be required as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. However, let's pick it up as an independent task outside of modularisation. Don't want to disturb the CyTests right now as we are working on a tight timeline

size="md"
startIcon={icon}
/>
Expand Down
Loading