Skip to content

Commit

Permalink
Merge pull request #36580 from appsmithorg/release
Browse files Browse the repository at this point in the history
27/09 Daily Promotion
  • Loading branch information
btsgh authored Sep 27, 2024
2 parents c570e72 + 6368215 commit c397bda
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe(
force: true,
})
.type(
"https://www.facebook.com/users/{{Button2.text}}?key=test&val={{Button2.text}}",
"http://host.docker.internal:5001/{{Button2.text}}?key=test&val={{Button2.text}}",
{ force: true, parseSpecialCharSequences: false },
)
.wait(3000)
Expand All @@ -106,7 +106,7 @@ describe(
.type("{enter}", { parseSpecialCharSequences: true });

cy.validateEvaluatedValue(
"https://www.facebook.com/users/Cancel?key=test&val=Cancel",
"http://host.docker.internal:5001/Cancel?key=test&val=Cancel",
);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import React from "react";
import APIEditorForm from "./components/APIEditorForm";
import { Flex } from "@appsmith/ads";
import { useChangeActionCall } from "./hooks/useChangeActionCall";
import { usePluginActionContext } from "../../PluginActionContext";
import { UIComponentTypes } from "api/PluginApi";

const PluginActionForm = () => {
useChangeActionCall();
const { plugin } = usePluginActionContext();

return (
<Flex p="spaces-2" w="100%">
<APIEditorForm />
{plugin.uiComponent === UIComponentTypes.ApiEditorForm ? (
<APIEditorForm />
) : null}
</Flex>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function useGetFormActionValues() {

// In an unlikely scenario where form is not initialised,
// return empty values to avoid form ui issues
if (!isAPIAction(formValues)) {
if (!formValues || !isAPIAction(formValues)) {
return {
actionHeaders: [],
actionParams: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function PluginActionResponse() {
expandedHeight={`${ActionExecutionResizerHeight}px`}
isCollapsed={!open}
onSelect={updateSelectedResponseTab}
selectedTabKey={selectedTab || tabs[0].key}
selectedTabKey={selectedTab || tabs[0]?.key}
tabs={tabs}
/>
</IDEBottomView>
Expand Down
53 changes: 53 additions & 0 deletions app/client/src/widgets/BaseInputWidget/component/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import { render } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import BaseInputComponent, { type BaseInputComponentProps } from "./index";
import { ThemeProvider } from "styled-components";
import { lightTheme } from "selectors/themeSelectors";

const renderBaseInputComponent = (
props: Partial<BaseInputComponentProps> = {},
) => {
const defaultProps: BaseInputComponentProps = {
value: "",
inputType: "TEXT",
inputHTMLType: "TEXT",
disabled: false,
isLoading: false,
compactMode: false,
isInvalid: false,
label: "Salary",
showError: false,
onValueChange: jest.fn(),
onFocusChange: jest.fn(),
widgetId: "test-widget",
rtl: true,
};

return render(
<ThemeProvider theme={lightTheme}>
<BaseInputComponent {...defaultProps} {...props} />
</ThemeProvider>,
);
};

describe("BaseInputComponent TestCases", () => {
test("1. Icon should be visible and aligned to the right when the input type is a number", () => {
const { container } = renderBaseInputComponent({
inputType: "NUMBER",
inputHTMLType: "NUMBER",
value: "123",
onStep: jest.fn(),
rtl: false,
shouldUseLocale: true,
iconName: "add",
iconAlign: "right",
});

const numericInputIcon = container.getElementsByClassName(
"bp3-icon bp3-icon-add",
)[0];

expect(numericInputIcon).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions app/client/src/widgets/BaseInputWidget/component/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ class BaseInputComponent extends React.Component<
onKeyUp={this.onKeyUp}
onValueChange={this.onNumberChange}
placeholder={this.props.placeholder}
rightElement={this.getRightIcon()}
stepSize={this.props.stepSize}
value={this.props.value}
{...conditionalProps}
Expand Down
82 changes: 53 additions & 29 deletions app/client/src/workers/Evaluation/handlers/jsLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,39 +128,31 @@ export async function installLibrary(
// Find keys add that were installed to the global scope.
const keysAfterInstallation = Object.keys(self);

const differentiatingKeys = difference(
let differentiatingKeys = difference(
keysAfterInstallation,
envKeysBeforeInstallation,
);

if (
differentiatingKeys.length > 0 &&
differentiatingKeys.includes("default")
) {
// Changing default export to library specific name
const uniqueName = generateUniqueAccessor(
url,
takenAccessors,
takenNamesMap,
);
// Changing default export to library specific name, if default exported
const uniqueName = generateUniqueAccessor(
url,
takenAccessors,
takenNamesMap,
);

// mapping default functionality to library name accessor
self[uniqueName] = self["default"];
// deleting the reference of default key from the self object
delete self["default"];
// mapping all the references of differentiating keys from the self object to the self[uniqueName] key object
differentiatingKeys.map((key) => {
if (key !== "default") {
self[uniqueName][key] = self[key];
// deleting the references from the self object
delete self[key];
}
});
// pushing the uniqueName to the accessor array
accessors.push(uniqueName);
} else {
accessors.push(...differentiatingKeys);
}
movetheDefaultExportedLibraryToAccessorKey(
differentiatingKeys,
uniqueName,
);

// Following the same process which was happening earlier
const keysAfterDefaultOperation = Object.keys(self);

differentiatingKeys = difference(
keysAfterDefaultOperation,
envKeysBeforeInstallation,
);
accessors.push(...differentiatingKeys);

/**
* Check the list of installed library to see if their values have changed.
Expand Down Expand Up @@ -308,7 +300,18 @@ export async function loadLibraries(
try {
self.importScripts(url);
const keysAfter = Object.keys(self);
const defaultAccessors = difference(keysAfter, keysBefore);
let defaultAccessors = difference(keysAfter, keysBefore);

// Changing default export to library accessors name which was saved when it was installed, if default export present
movetheDefaultExportedLibraryToAccessorKey(
defaultAccessors,
accessors[0],
);

// Following the same process which was happening earlier
const keysAfterDefaultOperation = Object.keys(self);

defaultAccessors = difference(keysAfterDefaultOperation, keysBefore);

/**
* Installing 2 different version of lodash tries to add the same accessor on the self object. Let take version a & b for example.
Expand Down Expand Up @@ -447,3 +450,24 @@ export function flattenModule(module: Record<string, any>) {

return libModule;
}

// This function will update the self keys only when the diffAccessors has default included in it.
function movetheDefaultExportedLibraryToAccessorKey(
diffAccessors: string[],
uniqAccessor: string,
) {
if (diffAccessors.length > 0 && diffAccessors.includes("default")) {
// mapping default functionality to library name accessor
self[uniqAccessor] = self["default"];
// deleting the reference of default key from the self object
delete self["default"];
// mapping all the references of differentiating keys from the self object to the self[uniqAccessor] key object
diffAccessors.map((key) => {
if (key !== "default") {
self[uniqAccessor][key] = self[key];
// deleting the references from the self object
delete self[key];
}
});
}
}

0 comments on commit c397bda

Please sign in to comment.