-
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.
chore: Add code-split for Git integration for packages (#39166)
## Description EE counterpart: appsmithorg/appsmith-ee#6032 Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.ImportExport, @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/13520092700> > Commit: 57eb731 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13520092700&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.ImportExport, @tag.Git` > Spec: > <hr>Tue, 25 Feb 2025 12:14:10 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 - **Bug Fixes** - Improved Git integration when discarding changes by adding extra validation and enhanced error reporting. These enhancements ensure that modifications are handled more reliably, resulting in a smoother and more consistent experience for users. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
5 changed files
with
87 additions
and
66 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
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(); | ||
|
||
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); | ||
} | ||
} |