Skip to content

Commit

Permalink
Add clearer error messages when sending to gallery (mit-cml#2791)
Browse files Browse the repository at this point in the history
  • Loading branch information
arinmodi authored Feb 24, 2025
1 parent 933f9d8 commit 85fc40e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public interface OdeMessages extends Messages, ComponentTranslations {
@Description("Error given when sending fails")
String GallerySendingError();

@DefaultMessage("This project contains extensions and cannot be published to gallery.")
@Description("Error Message for displaying error when user tries to publish the project" +
"containing extensions")
String ProjectContainsExtensions();

@DefaultMessage("Error Logging Into the Gallery")
@Description("Error given if login fails for some reason")
String GalleryLoginError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.google.appinventor.client.OdeAsyncCallback;
import com.google.appinventor.client.boxes.ProjectListBox;
import com.google.appinventor.client.explorer.project.Project;
import com.google.appinventor.shared.rpc.project.youngandroid.YoungAndroidComponentsFolder;
import com.google.appinventor.shared.rpc.project.youngandroid.YoungAndroidProjectNode;
import com.google.appinventor.shared.rpc.project.ProjectNode;
import com.google.appinventor.shared.rpc.RpcResult;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
Expand All @@ -23,6 +26,24 @@
public class SendToGalleryAction implements Command {
private static volatile boolean lockPublishButton = false; // To prevent double clicking

/**
* Check wether project contains any extensions or not
*
* @param project to check on
* @return true or false
*/
private boolean containsExtension(Project project) {
YoungAndroidComponentsFolder componentsFolder = ((YoungAndroidProjectNode) project.getRootNode()).getComponentsFolder();

for (ProjectNode node : componentsFolder.getChildren()) {
if (node.getName().equals("classes.jar")) {
return true;
}
}

return false;
}

@Override
public void execute() {
if (lockPublishButton) {
Expand Down Expand Up @@ -50,6 +71,10 @@ public void execute() {
}

private void sendToGallery(Project project) {
if (containsExtension(project)) {
ErrorReporter.reportInfo(MESSAGES.ProjectContainsExtensions());
return;
}
lockPublishButton = true;
Ode.getInstance().getProjectService().sendToGallery(project.getProjectId(),
new OdeAsyncCallback<RpcResult>(
Expand Down

0 comments on commit 85fc40e

Please sign in to comment.