Skip to content

Commit d381f21

Browse files
authored
Merge pull request #1241 from lowcoder-org/dev
Dev > Main 2.4.10
2 parents a43f807 + d632bbd commit d381f21

File tree

18 files changed

+44828
-523
lines changed

18 files changed

+44828
-523
lines changed

client/packages/lowcoder-comps/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-comps",
3-
"version": "2.4.18",
3+
"version": "2.4.19",
44
"type": "module",
55
"license": "MIT",
66
"dependencies": {

client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx

+66-21
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,67 @@ function fixOldData(oldData: any) {
8484
if(!Boolean(oldData)) return;
8585
let {events, resourcesEvents, ...data } = oldData;
8686
let allEvents: any[] = [];
87+
let isDynamicEventData = false;
8788

8889
if (events && typeof events === 'string') {
89-
let eventsList = JSON.parse(events);
90-
if (eventsList && eventsList.length) {
91-
eventsList = eventsList?.map(event => {
92-
const {title, ...eventData} = event;
93-
return {
94-
...eventData,
95-
label: title, // replace title field with label
96-
}
97-
});
98-
allEvents = allEvents.concat(eventsList);
90+
try {
91+
let eventsList = JSON.parse(events);
92+
if (eventsList && eventsList.length) {
93+
eventsList = eventsList?.map(event => {
94+
const {title, ...eventData} = event;
95+
return {
96+
...eventData,
97+
label: title, // replace title field with label
98+
}
99+
});
100+
allEvents = allEvents.concat(eventsList);
101+
}
102+
} catch (_) {
103+
isDynamicEventData = true;
99104
}
100105
}
101106
if (resourcesEvents && typeof resourcesEvents === 'string') {
102-
let resourceEventsList = JSON.parse(resourcesEvents);
103-
if (resourceEventsList && resourceEventsList.length) {
104-
resourceEventsList = resourceEventsList?.map(event => {
105-
const {title, ...eventData} = event;
106-
return {
107-
...eventData,
108-
label: title, // replace title field with label
109-
}
110-
});
111-
allEvents = allEvents.concat(resourceEventsList);
112-
}
107+
try {
108+
let resourceEventsList = JSON.parse(resourcesEvents);
109+
if (resourceEventsList && resourceEventsList.length) {
110+
resourceEventsList = resourceEventsList?.map(event => {
111+
const {title, ...eventData} = event;
112+
return {
113+
...eventData,
114+
label: title, // replace title field with label
115+
}
116+
});
117+
allEvents = allEvents.concat(resourceEventsList);
118+
}
119+
} catch (_) {}
113120
}
114121

122+
if (isDynamicEventData) {
123+
return {
124+
...data,
125+
events: {
126+
manual: {
127+
manual: allEvents,
128+
},
129+
mapData: {
130+
data: events,
131+
mapData: {
132+
id: "{{item.id}}",
133+
label: "{{item.title}}",
134+
detail: "{{item.detail}}",
135+
start: "{{item.start}}",
136+
end: "{{item.end}}",
137+
color: "{{item.color}}",
138+
allDay: "{{item.allDay}}",
139+
groupId: "{{item.groupId}}",
140+
resourceId: "{{item.resourceId}}",
141+
}
142+
},
143+
optionType: "map",
144+
},
145+
};
146+
}
147+
115148
if (allEvents.length) {
116149
return {
117150
...data,
@@ -121,11 +154,23 @@ function fixOldData(oldData: any) {
121154
},
122155
mapData: {
123156
data: JSON.stringify(allEvents, null, 2),
157+
mapData: {
158+
id: "{{item.id}}",
159+
label: "{{item.title}}",
160+
detail: "{{item.detail}}",
161+
start: "{{item.start}}",
162+
end: "{{item.end}}",
163+
color: "{{item.color}}",
164+
allDay: "{{item.allDay}}",
165+
groupId: "{{item.groupId}}",
166+
resourceId: "{{item.resourceId}}",
167+
}
124168
},
125169
optionType: "manual",
126170
},
127171
};
128172
}
173+
129174
return {
130175
...data,
131176
events,

client/packages/lowcoder/src/comps/comps/remoteComp/loaders.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import {
88
} from "types/remoteComp";
99

1010
async function npmLoader(
11-
remoteInfo: RemoteCompInfo
11+
{
12+
appId,
13+
...remoteInfo
14+
}: RemoteCompInfo & {appId?: string}
1215
): Promise<CompConstructor | null> {
1316

1417
// Falk: removed "packageVersion = "latest" as default value fir packageVersion - to ensure no automatic version jumping.
1518
const localPackageVersion = remoteInfo.packageVersion || "latest";
1619
const { packageName, packageVersion, compName } = remoteInfo;
17-
const entry = `${NPM_PLUGIN_ASSETS_BASE_URL}/${packageName}@${localPackageVersion}/index.js`;
20+
const entry = `${NPM_PLUGIN_ASSETS_BASE_URL}/${appId}/${packageName}@${localPackageVersion}/index.js`;
1821

1922
try {
2023
const module = await import(
@@ -51,7 +54,7 @@ async function bundleLoader(
5154
return comp;
5255
}
5356

54-
export const loaders: Record<RemoteCompSource, RemoteCompLoader> = {
57+
export const loaders: Record<RemoteCompSource, RemoteCompLoader<RemoteCompInfo & {appId?: string}>> = {
5558
npm: npmLoader,
5659
bundle: bundleLoader,
5760
};

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { CompContext } from "@lowcoder-ee/comps/utils/compContext";
1616
import React from "react";
1717
import type { AppState } from "@lowcoder-ee/redux/reducers";
1818
import { useSelector } from "react-redux";
19+
import { useApplicationId } from "@lowcoder-ee/util/hooks";
1920

2021
const ViewError = styled.div`
2122
display: flex;
@@ -51,7 +52,7 @@ interface RemoteCompReadyAction {
5152

5253
interface RemoteCompViewProps {
5354
isLowcoderComp?: boolean;
54-
loadComp: (packageVersion?: string) => Promise<void>;
55+
loadComp: (packageVersion?: string, appId?: string) => Promise<void>;
5556
loadingElement?: () => React.ReactNode;
5657
errorElement?: (error: any) => React.ReactNode;
5758
source?: RemoteCompSource;
@@ -62,6 +63,7 @@ const RemoteCompView = React.memo((props: React.PropsWithChildren<RemoteCompView
6263
const [error, setError] = useState<any>("");
6364
const editorState = useContext(EditorContext);
6465
const compState = useContext(CompContext);
66+
const appId = useApplicationId();
6567
const lowcoderCompPackageVersion = editorState?.getAppSettings().lowcoderCompVersion || 'latest';
6668
const latestLowcoderCompsVersion = useSelector((state: AppState) => state.npmPlugin.packageVersion['lowcoder-comps']);
6769

@@ -79,7 +81,7 @@ const RemoteCompView = React.memo((props: React.PropsWithChildren<RemoteCompView
7981

8082
useMount(() => {
8183
setError("");
82-
loadComp(packageVersion).catch((e) => {
84+
loadComp(packageVersion, appId).catch((e) => {
8385
setError(String(e));
8486
});
8587
});
@@ -117,7 +119,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
117119
this.compValue = params.value;
118120
}
119121

120-
private async load(packageVersion = 'latest') {
122+
private async load(packageVersion = 'latest', appId = 'none') {
121123
if (!remoteInfo) {
122124
return;
123125
}
@@ -129,7 +131,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
129131
log.error("loader not found, remote info:", remoteInfo);
130132
return;
131133
}
132-
const RemoteExportedComp = await finalLoader({...remoteInfo, packageVersion});
134+
const RemoteExportedComp = await finalLoader({...remoteInfo, packageVersion, appId});
133135
if (!RemoteExportedComp) {
134136
return;
135137
}
@@ -159,7 +161,7 @@ export function remoteComp<T extends RemoteCompInfo = RemoteCompInfo>(
159161
<RemoteCompView
160162
key={key}
161163
isLowcoderComp={remoteInfo?.packageName === 'lowcoder-comps'}
162-
loadComp={(packageVersion?: string) => this.load(packageVersion)}
164+
loadComp={(packageVersion?: string, appId?: string) => this.load(packageVersion, appId)}
163165
loadingElement={loadingElement}
164166
source={remoteInfo?.source}
165167
/>

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const StepsChildrenMap = {
9595
style: styleControl(StepsStyle , 'style'),
9696
viewRef: RefControl<HTMLDivElement>,
9797
animationStyle: styleControl(AnimationStyle ,'animationStyle' ),
98-
showVerticalScrollbar: withDefault(BoolControl, false),
98+
showScrollBars: withDefault(BoolControl, false),
9999
minHorizontalWidth: withDefault(RadiusControl, ''),
100100
};
101101

@@ -182,7 +182,7 @@ let StepControlBasicComp = (function () {
182182
padding: "0px",
183183
}}
184184
overflow="scroll"
185-
hideScrollbar={!props.showVerticalScrollbar}>
185+
hideScrollbar={!props.showScrollBars}>
186186
<Steps
187187
initial={props.initialValue.value -1}
188188
current={current}
@@ -197,6 +197,7 @@ let StepControlBasicComp = (function () {
197197
>
198198
{props.options.map((option, index) => (
199199
<Steps.Step
200+
style={{minWidth:props.minHorizontalWidth || '100%'}}
200201
key={index}
201202
title={option.label}
202203
subTitle={option.subTitle}
@@ -234,15 +235,6 @@ let StepControlBasicComp = (function () {
234235
{["layout", "both"].includes(useContext(EditorContext).editorModeStatus) && (
235236
<Section name={sectionNames.layout}>
236237
{children.autoHeight.getPropertyView()}
237-
{!children.autoHeight.getView() && (
238-
children.showVerticalScrollbar.propertyView({
239-
label: trans("prop.showVerticalScrollbar"),
240-
})
241-
)}
242-
{children.minHorizontalWidth.propertyView({
243-
label: trans("prop.minHorizontalWidth"),
244-
placeholder: '100px',
245-
})}
246238
{children.size.propertyView({
247239
label: trans("step.size"),
248240
radioButton: true,
@@ -261,15 +253,23 @@ let StepControlBasicComp = (function () {
261253
radioButton: true,
262254
})
263255
}
256+
{children.direction.getView() == "horizontal" && (
257+
children.minHorizontalWidth.propertyView({
258+
label: trans("prop.minHorizontalWidth"),
259+
placeholder: '100px',
260+
})
261+
)}
262+
{!children.autoHeight.getView() && (
263+
children.showScrollBars.propertyView({
264+
label: trans("prop.scrollbar"),
265+
})
266+
)}
264267
{ children.displayType.getView() != "inline" && !children.showIcons.getView() && (
265268
children.showDots.propertyView({label: trans("step.showDots")}
266269
))}
267270
{ children.displayType.getView() != "inline" && !children.showDots.getView() && (
268271
children.showIcons.propertyView({label: trans("step.showIcons")}
269272
))}
270-
{!children.autoHeight.getView() && (
271-
children.showVerticalScrollbar.propertyView({label: trans("prop.showVerticalScrollbar")})
272-
)}
273273
</Section>
274274
)}
275275

client/packages/lowcoder/src/comps/utils/remote.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function parseCompType(compType: string) {
3939
}
4040

4141
export async function getNpmPackageMeta(packageName: string) {
42-
const res = await axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/${packageName}`);
42+
const res = await axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/none/${packageName}`);
4343
if (res.status >= 400) {
4444
return null;
4545
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export const SERVER_HOST = `${REACT_APP_NODE_SERVICE_URL ?? ""}`;
2-
export const NPM_REGISTRY_URL = `${SERVER_HOST}/node-service/api/npm/registry`;
3-
export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/node-service/api/npm/package`;
1+
// export const SERVER_HOST = `${REACT_APP_NODE_SERVICE_URL ?? ""}`;
2+
// export const NPM_REGISTRY_URL = `${SERVER_HOST}/node-service/api/npm/registry`;
3+
// export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/node-service/api/npm/package`;
4+
5+
export const SERVER_HOST = `${REACT_APP_API_SERVICE_URL ?? ""}`;
6+
export const NPM_REGISTRY_URL = `${SERVER_HOST}/api/npm/registry`;
7+
export const NPM_PLUGIN_ASSETS_BASE_URL = `${SERVER_HOST}/api/npm/package`;

client/packages/lowcoder/src/pages/editor/right/PluginPanel/PluginCompItem.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { LowcoderCompMeta } from "types/remoteComp";
1111
import { TransparentImg } from "util/commonUtils";
1212
import { ModuleIcon } from "lowcoder-design";
1313
import { NPM_PLUGIN_ASSETS_BASE_URL } from "constants/npmPlugins";
14+
import { useApplicationId } from "@lowcoder-ee/index.sdk";
1415

1516
const ItemWrapper = styled.div`
1617
display: flex;
@@ -75,10 +76,11 @@ interface PluginCompItemProps {
7576
}
7677

7778
export function PluginCompItem(props: PluginCompItemProps) {
79+
const appId = useApplicationId();
7880
const { packageName, packageVersion, compName, compMeta, onDrag } = props;
7981
const compType = getRemoteCompType("npm", packageName, packageVersion, compName);
8082

81-
const icon = `${NPM_PLUGIN_ASSETS_BASE_URL}/${packageName}@${packageVersion}/${compMeta.icon}`;
83+
const icon = `${NPM_PLUGIN_ASSETS_BASE_URL}/${appId}/${packageName}@${packageVersion}/${compMeta.icon}`;
8284

8385
return (
8486
<ItemWrapper

client/packages/lowcoder/src/pages/editor/right/PluginPanel/PluginItem.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from "axios";
22
import { EmptyContent } from "components/EmptyContent";
33
import { LinkButton } from "lowcoder-design";
4-
import { useShallowEqualSelector } from "util/hooks";
4+
import { useApplicationId, useShallowEqualSelector } from "util/hooks";
55
import { useContext, useEffect, useMemo, useState } from "react";
66
import { useDispatch, useSelector } from "react-redux";
77
import { AppState } from "redux/reducers";
@@ -55,6 +55,7 @@ interface PluginViewProps {
5555
export function PluginItem(props: PluginViewProps) {
5656
const { name, onRemove } = props;
5757
const dispatch = useDispatch();
58+
const appId = useApplicationId();
5859
const { onDrag, searchValue } = useContext(RightContext);
5960
const [loading, setLoading] = useState(false);
6061
const packageMeta = useShallowEqualSelector(
@@ -67,7 +68,7 @@ export function PluginItem(props: PluginViewProps) {
6768

6869
useEffect(() => {
6970
setLoading(true);
70-
axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/${name}`).then((res) => {
71+
axios.get<NpmPackageMeta>(`${NPM_REGISTRY_URL}/${appId}/${name}`).then((res) => {
7172
if (res.status >= 400) {
7273
return;
7374
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/framework/security/SecurityConfig.java

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
145145
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.ORGANIZATION_URL + "/*/datasourceTypes"), // datasource types
146146
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.ORGANIZATION_URL + "/byuser/*"),
147147
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.DATASOURCE_URL + "/jsDatasourcePlugins"),
148+
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, NewUrl.NPM_REGISTRY + "/**"),
148149
ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/api/docs/**")
149150
)
150151
.permitAll()

0 commit comments

Comments
 (0)