fix: add overflow property in text-widget (#12160)
This commit is contained in:
parent
e5208b090e
commit
2b47e00a71
|
|
@ -118,9 +118,13 @@ describe("Text Widget color/font/alignment Functionality", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Test to validate enable scroll feature", function() {
|
it("Test to validate enable scroll feature", function() {
|
||||||
cy.get(".t--property-control-enablescroll .bp3-switch").click({
|
cy.selectDropdownValue(
|
||||||
force: true,
|
commonlocators.textOverflowDropdown,
|
||||||
});
|
"Scroll contents",
|
||||||
|
);
|
||||||
|
cy.get(commonlocators.textOverflowDropdown)
|
||||||
|
.last()
|
||||||
|
.should("have.text", "Scroll contents");
|
||||||
cy.wait("@updateLayout");
|
cy.wait("@updateLayout");
|
||||||
cy.get(commonlocators.headingTextStyle).trigger("mouseover", {
|
cy.get(commonlocators.headingTextStyle).trigger("mouseover", {
|
||||||
force: true,
|
force: true,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
const dsl = require("../../../../fixtures/textNewDsl.json");
|
const dsl = require("../../../../fixtures/textNewDsl.json");
|
||||||
|
const commonlocators = require("../../../../locators/commonlocators.json");
|
||||||
|
|
||||||
describe("Text Widget Truncate Functionality", function() {
|
describe("Text Widget Truncate Functionality", function() {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.addDsl(dsl);
|
cy.addDsl(dsl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Check default overflow property is No overflow", function() {
|
||||||
|
cy.openPropertyPane("textwidget");
|
||||||
|
cy.get(commonlocators.textOverflowDropdown)
|
||||||
|
.last()
|
||||||
|
.should("have.text", "No overflow");
|
||||||
|
cy.closePropertyPane();
|
||||||
|
});
|
||||||
|
|
||||||
it("Validate long text is not truncating in default", function() {
|
it("Validate long text is not truncating in default", function() {
|
||||||
cy.get(
|
cy.get(
|
||||||
`.appsmith_widget_${dsl.dsl.children[0].widgetId} .t--draggable-textwidget`,
|
`.appsmith_widget_${dsl.dsl.children[0].widgetId} .t--draggable-textwidget`,
|
||||||
|
|
@ -23,7 +32,13 @@ describe("Text Widget Truncate Functionality", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Enable Truncate Text option and Validate", function() {
|
it("Enable Truncate Text option and Validate", function() {
|
||||||
cy.get(".t--property-control-truncatetext > .bp3-switch").click();
|
cy.selectDropdownValue(
|
||||||
|
commonlocators.textOverflowDropdown,
|
||||||
|
"Truncate text",
|
||||||
|
);
|
||||||
|
cy.get(commonlocators.textOverflowDropdown)
|
||||||
|
.last()
|
||||||
|
.should("have.text", "Truncate text");
|
||||||
cy.wait("@updateLayout");
|
cy.wait("@updateLayout");
|
||||||
cy.get(
|
cy.get(
|
||||||
`.appsmith_widget_${dsl.dsl.children[0].widgetId} .t--widget-textwidget-truncate`,
|
`.appsmith_widget_${dsl.dsl.children[0].widgetId} .t--widget-textwidget-truncate`,
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@
|
||||||
"filePickerOnFilesSelected": ".t--property-control-onfilesselected",
|
"filePickerOnFilesSelected": ".t--property-control-onfilesselected",
|
||||||
"dataType": ".t--property-control-datatype .bp3-popover-target",
|
"dataType": ".t--property-control-datatype .bp3-popover-target",
|
||||||
"recaptchaVersion": ".t--property-control-googlerecaptchaversion .bp3-popover-target",
|
"recaptchaVersion": ".t--property-control-googlerecaptchaversion .bp3-popover-target",
|
||||||
|
"textOverflowDropdown": ".t--property-control-overflow .bp3-popover-target",
|
||||||
"jsonFormFieldType": ".t--property-control-fieldtype .bp3-popover-target",
|
"jsonFormFieldType": ".t--property-control-fieldtype .bp3-popover-target",
|
||||||
"jsonFormAddNewCustomFieldBtn": ".t--property-control-fieldconfiguration .t--add-column-btn",
|
"jsonFormAddNewCustomFieldBtn": ".t--property-control-fieldconfiguration .t--add-column-btn",
|
||||||
"evaluateMsg": ".t--evaluatedPopup-error",
|
"evaluateMsg": ".t--evaluatedPopup-error",
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ export const layoutConfigurations: LayoutConfigurations = {
|
||||||
FLUID: { minWidth: -1, maxWidth: -1 },
|
FLUID: { minWidth: -1, maxWidth: -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LATEST_PAGE_VERSION = 53;
|
export const LATEST_PAGE_VERSION = 54;
|
||||||
|
|
||||||
export const GridDefaults = {
|
export const GridDefaults = {
|
||||||
DEFAULT_CELL_SIZE: 1,
|
DEFAULT_CELL_SIZE: 1,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ import {
|
||||||
isSortableMigration,
|
isSortableMigration,
|
||||||
migrateTableWidgetIconButtonVariant,
|
migrateTableWidgetIconButtonVariant,
|
||||||
} from "./migrations/TableWidget";
|
} from "./migrations/TableWidget";
|
||||||
import { migrateTextStyleFromTextWidget } from "./migrations/TextWidgetReplaceTextStyle";
|
import {
|
||||||
|
migrateTextStyleFromTextWidget,
|
||||||
|
migrateScrollTruncateProperties,
|
||||||
|
} from "./migrations/TextWidget";
|
||||||
import { DATA_BIND_REGEX_GLOBAL } from "constants/BindingsConstants";
|
import { DATA_BIND_REGEX_GLOBAL } from "constants/BindingsConstants";
|
||||||
import { theme } from "constants/DefaultTheme";
|
import { theme } from "constants/DefaultTheme";
|
||||||
import { getCanvasSnapRows } from "./WidgetPropsUtils";
|
import { getCanvasSnapRows } from "./WidgetPropsUtils";
|
||||||
|
|
@ -1056,6 +1059,11 @@ export const transformDSL = (
|
||||||
|
|
||||||
if (currentDSL.version === 52) {
|
if (currentDSL.version === 52) {
|
||||||
currentDSL = migrateModalIconButtonWidget(currentDSL);
|
currentDSL = migrateModalIconButtonWidget(currentDSL);
|
||||||
|
currentDSL.version = 53;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentDSL.version === 53) {
|
||||||
|
currentDSL = migrateScrollTruncateProperties(currentDSL);
|
||||||
currentDSL.version = LATEST_PAGE_VERSION;
|
currentDSL.version = LATEST_PAGE_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { transformDSL } from "./DSLMigrations";
|
||||||
import { LATEST_PAGE_VERSION, RenderModes } from "constants/WidgetConstants";
|
import { LATEST_PAGE_VERSION, RenderModes } from "constants/WidgetConstants";
|
||||||
import { ContainerWidgetProps } from "widgets/ContainerWidget/widget";
|
import { ContainerWidgetProps } from "widgets/ContainerWidget/widget";
|
||||||
import { WidgetProps } from "widgets/BaseWidget";
|
import { WidgetProps } from "widgets/BaseWidget";
|
||||||
|
import { OverflowTypes } from "widgets/TextWidget/constants";
|
||||||
|
|
||||||
describe("correctly migrate dsl", () => {
|
describe("correctly migrate dsl", () => {
|
||||||
it("AddsPrivateWidgetsToAllListWidgets", () => {
|
it("AddsPrivateWidgetsToAllListWidgets", () => {
|
||||||
|
|
@ -975,7 +976,6 @@ describe("correctly migrate dsl", () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
leftColumn: 16,
|
leftColumn: 16,
|
||||||
shouldTruncate: false,
|
|
||||||
truncateButtonColor: "#FFC13D",
|
truncateButtonColor: "#FFC13D",
|
||||||
text: "{{currentItem.name}}",
|
text: "{{currentItem.name}}",
|
||||||
key: "yd217bk315",
|
key: "yd217bk315",
|
||||||
|
|
@ -1019,7 +1019,7 @@ describe("correctly migrate dsl", () => {
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
fontStyle: "BOLD",
|
fontStyle: "BOLD",
|
||||||
textColor: "#231F20",
|
textColor: "#231F20",
|
||||||
shouldScroll: false,
|
overflow: OverflowTypes.NONE,
|
||||||
version: 1,
|
version: 1,
|
||||||
parentId: "vqn2okwc6a",
|
parentId: "vqn2okwc6a",
|
||||||
renderMode: "CANVAS",
|
renderMode: "CANVAS",
|
||||||
|
|
@ -1043,7 +1043,6 @@ describe("correctly migrate dsl", () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
leftColumn: 16,
|
leftColumn: 16,
|
||||||
shouldTruncate: false,
|
|
||||||
truncateButtonColor: "#FFC13D",
|
truncateButtonColor: "#FFC13D",
|
||||||
text: "{{currentItem.id}}",
|
text: "{{currentItem.id}}",
|
||||||
key: "yd217bk315",
|
key: "yd217bk315",
|
||||||
|
|
@ -1087,7 +1086,7 @@ describe("correctly migrate dsl", () => {
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
fontStyle: "BOLD",
|
fontStyle: "BOLD",
|
||||||
textColor: "#231F20",
|
textColor: "#231F20",
|
||||||
shouldScroll: false,
|
overflow: OverflowTypes.NONE,
|
||||||
version: 1,
|
version: 1,
|
||||||
parentId: "vqn2okwc6a",
|
parentId: "vqn2okwc6a",
|
||||||
renderMode: "CANVAS",
|
renderMode: "CANVAS",
|
||||||
|
|
|
||||||
618
app/client/src/utils/migrations/TextWidget.test.ts
Normal file
618
app/client/src/utils/migrations/TextWidget.test.ts
Normal file
|
|
@ -0,0 +1,618 @@
|
||||||
|
import {
|
||||||
|
migrateTextStyleFromTextWidget,
|
||||||
|
migrateScrollTruncateProperties,
|
||||||
|
} from "utils/migrations/TextWidget";
|
||||||
|
import { FontStyleTypes, TextSizes } from "constants/WidgetConstants";
|
||||||
|
import { DSLWidget } from "widgets/constants";
|
||||||
|
import { OverflowTypes } from "widgets/TextWidget/constants";
|
||||||
|
|
||||||
|
const inputDsl1: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textStyle: "LABEL",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputDsl2: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textStyle: "HEADING",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputDsl3: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textStyle: "BODY",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl1: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl2: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.HEADING1,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl3: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("Text Widget Property Pane Upgrade", () => {
|
||||||
|
it("To test text widget textStyle property is migrated", () => {
|
||||||
|
const newDsl = migrateTextStyleFromTextWidget(inputDsl1);
|
||||||
|
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl1));
|
||||||
|
});
|
||||||
|
it("To test text widget textStyle property is migrated", () => {
|
||||||
|
const newDsl = migrateTextStyleFromTextWidget(inputDsl2);
|
||||||
|
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl2));
|
||||||
|
});
|
||||||
|
it("To test text widget textStyle property is migrated", () => {
|
||||||
|
const newDsl = migrateTextStyleFromTextWidget(inputDsl3);
|
||||||
|
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl3));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputDsl4: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
shouldScroll: true,
|
||||||
|
shouldTruncate: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl4: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
overflow: OverflowTypes.SCROLL,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputDsl5: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
shouldScroll: true,
|
||||||
|
shouldTruncate: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl5: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
overflow: OverflowTypes.TRUNCATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputDsl6: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
shouldScroll: false,
|
||||||
|
shouldTruncate: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const outputDsl6: DSLWidget = {
|
||||||
|
widgetName: "MainContainer",
|
||||||
|
backgroundColor: "none",
|
||||||
|
rightColumn: 1118,
|
||||||
|
snapColumns: 16,
|
||||||
|
detachFromLayout: true,
|
||||||
|
widgetId: "0",
|
||||||
|
topRow: 0,
|
||||||
|
bottomRow: 1280,
|
||||||
|
containerStyle: "none",
|
||||||
|
snapRows: 33,
|
||||||
|
parentRowSpace: 1,
|
||||||
|
type: "CANVAS_WIDGET",
|
||||||
|
canExtend: true,
|
||||||
|
version: 15,
|
||||||
|
minHeight: 1292,
|
||||||
|
parentColumnSpace: 1,
|
||||||
|
dynamicTriggerPathList: [],
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
leftColumn: 0,
|
||||||
|
isLoading: false,
|
||||||
|
parentId: "",
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
isVisible: true,
|
||||||
|
text: "Label",
|
||||||
|
textAlign: "LEFT",
|
||||||
|
widgetName: "Text1",
|
||||||
|
version: 1,
|
||||||
|
type: "TEXT_WIDGET",
|
||||||
|
isLoading: false,
|
||||||
|
parentColumnSpace: 67.375,
|
||||||
|
parentRowSpace: 40,
|
||||||
|
leftColumn: 3,
|
||||||
|
rightColumn: 7,
|
||||||
|
topRow: 1,
|
||||||
|
bottomRow: 2,
|
||||||
|
parentId: "0",
|
||||||
|
widgetId: "yf8bhokz7d",
|
||||||
|
dynamicBindingPathList: [],
|
||||||
|
fontSize: TextSizes.PARAGRAPH,
|
||||||
|
fontStyle: FontStyleTypes.BOLD,
|
||||||
|
renderMode: "CANVAS",
|
||||||
|
overflow: OverflowTypes.NONE,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("Text Widget Scroll and Truncate Property migrate", () => {
|
||||||
|
it("Overflow value should be SCROLL instead of shouldScroll true", () => {
|
||||||
|
const newDsl = migrateScrollTruncateProperties(inputDsl4);
|
||||||
|
expect(newDsl).toEqual(outputDsl4);
|
||||||
|
});
|
||||||
|
it("Overflow value should be TRUNCATE instead of shouldTruncate true", () => {
|
||||||
|
const newDsl = migrateScrollTruncateProperties(inputDsl5);
|
||||||
|
expect(newDsl).toEqual(outputDsl5);
|
||||||
|
});
|
||||||
|
it("Overflow value should be NONE in case of shouldScroll and shouldTruncate are false", () => {
|
||||||
|
const newDsl = migrateScrollTruncateProperties(inputDsl6);
|
||||||
|
expect(newDsl).toEqual(outputDsl6);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { WidgetProps } from "widgets/BaseWidget";
|
import { WidgetProps } from "widgets/BaseWidget";
|
||||||
import { FontStyleTypes, TextSizes } from "constants/WidgetConstants";
|
import { FontStyleTypes, TextSizes } from "constants/WidgetConstants";
|
||||||
import { DSLWidget } from "widgets/constants";
|
import { DSLWidget } from "widgets/constants";
|
||||||
|
import { OverflowTypes } from "widgets/TextWidget/constants";
|
||||||
|
|
||||||
export const migrateTextStyleFromTextWidget = (
|
export const migrateTextStyleFromTextWidget = (
|
||||||
currentDSL: DSLWidget,
|
currentDSL: DSLWidget,
|
||||||
|
|
@ -33,3 +34,25 @@ export const migrateTextStyleFromTextWidget = (
|
||||||
});
|
});
|
||||||
return currentDSL;
|
return currentDSL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const migrateScrollTruncateProperties = (
|
||||||
|
currentDSL: DSLWidget,
|
||||||
|
): DSLWidget => {
|
||||||
|
currentDSL.children = currentDSL.children?.map((child: WidgetProps) => {
|
||||||
|
if (child.type === "TEXT_WIDGET") {
|
||||||
|
if (child.shouldTruncate) {
|
||||||
|
child.overflow = OverflowTypes.TRUNCATE;
|
||||||
|
} else if (child.shouldScroll) {
|
||||||
|
child.overflow = OverflowTypes.SCROLL;
|
||||||
|
} else {
|
||||||
|
child.overflow = OverflowTypes.NONE;
|
||||||
|
}
|
||||||
|
delete child.shouldScroll;
|
||||||
|
delete child.shouldTruncate;
|
||||||
|
} else if (child.children && child.children.length > 0) {
|
||||||
|
child = migrateScrollTruncateProperties(child);
|
||||||
|
}
|
||||||
|
return child;
|
||||||
|
});
|
||||||
|
return currentDSL;
|
||||||
|
};
|
||||||
|
|
@ -1,302 +0,0 @@
|
||||||
import { migrateTextStyleFromTextWidget } from "utils/migrations/TextWidgetReplaceTextStyle";
|
|
||||||
import { FontStyleTypes, TextSizes } from "constants/WidgetConstants";
|
|
||||||
import { DSLWidget } from "widgets/constants";
|
|
||||||
|
|
||||||
const inputDsl1: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textStyle: "LABEL",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const inputDsl2: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textStyle: "HEADING",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const inputDsl3: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textStyle: "BODY",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const outputDsl1: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
fontSize: TextSizes.PARAGRAPH,
|
|
||||||
fontStyle: FontStyleTypes.BOLD,
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const outputDsl2: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
fontSize: TextSizes.HEADING1,
|
|
||||||
fontStyle: FontStyleTypes.BOLD,
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const outputDsl3: DSLWidget = {
|
|
||||||
widgetName: "MainContainer",
|
|
||||||
backgroundColor: "none",
|
|
||||||
rightColumn: 1118,
|
|
||||||
snapColumns: 16,
|
|
||||||
detachFromLayout: true,
|
|
||||||
widgetId: "0",
|
|
||||||
topRow: 0,
|
|
||||||
bottomRow: 1280,
|
|
||||||
containerStyle: "none",
|
|
||||||
snapRows: 33,
|
|
||||||
parentRowSpace: 1,
|
|
||||||
type: "CANVAS_WIDGET",
|
|
||||||
canExtend: true,
|
|
||||||
version: 15,
|
|
||||||
minHeight: 1292,
|
|
||||||
parentColumnSpace: 1,
|
|
||||||
dynamicTriggerPathList: [],
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
leftColumn: 0,
|
|
||||||
isLoading: false,
|
|
||||||
parentId: "",
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
isVisible: true,
|
|
||||||
text: "Label",
|
|
||||||
textAlign: "LEFT",
|
|
||||||
widgetName: "Text1",
|
|
||||||
version: 1,
|
|
||||||
type: "TEXT_WIDGET",
|
|
||||||
isLoading: false,
|
|
||||||
parentColumnSpace: 67.375,
|
|
||||||
parentRowSpace: 40,
|
|
||||||
leftColumn: 3,
|
|
||||||
rightColumn: 7,
|
|
||||||
topRow: 1,
|
|
||||||
bottomRow: 2,
|
|
||||||
parentId: "0",
|
|
||||||
widgetId: "yf8bhokz7d",
|
|
||||||
dynamicBindingPathList: [],
|
|
||||||
fontSize: TextSizes.PARAGRAPH,
|
|
||||||
renderMode: "CANVAS",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("Text Widget Property Pane Upgrade", () => {
|
|
||||||
it("To test text widget textStyle property is migrated", () => {
|
|
||||||
const newDsl = migrateTextStyleFromTextWidget(inputDsl1);
|
|
||||||
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl1));
|
|
||||||
});
|
|
||||||
it("To test text widget textStyle property is migrated", () => {
|
|
||||||
const newDsl = migrateTextStyleFromTextWidget(inputDsl2);
|
|
||||||
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl2));
|
|
||||||
});
|
|
||||||
it("To test text widget textStyle property is migrated", () => {
|
|
||||||
const newDsl = migrateTextStyleFromTextWidget(inputDsl3);
|
|
||||||
expect(JSON.stringify(newDsl) === JSON.stringify(outputDsl3));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -13,6 +13,7 @@ import Icon, { IconSize } from "components/ads/Icon";
|
||||||
import { isEqual, get } from "lodash";
|
import { isEqual, get } from "lodash";
|
||||||
import ModalComponent from "components/designSystems/appsmith/ModalComponent";
|
import ModalComponent from "components/designSystems/appsmith/ModalComponent";
|
||||||
import { Colors } from "constants/Colors";
|
import { Colors } from "constants/Colors";
|
||||||
|
import { OverflowTypes } from "../constants";
|
||||||
|
|
||||||
export type TextAlign = "LEFT" | "CENTER" | "RIGHT" | "JUSTIFY";
|
export type TextAlign = "LEFT" | "CENTER" | "RIGHT" | "JUSTIFY";
|
||||||
|
|
||||||
|
|
@ -94,8 +95,7 @@ const StyledIcon = styled(Icon)<{ backgroundColor?: string }>`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const StyledText = styled(Text)<{
|
export const StyledText = styled(Text)<{
|
||||||
scroll: boolean;
|
overflow: OverflowTypes;
|
||||||
truncate: boolean;
|
|
||||||
isTruncated: boolean;
|
isTruncated: boolean;
|
||||||
textAlign: string;
|
textAlign: string;
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
|
|
@ -104,10 +104,15 @@ export const StyledText = styled(Text)<{
|
||||||
fontSize?: TextSize;
|
fontSize?: TextSize;
|
||||||
}>`
|
}>`
|
||||||
height: ${(props) =>
|
height: ${(props) =>
|
||||||
props.isTruncated ? `calc(100% - ${ELLIPSIS_HEIGHT}px)` : "100%"};
|
props.overflow === OverflowTypes.TRUNCATE
|
||||||
|
? `calc(100% - ${ELLIPSIS_HEIGHT}px)`
|
||||||
|
: "100%"};
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: ${(props) =>
|
overflow-y: ${(props) =>
|
||||||
props.scroll ? (props.isTruncated ? "hidden" : "auto") : "hidden"};
|
props.overflow !== OverflowTypes.SCROLL ||
|
||||||
|
props.overflow === OverflowTypes.TRUNCATE.valueOf()
|
||||||
|
? "hidden"
|
||||||
|
: "auto"};
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
text-align: ${(props) => props.textAlign.toLowerCase()};
|
text-align: ${(props) => props.textAlign.toLowerCase()};
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -115,7 +120,10 @@ export const StyledText = styled(Text)<{
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex-direction: ${(props) => (props.isTruncated ? "column" : "unset")};
|
flex-direction: ${(props) => (props.isTruncated ? "column" : "unset")};
|
||||||
align-items: ${(props) =>
|
align-items: ${(props) =>
|
||||||
props.scroll || props.truncate ? "flex-start" : "center"};
|
props.overflow === OverflowTypes.SCROLL ||
|
||||||
|
props.overflow === OverflowTypes.TRUNCATE
|
||||||
|
? "flex-start"
|
||||||
|
: "center"};
|
||||||
background: ${(props) => props?.backgroundColor};
|
background: ${(props) => props?.backgroundColor};
|
||||||
color: ${(props) => props?.textColor};
|
color: ${(props) => props?.textColor};
|
||||||
font-style: ${(props) =>
|
font-style: ${(props) =>
|
||||||
|
|
@ -185,13 +193,12 @@ export interface TextComponentProps extends ComponentProps {
|
||||||
ellipsize?: boolean;
|
ellipsize?: boolean;
|
||||||
fontSize?: TextSize;
|
fontSize?: TextSize;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
shouldScroll?: boolean;
|
|
||||||
backgroundColor?: string;
|
backgroundColor?: string;
|
||||||
textColor?: string;
|
textColor?: string;
|
||||||
fontStyle?: string;
|
fontStyle?: string;
|
||||||
disableLink: boolean;
|
disableLink: boolean;
|
||||||
shouldTruncate: boolean;
|
|
||||||
truncateButtonColor?: string;
|
truncateButtonColor?: string;
|
||||||
|
overflow: OverflowTypes;
|
||||||
// helpers to detect and re-calculate content width
|
// helpers to detect and re-calculate content width
|
||||||
bottomRow?: number;
|
bottomRow?: number;
|
||||||
leftColumn?: number;
|
leftColumn?: number;
|
||||||
|
|
@ -225,7 +232,7 @@ class TextComponent extends React.Component<TextComponentProps, State> {
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
const textRef = get(this.textRef, "current.textRef");
|
const textRef = get(this.textRef, "current.textRef");
|
||||||
if (textRef && this.props.shouldTruncate) {
|
if (textRef && this.props.overflow === OverflowTypes.TRUNCATE) {
|
||||||
const isTruncated = this.getTruncate(textRef);
|
const isTruncated = this.getTruncate(textRef);
|
||||||
this.setState({ isTruncated });
|
this.setState({ isTruncated });
|
||||||
}
|
}
|
||||||
|
|
@ -233,13 +240,16 @@ class TextComponent extends React.Component<TextComponentProps, State> {
|
||||||
|
|
||||||
componentDidUpdate = (prevProps: TextComponentProps) => {
|
componentDidUpdate = (prevProps: TextComponentProps) => {
|
||||||
if (!isEqual(prevProps, this.props)) {
|
if (!isEqual(prevProps, this.props)) {
|
||||||
if (this.props.shouldTruncate) {
|
if (this.props.overflow === OverflowTypes.TRUNCATE) {
|
||||||
const textRef = get(this.textRef, "current.textRef");
|
const textRef = get(this.textRef, "current.textRef");
|
||||||
if (textRef) {
|
if (textRef) {
|
||||||
const isTruncated = this.getTruncate(textRef);
|
const isTruncated = this.getTruncate(textRef);
|
||||||
this.setState({ isTruncated });
|
this.setState({ isTruncated });
|
||||||
}
|
}
|
||||||
} else if (prevProps.shouldTruncate && !this.props.shouldTruncate) {
|
} else if (
|
||||||
|
prevProps.overflow === OverflowTypes.TRUNCATE &&
|
||||||
|
this.props.overflow !== OverflowTypes.TRUNCATE.valueOf()
|
||||||
|
) {
|
||||||
this.setState({ isTruncated: false });
|
this.setState({ isTruncated: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,8 +270,7 @@ class TextComponent extends React.Component<TextComponentProps, State> {
|
||||||
ellipsize,
|
ellipsize,
|
||||||
fontSize,
|
fontSize,
|
||||||
fontStyle,
|
fontStyle,
|
||||||
shouldScroll,
|
overflow,
|
||||||
shouldTruncate,
|
|
||||||
text,
|
text,
|
||||||
textAlign,
|
textAlign,
|
||||||
textColor,
|
textColor,
|
||||||
|
|
@ -278,11 +287,10 @@ class TextComponent extends React.Component<TextComponentProps, State> {
|
||||||
fontSize={fontSize}
|
fontSize={fontSize}
|
||||||
fontStyle={fontStyle}
|
fontStyle={fontStyle}
|
||||||
isTruncated={this.state.isTruncated}
|
isTruncated={this.state.isTruncated}
|
||||||
|
overflow={overflow}
|
||||||
ref={this.textRef}
|
ref={this.textRef}
|
||||||
scroll={!!shouldScroll}
|
|
||||||
textAlign={textAlign}
|
textAlign={textAlign}
|
||||||
textColor={textColor}
|
textColor={textColor}
|
||||||
truncate={!!shouldTruncate}
|
|
||||||
>
|
>
|
||||||
<Interweave
|
<Interweave
|
||||||
content={text}
|
content={text}
|
||||||
|
|
|
||||||
5
app/client/src/widgets/TextWidget/constants.ts
Normal file
5
app/client/src/widgets/TextWidget/constants.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export enum OverflowTypes {
|
||||||
|
SCROLL = "SCROLL",
|
||||||
|
TRUNCATE = "TRUNCATE",
|
||||||
|
NONE = "NONE",
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { OverflowTypes } from "./constants";
|
||||||
import IconSVG from "./icon.svg";
|
import IconSVG from "./icon.svg";
|
||||||
import Widget from "./widget";
|
import Widget from "./widget";
|
||||||
|
|
||||||
|
|
@ -15,8 +16,8 @@ export const CONFIG = {
|
||||||
rows: 4,
|
rows: 4,
|
||||||
columns: 16,
|
columns: 16,
|
||||||
widgetName: "Text",
|
widgetName: "Text",
|
||||||
shouldScroll: false,
|
|
||||||
shouldTruncate: false,
|
shouldTruncate: false,
|
||||||
|
overflow: OverflowTypes.NONE,
|
||||||
version: 1,
|
version: 1,
|
||||||
animateLoading: true,
|
animateLoading: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
||||||
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget";
|
||||||
import TextComponent, { TextAlign } from "../component";
|
import TextComponent, { TextAlign } from "../component";
|
||||||
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
import { AutocompleteDataType } from "utils/autocomplete/TernServer";
|
||||||
|
import { OverflowTypes } from "../constants";
|
||||||
|
|
||||||
class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
||||||
static getPropertyPaneConfig() {
|
static getPropertyPaneConfig() {
|
||||||
|
|
@ -33,18 +34,25 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
propertyName: "shouldScroll",
|
propertyName: "overflow",
|
||||||
label: "Enable Scroll",
|
label: "Overflow",
|
||||||
helpText: "Allows scrolling text instead of truncation",
|
helpText: "Controls the text behavior when length of text exceeds",
|
||||||
controlType: "SWITCH",
|
controlType: "DROP_DOWN",
|
||||||
isBindProperty: false,
|
options: [
|
||||||
isTriggerProperty: false,
|
{
|
||||||
},
|
label: "Scroll contents",
|
||||||
{
|
value: OverflowTypes.SCROLL,
|
||||||
propertyName: "shouldTruncate",
|
},
|
||||||
label: "Truncate Text",
|
{
|
||||||
helpText: "Set truncate text",
|
label: "Truncate text",
|
||||||
controlType: "SWITCH",
|
value: OverflowTypes.TRUNCATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "No overflow",
|
||||||
|
value: OverflowTypes.NONE,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
defaultValue: OverflowTypes.NONE,
|
||||||
isBindProperty: false,
|
isBindProperty: false,
|
||||||
isTriggerProperty: false,
|
isTriggerProperty: false,
|
||||||
},
|
},
|
||||||
|
|
@ -130,9 +138,9 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
||||||
regex: /^(?![<|{{]).+/,
|
regex: /^(?![<|{{]).+/,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dependencies: ["shouldTruncate"],
|
dependencies: ["overflow"],
|
||||||
hidden: (props: TextWidgetProps) => {
|
hidden: (props: TextWidgetProps) => {
|
||||||
return !props.shouldTruncate;
|
return props.overflow !== OverflowTypes.TRUNCATE;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -275,9 +283,8 @@ class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
||||||
isLoading={this.props.isLoading}
|
isLoading={this.props.isLoading}
|
||||||
key={this.props.widgetId}
|
key={this.props.widgetId}
|
||||||
leftColumn={this.props.leftColumn}
|
leftColumn={this.props.leftColumn}
|
||||||
|
overflow={this.props.overflow}
|
||||||
rightColumn={this.props.rightColumn}
|
rightColumn={this.props.rightColumn}
|
||||||
shouldScroll={this.props.shouldScroll}
|
|
||||||
shouldTruncate={this.props.shouldTruncate}
|
|
||||||
text={this.props.text}
|
text={this.props.text}
|
||||||
textAlign={this.props.textAlign ? this.props.textAlign : "LEFT"}
|
textAlign={this.props.textAlign ? this.props.textAlign : "LEFT"}
|
||||||
textColor={this.props.textColor}
|
textColor={this.props.textColor}
|
||||||
|
|
@ -315,9 +322,8 @@ export interface TextWidgetProps
|
||||||
WidgetStyleContainerProps {
|
WidgetStyleContainerProps {
|
||||||
text?: string;
|
text?: string;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
shouldScroll: boolean;
|
|
||||||
shouldTruncate: boolean;
|
|
||||||
disableLink: boolean;
|
disableLink: boolean;
|
||||||
|
overflow: OverflowTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TextWidget;
|
export default TextWidget;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user