From cd3a2ac1c4b80cdeb2af0d6c91b3da7ccf717655 Mon Sep 17 00:00:00 2001 From: Nayan Date: Fri, 24 Dec 2021 15:51:42 +0600 Subject: [PATCH] Set a default color to application when application has no color set from FE (#9919) --- .../appsmith/server/constants/ApplicationConstants.java | 8 ++++++++ .../server/services/ce/ApplicationServiceCE.java | 2 ++ .../server/services/ce/ApplicationServiceCEImpl.java | 9 +++++++++ .../appsmith/server/services/ApplicationServiceTest.java | 1 + 4 files changed, 20 insertions(+) create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ApplicationConstants.java diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ApplicationConstants.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ApplicationConstants.java new file mode 100644 index 0000000000..305711c216 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ApplicationConstants.java @@ -0,0 +1,8 @@ +package com.appsmith.server.constants; + +public class ApplicationConstants { + public static final String [] APP_CARD_COLORS = { + "#FFDEDE", "#FFEFDB", "#F3F1C7", "#F4FFDE", "#C7F3F0", "#D9E7FF", "#E3DEFF", "#F1DEFF", + "#C7F3E3", "#F5D1D1", "#ECECEC", "#FBF4ED", "#D6D1F2", "#FFEBFB", "#EAEDFB" + }; +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCE.java index 853a6e75cb..a7dac973d6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCE.java @@ -58,4 +58,6 @@ public interface ApplicationServiceCE extends CrudService { Mono getGitConnectedApplicationCount(String organizationId); + String getRandomAppCardColor(); + } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java index 145d9eedfe..bd5d33b4d7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java @@ -3,6 +3,7 @@ package com.appsmith.server.services.ce; import com.appsmith.external.models.Policy; import com.appsmith.git.helpers.StringOutputStream; import com.appsmith.server.acl.AclPermission; +import com.appsmith.server.constants.ApplicationConstants; import com.appsmith.server.constants.Assets; import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.Action; @@ -180,6 +181,9 @@ public class ApplicationServiceCEImpl extends BaseService createDefault(Application application) { application.setSlug(TextUtils.makeSlug(application.getName())); application.setLastEditedAt(Instant.now()); + if(!StringUtils.hasLength(application.getColor())) { + application.setColor(getRandomAppCardColor()); + } return super.create(application); } @@ -555,4 +559,9 @@ public class ApplicationServiceCEImpl extends BaseService