Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: git merge button visibility on branch change after a successful merge #38847

Merged
merged 1 commit into from
Jan 27, 2025
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 @@ -80,6 +80,7 @@ interface TabMergeViewProps {
mergeStatus: FetchMergeStatusResponseData | null;
protectedBranches: FetchProtectedBranchesResponseData | null;
resetMergeState: () => void;
resetMergeSuccessState: () => void;
}

export default function TabMergeView({
Expand All @@ -99,6 +100,7 @@ export default function TabMergeView({
mergeStatus = null,
protectedBranches = null,
resetMergeState = noop,
resetMergeSuccessState = noop,
}: TabMergeViewProps) {
const [selectedBranchOption, setSelectedBranchOption] =
useState<BranchOption>();
Expand Down Expand Up @@ -208,9 +210,15 @@ export default function TabMergeView({
// when user selects a branch to merge
if (currentBranch && selectedBranchOption?.value) {
fetchMergeStatus(currentBranch, selectedBranchOption?.value);
resetMergeSuccessState();
}
},
[currentBranch, selectedBranchOption?.value, fetchMergeStatus],
[
currentBranch,
selectedBranchOption?.value,
fetchMergeStatus,
resetMergeSuccessState,
],
);

useEffect(
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/git/components/OpsModal/TabMerge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function TabMerge() {
mergeError,
mergeStatus,
resetMergeState,
resetMergeSuccessState,
} = useMerge();
const { isFetchStatusLoading, status } = useStatus();
const { branches, currentBranch, fetchBranches, isFetchBranchesLoading } =
Expand All @@ -42,6 +43,7 @@ export default function TabMerge() {
mergeStatus={mergeStatus}
protectedBranches={protectedBranches}
resetMergeState={resetMergeState}
resetMergeSuccessState={resetMergeSuccessState}
/>
);
}
7 changes: 7 additions & 0 deletions app/client/src/git/hooks/useMerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export default function useMerge() {
}
}, [artifactDef, dispatch]);

const resetMergeSuccessState = useCallback(() => {
if (artifactDef) {
dispatch(gitArtifactActions.resetMergeSuccessState({ artifactDef }));
}
}, [artifactDef, dispatch]);

return {
isMergeLoading: mergeState?.loading ?? false,
mergeError: mergeState?.error ?? null,
Expand All @@ -77,5 +83,6 @@ export default function useMerge() {
clearMergeStatus,
isMergeSuccess: isMergeSuccess ?? false,
resetMergeState,
resetMergeSuccessState,
};
}
6 changes: 6 additions & 0 deletions app/client/src/git/store/actions/mergeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ export const resetMergeStateAction = createArtifactAction((state) => {

return state;
});

export const resetMergeSuccessAction = createArtifactAction((state) => {
state.ui.mergeSuccess = false;

return state;
});
2 changes: 2 additions & 0 deletions app/client/src/git/store/gitArtifactSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import {
mergeInitAction,
mergeSuccessAction,
resetMergeStateAction,
resetMergeSuccessAction,
} from "./actions/mergeActions";
import {
pollAutocommitProgressStopAction,
Expand Down Expand Up @@ -192,6 +193,7 @@ export const gitArtifactSlice = createSlice({
mergeSuccess: mergeSuccessAction,
mergeError: mergeErrorAction,
resetMergeState: resetMergeStateAction,
resetMergeSuccessState: resetMergeSuccessAction,
pullInit: pullInitAction,
pullSuccess: pullSuccessAction,
pullError: pullErrorAction,
Expand Down
Loading