Skip to content

Commit

Permalink
chore: adding minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brayn003 committed Dec 14, 2024
1 parent ee50685 commit e20e0a2
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/client/src/git/components/DangerZone/DangerZoneView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface DangerZoneViewProps {
isManageAutocommitPermitted: boolean;
isToggleAutocommitLoading: boolean;
isAutocommitEnabled: boolean;
isMetadataLoading: boolean;
isFetchMetadataLoading: boolean;
openDisconnectModal: () => void;
toggleAutocommit: () => void;
toggleDisableAutocommitModal: (open: boolean) => void;
Expand All @@ -69,8 +69,8 @@ interface DangerZoneViewProps {
function DangerZoneView({
isAutocommitEnabled = false,
isConnectPermitted = false,
isFetchMetadataLoading = false,
isManageAutocommitPermitted = false,
isMetadataLoading = false,
isToggleAutocommitLoading = false,
openDisconnectModal = noop,
toggleAutocommit = noop,
Expand Down Expand Up @@ -122,7 +122,7 @@ function DangerZoneView({
</BodyInnerContainer>
<Button
data-testid="t--git-autocommit-btn"
isLoading={isToggleAutocommitLoading || isMetadataLoading}
isLoading={isToggleAutocommitLoading || isFetchMetadataLoading}
kind={isAutocommitEnabled ? "error" : "secondary"}
onClick={handleToggleAutocommit}
size="md"
Expand Down
4 changes: 3 additions & 1 deletion app/client/src/git/components/DangerZone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useGitPermissions from "git/hooks/useGitPermissions";
import useSettings from "git/hooks/useSettings";
import React from "react";
import DangerZoneView from "./DangerZoneView";
import useMetadata from "git/hooks/useMetadata";

function DangerZone() {
const { closeDisconnectModal, openDisconnectModal } = useDisconnect();
Expand All @@ -16,14 +17,15 @@ function DangerZone() {
toggleAutocommitDisableModal,
} = useAutocommit();
const { toggleSettingsModal } = useSettings();
const { isFetchMetadataLoading } = useMetadata();

return (
<DangerZoneView
closeDisconnectModal={closeDisconnectModal}
isAutocommitEnabled={isAutocommitEnabled}
isConnectPermitted={isConnectPermitted}
isFetchMetadataLoading={isFetchMetadataLoading}
isManageAutocommitPermitted={isManageAutocommitPermitted}
isMetadataLoading={false}
isToggleAutocommitLoading={isToggleAutocommitLoading}
openDisconnectModal={openDisconnectModal}
toggleAutocommit={toggleAutocommit}
Expand Down
11 changes: 4 additions & 7 deletions app/client/src/git/components/LocalProfile/LocalProfileView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,10 @@ function LocalProfileView({

const isLoading = isFetchGlobalProfileLoading || isFetchLocalProfileLoading;

useEffect(
function fetchProfilesOnInitEffect() {
fetchGlobalProfile();
fetchLocalProfile();
},
[fetchGlobalProfile, fetchLocalProfile],
);
useEffect(function fetchProfilesOnInitEffect() {
fetchGlobalProfile();
fetchLocalProfile();
}, []);

useEffect(
function setDefaultProfileOnInitEffect() {
Expand Down
6 changes: 3 additions & 3 deletions app/client/src/git/hooks/useDisconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function useDisconnect() {
dispatch(gitArtifactActions.disconnectInit(artifactDef));
}, [artifactDef, dispatch]);

const diconnectBaseArtifactId = useSelector((state: GitRootState) =>
const disconnectBaseArtifactId = useSelector((state: GitRootState) =>
selectDisconnectBaseArtifactId(state, artifactDef),
);

Expand All @@ -45,8 +45,8 @@ export default function useDisconnect() {
isDisconnectLoading: disconnectState?.loading ?? false,
disconnectError: disconnectState?.error ?? null,
disconnect,
isDisconnectModalOpen: !!diconnectBaseArtifactId,
diconnectBaseArtifactId,
isDisconnectModalOpen: !!disconnectBaseArtifactId,
disconnectBaseArtifactId,
disconnectArtifactName,
openDisconnectModal,
closeDisconnectModal,
Expand Down
9 changes: 5 additions & 4 deletions app/client/src/git/hooks/useGlobalProfile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// useGlobaProfile same as useLocalProfile but it uses global state

import type { UpdateGlobalProfileRequestParams } from "git/requests/updateGlobalProfileRequest.types";
import { gitConfigActions } from "git/store/gitConfigSlice";
import { selectFetchGlobalProfileState } from "git/store/selectors/gitConfigSelectors";
import {
selectFetchGlobalProfileState,
selectUpdateGlobalProfileState,
} from "git/store/selectors/gitConfigSelectors";

import type { GitRootState } from "git/store/types";
import { useCallback } from "react";
Expand All @@ -19,7 +20,7 @@ export default function useGlobalProfile() {
}, [dispatch]);

const updateGlobalProfileState = useSelector((state: GitRootState) =>
selectFetchGlobalProfileState(state),
selectUpdateGlobalProfileState(state),
);

const updateGlobalProfile = useCallback(
Expand Down
8 changes: 5 additions & 3 deletions app/client/src/git/hooks/useLocalProfile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useGitContext } from "git/components/GitContextProvider";
import type { UpdateLocalProfileRequestParams } from "git/requests/updateLocalProfileRequest.types";
import { gitArtifactActions } from "git/store/gitArtifactSlice";
import { selectFetchGlobalProfileState } from "git/store/selectors/gitConfigSelectors";
import { selectFetchLocalProfileState } from "git/store/selectors/gitSingleArtifactSelectors";
import {
selectFetchLocalProfileState,
selectUpdateLocalProfileState,
} from "git/store/selectors/gitSingleArtifactSelectors";
import type { GitRootState } from "git/store/types";
import { useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
Expand All @@ -21,7 +23,7 @@ export default function useLocalProfile() {
}, [artifactDef, dispatch]);

const updateLocalProfileState = useSelector((state: GitRootState) =>
selectFetchGlobalProfileState(state),
selectUpdateLocalProfileState(state, artifactDef),
);

const updateLocalProfile = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/git/hooks/useMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function useMetadata() {

return {
metadata: metadataState.value ?? null,
fetchMetadataLoading: metadataState.loading ?? false,
isFetchMetadataLoading: metadataState.loading ?? false,
fetchMetadataError: metadataState.error ?? null,
isGitConnected,
};
Expand Down
3 changes: 3 additions & 0 deletions app/client/src/git/store/selectors/gitConfigSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ export const selectGitConfig = (state: GitRootState) => {
// global profile
export const selectFetchGlobalProfileState = (state: GitRootState) =>
selectGitConfig(state).globalProfile;

export const selectUpdateGlobalProfileState = (state: GitRootState) =>
selectGitConfig(state).updateGlobalProfile;

0 comments on commit e20e0a2

Please sign in to comment.