Skip to content

Commit

Permalink
Merge pull request #33949 from appsmithorg/release
Browse files Browse the repository at this point in the history
04/06 Daily Promotion
  • Loading branch information
trishaanand committed Jun 4, 2024
2 parents 9fd3b85 + d967cfe commit 1f33834
Show file tree
Hide file tree
Showing 24 changed files with 756 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ function TextArea(props: TextAreaProps, ref: TextAreaRef) {
}
input.style.alignSelf = "start";
input.style.height = "auto";
// offsetHeight - clientHeight accounts for the border/padding.

const computedStyle = getComputedStyle(input);
const paddingTop = parseFloat(computedStyle.paddingTop);
const paddingBottom = parseFloat(computedStyle.paddingBottom);
input.style.height = `${
input.scrollHeight + (input.offsetHeight - input.clientHeight)
// subtract comptued padding and border to get the actual content height
input.scrollHeight -
paddingTop -
paddingBottom +
// Also, adding 1px to fix a bug in browser where there is a scrolllbar on certain heights
1
}px`;
input.style.overflow = prevOverflow;
input.style.alignSelf = prevAlignment;
Expand Down
1 change: 1 addition & 0 deletions app/client/src/ce/api/ApplicationApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export interface UpdateApplicationResponse {
isPublic: boolean;
pages: PageDefaultMeta[];
appIsExample: boolean;
unreadCommentThreads: number;
color: string;
icon: IconNames;
slug: string;
Expand Down
68 changes: 28 additions & 40 deletions app/client/src/pages/Editor/PropertyPane/PropertyPaneView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { IPanelProps } from "@blueprintjs/core";
import equal from "fast-deep-equal/es6";
import type { ReactElement } from "react";
import React, {
useCallback,
Expand All @@ -6,47 +8,44 @@ import React, {
useMemo,
useRef,
} from "react";
import equal from "fast-deep-equal/es6";
import { useDispatch, useSelector } from "react-redux";
import { getWidgetPropsForPropertyPane } from "selectors/propertyPaneSelectors";
import type { IPanelProps } from "@blueprintjs/core";

import PropertyPaneTitle from "./PropertyPaneTitle";
import PropertyControlsGenerator from "./PropertyControlsGenerator";
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import {
BINDING_WIDGET_WALKTHROUGH_DESC,
BINDING_WIDGET_WALKTHROUGH_TITLE,
createMessage,
} from "@appsmith/constants/messages";
import { AB_TESTING_EVENT_KEYS } from "@appsmith/entities/FeatureFlag";
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
import WidgetFactory from "WidgetProvider/factory";
import { copyWidget, deleteSelectedWidget } from "actions/widgetActions";
import ConnectDataCTA, { actionsExist } from "./ConnectDataCTA";
import PropertyPaneConnections from "./PropertyPaneConnections";
import { EditorTheme } from "components/editorComponents/CodeEditor/EditorConfig";
import { PROPERTY_PANE_ID } from "components/editorComponents/PropertyPaneSidebar";
import WalkthroughContext from "components/featureWalkthrough/walkthroughContext";
import { FEATURE_WALKTHROUGH_KEYS } from "constants/WalkthroughConstants";
import type { WidgetType } from "constants/WidgetConstants";
import { WIDGET_ID_SHOW_WALKTHROUGH } from "constants/WidgetConstants";
import { Button } from "design-system";
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
import { getWidgets } from "sagas/selectors";
import { getCurrentUser } from "selectors/usersSelectors";
import type { InteractionAnalyticsEventDetail } from "utils/AppsmithUtils";
import { INTERACTION_ANALYTICS_EVENT } from "utils/AppsmithUtils";
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
import { buildDeprecationWidgetMessage, isWidgetDeprecated } from "../utils";
import { Button, Callout } from "design-system";
import WidgetFactory from "WidgetProvider/factory";
import { PropertyPaneTab } from "./PropertyPaneTab";
import { renderWidgetCallouts, useSearchText } from "./helpers";
import { PropertyPaneSearchInput } from "./PropertyPaneSearchInput";
import { sendPropertyPaneSearchAnalytics } from "./propertyPaneSearch";
import WalkthroughContext from "components/featureWalkthrough/walkthroughContext";
import { AB_TESTING_EVENT_KEYS } from "@appsmith/entities/FeatureFlag";
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
import localStorage from "utils/localStorage";
import { FEATURE_WALKTHROUGH_KEYS } from "constants/WalkthroughConstants";
import { PROPERTY_PANE_ID } from "components/editorComponents/PropertyPaneSidebar";
import {
isUserSignedUpFlagSet,
setFeatureWalkthroughShown,
} from "utils/storage";
import {
BINDING_WIDGET_WALKTHROUGH_DESC,
BINDING_WIDGET_WALKTHROUGH_TITLE,
createMessage,
} from "@appsmith/constants/messages";
import { getWidgets } from "sagas/selectors";
import { getCurrentUser } from "selectors/usersSelectors";
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
import ConnectDataCTA, { actionsExist } from "./ConnectDataCTA";
import PropertyControlsGenerator from "./PropertyControlsGenerator";
import PropertyPaneConnections from "./PropertyPaneConnections";
import { PropertyPaneSearchInput } from "./PropertyPaneSearchInput";
import { PropertyPaneTab } from "./PropertyPaneTab";
import PropertyPaneTitle from "./PropertyPaneTitle";
import { renderWidgetCallouts, useSearchText } from "./helpers";
import { sendPropertyPaneSearchAnalytics } from "./propertyPaneSearch";

// TODO(abhinav): The widget should add a flag in their configuration if they donot subscribe to data
// Widgets where we do not want to show the CTA
Expand Down Expand Up @@ -242,13 +241,6 @@ function PropertyPaneView(

if (!widgetProperties) return null;

// Building Deprecation Messages
const { isDeprecated, widgetReplacedWith } = isWidgetDeprecated(
widgetProperties.type,
);
// generate messages
const deprecationMessage = buildDeprecationWidgetMessage(widgetReplacedWith);

const isContentConfigAvailable =
WidgetFactory.getWidgetPropertyPaneContentConfig(
widgetProperties.type,
Expand Down Expand Up @@ -285,11 +277,7 @@ function PropertyPaneView(
widgetType={widgetProperties?.type}
/>
)}
{isDeprecated && (
<Callout data-testid="t--deprecation-warning" kind="warning">
{deprecationMessage}
</Callout>
)}

{renderWidgetCallouts(widgetProperties)}
</div>

Expand Down
12 changes: 6 additions & 6 deletions app/client/src/pages/Editor/PropertyPane/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import type { WidgetCallout } from "WidgetProvider/constants";
import WidgetFactory from "WidgetProvider/factory";
import type {
PropertyPaneConfig,
PropertyPaneControlConfig,
PropertyPaneSectionConfig,
} from "constants/PropertyControlConstants";
import { Callout } from "design-system";
import { debounce } from "lodash";
import { useCallback, useState } from "react";
import React, { useCallback, useState } from "react";
import { layoutSystemBasedPropertyFilter } from "sagas/WidgetEnhancementHelpers";
import type { WidgetProps } from "widgets/BaseWidget";
import { Callout } from "design-system";
import React from "react";
import WidgetFactory from "WidgetProvider/factory";
import type { WidgetCallout } from "WidgetProvider/constants";
import { isDynamicValue } from "utils/DynamicBindingUtils";
import type { WidgetProps } from "widgets/BaseWidget";

export function useSearchText(initialVal: string) {
const [searchText, setSearchText] = useState(initialVal);
Expand Down Expand Up @@ -104,6 +103,7 @@ export function updateConfigPaths(

export function renderWidgetCallouts(props: WidgetProps): JSX.Element[] {
const { getEditorCallouts } = WidgetFactory.getWidgetMethods(props.type);

if (getEditorCallouts) {
const callouts: WidgetCallout[] = getEditorCallouts(props);
return callouts.map((callout, index) => {
Expand Down
41 changes: 39 additions & 2 deletions app/client/src/utils/autocomplete/CodemirrorTernService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ export function isCustomKeywordType(
);
}

// Define the regex for extracting the final object path
const FINAL_OBJECT_PATH_REGEX = /(?:\w+\.)*\w+$/;

/**
* Extracts the final object path from a given input string.
* The final object path is the rightmost dot-separated path in the string.
*
* @param {string} input - The input string from which to extract the object path.
* @returns {string|null} - The extracted object path or null if no match is found.
*
* Example:
* Input: '\tconst k = PageQuery.run'
* Output: 'PageQuery.run'
*/
export function extractFinalObjectPath(input: string) {
const match = (input || "")?.trim().match(FINAL_OBJECT_PATH_REGEX);
return match ? match[0] : null;
}

export function getDataType(type: string): AutocompleteDataType {
if (type === "?") return AutocompleteDataType.UNKNOWN;
else if (type === "number") return AutocompleteDataType.NUMBER;
Expand Down Expand Up @@ -177,12 +196,14 @@ class CodeMirrorTernService {
string,
DataTreeDefEntityInformation
>();
entityDef: Def;
options: { async: boolean };
recentEntities: string[] = [];

constructor(options: { async: boolean }) {
this.options = options;
this.server = new TernWorkerServer(this);
this.entityDef = {};
}

resetServer = () => {
Expand Down Expand Up @@ -397,6 +418,7 @@ class CodeMirrorTernService {
this.server.deleteDefs(name);
}

this.entityDef = def || {};
if (entityInfo) this.defEntityInformation = entityInfo;
}

Expand Down Expand Up @@ -455,9 +477,21 @@ class CodeMirrorTernService {
completion.origin === "DATA_TREE" &&
this.defEntityInformation.has(completion.name);
let completionText = completion.name + after;
const completedLine = lineValue.substring(0, from.ch) + completion.name;
const entityPath = extractFinalObjectPath(completedLine);

if (dataType === "FUNCTION" && !completion.origin?.startsWith("LIB/")) {
if (token.type !== "string" && token.string !== "[") {
completionText = completionText + "()";
const entityDef = entityPath && this.entityDef[entityPath];
if (
entityDef &&
typeof entityDef === "object" &&
"!fnParams" in entityDef
) {
completionText = completionText + `(${entityDef["!fnParams"]})`;
} else {
completionText = completionText + "()";
}
}
}
const codeMirrorCompletion: Completion<TernCompletionResult> = {
Expand Down Expand Up @@ -1204,7 +1238,10 @@ export default new CodeMirrorTernService({
function dotToBracketNotationAtToken(token: CodeMirror.Token) {
return (cm: CodeMirror.Editor, hints: Hints, curr: Hint) => {
let completion = curr.text;
if (token.type === "string") {
if (
token.type === "string" ||
("type" in curr && curr.type === AutocompleteDataType.FUNCTION)
) {
// | represents the cursor
// Cases like JSObject1["myV|"]
cm.replaceRange(completion, hints.from, hints.to);
Expand Down
Loading

0 comments on commit 1f33834

Please sign in to comment.