-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release' into feat/eslint/eslint-package
- Loading branch information
Showing
42 changed files
with
976 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["../../.eslintrc.base.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@appsmith/git", | ||
"description": "This package contains all the git related functionality for Appsmith UI", | ||
"private": true, | ||
"version": "1.0.0", | ||
"main": "src/index.ts", | ||
"scripts": { | ||
"lint": "yarn g:lint", | ||
"prettier": "yarn g:prettier", | ||
"test:unit": "yarn g:jest --passWithNoTests" | ||
}, | ||
"dependencies": { | ||
"@reduxjs/toolkit": "^2.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction"; | ||
import type { GitArtifactPayloadAction } from "../types"; | ||
|
||
export const commitInitAction = createSingleArtifactAction((state) => { | ||
state.commit.loading = true; | ||
state.commit.error = null; | ||
|
||
return state; | ||
}); | ||
|
||
export const commitSuccessAction = createSingleArtifactAction((state) => { | ||
state.commit.loading = false; | ||
|
||
return state; | ||
}); | ||
|
||
export const commitErrorAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ error: string }>) => { | ||
const { error } = action.payload; | ||
|
||
state.commit.loading = false; | ||
state.commit.error = error; | ||
|
||
return state; | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction"; | ||
import type { GitArtifactPayloadAction } from "../types"; | ||
|
||
export const connectInitAction = createSingleArtifactAction((state) => { | ||
state.connect.loading = true; | ||
state.connect.error = null; | ||
|
||
return state; | ||
}); | ||
|
||
export const connectSuccessAction = createSingleArtifactAction((state) => { | ||
state.connect.loading = false; | ||
|
||
return state; | ||
}); | ||
|
||
export const connectErrorAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ error: string }>) => { | ||
const { error } = action.payload; | ||
|
||
state.connect.loading = false; | ||
state.connect.error = error; | ||
|
||
return state; | ||
}, | ||
); |
29 changes: 29 additions & 0 deletions
29
app/client/packages/git/src/actions/fetchBranchesActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { GitArtifactPayloadAction, GitBranches } from "../types"; | ||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction"; | ||
|
||
export const fetchBranchesInitAction = createSingleArtifactAction((state) => { | ||
state.branches.loading = true; | ||
state.branches.error = null; | ||
|
||
return state; | ||
}); | ||
|
||
export const fetchBranchesSuccessAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ branches: GitBranches }>) => { | ||
state.branches.loading = false; | ||
state.branches.value = action.payload.branches; | ||
|
||
return state; | ||
}, | ||
); | ||
|
||
export const fetchBranchesErrorAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ error: string }>) => { | ||
const { error } = action.payload; | ||
|
||
state.branches.loading = false; | ||
state.branches.error = error; | ||
|
||
return state; | ||
}, | ||
); |
29 changes: 29 additions & 0 deletions
29
app/client/packages/git/src/actions/fetchMetadataActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { GitArtifactPayloadAction, GitMetadata } from "../types"; | ||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction"; | ||
|
||
export const fetchMetadataInitAction = createSingleArtifactAction((state) => { | ||
state.metadata.loading = true; | ||
state.metadata.error = null; | ||
|
||
return state; | ||
}); | ||
|
||
export const fetchMetadataSuccessAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ metadata: GitMetadata }>) => { | ||
state.metadata.loading = false; | ||
state.metadata.value = action.payload.metadata; | ||
|
||
return state; | ||
}, | ||
); | ||
|
||
export const fetchMetadataErrorAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ error: string }>) => { | ||
const { error } = action.payload; | ||
|
||
state.metadata.loading = false; | ||
state.metadata.error = error; | ||
|
||
return state; | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { GitArtifactPayloadAction, GitStatus } from "../types"; | ||
import { createSingleArtifactAction } from "./helpers/createSingleArtifactAction"; | ||
|
||
export const fetchStatusInitAction = createSingleArtifactAction((state) => { | ||
state.status.loading = true; | ||
state.status.error = null; | ||
|
||
return state; | ||
}); | ||
|
||
export const fetchStatusSuccessAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ status: GitStatus }>) => { | ||
state.status.loading = false; | ||
state.status.value = action.payload.status; | ||
|
||
return state; | ||
}, | ||
); | ||
|
||
export const fetchStatusErrorAction = createSingleArtifactAction( | ||
(state, action: GitArtifactPayloadAction<{ error: string }>) => { | ||
const { error } = action.payload; | ||
|
||
state.status.loading = false; | ||
state.status.error = error; | ||
|
||
return state; | ||
}, | ||
); |
63 changes: 63 additions & 0 deletions
63
app/client/packages/git/src/actions/helpers/createSingleArtifactAction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { | ||
GitArtifactPayloadAction, | ||
GitArtifactReduxState, | ||
GitSingleArtifactReduxState, | ||
} from "../../types"; | ||
|
||
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>, | ||
) => { | ||
return ( | ||
state: GitArtifactReduxState, | ||
action: GitArtifactPayloadAction<T>, | ||
) => { | ||
const { artifactType, baseArtifactId } = action.payload; | ||
|
||
state[artifactType] ??= {}; | ||
state[artifactType][baseArtifactId] ??= gitSingleArtifactInitialState; | ||
|
||
const singleArtifactState = state[artifactType][baseArtifactId]; | ||
|
||
state[artifactType][baseArtifactId] = singleArtifactStateCb( | ||
singleArtifactState, | ||
action, | ||
); | ||
|
||
return state; | ||
}; | ||
}; |
Oops, something went wrong.