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

feat: git mod - updating redux slice and adding pending actions #37830

Merged
merged 2 commits into from
Nov 29, 2024
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
28 changes: 28 additions & 0 deletions app/client/packages/git/src/actions/checkoutBranchActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactErrorPayloadAction } from "../types";

export const checkoutBranchInitAction = createSingleArtifactAction((state) => {
state.apiResponses.checkoutBranch.loading = true;
state.apiResponses.checkoutBranch.error = null;

return state;
});

export const checkoutBranchSuccessAction = createSingleArtifactAction(
(state) => {
state.apiResponses.checkoutBranch.loading = false;

return state;
},
);

brayn003 marked this conversation as resolved.
Show resolved Hide resolved
export const checkoutBranchErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.checkoutBranch.loading = false;
state.apiResponses.checkoutBranch.error = error;

return state;
},
);
14 changes: 7 additions & 7 deletions app/client/packages/git/src/actions/commitActions.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactPayloadAction } from "../types";
import type { GitArtifactErrorPayloadAction } from "../types";

export const commitInitAction = createSingleArtifactAction((state) => {
state.commit.loading = true;
state.commit.error = null;
state.apiResponses.commit.loading = true;
state.apiResponses.commit.error = null;

return state;
});

export const commitSuccessAction = createSingleArtifactAction((state) => {
state.commit.loading = false;
state.apiResponses.commit.loading = false;

return state;
});

export const commitErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.commit.loading = false;
state.commit.error = error;
state.apiResponses.commit.loading = false;
state.apiResponses.commit.error = error;

return state;
},
Expand Down
14 changes: 7 additions & 7 deletions app/client/packages/git/src/actions/connectActions.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactPayloadAction } from "../types";
import type { GitArtifactErrorPayloadAction } from "../types";

export const connectInitAction = createSingleArtifactAction((state) => {
state.connect.loading = true;
state.connect.error = null;
state.apiResponses.connect.loading = true;
state.apiResponses.connect.error = null;

return state;
});

export const connectSuccessAction = createSingleArtifactAction((state) => {
state.connect.loading = false;
state.apiResponses.connect.loading = false;

return state;
});

export const connectErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.connect.loading = false;
state.connect.error = error;
state.apiResponses.connect.loading = false;
state.apiResponses.connect.error = error;

return state;
},
Expand Down
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/createBranchActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactErrorPayloadAction } from "../types";

export const createBranchInitAction = createSingleArtifactAction((state) => {
state.apiResponses.createBranch.loading = true;
state.apiResponses.createBranch.error = null;

return state;
});

export const createBranchSuccessAction = createSingleArtifactAction((state) => {
state.apiResponses.createBranch.loading = false;

return state;
});

export const createBranchErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.createBranch.loading = false;
state.apiResponses.createBranch.error = error;

return state;
},
);
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/deleteBranchActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactErrorPayloadAction } from "../types";

export const deleteBranchInitAction = createSingleArtifactAction((state) => {
state.apiResponses.deleteBranch.loading = true;
state.apiResponses.deleteBranch.error = null;

return state;
});

export const deleteBranchSuccessAction = createSingleArtifactAction((state) => {
state.apiResponses.deleteBranch.loading = false;

return state;
});

export const deleteBranchErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.deleteBranch.loading = false;
state.apiResponses.deleteBranch.error = error;

return state;
},
);
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/discardActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactErrorPayloadAction } from "../types";

export const discardInitAction = createSingleArtifactAction((state) => {
state.apiResponses.discard.loading = true;
state.apiResponses.discard.error = null;

return state;
});

export const discardSuccessAction = createSingleArtifactAction((state) => {
state.apiResponses.discard.loading = false;

return state;
});

export const discardErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.discard.loading = false;
state.apiResponses.discard.error = error;

return state;
},
);
26 changes: 26 additions & 0 deletions app/client/packages/git/src/actions/disconnectActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
import type { GitArtifactErrorPayloadAction } from "../types";

export const disconnectInitAction = createSingleArtifactAction((state) => {
state.apiResponses.disconnect.loading = true;
state.apiResponses.disconnect.error = null;

return state;
});

export const disconnectSuccessAction = createSingleArtifactAction((state) => {
state.apiResponses.disconnect.loading = false;

return state;
});

export const disconnectErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.disconnect.loading = false;
state.apiResponses.disconnect.error = error;

return state;
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type {
GitArtifactPayloadAction,
GitArtifactErrorPayloadAction,
GitAutocommitProgress,
} from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchAutocommitProgressInitAction = createSingleArtifactAction(
(state) => {
state.apiResponses.autocommitProgress.loading = true;
state.apiResponses.autocommitProgress.error = null;

return state;
},
);

export const fetchAutocommitProgressSuccessAction = createSingleArtifactAction(
(
state,
action: GitArtifactPayloadAction<{
autocommitProgress: GitAutocommitProgress;
}>,
) => {
state.apiResponses.autocommitProgress.loading = false;
state.apiResponses.autocommitProgress.value =
action.payload.autocommitProgress;

return state;
},
);

export const fetchAutocommitProgressErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.autocommitProgress.loading = false;
state.apiResponses.autocommitProgress.error = error;

return state;
},
);
20 changes: 12 additions & 8 deletions app/client/packages/git/src/actions/fetchBranchesActions.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import type { GitArtifactPayloadAction, GitBranches } from "../types";
import type {
GitArtifactPayloadAction,
GitArtifactErrorPayloadAction,
GitBranches,
} from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchBranchesInitAction = createSingleArtifactAction((state) => {
state.branches.loading = true;
state.branches.error = null;
state.apiResponses.branches.loading = true;
state.apiResponses.branches.error = null;

return state;
});

export const fetchBranchesSuccessAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ branches: GitBranches }>) => {
state.branches.loading = false;
state.branches.value = action.payload.branches;
state.apiResponses.branches.loading = false;
state.apiResponses.branches.value = action.payload.branches;

return state;
},
);

export const fetchBranchesErrorAction = createSingleArtifactAction(
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.branches.loading = false;
state.branches.error = error;
state.apiResponses.branches.loading = false;
state.apiResponses.branches.error = error;

return state;
},
Expand Down
38 changes: 38 additions & 0 deletions app/client/packages/git/src/actions/fetchGlobalConfigActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type {
GitArtifactPayloadAction,
GitArtifactErrorPayloadAction,
GitGlobalConfig,
} from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchGlobalConfigInitAction = createSingleArtifactAction(
(state) => {
state.apiResponses.globalConfig.loading = true;
state.apiResponses.globalConfig.error = null;

return state;
},
);

export const fetchGlobalConfigSuccessAction = createSingleArtifactAction(
(
state,
action: GitArtifactPayloadAction<{ globalConfig: GitGlobalConfig }>,
) => {
state.apiResponses.globalConfig.loading = false;
state.apiResponses.globalConfig.value = action.payload.globalConfig;

return state;
},
);

export const fetchGlobalConfigErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.globalConfig.loading = false;
state.apiResponses.globalConfig.error = error;

return state;
},
);
38 changes: 38 additions & 0 deletions app/client/packages/git/src/actions/fetchLocalConfigActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type {
GitArtifactPayloadAction,
GitArtifactErrorPayloadAction,
GitLocalConfig,
} from "../types";
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";

export const fetchLocalConfigInitAction = createSingleArtifactAction(
(state) => {
state.apiResponses.localConfig.loading = true;
state.apiResponses.localConfig.error = null;

return state;
},
);

export const fetchLocalConfigSuccessAction = createSingleArtifactAction(
(
state,
action: GitArtifactPayloadAction<{ localConfig: GitLocalConfig }>,
) => {
state.apiResponses.localConfig.loading = false;
state.apiResponses.localConfig.value = action.payload.localConfig;

return state;
},
);
brayn003 marked this conversation as resolved.
Show resolved Hide resolved

export const fetchLocalConfigErrorAction = createSingleArtifactAction(
(state, action: GitArtifactErrorPayloadAction) => {
const { error } = action.payload;

state.apiResponses.localConfig.loading = false;
state.apiResponses.localConfig.error = error;

return state;
},
);
Loading
Loading