From 73fd5b39aa344eaa46df89b8d9e037bd4e5eff61 Mon Sep 17 00:00:00 2001 From: Nilansh Bansal Date: Fri, 8 Sep 2023 19:26:20 +0530 Subject: [PATCH] chore: JS icon update (#27020) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > This PR updates the JS Icon to the new yellow colored one. #### PR fixes following issue(s) Fixes #24093 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Chore > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../db/ce/Migration022UpdateJSPluginIcon.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration022UpdateJSPluginIcon.java diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration022UpdateJSPluginIcon.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration022UpdateJSPluginIcon.java new file mode 100644 index 0000000000..06548938bb --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/db/ce/Migration022UpdateJSPluginIcon.java @@ -0,0 +1,45 @@ +package com.appsmith.server.migrations.db.ce; + +import com.appsmith.server.domains.Plugin; +import com.appsmith.server.domains.QPlugin; +import io.mongock.api.annotations.ChangeUnit; +import io.mongock.api.annotations.Execution; +import io.mongock.api.annotations.RollbackExecution; +import lombok.RequiredArgsConstructor; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; + +import java.util.List; + +import static com.appsmith.server.repositories.ce.BaseAppsmithRepositoryCEImpl.fieldName; +import static org.springframework.data.mongodb.core.query.Criteria.where; +import static org.springframework.data.mongodb.core.query.Query.query; +import static org.springframework.data.mongodb.core.query.Update.update; + +@RequiredArgsConstructor +@ChangeUnit(order = "022", id = "update-js-plugin-icon") +public class Migration022UpdateJSPluginIcon { + private final MongoTemplate mongoTemplate; + + @RollbackExecution + public void rollbackExecution() {} + + @Execution + public void executeMigration() { + Criteria jsFunctionsPlugin = where("name").is("JS Functions"); + final Query query = query((new Criteria()).andOperator(jsFunctionsPlugin)); + + query.fields().include(fieldName(QPlugin.plugin.iconLocation)); + List plugins = mongoTemplate.find(query, Plugin.class); + for (final Plugin plugin : plugins) { + if (plugin.getIconLocation() != null) { + final String updatedJSIconUrl = plugin.getIconLocation().replace("JSFile.svg", "js-yellow.svg"); + mongoTemplate.updateFirst( + query(where(fieldName(QPlugin.plugin.id)).is(plugin.getId())), + update(fieldName(QPlugin.plugin.iconLocation), updatedJSIconUrl), + Plugin.class); + } + } + } +}