feat: git mod - updating redux slice and adding pending actions (#37830)
## Description - Updates the keys for redux store according to https://miro.com/app/board/uXjVL-Nij1k=/?share_link_id=2678396780 - Adds pending actions Fixes https://github.com/appsmithorg/appsmith/issues/36808 Fixes https://github.com/appsmithorg/appsmith/issues/36809 Fixes https://github.com/appsmithorg/appsmith/issues/36810 ## 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/12080417362> > Commit: 3d9de62323cf3dc179da4219d8258c5f79a25c1f > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12080417362&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Git` > Spec: > <hr>Fri, 29 Nov 2024 08:00:47 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 ## Release Notes - **New Features** - Introduced new actions for managing branch operations (checkout, create, delete) and configurations (global, local). - Added actions for fetching and updating various Git-related data, including autocommit progress, merge status, and SSH keys. - New enumerations for Git artifact types and connection steps to enhance clarity and organization. - **Bug Fixes** - Improved error handling and loading state management across various actions. - **Documentation** - Enhanced type definitions and state structure for clearer understanding and usage. - **Refactor** - Updated state management structure to utilize a nested approach under `apiResponses`, improving consistency across actions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
731356a0f3
commit
f308ca887c
28
app/client/packages/git/src/actions/checkoutBranchActions.ts
Normal file
28
app/client/packages/git/src/actions/checkoutBranchActions.ts
Normal file
|
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
||||
export const checkoutBranchErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.checkoutBranch.loading = false;
|
||||
state.apiResponses.checkoutBranch.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
26
app/client/packages/git/src/actions/createBranchActions.ts
Normal file
26
app/client/packages/git/src/actions/createBranchActions.ts
Normal file
|
|
@ -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
app/client/packages/git/src/actions/deleteBranchActions.ts
Normal file
26
app/client/packages/git/src/actions/deleteBranchActions.ts
Normal file
|
|
@ -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
app/client/packages/git/src/actions/discardActions.ts
Normal file
26
app/client/packages/git/src/actions/discardActions.ts
Normal file
|
|
@ -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
app/client/packages/git/src/actions/disconnectActions.ts
Normal file
26
app/client/packages/git/src/actions/disconnectActions.ts
Normal file
|
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
|
@ -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;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchLocalConfigErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.localConfig.loading = false;
|
||||
state.apiResponses.localConfig.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import type {
|
||||
GitArtifactPayloadAction,
|
||||
GitArtifactErrorPayloadAction,
|
||||
GitMergeStatus,
|
||||
} from "../types";
|
||||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
|
||||
export const fetchMergeStatusInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.mergeStatus.loading = true;
|
||||
state.apiResponses.mergeStatus.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchMergeStatusSuccessAction = createSingleArtifactAction(
|
||||
(
|
||||
state,
|
||||
action: GitArtifactPayloadAction<{ mergeStatus: GitMergeStatus }>,
|
||||
) => {
|
||||
state.apiResponses.mergeStatus.loading = false;
|
||||
state.apiResponses.mergeStatus.value = action.payload.mergeStatus;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchMergeStatusErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.mergeStatus.loading = false;
|
||||
state.apiResponses.mergeStatus.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -1,28 +1,32 @@
|
|||
import type { GitArtifactPayloadAction, GitMetadata } from "../types";
|
||||
import type {
|
||||
GitArtifactPayloadAction,
|
||||
GitArtifactErrorPayloadAction,
|
||||
GitMetadata,
|
||||
} from "../types";
|
||||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
|
||||
export const fetchMetadataInitAction = createSingleArtifactAction((state) => {
|
||||
state.metadata.loading = true;
|
||||
state.metadata.error = null;
|
||||
state.apiResponses.metadata.loading = true;
|
||||
state.apiResponses.metadata.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const fetchMetadataSuccessAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ metadata: GitMetadata }>) => {
|
||||
state.metadata.loading = false;
|
||||
state.metadata.value = action.payload.metadata;
|
||||
state.apiResponses.metadata.loading = false;
|
||||
state.apiResponses.metadata.value = action.payload.metadata;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchMetadataErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.metadata.loading = false;
|
||||
state.metadata.error = error;
|
||||
state.apiResponses.metadata.loading = false;
|
||||
state.apiResponses.metadata.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
import type {
|
||||
GitArtifactPayloadAction,
|
||||
GitArtifactErrorPayloadAction,
|
||||
GitProtectedBranches,
|
||||
} from "../types";
|
||||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
|
||||
export const fetchProtectedBranchesInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.protectedBranches.loading = true;
|
||||
state.apiResponses.protectedBranches.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchProtectedBranchesSuccessAction = createSingleArtifactAction(
|
||||
(
|
||||
state,
|
||||
action: GitArtifactPayloadAction<{
|
||||
protectedBranches: GitProtectedBranches;
|
||||
}>,
|
||||
) => {
|
||||
state.apiResponses.protectedBranches.loading = false;
|
||||
state.apiResponses.protectedBranches.value =
|
||||
action.payload.protectedBranches;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchProtectedBranchesErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.protectedBranches.loading = false;
|
||||
state.apiResponses.protectedBranches.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
33
app/client/packages/git/src/actions/fetchSSHKeyActions.ts
Normal file
33
app/client/packages/git/src/actions/fetchSSHKeyActions.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import type {
|
||||
GitArtifactPayloadAction,
|
||||
GitArtifactErrorPayloadAction,
|
||||
GitSSHKey,
|
||||
} from "../types";
|
||||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
|
||||
export const fetchSSHKeyInitAction = createSingleArtifactAction((state) => {
|
||||
state.apiResponses.sshKey.loading = true;
|
||||
state.apiResponses.sshKey.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const fetchSSHKeySuccessAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ sshKey: GitSSHKey }>) => {
|
||||
state.apiResponses.sshKey.loading = false;
|
||||
state.apiResponses.sshKey.value = action.payload.sshKey;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchSSHKeyErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.sshKey.loading = false;
|
||||
state.apiResponses.sshKey.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -1,28 +1,32 @@
|
|||
import type { GitArtifactPayloadAction, GitStatus } from "../types";
|
||||
import type {
|
||||
GitArtifactPayloadAction,
|
||||
GitArtifactErrorPayloadAction,
|
||||
GitStatus,
|
||||
} from "../types";
|
||||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
|
||||
export const fetchStatusInitAction = createSingleArtifactAction((state) => {
|
||||
state.status.loading = true;
|
||||
state.status.error = null;
|
||||
state.apiResponses.status.loading = true;
|
||||
state.apiResponses.status.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const fetchStatusSuccessAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ status: GitStatus }>) => {
|
||||
state.status.loading = false;
|
||||
state.status.value = action.payload.status;
|
||||
state.apiResponses.status.loading = false;
|
||||
state.apiResponses.status.value = action.payload.status;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const fetchStatusErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.status.loading = false;
|
||||
state.status.error = error;
|
||||
state.apiResponses.status.loading = false;
|
||||
state.apiResponses.status.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
|
|
|
|||
28
app/client/packages/git/src/actions/generateSSHKey.ts
Normal file
28
app/client/packages/git/src/actions/generateSSHKey.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const generateSSHKeyInitAction = createSingleArtifactAction((state) => {
|
||||
state.apiResponses.generateSSHKey.loading = true;
|
||||
state.apiResponses.generateSSHKey.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const generateSSHKeySuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.generateSSHKey.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const generateSSHKeyErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.generateSSHKey.loading = false;
|
||||
state.apiResponses.generateSSHKey.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -3,42 +3,13 @@ import type {
|
|||
GitArtifactReduxState,
|
||||
GitSingleArtifactReduxState,
|
||||
} from "../../types";
|
||||
import { gitSingleArtifactInitialState } from "./singleArtifactInitialState";
|
||||
|
||||
type SingleArtifactStateCb<T> = (
|
||||
singleArtifactState: GitSingleArtifactReduxState,
|
||||
action: GitArtifactPayloadAction<T>,
|
||||
) => GitSingleArtifactReduxState;
|
||||
|
||||
export const gitSingleArtifactInitialState: GitSingleArtifactReduxState = {
|
||||
metadata: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
connect: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
branches: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
status: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
commit: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
pull: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const createSingleArtifactAction = <T>(
|
||||
singleArtifactStateCb: SingleArtifactStateCb<T>,
|
||||
) => {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
import {
|
||||
GitConnectStep,
|
||||
GitImportStep,
|
||||
GitOpsTab,
|
||||
GitSettingsTab,
|
||||
} from "../../enums";
|
||||
import type {
|
||||
GitSingleArtifactAPIResponsesReduxState,
|
||||
GitSingleArtifactUIReduxState,
|
||||
GitSingleArtifactReduxState,
|
||||
} from "../../types";
|
||||
|
||||
const gitSingleArtifactInitialUIState: GitSingleArtifactUIReduxState = {
|
||||
connectModal: {
|
||||
open: false,
|
||||
step: GitConnectStep.Provider,
|
||||
},
|
||||
importModal: {
|
||||
open: false,
|
||||
step: GitImportStep.Provider,
|
||||
},
|
||||
branchList: {
|
||||
open: false,
|
||||
},
|
||||
opsModal: {
|
||||
open: false,
|
||||
tab: GitOpsTab.Deploy,
|
||||
},
|
||||
settingsModal: {
|
||||
open: false,
|
||||
tab: GitSettingsTab.General,
|
||||
},
|
||||
};
|
||||
|
||||
const gitSingleArtifactInitialAPIResponses: GitSingleArtifactAPIResponsesReduxState =
|
||||
{
|
||||
metadata: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
connect: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
status: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
commit: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
pull: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
discard: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
mergeStatus: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
merge: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
branches: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
checkoutBranch: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
createBranch: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
deleteBranch: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
globalConfig: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
localConfig: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
updateGlobalConfig: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
updateLocalConfig: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
disconnect: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
protectedBranches: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
updateProtectedBranches: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
autocommitProgress: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
toggleAutocommit: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
triggerAutocommit: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
generateSSHKey: {
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
sshKey: {
|
||||
value: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const gitSingleArtifactInitialState: GitSingleArtifactReduxState = {
|
||||
ui: gitSingleArtifactInitialUIState,
|
||||
apiResponses: gitSingleArtifactInitialAPIResponses,
|
||||
};
|
||||
26
app/client/packages/git/src/actions/mergeActions.ts
Normal file
26
app/client/packages/git/src/actions/mergeActions.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const mergeInitAction = createSingleArtifactAction((state) => {
|
||||
state.apiResponses.merge.loading = true;
|
||||
state.apiResponses.merge.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const mergeSuccessAction = createSingleArtifactAction((state) => {
|
||||
state.apiResponses.merge.loading = false;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const mergeErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.merge.loading = false;
|
||||
state.apiResponses.merge.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { PayloadAction } from "@reduxjs/toolkit";
|
||||
import type { GitArtifactBasePayload, GitArtifactReduxState } from "../types";
|
||||
import { gitSingleArtifactInitialState } from "./helpers/createSingleArtifactAction";
|
||||
import { gitSingleArtifactInitialState } from "./helpers/singleArtifactInitialState";
|
||||
|
||||
// ! This might be removed later
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactPayloadAction } from "../types";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const pullInitAction = createSingleArtifactAction((state) => {
|
||||
state.pull.loading = true;
|
||||
state.pull.error = null;
|
||||
state.apiResponses.pull.loading = true;
|
||||
state.apiResponses.pull.error = null;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const pullSuccessAction = createSingleArtifactAction((state) => {
|
||||
state.pull.loading = false;
|
||||
state.apiResponses.pull.loading = false;
|
||||
|
||||
return state;
|
||||
});
|
||||
|
||||
export const pullErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactPayloadAction<{ error: string }>) => {
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.pull.loading = false;
|
||||
state.pull.error = error;
|
||||
state.apiResponses.pull.loading = false;
|
||||
state.apiResponses.pull.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const toggleAutocommitInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.toggleAutocommit.loading = true;
|
||||
state.apiResponses.toggleAutocommit.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const toggleAutocommitSuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.toggleAutocommit.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const toggleAutocommitErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.toggleAutocommit.loading = false;
|
||||
state.apiResponses.toggleAutocommit.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const triggerAutocommitInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.triggerAutocommit.loading = true;
|
||||
state.apiResponses.triggerAutocommit.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const triggerAutocommitSuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.triggerAutocommit.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const triggerAutocommitErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.triggerAutocommit.loading = false;
|
||||
state.apiResponses.triggerAutocommit.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const updateGlobalConfigInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateGlobalConfig.loading = true;
|
||||
state.apiResponses.updateGlobalConfig.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateGlobalConfigSuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateGlobalConfig.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateGlobalConfigErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.updateGlobalConfig.loading = false;
|
||||
state.apiResponses.updateGlobalConfig.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const updateLocalConfigInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateLocalConfig.loading = true;
|
||||
state.apiResponses.updateLocalConfig.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateLocalConfigSuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateLocalConfig.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateLocalConfigErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.updateLocalConfig.loading = false;
|
||||
state.apiResponses.updateLocalConfig.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction";
|
||||
import type { GitArtifactErrorPayloadAction } from "../types";
|
||||
|
||||
export const updateProtectedBranchesInitAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateProtectedBranches.loading = true;
|
||||
state.apiResponses.updateProtectedBranches.error = null;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateProtectedBranchesSuccessAction = createSingleArtifactAction(
|
||||
(state) => {
|
||||
state.apiResponses.updateProtectedBranches.loading = false;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
|
||||
export const updateProtectedBranchesErrorAction = createSingleArtifactAction(
|
||||
(state, action: GitArtifactErrorPayloadAction) => {
|
||||
const { error } = action.payload;
|
||||
|
||||
state.apiResponses.updateProtectedBranches.loading = false;
|
||||
state.apiResponses.updateProtectedBranches.error = error;
|
||||
|
||||
return state;
|
||||
},
|
||||
);
|
||||
27
app/client/packages/git/src/enums.ts
Normal file
27
app/client/packages/git/src/enums.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
export enum GitArtifactType {
|
||||
Application = "Application",
|
||||
Package = "Package",
|
||||
Workflow = "Workflow",
|
||||
}
|
||||
|
||||
export enum GitConnectStep {
|
||||
Provider = "Provider",
|
||||
Remote = "Remote",
|
||||
SSH = "SSH",
|
||||
}
|
||||
|
||||
export enum GitImportStep {
|
||||
Provider = "Provider",
|
||||
remote = "remote",
|
||||
SSH = "SSH",
|
||||
}
|
||||
|
||||
export enum GitOpsTab {
|
||||
Deploy = "Deploy",
|
||||
Merge = "Merge",
|
||||
}
|
||||
|
||||
export enum GitSettingsTab {
|
||||
General = "General",
|
||||
Branch = "Branch",
|
||||
}
|
||||
|
|
@ -1,4 +1,11 @@
|
|||
import type { PayloadAction } from "@reduxjs/toolkit";
|
||||
import type {
|
||||
GitArtifactType,
|
||||
GitConnectStep,
|
||||
GitImportStep,
|
||||
GitOpsTab,
|
||||
GitSettingsTab,
|
||||
} from "./enums";
|
||||
|
||||
// These will be updated when contracts are finalized
|
||||
export type GitMetadata = Record<string, unknown>;
|
||||
|
|
@ -7,19 +14,79 @@ export type GitBranches = Record<string, unknown>;
|
|||
|
||||
export type GitStatus = Record<string, unknown>;
|
||||
|
||||
export type GitMergeStatus = Record<string, unknown>;
|
||||
|
||||
export type GitGlobalConfig = Record<string, unknown>;
|
||||
|
||||
export type GitLocalConfig = Record<string, unknown>;
|
||||
|
||||
export type GitProtectedBranches = Record<string, unknown>;
|
||||
|
||||
export type GitAutocommitProgress = Record<string, unknown>;
|
||||
|
||||
export type GitSSHKey = Record<string, unknown>;
|
||||
|
||||
interface AsyncState<T = unknown> {
|
||||
value: T | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface GitSingleArtifactReduxState {
|
||||
interface AsyncStateWithoutValue {
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
export interface GitSingleArtifactAPIResponsesReduxState {
|
||||
metadata: AsyncState<GitMetadata>;
|
||||
connect: Omit<AsyncState, "value">;
|
||||
branches: AsyncState<GitBranches>;
|
||||
connect: AsyncStateWithoutValue;
|
||||
status: AsyncState<GitStatus>;
|
||||
commit: Omit<AsyncState, "value">;
|
||||
pull: Omit<AsyncState, "value">;
|
||||
commit: AsyncStateWithoutValue;
|
||||
pull: AsyncStateWithoutValue;
|
||||
discard: AsyncStateWithoutValue;
|
||||
mergeStatus: AsyncState<GitMergeStatus>;
|
||||
merge: AsyncStateWithoutValue;
|
||||
branches: AsyncState<GitBranches>;
|
||||
checkoutBranch: AsyncStateWithoutValue;
|
||||
createBranch: AsyncStateWithoutValue;
|
||||
deleteBranch: AsyncStateWithoutValue;
|
||||
globalConfig: AsyncState<GitGlobalConfig>;
|
||||
localConfig: AsyncState<GitLocalConfig>;
|
||||
updateGlobalConfig: AsyncStateWithoutValue;
|
||||
updateLocalConfig: AsyncStateWithoutValue;
|
||||
disconnect: AsyncStateWithoutValue;
|
||||
protectedBranches: AsyncState<GitProtectedBranches>;
|
||||
updateProtectedBranches: AsyncStateWithoutValue;
|
||||
autocommitProgress: AsyncState<GitAutocommitProgress>;
|
||||
toggleAutocommit: AsyncStateWithoutValue;
|
||||
triggerAutocommit: AsyncStateWithoutValue;
|
||||
sshKey: AsyncState<GitSSHKey>;
|
||||
generateSSHKey: AsyncStateWithoutValue;
|
||||
}
|
||||
|
||||
export interface GitSingleArtifactUIReduxState {
|
||||
connectModal: {
|
||||
open: boolean;
|
||||
step: keyof typeof GitConnectStep;
|
||||
};
|
||||
importModal: {
|
||||
open: boolean;
|
||||
step: keyof typeof GitImportStep;
|
||||
};
|
||||
branchList: {
|
||||
open: boolean;
|
||||
};
|
||||
opsModal: {
|
||||
open: boolean;
|
||||
tab: keyof typeof GitOpsTab;
|
||||
};
|
||||
settingsModal: {
|
||||
open: boolean;
|
||||
tab: keyof typeof GitSettingsTab;
|
||||
};
|
||||
}
|
||||
export interface GitSingleArtifactReduxState {
|
||||
ui: GitSingleArtifactUIReduxState;
|
||||
apiResponses: GitSingleArtifactAPIResponsesReduxState;
|
||||
}
|
||||
|
||||
export interface GitArtifactReduxState {
|
||||
|
|
@ -27,9 +94,13 @@ export interface GitArtifactReduxState {
|
|||
}
|
||||
|
||||
export interface GitArtifactBasePayload {
|
||||
artifactType: string;
|
||||
artifactType: keyof typeof GitArtifactType;
|
||||
baseArtifactId: string;
|
||||
}
|
||||
|
||||
export type GitArtifactPayloadAction<T = Record<string, unknown>> =
|
||||
PayloadAction<GitArtifactBasePayload & T>;
|
||||
|
||||
export type GitArtifactErrorPayloadAction = GitArtifactPayloadAction<{
|
||||
error: string;
|
||||
}>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user