## Description Fixes issue with missing success toast related to git Fixes https://github.com/appsmithorg/appsmith/issues/38872 Fixes https://github.com/appsmithorg/appsmith/issues/38862 ## Automation /ok-to-test tags="@tag.Git" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/13216997415> > Commit: 95ccaedc4583492a5a6c7b88c6ca8215b2a55807 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13216997415&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Git` > Spec: > <hr>Sat, 08 Feb 2025 17:43:52 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Discard operations now display clear, contextual success messages to enhance user feedback. - Toast notifications have been added for pull actions and protected branch updates, providing real-time confirmation of successful operations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
206 lines
5.9 KiB
TypeScript
206 lines
5.9 KiB
TypeScript
import React, { useCallback } from "react";
|
|
import styled from "styled-components";
|
|
|
|
import {
|
|
AUTOCOMMIT_IN_PROGRESS_MESSAGE,
|
|
COMMIT_CHANGES,
|
|
createMessage,
|
|
DISCARD_AND_PULL_SUCCESS,
|
|
GIT_SETTINGS,
|
|
MERGE,
|
|
} from "ee/constants/messages";
|
|
|
|
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
|
|
import { GitOpsTab } from "../../constants/enums";
|
|
import { GitSettingsTab } from "../../constants/enums";
|
|
import ConnectButton from "./ConnectButton";
|
|
import QuickActionButton from "./QuickActionButton";
|
|
import Statusbar from "../Statusbar";
|
|
import getPullBtnStatus from "./helpers/getPullButtonStatus";
|
|
import noop from "lodash/noop";
|
|
import BranchButton from "./BranchButton";
|
|
|
|
const Container = styled.div`
|
|
height: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
`;
|
|
|
|
interface QuickActionsViewProps {
|
|
currentBranch: string | null;
|
|
discard: (successMessage: string) => void;
|
|
isAutocommitEnabled: boolean;
|
|
isAutocommitPolling: boolean;
|
|
isBranchPopupOpen: boolean;
|
|
isConnectPermitted: boolean;
|
|
isDiscardLoading: boolean;
|
|
isFetchStatusLoading: boolean;
|
|
isInitialized: boolean;
|
|
isConnected: boolean;
|
|
isProtectedMode: boolean;
|
|
isPullFailing: boolean;
|
|
isPullLoading: boolean;
|
|
isStatusClean: boolean;
|
|
isTriggerAutocommitLoading: boolean;
|
|
pull: () => void;
|
|
statusBehindCount: number;
|
|
statusChangeCount: number;
|
|
toggleConnectModal: (open: boolean) => void;
|
|
toggleOpsModal: (open: boolean, tab: keyof typeof GitOpsTab) => void;
|
|
toggleSettingsModal: (
|
|
open: boolean,
|
|
tab: keyof typeof GitSettingsTab,
|
|
) => void;
|
|
toggleBranchPopup: (open: boolean) => void;
|
|
}
|
|
|
|
function QuickActionsView({
|
|
currentBranch = null,
|
|
discard = noop,
|
|
isAutocommitEnabled = false,
|
|
isAutocommitPolling = false,
|
|
isBranchPopupOpen = false,
|
|
isConnected = false,
|
|
isConnectPermitted = false,
|
|
isDiscardLoading = false,
|
|
isFetchStatusLoading = false,
|
|
isInitialized = false,
|
|
isProtectedMode = false,
|
|
isPullFailing = false,
|
|
isPullLoading = false,
|
|
isStatusClean = true,
|
|
isTriggerAutocommitLoading = false,
|
|
pull = noop,
|
|
statusBehindCount = 0,
|
|
statusChangeCount = 0,
|
|
toggleBranchPopup = noop,
|
|
toggleConnectModal = noop,
|
|
toggleOpsModal = noop,
|
|
toggleSettingsModal = noop,
|
|
}: QuickActionsViewProps) {
|
|
const { isDisabled: isPullDisabled, message: pullTooltipMessage } =
|
|
getPullBtnStatus({
|
|
isStatusClean,
|
|
isProtectedMode,
|
|
isPullFailing,
|
|
statusBehindCount,
|
|
});
|
|
|
|
const isPullButtonLoading =
|
|
isDiscardLoading || isPullLoading || isFetchStatusLoading;
|
|
|
|
const onCommitBtnClick = useCallback(() => {
|
|
if (!isFetchStatusLoading && !isProtectedMode) {
|
|
toggleOpsModal(true, GitOpsTab.Deploy);
|
|
|
|
AnalyticsUtil.logEvent("GS_DEPLOY_GIT_MODAL_TRIGGERED", {
|
|
source: "BOTTOM_BAR_GIT_COMMIT_BUTTON",
|
|
});
|
|
}
|
|
}, [isFetchStatusLoading, isProtectedMode, toggleOpsModal]);
|
|
|
|
const onPullBtnClick = useCallback(() => {
|
|
if (!isPullButtonLoading && !isPullDisabled) {
|
|
AnalyticsUtil.logEvent("GS_PULL_GIT_CLICK", {
|
|
source: "BOTTOM_BAR_GIT_PULL_BUTTON",
|
|
});
|
|
|
|
if (isProtectedMode) {
|
|
discard(createMessage(DISCARD_AND_PULL_SUCCESS));
|
|
} else {
|
|
pull();
|
|
}
|
|
}
|
|
}, [discard, isProtectedMode, pull, isPullDisabled, isPullButtonLoading]);
|
|
|
|
const onMergeBtnClick = useCallback(() => {
|
|
AnalyticsUtil.logEvent("GS_MERGE_GIT_MODAL_TRIGGERED", {
|
|
source: "BOTTOM_BAR_GIT_MERGE_BUTTON",
|
|
});
|
|
toggleOpsModal(true, GitOpsTab.Merge);
|
|
}, [toggleOpsModal]);
|
|
|
|
const onSettingsClick = useCallback(() => {
|
|
toggleSettingsModal(true, GitSettingsTab.General);
|
|
AnalyticsUtil.logEvent("GS_SETTING_CLICK", {
|
|
source: "BOTTOM_BAR_GIT_SETTING_BUTTON",
|
|
});
|
|
}, [toggleSettingsModal]);
|
|
|
|
const onConnectBtnClick = useCallback(() => {
|
|
AnalyticsUtil.logEvent("GS_CONNECT_GIT_CLICK", {
|
|
source: "BOTTOM_BAR_GIT_CONNECT_BUTTON",
|
|
});
|
|
|
|
toggleConnectModal(true);
|
|
}, [toggleConnectModal]);
|
|
|
|
if (!isInitialized) {
|
|
return null;
|
|
}
|
|
|
|
return isConnected ? (
|
|
<Container>
|
|
<BranchButton
|
|
currentBranch={currentBranch}
|
|
isAutocommitPolling={isAutocommitPolling}
|
|
isBranchPopupOpen={isBranchPopupOpen}
|
|
isProtectedMode={isProtectedMode}
|
|
isStatusClean={isStatusClean}
|
|
isTriggerAutocommitLoading={isTriggerAutocommitLoading}
|
|
toggleBranchPopup={toggleBranchPopup}
|
|
/>
|
|
|
|
{isAutocommitEnabled && isAutocommitPolling ? (
|
|
<div data-testid="t--git-autocommit-loader">
|
|
<Statusbar
|
|
completed={!isAutocommitPolling}
|
|
message={createMessage(AUTOCOMMIT_IN_PROGRESS_MESSAGE)}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<QuickActionButton
|
|
count={isProtectedMode ? undefined : statusChangeCount}
|
|
disabled={!isFetchStatusLoading && isProtectedMode}
|
|
icon="plus"
|
|
loading={isFetchStatusLoading}
|
|
onClick={onCommitBtnClick}
|
|
testKey="commit"
|
|
tooltipText={createMessage(COMMIT_CHANGES)}
|
|
/>
|
|
<QuickActionButton
|
|
count={statusBehindCount}
|
|
disabled={!isPullButtonLoading && isPullDisabled}
|
|
icon="down-arrow-2"
|
|
loading={isPullButtonLoading}
|
|
onClick={onPullBtnClick}
|
|
testKey="pull"
|
|
tooltipText={pullTooltipMessage}
|
|
/>
|
|
<QuickActionButton
|
|
disabled={isProtectedMode}
|
|
icon="fork"
|
|
onClick={onMergeBtnClick}
|
|
testKey="merge"
|
|
tooltipText={createMessage(MERGE)}
|
|
/>
|
|
<QuickActionButton
|
|
icon="settings-v3"
|
|
onClick={onSettingsClick}
|
|
testKey="settings"
|
|
tooltipText={createMessage(GIT_SETTINGS)}
|
|
/>
|
|
</>
|
|
)}
|
|
</Container>
|
|
) : (
|
|
<ConnectButton
|
|
isConnectPermitted={isConnectPermitted}
|
|
onClick={onConnectBtnClick}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default QuickActionsView;
|