-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore: Add code-split for Git integration for packages #39166
Merged
+87
−66
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
9e23ae6
Add code-split for Git integration for packages
subrata71 b2f06cc
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
subrata71 57eb731
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
subrata71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
53 changes: 53 additions & 0 deletions
53
...erver/appsmith-server/src/test/utils/com/appsmith/server/git/GitApplicationTestUtils.java
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,53 @@ | ||
package com.appsmith.server.git; | ||
|
||
import com.appsmith.external.constants.PluginConstants; | ||
import com.appsmith.external.models.ActionConfiguration; | ||
import com.appsmith.external.models.ActionDTO; | ||
import com.appsmith.external.models.Datasource; | ||
import com.appsmith.external.models.PluginType; | ||
import com.appsmith.server.domains.Application; | ||
import com.appsmith.server.domains.Artifact; | ||
import com.appsmith.server.domains.Plugin; | ||
import com.appsmith.server.plugins.base.PluginService; | ||
import com.appsmith.server.services.LayoutActionService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.UUID; | ||
|
||
@Component | ||
public class GitApplicationTestUtils implements GitArtifactTestUtils<Application> { | ||
|
||
@Autowired | ||
LayoutActionService layoutActionService; | ||
@Autowired | ||
PluginService pluginService; | ||
|
||
|
||
@Override | ||
public Mono<Void> createADiff(Artifact artifact) { | ||
|
||
Application application = (Application) artifact; | ||
String pageId = application.getPages().get(0).getId(); | ||
Plugin plugin = pluginService.findByPackageName("restapi-plugin").block(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid blocking calls in reactive code. The - Plugin plugin = pluginService.findByPackageName("restapi-plugin").block();
+ return pluginService.findByPackageName("restapi-plugin")
+ .flatMap(plugin -> {
+ Datasource datasource = new Datasource();
+ // ... rest of the code
+ return layoutActionService.createSingleAction(action, Boolean.FALSE);
+ })
+ .then();
|
||
|
||
Datasource datasource = new Datasource(); | ||
datasource.setName(PluginConstants.DEFAULT_REST_DATASOURCE); | ||
datasource.setWorkspaceId(application.getWorkspaceId()); | ||
datasource.setPluginId(plugin.getId()); | ||
|
||
ActionDTO action = new ActionDTO(); | ||
action.setPluginType(PluginType.API); | ||
action.setName("aGetAction_" + UUID.randomUUID()); | ||
action.setDatasource(datasource); | ||
action.setActionConfiguration(new ActionConfiguration()); | ||
action.getActionConfiguration().setHttpMethod(HttpMethod.GET); | ||
action.setPageId(pageId); | ||
|
||
return layoutActionService | ||
.createSingleAction(action, Boolean.FALSE) | ||
.then(); | ||
} | ||
} |
48 changes: 2 additions & 46 deletions
48
app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitArtifactTestUtils.java
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 |
---|---|---|
@@ -1,52 +1,8 @@ | ||
package com.appsmith.server.git; | ||
|
||
import com.appsmith.external.constants.PluginConstants; | ||
import com.appsmith.external.models.ActionConfiguration; | ||
import com.appsmith.external.models.ActionDTO; | ||
import com.appsmith.external.models.Datasource; | ||
import com.appsmith.external.models.PluginType; | ||
import com.appsmith.server.domains.Application; | ||
import com.appsmith.server.domains.Artifact; | ||
import com.appsmith.server.domains.Plugin; | ||
import com.appsmith.server.plugins.base.PluginService; | ||
import com.appsmith.server.services.LayoutActionService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.UUID; | ||
|
||
@Component | ||
public class GitArtifactTestUtils<T extends Artifact> { | ||
|
||
@Autowired | ||
LayoutActionService layoutActionService; | ||
@Autowired | ||
PluginService pluginService; | ||
|
||
Mono<Void> createADiff(Artifact artifact) { | ||
|
||
Application application = (Application) artifact; | ||
|
||
String pageId = application.getPages().get(0).getId(); | ||
Plugin plugin = pluginService.findByPackageName("restapi-plugin").block(); | ||
|
||
Datasource datasource = new Datasource(); | ||
datasource.setName(PluginConstants.DEFAULT_REST_DATASOURCE); | ||
datasource.setWorkspaceId(application.getWorkspaceId()); | ||
datasource.setPluginId(plugin.getId()); | ||
|
||
ActionDTO action = new ActionDTO(); | ||
action.setPluginType(PluginType.API); | ||
action.setName("aGetAction_" + UUID.randomUUID()); | ||
action.setDatasource(datasource); | ||
action.setActionConfiguration(new ActionConfiguration()); | ||
action.getActionConfiguration().setHttpMethod(HttpMethod.GET); | ||
action.setPageId(pageId); | ||
|
||
return layoutActionService | ||
.createSingleAction(action, Boolean.FALSE) | ||
.then(); | ||
} | ||
public interface GitArtifactTestUtils<T extends Artifact> { | ||
Mono<Void> createADiff(Artifact artifact); | ||
} |
24 changes: 5 additions & 19 deletions
24
app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitTestUtils.java
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 |
---|---|---|
@@ -1,27 +1,13 @@ | ||
package com.appsmith.server.git; | ||
|
||
import com.appsmith.server.constants.ArtifactType; | ||
|
||
import com.appsmith.server.domains.Application; | ||
import com.appsmith.server.domains.Artifact; | ||
import lombok.RequiredArgsConstructor; | ||
import com.appsmith.server.git.ce.GitTestUtilsCE; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class GitTestUtils { | ||
|
||
private final GitArtifactTestUtils<Application> gitApplicationTestUtils; | ||
|
||
private GitArtifactTestUtils<?> getArtifactSpecificUtils(ArtifactType artifactType) { | ||
// TODO For now just work with apps | ||
return gitApplicationTestUtils; | ||
} | ||
|
||
|
||
public Mono<Void> createADiffInArtifact(Artifact artifact) { | ||
GitArtifactTestUtils<?> artifactSpecificUtils = getArtifactSpecificUtils(artifact.getArtifactType()); | ||
|
||
return artifactSpecificUtils.createADiff(artifact); | ||
public class GitTestUtils extends GitTestUtilsCE { | ||
public GitTestUtils(GitArtifactTestUtils<Application> gitApplicationTestUtils) { | ||
super(gitApplicationTestUtils); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/server/appsmith-server/src/test/utils/com/appsmith/server/git/ce/GitTestUtilsCE.java
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 @@ | ||
package com.appsmith.server.git.ce; | ||
|
||
import com.appsmith.server.constants.ArtifactType; | ||
import com.appsmith.server.domains.Application; | ||
import com.appsmith.server.domains.Artifact; | ||
import com.appsmith.server.git.GitArtifactTestUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class GitTestUtilsCE { | ||
|
||
private final GitArtifactTestUtils<Application> gitApplicationTestUtils; | ||
protected GitArtifactTestUtils<?> getArtifactSpecificUtils(ArtifactType artifactType) { | ||
return gitApplicationTestUtils; | ||
} | ||
|
||
|
||
public Mono<Void> createADiffInArtifact(Artifact artifact) { | ||
GitArtifactTestUtils<?> artifactSpecificUtils = getArtifactSpecificUtils(artifact.getArtifactType()); | ||
|
||
return artifactSpecificUtils.createADiff(artifact); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Replace field injection with constructor injection.
Field injection is not recommended. Use constructor injection instead for better testability and explicit dependency declaration.
📝 Committable suggestion