Repository: appsmithorg/appsmith
File: app/client/src/pages/AppIDE/layouts/components/Header/DeployButton.tsx (TypeScript)

Code before:
  const applicationId = useSelector(getCurrentApplicationId);
  const isPackageUpgrading = useSelector(getIsPackageUpgrading);
  const isProtectedMode = useGitProtectedMode();
  const isDeployDisabled = isPackageUpgrading || isProtectedMode;
  const isPublishing = useSelector(getIsPublishingApplication);
  const isGitConnected = useGitConnected();
  const isGitModEnabled = useGitModEnabled();
  const { toggleOpsModal } = useGitOps();
  const gitStatusState = useArtifactSelector(selectStatusState);
  const redeployTrigger = useSelector(getRedeployApplicationTrigger);

  const getTooltipText = useCallback(() => {
    if (isPackageUpgrading) {
      return createMessage(PACKAGE_UPGRADING_ACTION_STATUS, "deploy this app");
    }

    if (isGitConnected && !gitStatusState?.loading) {
      const hasPendingCommits =
        gitStatusState?.value && !gitStatusState.value.isClean;

      if (hasPendingCommits) {
        return createMessage(UNCOMMITTED_CHANGES);
      }

      if (redeployTrigger) {
        return REDEPLOY_BUTTON_TOOLTIP(redeployTrigger);
      }
    }

    return createMessage(DEPLOY_BUTTON_TOOLTIP);
  }, [isPackageUpgrading, isGitConnected, gitStatusState, redeployTrigger]);

  const dispatch = useDispatch();

  const isAnvilEnabled = useSelector(getIsAnvilEnabledInCurrentApplication);

  const handleClickDeploy = useCallback(() => {
    if (isGitConnected) {
      if (isGitModEnabled) {
        toggleOpsModal(true);
      } else {
        dispatch(showConnectGitModal());
      }

      AnalyticsUtil.logEvent("GS_DEPLOY_GIT_CLICK", {
        source: "Deploy button",
      });
    } else if (isAnvilEnabled) {
      dispatch(publishAnvilApplication(applicationId));
    } else {
      dispatch(publishApplication(applicationId));

Review comment (suggestion):
Create a new constant file in ce;
Declare enums like this src/ce/entities/DataTree/types.ts
extend in ee
create a mapping of enum to message.
Keep message atomic

Code after:
  const applicationId = useSelector(getCurrentApplicationId);
  const isPackageUpgrading = useSelector(getIsPackageUpgrading);
  const isProtectedMode = useGitProtectedMode();
  const isDeployDisabled = isPackageUpgrading || isProtectedMode;
  const isPublishing = useSelector(getIsPublishingApplication);
  const isGitConnected = useGitConnected();
  const isGitModEnabled = useGitModEnabled();
  const { toggleOpsModal } = useGitOps();
  const gitStatusState = useArtifactSelector(selectStatusState);
  const redeployTrigger = useSelector(getRedeployApplicationTrigger);

  const tooltipText = useMemo(() => {
    if (isPackageUpgrading) {
      return createMessage(PACKAGE_UPGRADING_ACTION_STATUS, "deploy this app");
    }

    if (isGitConnected && !gitStatusState?.loading) {
      const hasPendingCommits =
        gitStatusState?.value && !gitStatusState.value.isClean;

      if (hasPendingCommits) {
        return createMessage(UNCOMMITTED_CHANGES);
      }

      if (redeployTrigger) {
        return createMessage(REDEPLOY_APP_BUTTON_TOOLTIP);
      }
    }

    return createMessage(DEPLOY_BUTTON_TOOLTIP);
  }, [isPackageUpgrading, isGitConnected, gitStatusState, redeployTrigger]);

  const dispatch = useDispatch();

  const isAnvilEnabled = useSelector(getIsAnvilEnabledInCurrentApplication);

  const handleClickDeploy = useCallback(() => {
    if (isGitConnected) {
      if (isGitModEnabled) {
        toggleOpsModal(true);
      } else {
        dispatch(showConnectGitModal());
      }

      AnalyticsUtil.logEvent("GS_DEPLOY_GIT_CLICK", {
        source: "Deploy button",
      });
    } else if (isAnvilEnabled) {
      dispatch(publishAnvilApplication(applicationId));
    } else {
      dispatch(publishApplication(applicationId));