From f122713b48fe6f48bab440c4df88fbd4cc21c3cf Mon Sep 17 00:00:00 2001 From: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Date: Fri, 28 May 2021 08:28:02 +0530 Subject: [PATCH 1/8] Fix: Adding missing widget properties when a new tab is created. (#4733) * dip * dip * dip * Revert "dip" This reverts commit f0eeaa4a2dc9845509945c2af9376f1573baafdf. * dip * removing unwanted iteration. * Adding and fixing specs. (cherry picked from commit 575d7fe7f97596c5565010727634d7a67b68f5a2) --- .../Applications/DuplicateApplication_spec.js | 2 +- .../Applications/ForkApplication_spec.js | 2 +- app/client/src/constants/WidgetConstants.tsx | 2 +- .../mockResponses/WidgetConfigResponse.tsx | 2 +- .../src/utils/WidgetPropsUtils.test.tsx | 46 +++++++++++++++++++ app/client/src/utils/WidgetPropsUtils.tsx | 45 +++++++++++++++++- app/client/src/widgets/Tabs/TabsWidget.tsx | 7 +++ 7 files changed, 101 insertions(+), 5 deletions(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js index 31427f6462..74f6848425 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js @@ -6,7 +6,7 @@ let duplicateApplicationDsl; describe("Duplicate application", function() { before(() => { - dsl.dsl.version = 20; // latest migrated version + dsl.dsl.version = 21; // latest migrated version cy.addDsl(dsl); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js index 4defd83f1b..2dc3773ffc 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js @@ -5,7 +5,7 @@ let forkedApplicationDsl; describe("Fork application across orgs", function() { before(() => { - dsl.dsl.version = 20; // latest migrated version + dsl.dsl.version = 21; // latest migrated version cy.addDsl(dsl); }); diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index 12c34a9ff1..6226293292 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -96,7 +96,7 @@ export const layoutConfigurations: LayoutConfigurations = { FLUID: { minWidth: -1, maxWidth: -1 }, }; -export const LATEST_PAGE_VERSION = 20; +export const LATEST_PAGE_VERSION = 21; export const GridDefaults = { DEFAULT_CELL_SIZE: 1, diff --git a/app/client/src/mockResponses/WidgetConfigResponse.tsx b/app/client/src/mockResponses/WidgetConfigResponse.tsx index 521ce177cf..51545b5945 100644 --- a/app/client/src/mockResponses/WidgetConfigResponse.tsx +++ b/app/client/src/mockResponses/WidgetConfigResponse.tsx @@ -368,7 +368,7 @@ const WidgetConfigResponse: WidgetConfigReducerState = { }, ], }, - version: 2, + version: 3, }, MODAL_WIDGET: { rows: 6 * GRID_DENSITY_MIGRATION_V1, diff --git a/app/client/src/utils/WidgetPropsUtils.test.tsx b/app/client/src/utils/WidgetPropsUtils.test.tsx index 2b774e45fb..c4b9565c3d 100644 --- a/app/client/src/utils/WidgetPropsUtils.test.tsx +++ b/app/client/src/utils/WidgetPropsUtils.test.tsx @@ -4,9 +4,11 @@ import { migrateChartDataFromArrayToObject, migrateToNewLayout, migrateInitialValues, + extractCurrentDSL, } from "./WidgetPropsUtils"; import { buildChildren, + widgetCanvasFactory, buildDslWithChildren, } from "test/factories/WidgetFactoryUtils"; import { cloneDeep } from "lodash"; @@ -694,4 +696,48 @@ describe("Initial value migration test", () => { expect(migrateInitialValues(input)).toEqual(output); }); + it("", () => { + const tabsWidgetDSL: any = (version = 1) => { + const children: any = buildChildren([ + { + version, + type: "TABS_WIDGET", + children: [ + { + type: "CANVAS_WIDGET", + tabId: "tab1212332", + tabName: "Newly Added Tab", + widgetId: "o9ody00ep7", + parentId: "jd83uvbkmp", + detachFromLayout: true, + children: [], + parentRowSpace: 1, + parentColumnSpace: 1, + // leftColumn: 0, + // rightColumn: 592, // Commenting these coz they are not provided for a newly added tab in the Tabs widget version 2 + // bottomRow: 280, + topRow: 0, + isLoading: false, + widgetName: "Canvas1", + renderMode: "CANVAS", + }, + ], + }, + ]); + const dsl: any = widgetCanvasFactory.build({ + children, + }); + return { + data: { + layouts: [{ dsl }], + }, + }; + }; + const migratedDslV2: any = extractCurrentDSL(tabsWidgetDSL()); + expect(migratedDslV2.children[0].children[0].leftColumn).toBeNaN(); + const migratedDslV3: any = extractCurrentDSL(tabsWidgetDSL(2)); + expect(migratedDslV3.children[0].version).toBe(3); + expect(migratedDslV3.children[0].children[0].leftColumn).not.toBeNaN(); + expect(migratedDslV3.children[0].children[0].leftColumn).toBe(0); + }); }); diff --git a/app/client/src/utils/WidgetPropsUtils.tsx b/app/client/src/utils/WidgetPropsUtils.tsx index 54979e9b1b..672abde7b4 100644 --- a/app/client/src/utils/WidgetPropsUtils.tsx +++ b/app/client/src/utils/WidgetPropsUtils.tsx @@ -22,7 +22,7 @@ import defaultTemplate from "templates/default"; import { generateReactKey } from "./generators"; import { ChartDataPoint } from "widgets/ChartWidget"; import { FlattenedWidgetProps } from "reducers/entityReducers/canvasWidgetsReducer"; -import { isString, set } from "lodash"; +import { has, isString, set } from "lodash"; import log from "loglevel"; import { migrateTablePrimaryColumnsBindings, @@ -735,12 +735,55 @@ const transformDSL = (currentDSL: ContainerWidgetProps) => { currentDSL.detachFromLayout || false, ); currentDSL = migrateToNewLayout(currentDSL); + currentDSL.version = 20; + } + + if (currentDSL.version === 20) { + currentDSL = migrateNewlyAddedTabsWidgetsMissingData(currentDSL); currentDSL.version = LATEST_PAGE_VERSION; } return currentDSL; }; +const migrateNewlyAddedTabsWidgetsMissingData = ( + currentDSL: ContainerWidgetProps, +) => { + if (currentDSL.type === WidgetTypes.TABS_WIDGET && currentDSL.version === 2) { + try { + if (currentDSL.children && currentDSL.children.length) { + currentDSL.children = currentDSL.children.map((each) => { + if (has(currentDSL, ["leftColumn", "rightColumn", "bottomRow"])) { + return each; + } + return { + ...each, + leftColumn: 0, + rightColumn: + (currentDSL.rightColumn - currentDSL.leftColumn) * + currentDSL.parentColumnSpace, + bottomRow: + (currentDSL.bottomRow - currentDSL.topRow) * + currentDSL.parentRowSpace, + }; + }); + } + currentDSL.version = 3; + } catch (error) { + Sentry.captureException({ + message: "Tabs Migration to add missing fields Failed", + oldData: currentDSL.children, + }); + } + } + if (currentDSL.children && currentDSL.children.length) { + currentDSL.children = currentDSL.children.map( + migrateNewlyAddedTabsWidgetsMissingData, + ); + } + return currentDSL; +}; + export const migrateToNewLayout = (dsl: ContainerWidgetProps) => { const scaleWidget = (widgetProps: WidgetProps) => { widgetProps.bottomRow *= GRID_DENSITY_MIGRATION_V1; diff --git a/app/client/src/widgets/Tabs/TabsWidget.tsx b/app/client/src/widgets/Tabs/TabsWidget.tsx index f8cd1ec930..6e164ede2e 100644 --- a/app/client/src/widgets/Tabs/TabsWidget.tsx +++ b/app/client/src/widgets/Tabs/TabsWidget.tsx @@ -210,6 +210,13 @@ class TabsWidget extends BaseWidget< topRow: 1, newWidgetId, widgetId: this.props.widgetId, + leftColumn: 0, + rightColumn: + (this.props.rightColumn - this.props.leftColumn) * + this.props.parentColumnSpace, + bottomRow: + (this.props.bottomRow - this.props.topRow) * + this.props.parentRowSpace, props: { tabId: tab.id, tabName: tab.label, From 18275be7fd6906570e8883750c0d200e43a82f58 Mon Sep 17 00:00:00 2001 From: Sumit Kumar Date: Mon, 31 May 2021 11:55:47 +0530 Subject: [PATCH 2/8] Fix: Fix redis plugin socket error (#4791) * fix socket error * fix default port * remove invalid check for missing port, since default port would be supplied if user leaves the port field empty. (cherry picked from commit e2f4fd5e94a1ca34fc703b2a94e5c773ca454d63) --- .../java/com/external/plugins/RedisPlugin.java | 16 ++++++++++++---- .../com/external/plugins/RedisPluginTest.java | 7 ++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java b/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java index 4a5dfcd059..f5dca31ecb 100644 --- a/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java +++ b/app/server/appsmith-plugins/redisPlugin/src/main/java/com/external/plugins/RedisPlugin.java @@ -36,7 +36,7 @@ import java.util.stream.Collectors; import static com.appsmith.external.constants.ActionConstants.ACTION_CONFIGURATION_BODY; public class RedisPlugin extends BasePlugin { - private static final Integer DEFAULT_PORT = 6379; + private static final Long DEFAULT_PORT = 6379L; public RedisPlugin(PluginWrapper wrapper) { super(wrapper); @@ -106,6 +106,17 @@ public class RedisPlugin extends BasePlugin { result.setRequest(request); return result; }) + .doFinally(signalType -> { + /* + * - For some reason, Jedis throws a socket error when kept idle for like 10 min when + * appsmith is setup via docker image. + * - APMU, jedis.close() should disconnect the connection, causing jedis to refresh connection + * during next execution. + * - This is a placeholder solution till better fix is available (would connection pool fix + * it ?) + */ + jedis.close(); + }) .subscribeOn(scheduler); } @@ -178,9 +189,6 @@ public class RedisPlugin extends BasePlugin { if (StringUtils.isNullOrEmpty(endpoint.getHost())) { invalids.add("Missing host for endpoint"); } - if (endpoint.getPort() == null) { - invalids.add("Missing port for endpoint"); - } } DBAuth auth = (DBAuth) datasourceConfiguration.getAuthentication(); diff --git a/app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java b/app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java index 72198786c1..58274a14d2 100644 --- a/app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java +++ b/app/server/appsmith-plugins/redisPlugin/src/test/java/com/external/plugins/RedisPluginTest.java @@ -83,7 +83,7 @@ public class RedisPluginTest { Endpoint endpoint = new Endpoint(); invalidDatasourceConfiguration.setEndpoints(Collections.singletonList(endpoint)); - Assert.assertEquals(Set.of("Missing port for endpoint", "Missing host for endpoint"), + Assert.assertEquals(Set.of("Missing host for endpoint"), pluginExecutor.validateDatasource(invalidDatasourceConfiguration)); } @@ -95,7 +95,8 @@ public class RedisPluginTest { endpoint.setHost("test-host"); invalidDatasourceConfiguration.setEndpoints(Collections.singletonList(endpoint)); - Assert.assertEquals(pluginExecutor.validateDatasource(invalidDatasourceConfiguration), Set.of("Missing port for endpoint")); + // Since default port is picked, set of invalids should be empty. + Assert.assertEquals(pluginExecutor.validateDatasource(invalidDatasourceConfiguration), Set.of()); } @Test @@ -112,7 +113,7 @@ public class RedisPluginTest { invalidDatasourceConfiguration.setEndpoints(Collections.singletonList(endpoint)); Assert.assertEquals( - Set.of("Missing port for endpoint", "Missing username for authentication.", "Missing password for authentication."), + Set.of("Missing username for authentication.", "Missing password for authentication."), pluginExecutor.validateDatasource(invalidDatasourceConfiguration) ); } From f85b21199375c686770dc2867478bf8d2a7902a1 Mon Sep 17 00:00:00 2001 From: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Date: Fri, 28 May 2021 22:25:10 +0530 Subject: [PATCH 3/8] Fix: Positioning widgets without left right column towards the end of the page. (#4777) --- app/client/src/constants/WidgetConstants.tsx | 2 +- app/client/src/utils/WidgetPropsUtils.tsx | 98 +++++++++++++++++++- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index 6226293292..9f8cc38859 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -96,7 +96,7 @@ export const layoutConfigurations: LayoutConfigurations = { FLUID: { minWidth: -1, maxWidth: -1 }, }; -export const LATEST_PAGE_VERSION = 21; +export const LATEST_PAGE_VERSION = 22; export const GridDefaults = { DEFAULT_CELL_SIZE: 1, diff --git a/app/client/src/utils/WidgetPropsUtils.tsx b/app/client/src/utils/WidgetPropsUtils.tsx index 672abde7b4..338c9db8ca 100644 --- a/app/client/src/utils/WidgetPropsUtils.tsx +++ b/app/client/src/utils/WidgetPropsUtils.tsx @@ -22,7 +22,7 @@ import defaultTemplate from "templates/default"; import { generateReactKey } from "./generators"; import { ChartDataPoint } from "widgets/ChartWidget"; import { FlattenedWidgetProps } from "reducers/entityReducers/canvasWidgetsReducer"; -import { has, isString, set } from "lodash"; +import { has, isString, omit, set } from "lodash"; import log from "loglevel"; import { migrateTablePrimaryColumnsBindings, @@ -33,7 +33,10 @@ import * as Sentry from "@sentry/react"; import { migrateTextStyleFromTextWidget } from "./migrations/TextWidgetReplaceTextStyle"; import { nextAvailableRowInContainer } from "entities/Widget/utils"; import { DATA_BIND_REGEX_GLOBAL } from "constants/BindingsConstants"; -import { GRID_DENSITY_MIGRATION_V1 } from "mockResponses/WidgetConfigResponse"; +import WidgetConfigResponse, { + GRID_DENSITY_MIGRATION_V1, +} from "mockResponses/WidgetConfigResponse"; +import CanvasWidgetsNormalizer from "normalizers/CanvasWidgetsNormalizer"; export type WidgetOperationParams = { operation: WidgetOperation; @@ -740,12 +743,103 @@ const transformDSL = (currentDSL: ContainerWidgetProps) => { if (currentDSL.version === 20) { currentDSL = migrateNewlyAddedTabsWidgetsMissingData(currentDSL); + currentDSL.version = 21; + } + + if (currentDSL.version === 21) { + const { + entities: { canvasWidgets }, + } = CanvasWidgetsNormalizer.normalize(currentDSL); + currentDSL = migrateWidgetsWithoutLeftRightColumns( + currentDSL, + canvasWidgets, + ); + currentDSL = migrateOverFlowingTabsWidgets(currentDSL, canvasWidgets); currentDSL.version = LATEST_PAGE_VERSION; } return currentDSL; }; +const migrateOverFlowingTabsWidgets = ( + currentDSL: ContainerWidgetProps, + canvasWidgets: any, +) => { + if ( + currentDSL.type === "TABS_WIDGET" && + currentDSL.version === 3 && + currentDSL.children && + currentDSL.children.length + ) { + const tabsWidgetHeight = + (currentDSL.bottomRow - currentDSL.topRow) * currentDSL.parentRowSpace; + const widgetHasOverflowingChildren = currentDSL.children.some((eachTab) => { + if (eachTab.children && eachTab.children.length) { + return eachTab.children.some((child: WidgetProps) => { + if (canvasWidgets[child.widgetId].repositioned) { + const tabHeight = child.bottomRow * child.parentRowSpace; + return tabsWidgetHeight < tabHeight; + } + return false; + }); + } + return false; + }); + if (widgetHasOverflowingChildren) { + currentDSL.shouldScrollContents = true; + } + } + if (currentDSL.children && currentDSL.children.length) { + currentDSL.children = currentDSL.children.map((eachChild) => + migrateOverFlowingTabsWidgets(eachChild, canvasWidgets), + ); + } + return currentDSL; +}; + +const migrateWidgetsWithoutLeftRightColumns = ( + currentDSL: ContainerWidgetProps, + canvasWidgets: any, +) => { + if ( + currentDSL.widgetId !== MAIN_CONTAINER_WIDGET_ID && + !( + currentDSL.hasOwnProperty("leftColumn") && + currentDSL.hasOwnProperty("rightColumn") + ) + ) { + try { + const nextRow = nextAvailableRowInContainer( + currentDSL.parentId || MAIN_CONTAINER_WIDGET_ID, + omit(canvasWidgets, [currentDSL.widgetId]), + ); + canvasWidgets[currentDSL.widgetId].repositioned = true; + const leftColumn = 0; + const rightColumn = WidgetConfigResponse.config[currentDSL.type].rows; + const bottomRow = nextRow + (currentDSL.bottomRow - currentDSL.topRow); + const topRow = nextRow; + currentDSL = { + ...currentDSL, + topRow, + bottomRow, + rightColumn, + leftColumn, + }; + } catch (error) { + Sentry.captureException({ + message: "Migrating position of widget on data loss failed", + oldData: currentDSL, + }); + } + } + if (currentDSL.children && currentDSL.children.length) { + currentDSL.children = currentDSL.children.map((dsl) => + migrateWidgetsWithoutLeftRightColumns(dsl, canvasWidgets), + ); + } + return currentDSL; +}; + const migrateNewlyAddedTabsWidgetsMissingData = ( currentDSL: ContainerWidgetProps, ) => { From 8fc2b6251dedb363e7a5e372afb29a9a773e691f Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Mon, 31 May 2021 17:09:06 +0530 Subject: [PATCH 4/8] Added migration to update parentRowSpace property of table widget --- app/client/src/constants/WidgetConstants.tsx | 2 +- app/client/src/utils/WidgetPropsUtils.tsx | 6 + .../src/utils/migrations/TableWidget.test.ts | 282 +++++++++++++++++- .../src/utils/migrations/TableWidget.ts | 17 ++ 4 files changed, 305 insertions(+), 2 deletions(-) diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index 9f8cc38859..a1b2807a35 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -96,7 +96,7 @@ export const layoutConfigurations: LayoutConfigurations = { FLUID: { minWidth: -1, maxWidth: -1 }, }; -export const LATEST_PAGE_VERSION = 22; +export const LATEST_PAGE_VERSION = 23; export const GridDefaults = { DEFAULT_CELL_SIZE: 1, diff --git a/app/client/src/utils/WidgetPropsUtils.tsx b/app/client/src/utils/WidgetPropsUtils.tsx index 338c9db8ca..1f580a6abc 100644 --- a/app/client/src/utils/WidgetPropsUtils.tsx +++ b/app/client/src/utils/WidgetPropsUtils.tsx @@ -27,6 +27,7 @@ import log from "loglevel"; import { migrateTablePrimaryColumnsBindings, tableWidgetPropertyPaneMigrations, + migrateTableWidgetParentRowSpaceProperty, } from "utils/migrations/TableWidget"; import { migrateIncorrectDynamicBindingPathLists } from "utils/migrations/IncorrectDynamicBindingPathLists"; import * as Sentry from "@sentry/react"; @@ -755,6 +756,11 @@ const transformDSL = (currentDSL: ContainerWidgetProps) => { canvasWidgets, ); currentDSL = migrateOverFlowingTabsWidgets(currentDSL, canvasWidgets); + currentDSL.version = 22; + } + + if (currentDSL.version === 22) { + currentDSL = migrateTableWidgetParentRowSpaceProperty(currentDSL); currentDSL.version = LATEST_PAGE_VERSION; } diff --git a/app/client/src/utils/migrations/TableWidget.test.ts b/app/client/src/utils/migrations/TableWidget.test.ts index 5715074956..11b0000740 100644 --- a/app/client/src/utils/migrations/TableWidget.test.ts +++ b/app/client/src/utils/migrations/TableWidget.test.ts @@ -1,6 +1,9 @@ import { WidgetProps } from "widgets/BaseWidget"; import { ContainerWidgetProps } from "widgets/ContainerWidget"; -import { tableWidgetPropertyPaneMigrations } from "./TableWidget"; +import { + tableWidgetPropertyPaneMigrations, + migrateTableWidgetParentRowSpaceProperty, +} from "./TableWidget"; const input1: ContainerWidgetProps = { widgetName: "MainContainer", @@ -639,4 +642,281 @@ describe("Table Widget Property Pane Upgrade", () => { const newDsl = tableWidgetPropertyPaneMigrations(input3); expect(JSON.stringify(newDsl) === JSON.stringify(output3)); }); + + it("To test table parentRowSpace is updated", () => { + const inputDsl: ContainerWidgetProps = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1224, + snapColumns: 16, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 1840, + containerStyle: "none", + snapRows: 33, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 7, + minHeight: 1292, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + isLoading: false, + parentId: "", + renderMode: "CANVAS", + children: [ + { + isVisible: true, + label: "Data", + widgetName: "Table1", + searchKey: "", + tableData: + '[\n {\n "id": 2381224,\n "email": "michael.lawson@reqres.in",\n "userName": "Michael Lawson",\n "productName": "Chicken Sandwich",\n "orderAmount": 4.99\n },\n {\n "id": 2736212,\n "email": "lindsay.ferguson@reqres.in",\n "userName": "Lindsay Ferguson",\n "productName": "Tuna Salad",\n "orderAmount": 9.99\n },\n {\n "id": 6788734,\n "email": "tobias.funke@reqres.in",\n "userName": "Tobias Funke",\n "productName": "Beef steak",\n "orderAmount": 19.99\n }\n]', + type: "TABLE_WIDGET", + isLoading: false, + parentColumnSpace: 74, + parentRowSpace: 40, + leftColumn: 0, + rightColumn: 8, + topRow: 19, + bottomRow: 26, + parentId: "0", + widgetId: "fs785w9gcy", + dynamicBindingPathList: [], + primaryColumns: { + id: { + index: 0, + width: 150, + id: "id", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "id", + computedValue: "", + }, + email: { + index: 1, + width: 150, + id: "email", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "email", + computedValue: "", + }, + userName: { + index: 2, + width: 150, + id: "userName", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "userName", + computedValue: "", + }, + productName: { + index: 3, + width: 150, + id: "productName", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "productName", + computedValue: "", + }, + orderAmount: { + index: 4, + width: 150, + id: "orderAmount", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "orderAmount", + computedValue: "", + }, + }, + textSize: "PARAGRAPH", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + renderMode: "CANVAS", + version: 1, + }, + ], + }; + const outputDsl: ContainerWidgetProps = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1224, + snapColumns: 16, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 1840, + containerStyle: "none", + snapRows: 33, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 7, + minHeight: 1292, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + isLoading: false, + parentId: "", + renderMode: "CANVAS", + children: [ + { + isVisible: true, + label: "Data", + widgetName: "Table1", + searchKey: "", + tableData: + '[\n {\n "id": 2381224,\n "email": "michael.lawson@reqres.in",\n "userName": "Michael Lawson",\n "productName": "Chicken Sandwich",\n "orderAmount": 4.99\n },\n {\n "id": 2736212,\n "email": "lindsay.ferguson@reqres.in",\n "userName": "Lindsay Ferguson",\n "productName": "Tuna Salad",\n "orderAmount": 9.99\n },\n {\n "id": 6788734,\n "email": "tobias.funke@reqres.in",\n "userName": "Tobias Funke",\n "productName": "Beef steak",\n "orderAmount": 19.99\n }\n]', + type: "TABLE_WIDGET", + isLoading: false, + parentColumnSpace: 74, + parentRowSpace: 10, + leftColumn: 0, + rightColumn: 8, + topRow: 19, + bottomRow: 26, + parentId: "0", + widgetId: "fs785w9gcy", + dynamicBindingPathList: [], + primaryColumns: { + id: { + index: 0, + width: 150, + id: "id", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "id", + computedValue: "", + }, + email: { + index: 1, + width: 150, + id: "email", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "email", + computedValue: "", + }, + userName: { + index: 2, + width: 150, + id: "userName", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "userName", + computedValue: "", + }, + productName: { + index: 3, + width: 150, + id: "productName", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "productName", + computedValue: "", + }, + orderAmount: { + index: 4, + width: 150, + id: "orderAmount", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + columnType: "text", + textColor: "#231F20", + textSize: "PARAGRAPH", + fontStyle: "REGULAR", + enableFilter: true, + enableSort: true, + isVisible: true, + isDerived: false, + label: "orderAmount", + computedValue: "", + }, + }, + textSize: "PARAGRAPH", + horizontalAlignment: "LEFT", + verticalAlignment: "CENTER", + renderMode: "CANVAS", + version: 1, + }, + ], + }; + const newDsl = migrateTableWidgetParentRowSpaceProperty(inputDsl); + expect(JSON.stringify(newDsl) === JSON.stringify(output1)); + }); }); diff --git a/app/client/src/utils/migrations/TableWidget.ts b/app/client/src/utils/migrations/TableWidget.ts index 7daddef4de..edd976764b 100644 --- a/app/client/src/utils/migrations/TableWidget.ts +++ b/app/client/src/utils/migrations/TableWidget.ts @@ -4,6 +4,7 @@ import { WidgetTypes, FontStyleTypes, TextSizes, + GridDefaults, } from "constants/WidgetConstants"; import { getAllTableColumnKeys } from "components/designSystems/appsmith/TableComponent/TableHelpers"; import { @@ -214,3 +215,19 @@ export const migrateTablePrimaryColumnsBindings = ( }); return currentDSL; }; + +export const migrateTableWidgetParentRowSpaceProperty = ( + currentDSL: ContainerWidgetProps, +) => { + currentDSL.children = currentDSL.children?.map((child: WidgetProps) => { + if (child.type === WidgetTypes.TABLE_WIDGET) { + if (child.parentRowSpace === 40) { + child.parentRowSpace = GridDefaults.DEFAULT_GRID_ROW_HEIGHT; + } + } else if (child.children && child.children.length > 0) { + child = migrateTableWidgetParentRowSpaceProperty(child); + } + return child; + }); + return currentDSL; +}; From 2357f886fcad5bfc5457334d15129847c9ad59c3 Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Wed, 2 Jun 2021 13:34:02 +0530 Subject: [PATCH 5/8] Added wait for route (#4817) * Added wait for route * updated test with datasource route * udpated version and cleanup * updated duplicate app --- .../Applications/DuplicateApplication_spec.js | 2 +- .../ClientSideTests/Applications/ForkApplication_spec.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js index 74f6848425..7cc05bf94f 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js @@ -6,7 +6,7 @@ let duplicateApplicationDsl; describe("Duplicate application", function() { before(() => { - dsl.dsl.version = 21; // latest migrated version + dsl.dsl.version = 23; // latest migrated version cy.addDsl(dsl); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js index 2dc3773ffc..91f4ece082 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js @@ -5,7 +5,7 @@ let forkedApplicationDsl; describe("Fork application across orgs", function() { before(() => { - dsl.dsl.version = 21; // latest migrated version + dsl.dsl.version = 23; // latest migrated version cy.addDsl(dsl); }); @@ -32,12 +32,15 @@ describe("Fork application across orgs", function() { cy.wait("@postForkAppOrg").then((httpResponse) => { expect(httpResponse.status).to.equal(200); }); + cy.get("@getPage").then((httpResponse) => { + expect(httpResponse.status).to.deep.equal(200); + }); // check that forked application has same dsl cy.get("@getPage").then((httpResponse) => { const data = httpResponse.response.body.data; forkedApplicationDsl = data.layouts[0].dsl; - expect(forkedApplicationDsl).to.deep.equal(dsl.dsl); }); + cy.NavigateToHome(); }); }); From 2eff8bd821abe780167c3e30af709920727599b2 Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Mon, 31 May 2021 17:27:00 +0530 Subject: [PATCH 6/8] Fix unused variable issue --- app/client/src/utils/migrations/TableWidget.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/utils/migrations/TableWidget.test.ts b/app/client/src/utils/migrations/TableWidget.test.ts index 11b0000740..a135af9384 100644 --- a/app/client/src/utils/migrations/TableWidget.test.ts +++ b/app/client/src/utils/migrations/TableWidget.test.ts @@ -917,6 +917,6 @@ describe("Table Widget Property Pane Upgrade", () => { ], }; const newDsl = migrateTableWidgetParentRowSpaceProperty(inputDsl); - expect(JSON.stringify(newDsl) === JSON.stringify(output1)); + expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl)); }); }); From c5c0269954e9ebe22bc5dd8b4450680373060319 Mon Sep 17 00:00:00 2001 From: Nidhi Date: Thu, 3 Jun 2021 09:20:47 +0530 Subject: [PATCH 7/8] Default state for mongo actions that were already configured (#4873) * Default state for mongo actions that were already configured * Clean up --- .../server/migrations/DatabaseChangelog.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java index 2a206bb0ce..6058061098 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java @@ -50,6 +50,7 @@ import com.appsmith.server.services.OrganizationService; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cloudyrock.mongock.ChangeLog; import com.github.cloudyrock.mongock.ChangeSet; +import com.github.cloudyrock.mongock.decorator.impl.MongockTemplate; import com.google.gson.Gson; import com.mongodb.MongoClient; import com.mongodb.MongoException; @@ -2277,4 +2278,34 @@ public class DatabaseChangelog { // Delete all the existing mongo datasource structures by setting the key to null. mongoOperations.updateMulti(query, update, Datasource.class); } + + @ChangeSet(order = "069", id = "set-mongo-actions-type-to-raw", author = "") + public void setMongoActionInputToRaw(MongockTemplate mongockTemplate) { + + // All the existing mongo actions at this point will only have ever been in the raw format + // For these actions to be readily available to users, we need to set their input type to raw manually + // This is required because since the mongo form, the default input type on the UI has been set to FORM + Plugin mongoPlugin = mongockTemplate.findOne(query(where("packageName").is("mongo-plugin")), Plugin.class); + + // Fetch all the actions built on top of a mongo database, not having any value set for input type + assert mongoPlugin != null; + List rawMongoActions = mongockTemplate.find( + query(new Criteria().andOperator( + where(fieldName(QNewAction.newAction.pluginId)).is(mongoPlugin.getId()))), + NewAction.class + ) + .stream() + .filter(mongoAction -> { + final List pluginSpecifiedTemplates = mongoAction.getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates(); + return pluginSpecifiedTemplates != null && pluginSpecifiedTemplates.size() == 1; + }) + .collect(Collectors.toList()); + + for (NewAction action : rawMongoActions) { + List pluginSpecifiedTemplates = action.getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates(); + pluginSpecifiedTemplates.add(new Property(null, "RAW")); + + mongockTemplate.save(action); + } + } } From ad9e7e05152696a7b1bd243dc0a2de3a6aafe273 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Thu, 3 Jun 2021 10:58:26 +0530 Subject: [PATCH 8/8] Fix migration NPE --- .../java/com/appsmith/server/migrations/DatabaseChangelog.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java index 6058061098..9d1b3e4d18 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/DatabaseChangelog.java @@ -2296,6 +2296,9 @@ public class DatabaseChangelog { ) .stream() .filter(mongoAction -> { + if (mongoAction.getUnpublishedAction() == null || mongoAction.getUnpublishedAction().getActionConfiguration() == null) { + return false; + } final List pluginSpecifiedTemplates = mongoAction.getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates(); return pluginSpecifiedTemplates != null && pluginSpecifiedTemplates.size() == 1; })