Skip to content

Commit 6dbf6ad

Browse files
authored
Merge branch 'dev' into deployment_updates
2 parents 2c6c810 + d6fde12 commit 6dbf6ad

File tree

25 files changed

+258
-457
lines changed

25 files changed

+258
-457
lines changed

client/packages/lowcoder-comps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-comps",
3-
"version": "2.6.6",
3+
"version": "2.7.0",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {

client/packages/lowcoder/src/components/ResCreatePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Datasource } from "constants/datasourceConstants";
1717
import {
1818
QUICK_GRAPHQL_ID,
1919
QUICK_REST_API_ID,
20+
JS_CODE_ID,
2021
} from "../constants/datasourceConstants";
2122
import { ResourceType } from "constants/queryConstants";
2223
import { default as Upload } from "antd/es/upload";
@@ -25,7 +26,6 @@ import { getUser } from "../redux/selectors/usersSelectors";
2526
import DataSourceIcon from "./DataSourceIcon";
2627
import { genRandomKey } from "comps/utils/idGenerator";
2728
import { isPublicApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
28-
import { JS_CODE_ID } from "constants/datasourceConstants";
2929

3030
const Wrapper = styled.div<{ $placement: PageType }>`
3131
width: 100%;

client/packages/lowcoder/src/comps/comps/buttonComp/buttonComp.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const childrenMap = {
134134
style: ButtonStyleControl,
135135
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
136136
viewRef: RefControl<HTMLElement>,
137+
tooltip: StringControl
137138
};
138139

139140
type ChildrenType = NewChildren<RecordConstructorToComp<typeof childrenMap>>;
@@ -146,6 +147,7 @@ const ButtonPropertyView = React.memo((props: {
146147
<>
147148
<Section name={sectionNames.basic}>
148149
{props.children.text.propertyView({ label: trans("text") })}
150+
{props.children.tooltip.propertyView({ label: trans("labelProp.tooltip")})}
149151
</Section>
150152

151153
{(editorModeStatus === "logic" || editorModeStatus === "both") && (
@@ -204,7 +206,7 @@ const ButtonView = React.memo((props: ToViewReturn<ChildrenType>) => {
204206
<ButtonCompWrapper $disabled={props.disabled}>
205207
<EditorContext.Consumer>
206208
{(editorState) => (
207-
<Tooltip title={props.text}>
209+
<Tooltip title={props.tooltip}>
208210
<Button100
209211
ref={props.viewRef}
210212
$buttonStyle={props.style}

client/packages/lowcoder/src/comps/comps/buttonComp/toggleButtonComp.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const ToggleTmpComp = (function () {
6666
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
6767
showBorder: withDefault(BoolControl, true),
6868
viewRef: RefControl<HTMLElement>,
69+
tooltip: StringControl,
6970
};
7071
return new UICompBuilder(childrenMap, (props) => {
7172
const text = props.showText
@@ -79,7 +80,7 @@ const ToggleTmpComp = (function () {
7980
$showBorder={props.showBorder}
8081
$animationStyle={props.animationStyle}
8182
>
82-
<Tooltip title={props.value.value ? props.trueText : props.falseText}>
83+
<Tooltip title={props.tooltip}>
8384
<Button100
8485
ref={props.viewRef}
8586
$buttonStyle={props.style}
@@ -117,6 +118,7 @@ const ToggleTmpComp = (function () {
117118
</Section>
118119
<Section name={sectionNames.advanced}>
119120
{children.showText.propertyView({ label: trans("toggleButton.showText") })}
121+
{children.tooltip.propertyView({label: trans("labelProp.tooltip")})}
120122
{children.showText.getView() &&
121123
children.trueText.propertyView({ label: trans("toggleButton.trueLabel") })}
122124
{children.showText.getView() &&

client/packages/lowcoder/src/comps/comps/meetingComp/controlButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ const childrenMap = {
201201
iconScoutAsset: IconscoutControl(AssetType.ICON),
202202
style: ButtonStyleControl,
203203
viewRef: RefControl<HTMLElement>,
204-
restrictPaddingOnRotation:withDefault(StringControl, 'controlButton')
204+
restrictPaddingOnRotation:withDefault(StringControl, 'controlButton'),
205+
tooltip: StringControl
205206
};
206207

207208
let ButtonTmpComp = (function () {
@@ -259,7 +260,7 @@ let ButtonTmpComp = (function () {
259260
: undefined
260261
}
261262
>
262-
<Tooltip title={trans("meeting.meetingControlCompName")}>
263+
<Tooltip title={props.tooltip}>
263264
<Button100
264265
ref={props.viewRef}
265266
$buttonStyle={props.style}
@@ -323,6 +324,9 @@ let ButtonTmpComp = (function () {
323324
{children.sourceMode.getView() === 'asset-library' &&children.iconScoutAsset.propertyView({
324325
label: trans("button.icon"),
325326
})}
327+
{children.tooltip.propertyView({
328+
label: trans("labelProp.tooltip"),
329+
})}
326330
</Section>
327331

328332
{(useContext(EditorContext).editorModeStatus === "logic" ||

client/packages/lowcoder/src/comps/comps/selectInputComp/checkboxComp.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,7 @@ let CheckboxBasicComp = (function () {
231231
return props.options
232232
.filter((option) => option.value !== undefined && !option.hidden)
233233
.map((option) => ({
234-
label: (
235-
<Tooltip title={option.label}>
236-
<span>{option.label}</span>
237-
</Tooltip>
238-
),
234+
label: option.label,
239235
value: option.value,
240236
disabled: option.disabled,
241237
}));

client/packages/lowcoder/src/comps/comps/selectInputComp/radioComp.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,7 @@ const MemoizedRadio = memo(({
134134
return options
135135
.filter((option) => option.value !== undefined && !option.hidden)
136136
.map((option) => ({
137-
label: (
138-
<Tooltip title={option.label}>
139-
<span>{option.label}</span>
140-
</Tooltip>
141-
),
137+
label: option.label,
142138
value: option.value,
143139
disabled: option.disabled,
144140
}));

client/packages/lowcoder/src/comps/queries/libraryQuery.tsx

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { default as LoadingOutlined } from "@ant-design/icons/LoadingOutlined";
22
import { default as Spin } from "antd/es/spin";
33
import DataSourceIcon from "components/DataSourceIcon";
44
import { ContextControlType, ContextJsonControl } from "comps/controls/contextCodeControl";
5+
import { FunctionControl } from "comps/controls/codeControl";
56
import { trans } from "i18n";
67
import {
78
CompAction,
@@ -10,6 +11,7 @@ import {
1011
isMyCustomAction,
1112
MultiBaseComp,
1213
wrapChildAction,
14+
evalFunc,
1315
} from "lowcoder-core";
1416
import {
1517
Dropdown,
@@ -34,6 +36,9 @@ import {
3436
ToInstanceType,
3537
} from "../generators/multi";
3638
import { toQueryView } from "./queryCompUtils";
39+
import { getGlobalSettings } from "comps/utils/globalSettings";
40+
import { QUERY_EXECUTION_ERROR, QUERY_EXECUTION_OK } from "../../constants/queryConstants";
41+
import type { SandBoxOption } from "lowcoder-core/src/eval/utils/evalScript";
3742

3843
const NoInputsWrapper = styled.div`
3944
color: ${GreyTextColor};
@@ -133,13 +138,70 @@ export const LibraryQuery = class extends LibraryQueryBase {
133138
readonly isReady: boolean = false;
134139

135140
private value: DataType | undefined;
141+
private queryInfo: any = null;
136142

137143
constructor(params: CompParams<DataType>) {
138144
super(params);
139145
this.value = params.value;
140146
}
141147

142148
override getView() {
149+
// Check if this is a JS query
150+
if (this.queryInfo?.query?.compType === "js") {
151+
return async (props: any) => {
152+
try {
153+
const { orgCommonSettings } = getGlobalSettings();
154+
const runInHost = !!orgCommonSettings?.runJavaScriptInHost;
155+
const timer = performance.now();
156+
const script = this.queryInfo.query.comp.script || "";
157+
const options: SandBoxOption = { disableLimit: runInHost };
158+
159+
// Get input values from the inputs component and resolve any variables
160+
const inputValues = Object.entries(this.children.inputs.children).reduce((acc, [name, input]) => {
161+
// Get the raw value from the input component's text property
162+
let value = input.children.text.getView();
163+
164+
// Resolve any variables in the value
165+
if (typeof value === 'string') {
166+
value = value.replace(/\{\{([^}]+)\}\}/g, (match, path) => {
167+
const parts = path.split('.');
168+
let current = props.args || {};
169+
for (const part of parts) {
170+
if (current && typeof current === 'object') {
171+
current = current[part];
172+
} else {
173+
return match; // Return original if path not found
174+
}
175+
}
176+
return current?.value ?? match;
177+
});
178+
}
179+
180+
acc[name] = value;
181+
return acc;
182+
}, {} as Record<string, any>);
183+
184+
console.log("script: " + script);
185+
console.log("inputValues: ", inputValues);
186+
187+
const data = await evalFunc(script, inputValues, undefined, options);
188+
return {
189+
data: data,
190+
code: QUERY_EXECUTION_OK,
191+
success: true,
192+
runTime: Number((performance.now() - timer).toFixed()),
193+
};
194+
} catch (e) {
195+
return {
196+
success: false,
197+
data: "",
198+
code: QUERY_EXECUTION_ERROR,
199+
message: (e as any).message || "",
200+
};
201+
}
202+
};
203+
}
204+
143205
return toQueryView(
144206
Object.entries(this.children.inputs.children).map(([name, input]) => ({
145207
key: name,
@@ -161,6 +223,7 @@ export const LibraryQuery = class extends LibraryQueryBase {
161223

162224
override reduce(action: CompAction): this {
163225
if (isMyCustomAction<QueryLibraryUpdateAction>(action, "queryLibraryUpdate")) {
226+
this.queryInfo = action.value?.dsl;
164227
const inputs = this.children.inputs.setInputs(action.value?.dsl?.["inputs"] ?? []);
165228
return setFieldsNoTypeCheck(this, {
166229
children: { ...this.children, inputs: inputs },
@@ -258,7 +321,7 @@ const PropertyView = (props: { comp: InstanceType<typeof LibraryQuery> }) => {
258321
<QueryTutorialButton
259322
label={trans("queryLibrary.viewQuery")}
260323
url={`/query-library?forwardQueryId=${queryId}`}
261-
styleName={"dropdownRight"}
324+
styleName="dropdownRight"
262325
/>
263326
</QueryConfigWrapper>
264327

@@ -284,4 +347,4 @@ const PropertyView = (props: { comp: InstanceType<typeof LibraryQuery> }) => {
284347
const QueryLabelWrapper = styled.div`
285348
display: flex;
286349
align-items: center;
287-
`;
350+
`;

client/packages/lowcoder/src/comps/queries/queryComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ QueryCompTmp = class extends QueryCompTmp {
487487
args: action.args,
488488
variables: action.args,
489489
timeout: this.children.timeout,
490-
callback: (result) => this.processResult(result, action, startTime)
490+
callback: (result: QueryResult) => this.processResult(result, action, startTime)
491491
});
492492
}, getTriggerType(this) === "manual")
493493
.then(

client/packages/lowcoder/src/comps/queries/queryCompUtils.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { Fragment } from "react";
77
import { ParamsControlType, ValueFunction } from "../controls/paramsControl";
88
import { getGlobalSettings } from "comps/utils/globalSettings";
99
import { ResourceType } from "@lowcoder-ee/constants/queryConstants";
10+
import { evalFunc } from "lowcoder-core";
11+
import { QUERY_EXECUTION_ERROR, QUERY_EXECUTION_OK } from "../../constants/queryConstants";
12+
import type { SandBoxOption } from "lowcoder-core/src/eval/utils/evalScript";
1013

1114
export type FunctionProperty = {
1215
key: string;
@@ -30,6 +33,32 @@ export function toQueryView(params: FunctionProperty[]) {
3033
}): Promise<QueryResult> => {
3134
const { applicationId, isViewMode } = getGlobalSettings();
3235

36+
// Check if this is a JS query
37+
const isJsQuery = props.queryId?.startsWith("js:");
38+
if (isJsQuery) {
39+
try {
40+
const { orgCommonSettings } = getGlobalSettings();
41+
const runInHost = !!orgCommonSettings?.runJavaScriptInHost;
42+
const timer = performance.now();
43+
const script = props.args?.script || "";
44+
const options: SandBoxOption = { disableLimit: runInHost };
45+
const data = await evalFunc(`return (${script}\n);`, props.args || {}, undefined, options);
46+
return {
47+
data: data,
48+
code: QUERY_EXECUTION_OK,
49+
success: true,
50+
runTime: Number((performance.now() - timer).toFixed()),
51+
};
52+
} catch (e) {
53+
return {
54+
success: false,
55+
data: "",
56+
code: QUERY_EXECUTION_ERROR,
57+
message: (e as any).message || "",
58+
};
59+
}
60+
}
61+
3362
let mappedVariables: Array<{key: string, value: string}> = [];
3463
Object.keys(props.variables)
3564
.filter(k => k !== "$queryName")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy