Skip to content

Commit

Permalink
Merge branch 'release' of github.com:appsmithorg/appsmith into release
Browse files Browse the repository at this point in the history
  • Loading branch information
NilanshBansal committed Jun 26, 2023
2 parents 0f40417 + af7e389 commit b44ec5e
Show file tree
Hide file tree
Showing 29 changed files with 679 additions and 435 deletions.
2 changes: 1 addition & 1 deletion .github/config.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ describe("FirstTimeUserOnboarding", function () {
});
cy.get(OnboardingLocator.checklistDeployBtn).should("be.visible");
cy.get(OnboardingLocator.checklistDeployBtn).click();
agHelper.GetNClick(debuggerHelper.locators._helpButton);
agHelper.AssertElementExist(OnboardingLocator.checklistCompletionBanner);
agHelper.AssertElementAbsence(OnboardingLocator.checklistDeployBtn);
cy.window().then((window) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Tests fetch calls", () => {
agHelper.AssertContains("anonymousUser", "exist");
});

it("3. Tests if fetch works with store value", function () {
it.skip("3. Tests if fetch works with store value", function () {
entityExplorer.NavigateToSwitcher("Widgets");
entityExplorer.DragDropWidgetNVerify("buttonwidget", 500, 200);
entityExplorer.SelectEntityByName("Button1");
Expand Down
3 changes: 2 additions & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"scripts": {
"analyze": "yarn cra-bundle-analyzer",
"start": "yarn workspace @shared/ast build && BROWSER=none EXTEND_ESLINT=true REACT_APP_ENVIRONMENT=DEVELOPMENT REACT_APP_CLIENT_LOG_LEVEL=debug HOST=dev.appsmith.com craco start",
"start": "yarn workspace @shared/dsl build && yarn workspace @shared/ast build && BROWSER=none EXTEND_ESLINT=true REACT_APP_ENVIRONMENT=DEVELOPMENT REACT_APP_CLIENT_LOG_LEVEL=debug HOST=dev.appsmith.com craco start",
"build": "./build.sh",
"build-airgap": "node download-assets.js && ./build.sh",
"build-local": "craco --max-old-space-size=4096 build --config craco.build.config.js",
Expand Down Expand Up @@ -62,6 +62,7 @@
"@sentry/react": "^6.2.4",
"@sentry/tracing": "^6.2.4",
"@shared/ast": "workspace:^",
"@shared/dsl": "workspace:^",
"@tanstack/virtual-core": "^3.0.0-beta.18",
"@tinymce/tinymce-react": "^3.13.0",
"@types/google.maps": "^3.51.0",
Expand Down
4 changes: 4 additions & 0 deletions app/client/packages/dsl/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["../../.eslintrc.base.json"],
"ignorePatterns": ["build"]
}
3 changes: 3 additions & 0 deletions app/client/packages/dsl/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage-summary.json
build/
package.json
6 changes: 6 additions & 0 deletions app/client/packages/dsl/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
transform: {
"^.+\\.(png|js|ts|tsx)$": "ts-jest",
},
verbose: true,
};
42 changes: 42 additions & 0 deletions app/client/packages/dsl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@shared/dsl",
"private": true,
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"scripts": {
"test:unit": "jest -b --colors --no-cache --silent --coverage --collectCoverage=true --coverageDirectory='./' --coverageReporters='json-summary'",
"test:jest": "jest --watch",
"lint": "yarn g:lint",
"prettier": "yarn g:prettier",
"build": "rollup -c",
"start": "rollup -c",
"postinstall": "yarn build"
},
"main": "build/index.js",
"module": "build/index.es.js",
"types": "build/index.d.ts",
"files": [
"build"
],
"publishConfig": {
"directory": "build"
},
"dependencies": {
"@babel/runtime": "^7.21.0",
"@rollup/plugin-commonjs": "^22.0.0",
"@types/escodegen": "^0.0.7",
"@types/lodash": "^4.14.120",
"normalizr": "^3.6.2",
"rollup": "^2.77.0",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.32.0",
"typescript": "4.5.5"
},
"devDependencies": {
"jest": "^29.5.0",
"ts-jest": "^29.1.0"
}
}
38 changes: 38 additions & 0 deletions app/client/packages/dsl/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import generatePackageJson from "rollup-plugin-generate-package-json";

const packageJson = require("./package.json");

export default {
// TODO: Figure out regex where each directory can be a separate module without having to manually add them
input: ["./src/index.ts"],
output: [
{
file: packageJson.module,
format: "esm",
sourcemap: true,
},
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
typescript({
useTsconfigDeclarationDir: true,
}),
generatePackageJson({
baseContents: (pkg) => ({
...pkg,
main: "index.js",
module: "index.es.js",
types: "index.d.ts",
}),
}),
],
};
39 changes: 39 additions & 0 deletions app/client/packages/dsl/src/DSL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ROOT_CONTAINER_WIDGET_ID } from "./constants";
import type { NormalizedSchema } from "normalizr";
import { schema, normalize, denormalize } from "normalizr";

export type NestedDSLWidget<W> = W & { children?: NestedDSLWidget<W>[] };
export type NestedDSL<W> = NestedDSLWidget<W>;

export type FlattenedDSLWidget<W> = W & { children?: string[] };
export type FlattenedDSL<W> = { [widgetId: string]: FlattenedDSLWidget<W> };

export type FlattenedDSLEntities<W> = { canvasWidgets: FlattenedDSL<W> };

// Schema by widgetId
const SCHEMA_BY_ID = new schema.Entity(
"canvasWidgets",
{},
{ idAttribute: "widgetId" },
);
SCHEMA_BY_ID.define({ children: [SCHEMA_BY_ID] });

// Normalising using widgetId
export function flattenDSL<W>(nestedDSL: NestedDSL<W>): FlattenedDSL<W> {
const {
entities,
}: NormalizedSchema<FlattenedDSLEntities<W>, string> = normalize(
nestedDSL,
SCHEMA_BY_ID,
);
return entities.canvasWidgets;
}

// Denormalising using widgetId
export function nestDSL<W>(
flattenedDSL: FlattenedDSL<W>,
widgetId: string = ROOT_CONTAINER_WIDGET_ID,
): NestedDSL<W> {
const entities = { canvasWidgets: flattenedDSL };
return denormalize(widgetId, SCHEMA_BY_ID, entities);
}
2 changes: 2 additions & 0 deletions app/client/packages/dsl/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ROOT_CONTAINER_WIDGET_ID = "0";
export const ROOT_CONTAINER_WIDGET_NAME = "MainContainer";
98 changes: 98 additions & 0 deletions app/client/packages/dsl/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { nestDSL, flattenDSL } from "./DSL";
import { ROOT_CONTAINER_WIDGET_ID } from "./constants";

describe("Test #1 - Check export types & constant values", () => {
it("nestDSL is a function", () => {
expect(typeof nestDSL).toBe("function");
});

it("flattenDSL is a function", () => {
expect(typeof flattenDSL).toBe("function");
});

it("ROOT_CONTAINER_WIDGET_ID is a string", () => {
expect(typeof ROOT_CONTAINER_WIDGET_ID).toBe("string");
});

it("ROOT_CONTAINER_WIDGET_ID remains 0", () => {
expect(ROOT_CONTAINER_WIDGET_ID).toBe("0");
});
});

describe("Test #2 - normalize operations on SIMPLE DSL structures", () => {
const simple_dsl = {
widgetId: "0",
widgetName: "MainContainer",
isCanvas: true,
children: [
{
widgetId: "0/0",
widgetName: "Text1",
isCanvas: false,
},
{
widgetId: "0/1",
widgetName: "Container1",
isCanvas: false,
children: [
{
widgetId: "0/1/0",
widgetName: "Canvas1",
isCanvas: true,
children: [
{
widgetId: "0/1/0/0",
widgetName: "Button1",
isCanvas: false,
label: "Click me!",
},
],
},
],
},
],
};
const simple_flat_dsl = {
"0": {
widgetId: "0",
widgetName: "MainContainer",
isCanvas: true,
children: ["0/0", "0/1"],
},
"0/0": {
widgetId: "0/0",
widgetName: "Text1",
isCanvas: false,
},
"0/1": {
widgetId: "0/1",
widgetName: "Container1",
children: ["0/1/0"],
isCanvas: false,
},
"0/1/0": {
widgetId: "0/1/0",
widgetName: "Canvas1",
isCanvas: true,
children: ["0/1/0/0"],
},
"0/1/0/0": {
widgetId: "0/1/0/0",
widgetName: "Button1",
isCanvas: false,
label: "Click me!",
},
};

it("Test `flattenDSL` for simple_dsl", () => {
const flatDSL = flattenDSL<Record<string, any>>(simple_dsl);
expect(flatDSL).toStrictEqual(simple_flat_dsl);
});

it("Test `nestDSL` for simple_flat_dsl", () => {
const nestedDSL = nestDSL(simple_flat_dsl);
expect(nestedDSL).toStrictEqual(simple_dsl);
});
});

export {};
10 changes: 10 additions & 0 deletions app/client/packages/dsl/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export { nestDSL, flattenDSL } from "./DSL";
export { ROOT_CONTAINER_WIDGET_ID } from "./constants";

export type {
NestedDSLWidget,
NestedDSL,
FlattenedDSLWidget,
FlattenedDSL,
FlattenedDSLEntities,
} from "./DSL";
8 changes: 8 additions & 0 deletions app/client/packages/dsl/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"include": ["./src/**/*"],
"compilerOptions": {
"declaration": true,
"declarationDir": "build"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import { debug } from "loglevel";
import { PeekOverlayExpressionIdentifier, SourceType } from "@shared/ast";
import type { MultiplexingModeConfig } from "components/editorComponents/CodeEditor/modes";
import { MULTIPLEXING_MODE_CONFIGS } from "components/editorComponents/CodeEditor/modes";
import { getDeleteLineShortcut } from "./utils/deleteLine";

type ReduxStateProps = ReturnType<typeof mapStateToProps>;
type ReduxDispatchProps = ReturnType<typeof mapDispatchToProps>;
Expand Down Expand Up @@ -379,6 +380,9 @@ class CodeEditor extends Component<Props, State> {
saveAndAutoIndentCode(editor);
AnalyticsUtil.logEvent("PRETTIFY_AND_SAVE_KEYBOARD_SHORTCUT");
},
[getDeleteLineShortcut()]: () => {
return;
},
};

if (this.props.tabBehaviour === TabBehaviour.INPUT) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getPlatformOS } from "utils/helpers";
import { KEYBOARD_SHORTCUTS_BY_PLATFORM } from "./keyboardShortcutConstants";

export const getDeleteLineShortcut = () => {
const platformOS = getPlatformOS() || "default";
return KEYBOARD_SHORTCUTS_BY_PLATFORM[platformOS].deleteLine;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,46 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = {
autoIndentShortcut: "Shift-Cmd-P",
autoIndentShortcutText: "Shift + Cmd + P",
codeComment: "Cmd-/",
deleteLine: "Cmd-D",
},
[PLATFORM_OS.IOS]: {
saveAndAutoIndent: "Cmd-S",
cursorLeftMovement: "Cmd-Left",
autoIndentShortcut: "Shift-Cmd-P",
autoIndentShortcutText: "Shift + Cmd + P",
codeComment: "Cmd-/",
deleteLine: "Cmd-D",
},
[PLATFORM_OS.WINDOWS]: {
saveAndAutoIndent: "Ctrl-S",
cursorLeftMovement: "Home",
autoIndentShortcut: "Shift-Alt-F",
autoIndentShortcutText: "Shift + Alt + F",
codeComment: "Ctrl-/",
deleteLine: "Ctrl-D",
},
[PLATFORM_OS.ANDROID]: {
saveAndAutoIndent: "Ctrl-S",
cursorLeftMovement: "Home",
autoIndentShortcut: "Shift-Alt-F",
autoIndentShortcutText: "Shift + Alt + F",
codeComment: "Ctrl-/",
deleteLine: "Ctrl-D",
},
[PLATFORM_OS.LINUX]: {
saveAndAutoIndent: "Ctrl-S",
cursorLeftMovement: "Home",
autoIndentShortcut: "Shift-Ctrl-I",
autoIndentShortcutText: "Shift + Ctrl + I",
codeComment: "Ctrl-/",
deleteLine: "Ctrl-D",
},
default: {
saveAndAutoIndent: "Ctrl-S",
cursorLeftMovement: "Home",
autoIndentShortcut: "Shift-Alt-F",
autoIndentShortcutText: "Shift + Alt + F",
codeComment: "Ctrl-/",
deleteLine: "Ctrl-D",
},
};
21 changes: 0 additions & 21 deletions app/client/src/normalizers/CanvasWidgetsNormalizer.tsx

This file was deleted.

Loading

0 comments on commit b44ec5e

Please sign in to comment.