From 29d4f2b7a8669c40d64ffa3dc392c64bac39d154 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Fri, 12 Jul 2024 15:44:22 +0500 Subject: [PATCH 01/40] update sdk version --- client/packages/lowcoder-sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/packages/lowcoder-sdk/package.json b/client/packages/lowcoder-sdk/package.json index f774eebd3..49acf03f4 100644 --- a/client/packages/lowcoder-sdk/package.json +++ b/client/packages/lowcoder-sdk/package.json @@ -1,6 +1,6 @@ { "name": "lowcoder-sdk", - "version": "2.4.7", + "version": "2.4.8", "type": "module", "files": [ "src", From 6d59b2836786981f5bd52b48fe62c6211d568099 Mon Sep 17 00:00:00 2001 From: Thomasr Date: Fri, 12 Jul 2024 14:23:14 -0400 Subject: [PATCH 02/40] wrap legacy oauth provider with genericoauth --- .../sdk/auth/constants/Oauth2Constants.java | 2 +- .../oauth2/Oauth2AuthRequestFactory.java | 98 ++++++++++++++++++- 2 files changed, 95 insertions(+), 5 deletions(-) diff --git a/server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/constants/Oauth2Constants.java b/server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/constants/Oauth2Constants.java index 3ba925d0d..e0c2bda8e 100644 --- a/server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/constants/Oauth2Constants.java +++ b/server/api-service/lowcoder-sdk/src/main/java/org/lowcoder/sdk/auth/constants/Oauth2Constants.java @@ -17,7 +17,7 @@ public class Oauth2Constants { + "&client_id=" + CLIENT_ID_PLACEHOLDER + "&redirect_uri=" + REDIRECT_URL_PLACEHOLDER + "&state=" + STATE_PLACEHOLDER - + "&scope="; + + "&scope=user"; public static final String GOOGLE_AUTHORIZE_URL = "https://accounts.google.com/o/oauth2/v2/auth" + "?response_type=code" diff --git a/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java b/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java index 5444d203f..0024d03f5 100644 --- a/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java +++ b/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java @@ -1,5 +1,6 @@ package org.lowcoder.api.authentication.request.oauth2; +import java.util.HashMap; import java.util.Set; import org.lowcoder.api.authentication.request.AuthRequest; @@ -9,6 +10,7 @@ import org.lowcoder.sdk.auth.Oauth2KeycloakAuthConfig; import org.lowcoder.sdk.auth.Oauth2OryAuthConfig; import org.lowcoder.sdk.auth.Oauth2SimpleAuthConfig; +import org.lowcoder.sdk.auth.constants.AuthTypeConstants; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; @@ -25,10 +27,98 @@ public Mono build(OAuth2RequestContext context) { private AbstractOauth2Request buildRequest(OAuth2RequestContext context) { return switch (context.getAuthConfig().getAuthType()) { - case GITHUB -> new GithubRequest((Oauth2SimpleAuthConfig) context.getAuthConfig()); - case GOOGLE -> new GoogleRequest((Oauth2SimpleAuthConfig) context.getAuthConfig()); - case ORY -> new OryRequest((Oauth2OryAuthConfig) context.getAuthConfig()); - case KEYCLOAK -> new KeycloakRequest((Oauth2KeycloakAuthConfig)context.getAuthConfig()); + case GITHUB -> { + HashMap sourceMappings = new HashMap<>(); + sourceMappings.put("uid", "id"); + sourceMappings.put("email", "email"); + sourceMappings.put("username", "login"); + sourceMappings.put("avatar", "avatar_url"); + Oauth2SimpleAuthConfig config = (Oauth2SimpleAuthConfig) context.getAuthConfig(); + yield new GenericAuthRequest(Oauth2GenericAuthConfig.builder() + .tokenEndpoint(Oauth2DefaultSource.GITHUB.accessToken()) + .userInfoEndpoint(Oauth2DefaultSource.GITHUB.userInfo()) + .userInfoIntrospection(true) + .source(config.getSource()) + .sourceName(config.getSourceName()) + .enableRegister(config.isEnableRegister()) + .enable(config.isEnable()) + .scope("read:email read:user") + .userCanSelectAccounts(true) + .sourceMappings(sourceMappings) + .clientSecret(config.getClientSecret()) + .clientId(config.getClientId()) + .authType(GENERIC) + .build()); + } + case GOOGLE -> { + HashMap sourceMappings = new HashMap<>(); + sourceMappings.put("uid", "sub"); + sourceMappings.put("email", "email"); + sourceMappings.put("username", "email"); + sourceMappings.put("avatar", "picture"); + Oauth2SimpleAuthConfig config = (Oauth2SimpleAuthConfig) context.getAuthConfig(); + yield new GenericAuthRequest(Oauth2GenericAuthConfig.builder() + .tokenEndpoint(Oauth2DefaultSource.GOOGLE.accessToken()) + .userInfoEndpoint(Oauth2DefaultSource.GOOGLE.userInfo()) + .userInfoIntrospection(true) + .source(config.getSource()) + .sourceName(config.getSourceName()) + .enableRegister(config.isEnableRegister()) + .enable(config.isEnable()) + .scope("openid email profile") + .userCanSelectAccounts(true) + .sourceMappings(sourceMappings) + .clientSecret(config.getClientSecret()) + .clientId(config.getClientId()) + .authType(GENERIC) + .build()); + } + case ORY -> { + HashMap sourceMappings = new HashMap<>(); + sourceMappings.put("uid", "sub"); + sourceMappings.put("email", "email"); + sourceMappings.put("username", "email"); + sourceMappings.put("avatar", "picture"); + Oauth2OryAuthConfig config = (Oauth2OryAuthConfig) context.getAuthConfig(); + yield new GenericAuthRequest(Oauth2GenericAuthConfig.builder() + .tokenEndpoint(config.replaceAuthUrlClientIdPlaceholder(Oauth2DefaultSource.ORY.accessToken())) + .userInfoEndpoint(config.replaceAuthUrlClientIdPlaceholder(Oauth2DefaultSource.ORY.userInfo())) + .userInfoIntrospection(true) + .source(config.getSource()) + .sourceName(config.getSourceName()) + .enableRegister(config.isEnableRegister()) + .enable(config.isEnable()) + .scope(config.getScope()) + .userCanSelectAccounts(false) + .sourceMappings(sourceMappings) + .clientSecret(config.getClientSecret()) + .clientId(config.getClientId()) + .authType(GENERIC) + .build()); + } + case KEYCLOAK -> { + HashMap sourceMappings = new HashMap<>(); + sourceMappings.put("uid", "sub"); + sourceMappings.put("email", "email"); + sourceMappings.put("username", "email"); + sourceMappings.put("avatar", "false"); + Oauth2KeycloakAuthConfig config = (Oauth2KeycloakAuthConfig) context.getAuthConfig(); + yield new GenericAuthRequest(Oauth2GenericAuthConfig.builder() + .tokenEndpoint(config.replaceAuthUrlClientIdPlaceholder(Oauth2DefaultSource.KEYCLOAK.accessToken())) + .userInfoEndpoint(config.replaceAuthUrlClientIdPlaceholder(Oauth2DefaultSource.KEYCLOAK.userInfo())) + .userInfoIntrospection(true) + .source(config.getSource()) + .sourceName(config.getSourceName()) + .enableRegister(config.isEnableRegister()) + .enable(config.isEnable()) + .scope(config.getScope()) + .userCanSelectAccounts(false) + .sourceMappings(sourceMappings) + .clientSecret(config.getClientSecret()) + .clientId(config.getClientId()) + .authType(GENERIC) + .build()); + } case GENERIC -> new GenericAuthRequest((Oauth2GenericAuthConfig) context.getAuthConfig()); default -> throw new UnsupportedOperationException(context.getAuthConfig().getAuthType()); }; From 7919ba6adc9861f0fea843012f87d2e011385190 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Mon, 15 Jul 2024 16:11:28 +0500 Subject: [PATCH 03/40] lowcoder-comps backward compatibility --- client/packages/lowcoder-comps/package.json | 2 +- .../src/comps/basicChartComp/chartComp.tsx | 2 +- .../comps/basicChartComp/chartConstants.tsx | 12 ++++++++--- .../src/comps/calendarComp/calendarComp.tsx | 20 ++++++++++++------- .../candleStickChartConstants.tsx | 10 ++++++++-- .../candleStickChartPropertyView.tsx | 2 +- .../src/comps/chartComp/chartComp.tsx | 2 +- .../funnelChartComp/funnelChartConstants.tsx | 10 ++++++++-- .../funnelChartPropertyView.tsx | 2 +- .../gaugeChartComp/gaugeChartConstants.tsx | 11 +++++++--- .../gaugeChartComp/gaugeChartPropertyView.tsx | 2 +- .../graphChartComp/graphChartConstants.tsx | 10 ++++++++-- .../graphChartComp/graphChartPropertyView.tsx | 2 +- .../heatmapChartConstants.tsx | 10 ++++++++-- .../heatmapChartPropertyView.tsx | 2 +- .../radarChartComp/radarChartConstants.tsx | 10 ++++++++-- .../radarChartComp/radarChartPropertyView.tsx | 2 +- .../sankeyChartComp/sankeyChartConstants.tsx | 10 ++++++++-- .../sankeyChartPropertyView.tsx | 2 +- .../sunburstChartConstants.tsx | 10 ++++++++-- .../sunburstChartPropertyView.tsx | 2 +- .../themeriverChartConstants.tsx | 11 +++++++--- .../themeriverChartPropertyView.tsx | 2 +- .../treeChartComp/treeChartConstants.tsx | 10 ++++++++-- .../treeChartComp/treeChartPropertyView.tsx | 2 +- .../treemapChartConstants.tsx | 10 ++++++++-- .../treemapChartPropertyView.tsx | 2 +- 27 files changed, 124 insertions(+), 48 deletions(-) diff --git a/client/packages/lowcoder-comps/package.json b/client/packages/lowcoder-comps/package.json index ff70d4a41..6bf9d1425 100644 --- a/client/packages/lowcoder-comps/package.json +++ b/client/packages/lowcoder-comps/package.json @@ -1,6 +1,6 @@ { "name": "lowcoder-comps", - "version": "2.4.8", + "version": "2.4.9", "type": "module", "license": "MIT", "dependencies": { diff --git a/client/packages/lowcoder-comps/src/comps/basicChartComp/chartComp.tsx b/client/packages/lowcoder-comps/src/comps/basicChartComp/chartComp.tsx index e2a162810..a3522ed1e 100644 --- a/client/packages/lowcoder-comps/src/comps/basicChartComp/chartComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/basicChartComp/chartComp.tsx @@ -74,7 +74,7 @@ BasicChartTmpComp = withViewFn(BasicChartTmpComp, (comp) => { log.error('theme chart error: ', error); } - useMergeCompStyles(childrenToProps(comp.children), comp.dispatch); + useMergeCompStyles?.(childrenToProps(comp.children), comp.dispatch); const triggerClickEvent = async (dispatch: any, action: CompAction) => { await getPromiseAfterDispatch( diff --git a/client/packages/lowcoder-comps/src/comps/basicChartComp/chartConstants.tsx b/client/packages/lowcoder-comps/src/comps/basicChartComp/chartConstants.tsx index a216e5a49..8d8811daf 100644 --- a/client/packages/lowcoder-comps/src/comps/basicChartComp/chartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/basicChartComp/chartConstants.tsx @@ -249,16 +249,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultEchartsJsonOption), - echartsTitle: withDefault(StringControl, trans("echarts.defaultTitle")), + echartsTitle: withDefault(StringControl, trans("echarts.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx index 2b512507c..f3711990d 100644 --- a/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx @@ -39,6 +39,7 @@ import { ThemeContext, CalendarStyle, DateParser, + modalInstance, CustomModal, jsonValueExposingStateControl, CalendarDeleteIcon, @@ -70,16 +71,13 @@ import { resourceTimeGridHeaderToolbar, } from "./calendarConstants"; -// this should ensure backwards compatibility with older versions of the SDK -const safeDragEventHandlerControl = typeof DragEventHandlerControl !== 'undefined' ? DragEventHandlerControl : () => {}; - -const childrenMap = { +let childrenMap: any = { events: jsonValueExposingStateControl("events", defaultData), resourcesEvents: jsonValueExposingStateControl("resourcesEvents", resourcesEventsDefaultData), resources: jsonValueExposingStateControl("resources", resourcesDefaultData), resourceName: withDefault(StringControl, trans("calendar.resourcesDefault")), onEvent: ChangeEventHandlerControl, - onDropEvent: safeDragEventHandlerControl, + // onDropEvent: safeDragEventHandlerControl, editable: withDefault(BoolControl, true), showEventTime: withDefault(BoolControl, true), showWeekends: withDefault(BoolControl, true), @@ -93,7 +91,13 @@ const childrenMap = { currentFreeView: dropdownControl(DefaultWithFreeViewOptions, "timeGridWeek"), currentPremiumView: dropdownControl(DefaultWithPremiumViewOptions, "resourceTimelineDay"), }; - +// this should ensure backwards compatibility with older versions of the SDK +if (DragEventHandlerControl) { + childrenMap = { + ...childrenMap, + onDropEvent: DragEventHandlerControl, + } +} let CalendarBasicComp = (function () { return new UICompBuilder(childrenMap, (props: { events: any; @@ -124,7 +128,7 @@ let CalendarBasicComp = (function () { const [left, setLeft] = useState(undefined); const [licensed, setLicensed] = useState(props.licenseKey !== ""); - useMergeCompStyles(props, dispatch); + useMergeCompStyles?.(props, dispatch); useEffect(() => { setLicensed(props.licenseKey !== ""); @@ -326,6 +330,8 @@ let CalendarBasicComp = (function () { }; const showModal = (event: EventType, ifEdit: boolean) => { + if (!modalInstance) return; + const modalTitle = ifEdit ? trans("calendar.editEvent") : trans("calendar.creatEvent"); diff --git a/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartConstants.tsx index cee782aab..35852214d 100644 --- a/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultCandleStickChartOption), echartsTitle: withDefault(StringControl, trans("candleStickChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartPropertyView.tsx index 9fa9060e3..f0eea1e15 100644 --- a/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartPropertyView.tsx @@ -38,7 +38,7 @@ export function candleStickChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx b/client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx index 7e49fed09..f93ae0f50 100644 --- a/client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx +++ b/client/packages/lowcoder-comps/src/comps/chartComp/chartComp.tsx @@ -78,7 +78,7 @@ ChartTmpComp = withViewFn(ChartTmpComp, (comp) => { } const triggerClickEvent = async (dispatch: any, action: CompAction) => { - await getPromiseAfterDispatch( + await getPromiseAfterDispatch?.( dispatch, action, { autoHandleAfterReduce: true } diff --git a/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartConstants.tsx index e668de39a..0475493b0 100644 --- a/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartConstants.tsx @@ -248,14 +248,14 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultFunnelChartOption), echartsTitle: withDefault(StringControl, trans("funnelChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, echartsTitleConfig:EchartsTitleConfig, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), label: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), @@ -267,6 +267,12 @@ const chartJsonModeChildren = { max:withDefault(NumberControl,trans('funnelChart.defaultMax')), gap:withDefault(NumberControl,trans('funnelChart.defaultGap')) } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartPropertyView.tsx index 4f90f9ac9..38171e34e 100644 --- a/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartPropertyView.tsx @@ -50,7 +50,7 @@ export function funnelChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartConstants.tsx index 23f14ce77..89571a5bd 100644 --- a/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartConstants.tsx @@ -248,14 +248,14 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultGaugeChartOption), echartsTitle: withDefault(StringControl, trans("gaugeChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, echartsTitleConfig:EchartsTitleConfig, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), label: withDefault(BoolControl, true), @@ -267,7 +267,12 @@ const chartJsonModeChildren = { max:withDefault(NumberControl,trans('gaugeChart.defaultMax')), gap:withDefault(NumberControl,trans('gaugeChart.defaultGap')) } - +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), getMapInstance: FunctionControl, diff --git a/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartPropertyView.tsx index b1ac4bad3..026006072 100644 --- a/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartPropertyView.tsx @@ -46,7 +46,7 @@ export function gaugeChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartConstants.tsx index a643affc4..ae000e6f7 100644 --- a/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultGraphChartOption), echartsTitle: withDefault(StringControl, trans("graphChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartPropertyView.tsx index 3ad76fb1e..ba9ebbebc 100644 --- a/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartPropertyView.tsx @@ -38,7 +38,7 @@ export function graphChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartConstants.tsx index 2ecfd3091..51ccd46da 100644 --- a/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultHeatmapChartOption), echartsTitle: withDefault(StringControl, trans("heatmapChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartPropertyView.tsx index 8f990546e..c7d350bfc 100644 --- a/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/heatmapChartComp/heatmapChartPropertyView.tsx @@ -38,7 +38,7 @@ export function heatmapChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartConstants.tsx index be9ed1ec1..44d2631b8 100644 --- a/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultRadarChartOption), echartsTitle: withDefault(StringControl, trans("radarChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartPropertyView.tsx index f6ea20b14..9a095b585 100644 --- a/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartPropertyView.tsx @@ -38,7 +38,7 @@ export function radarChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartConstants.tsx index 7d834e9d7..681d119e6 100644 --- a/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultSankeyChartOption), echartsTitle: withDefault(StringControl, trans("sankeyChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartPropertyView.tsx index da18ef2a4..4acfb77f8 100644 --- a/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartPropertyView.tsx @@ -39,7 +39,7 @@ export function sankeyChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartConstants.tsx index 51aa6ae0e..a26e08c2c 100644 --- a/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultSunburstChartOption), echartsTitle: withDefault(StringControl, trans("sunburstChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartPropertyView.tsx index c8e631be8..9b2ff99b0 100644 --- a/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/sunburstChartComp/sunburstChartPropertyView.tsx @@ -38,7 +38,7 @@ export function sunburstChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartConstants.tsx index e2f973ea2..8819fb2fb 100644 --- a/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartConstants.tsx @@ -247,17 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultThemeriverChartOption), echartsTitle: withDefault(StringControl, trans("themeriverChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } - +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), getMapInstance: FunctionControl, diff --git a/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartPropertyView.tsx index 529dbcc57..1825bc6ee 100644 --- a/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartPropertyView.tsx @@ -38,7 +38,7 @@ export function themeriverChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartConstants.tsx index 8dfe7f49c..62804d637 100644 --- a/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultTreeChartOption), echartsTitle: withDefault(StringControl, trans("treeChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartPropertyView.tsx index 920062913..342906516 100644 --- a/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartPropertyView.tsx @@ -38,7 +38,7 @@ export function treeChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
diff --git a/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartConstants.tsx b/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartConstants.tsx index 45ff3ad5d..92697cb79 100644 --- a/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartConstants.tsx +++ b/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartConstants.tsx @@ -247,16 +247,22 @@ export const chartUiModeChildren = { onUIEvent: eventHandlerControl(UIEventOptions), }; -const chartJsonModeChildren = { +let chartJsonModeChildren: any = { echartsOption: jsonControl(toObject, i18nObjs.defaultTreemapChartOption), echartsTitle: withDefault(StringControl, trans("treemapChart.defaultTitle")), echartsLegendConfig: EchartsLegendConfig, echartsLabelConfig: EchartsLabelConfig, echartsConfig: EchartsOptionComp, - style: styleControl(EchartsStyle, 'style'), + // style: styleControl(EchartsStyle, 'style'), tooltip: withDefault(BoolControl, true), legendVisibility: withDefault(BoolControl, true), } +if (EchartsStyle) { + chartJsonModeChildren = { + ...chartJsonModeChildren, + style: styleControl(EchartsStyle, 'style'), + } +} const chartMapModeChildren = { mapInstance: stateComp(), diff --git a/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartPropertyView.tsx b/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartPropertyView.tsx index 4d5c543bb..a4fc43e02 100644 --- a/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartPropertyView.tsx +++ b/client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartPropertyView.tsx @@ -38,7 +38,7 @@ export function treeChartPropertyView( {children.onEvent.propertyView()}
- {children.style.getPropertyView()} + {children.style?.getPropertyView()}
{hiddenPropertyView(children)}
From 1e63563a07ce707707f4b6254e28a7b37bda9e1b Mon Sep 17 00:00:00 2001 From: Thomasr Date: Mon, 15 Jul 2024 12:05:36 -0400 Subject: [PATCH 04/40] fix github issue and null email issue --- .../java/org/lowcoder/domain/user/service/UserServiceImpl.java | 1 + .../authentication/request/oauth2/Oauth2AuthRequestFactory.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/service/UserServiceImpl.java b/server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/service/UserServiceImpl.java index 58c2eaf21..5ea708c26 100644 --- a/server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/service/UserServiceImpl.java +++ b/server/api-service/lowcoder-domain/src/main/java/org/lowcoder/domain/user/service/UserServiceImpl.java @@ -113,6 +113,7 @@ public Mono findByName(String rawUuid) { } public Mono findByEmailDeep(String email) { + if(StringUtils.isEmpty(email)) return Mono.empty(); return repository.findByEmailOrConnections_Email(email, email).next(); } diff --git a/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java b/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java index 0024d03f5..2fc33e9fb 100644 --- a/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java +++ b/server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/request/oauth2/Oauth2AuthRequestFactory.java @@ -43,7 +43,6 @@ yield new GenericAuthRequest(Oauth2GenericAuthConfig.builder() .enableRegister(config.isEnableRegister()) .enable(config.isEnable()) .scope("read:email read:user") - .userCanSelectAccounts(true) .sourceMappings(sourceMappings) .clientSecret(config.getClientSecret()) .clientId(config.getClientId()) From 0e2b3cc23be50a6e5b4e90e1d578f11b63e2cdb7 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Tue, 16 Jul 2024 21:41:14 +0500 Subject: [PATCH 05/40] fix dropdown options events wrongly trigger on hiding option --- .../lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx b/client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx index 8e99f5a4c..629314582 100644 --- a/client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx @@ -111,7 +111,8 @@ const DropdownTmpComp = (function () { items={items} onClick={({ key }) => { const item = items.find((o) => o.key === key); - item && props.options[item.index]?.onEvent("click"); + const itemIndex = props.options.findIndex(option => option.label === item?.label); + item && props.options[itemIndex]?.onEvent("click"); }} /> ); From 6c8722a5088196caa7e8af1ec9f8311b87844b94 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Wed, 17 Jul 2024 21:17:16 +0500 Subject: [PATCH 06/40] added oauth and cookie fields for data sources --- client/packages/lowcoder-sdk/dataSource.d.ts | 12 +++ .../datasource/form/httpDatasourceForm.tsx | 2 +- .../datasource/form/pluginDataSourceForm.tsx | 93 ++++++++++++++++++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/client/packages/lowcoder-sdk/dataSource.d.ts b/client/packages/lowcoder-sdk/dataSource.d.ts index 797698767..2d9c4f980 100644 --- a/client/packages/lowcoder-sdk/dataSource.d.ts +++ b/client/packages/lowcoder-sdk/dataSource.d.ts @@ -319,6 +319,18 @@ export interface DataSourcePluginMeta extends DataSourcePluginBasicInfo { DataSourceConfig, { extra?: DynamicConfigObject; + authConfig?: { + type: AuthType; + authId?: string; + } & ( + | { + username: string; // basic auth + password: string; + } + | OAuthConfig + ); + + sslConfig?: SSLConfig; } >; queryConfig: DynamicConfigObject | QueryConfig; diff --git a/client/packages/lowcoder/src/pages/datasource/form/httpDatasourceForm.tsx b/client/packages/lowcoder/src/pages/datasource/form/httpDatasourceForm.tsx index 7c4b13a0e..150ce84de 100644 --- a/client/packages/lowcoder/src/pages/datasource/form/httpDatasourceForm.tsx +++ b/client/packages/lowcoder/src/pages/datasource/form/httpDatasourceForm.tsx @@ -24,7 +24,7 @@ import { useHostCheck } from "./useHostCheck"; import { useSelector } from "react-redux"; import { getUser } from "redux/selectors/usersSelectors"; -const AuthTypeOptions = [ +export const AuthTypeOptions = [ { label: "None", value: "NO_AUTH" }, { label: "Basic", value: "BASIC_AUTH" }, { label: "Digest", value: "DIGEST_AUTH" }, diff --git a/client/packages/lowcoder/src/pages/datasource/form/pluginDataSourceForm.tsx b/client/packages/lowcoder/src/pages/datasource/form/pluginDataSourceForm.tsx index 3ed9c974a..c511bfd1c 100644 --- a/client/packages/lowcoder/src/pages/datasource/form/pluginDataSourceForm.tsx +++ b/client/packages/lowcoder/src/pages/datasource/form/pluginDataSourceForm.tsx @@ -22,7 +22,7 @@ import { TacoMarkDown, } from "lowcoder-design"; import { DatasourceFormProps } from "./datasourceFormRegistry"; -import { DatasourceNameFormInputItem, GeneralSettingFormSectionLabel } from "../form"; +import { AdvancedSettingFormSectionLabel, CertValidationFormItem, DatasourceNameFormInputItem, ForwardCookiesFormItem, GeneralSettingFormSectionLabel, encryptedPlaceholder } from "../form"; import { DataSourceParamConfig, ParamOption, @@ -38,6 +38,9 @@ import { FieldData } from "rc-field-form/es/interface"; import { default as Alert } from "antd/es/alert"; import { default as Form } from "antd/es/form"; import { default as Input } from "antd/es/input"; +import { AuthType, AuthTypeOptions } from "./httpDatasourceForm"; +import { useSelector } from "react-redux"; +import { getUser } from "@lowcoder-ee/redux/selectors/usersSelectors"; const TooltipWrapper = styled.div` .markdown-body { @@ -130,14 +133,24 @@ export const PluginDataSourceForm = (props: DatasourceFormProps) => { const [extraParamConfigs, setExtraParamConfigs] = useState([]); const [isExtraParamsRefreshing, setExtraParamRefreshing] = useState(false); const [isExtraParamsRefreshError, setExtraParamRefreshError] = useState(false); + const pluginDef = dataSourceTypeInfo?.definition || datasource.pluginDefinition; const pluginName = dataSourceTypeInfo?.id || datasource.pluginDefinition?.id; const isEditing = !!datasource; const hasDynamicConfig = !!pluginDef?.dataSourceConfig?.extra; + + const [authType, setAuthType] = useState(pluginDef?.dataSourceConfig?.authConfig?.type); + const [authId, setAuthId] = useState(pluginDef?.dataSourceConfig?.authConfig?.authId); const readyStatusCallbackRef = useRef(onFormReadyStatusChange); readyStatusCallbackRef.current = onFormReadyStatusChange; + const userAuthSources = useSelector(getUser).connections?.filter(authSource => authSource.source !== "EMAIL");; + const userAuthSourcesOptions = userAuthSources?.map(item => ({ + label: item.source, + value: item.authId + })) || []; + const handleRefreshExtraParams = useCallback(() => { if (!pluginName) { return; @@ -205,6 +218,65 @@ export const PluginDataSourceForm = (props: DatasourceFormProps) => { const initialValues = getDefaultValues(pluginDef, datasource); const hasGeneralSettings = dataSourceConfig.params?.[0]?.type !== "groupTitle"; + const UsernameFormItem = ( + + ); + + const PasswordFormItem = ( + + ); + + const showAuthItem = (type: AuthType) => { + switch (type) { + case "BASIC_AUTH": + return ( + <> + {UsernameFormItem} + {PasswordFormItem} + + ); + case "DIGEST_AUTH": + return ( + <> + {UsernameFormItem} + {PasswordFormItem} + + ); + } + }; + + const showUserAuthSourceSelector = () => { + if (authType === "OAUTH2_INHERIT_FROM_LOGIN") { + return ( + setAuthId(value) } + labelWidth={142} + /> + ); + } + return null; + }; + return ( @@ -237,6 +309,25 @@ export const PluginDataSourceForm = (props: DatasourceFormProps) => { ); })} + + {trans("query.authentication")} + setAuthType(value)} + labelWidth={142} + /> + {showUserAuthSourceSelector()} + {showAuthItem(authType)} + + + + + + + {isExtraParamsRefreshing && ( )} From 982f98be195087252d43175a7cf2006a209f57f7 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Tue, 16 Jul 2024 18:34:45 +0500 Subject: [PATCH 07/40] added dropdown in app settings to change lowcoder-comps version --- .../src/comps/comps/appSettingsComp.tsx | 45 ++++++++++++++++++- .../src/comps/comps/remoteComp/remoteComp.tsx | 26 +++++++---- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx b/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx index d4de3b59f..1f8016ced 100644 --- a/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx @@ -4,7 +4,7 @@ import { dropdownInputSimpleControl } from "comps/controls/dropdownInputSimpleCo import { MultiCompBuilder, valueComp, withDefault } from "comps/generators"; import { AddIcon, Dropdown } from "lowcoder-design"; import { EllipsisSpan } from "pages/setting/theme/styledComponents"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import { getDefaultTheme, getThemeList } from "redux/selectors/commonSettingSelectors"; import styled, { css } from "styled-components"; @@ -19,6 +19,8 @@ import { IconControl } from "comps/controls/iconControl"; import { dropdownControl } from "comps/controls/dropdownControl"; import { ApplicationCategoriesEnum } from "constants/applicationConstants"; import { BoolControl } from "../controls/boolControl"; +import { getNpmPackageMeta } from "../utils/remote"; +import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils"; const TITLE = trans("appSetting.title"); const USER_DEFINE = "__USER_DEFINE"; @@ -189,6 +191,7 @@ const childrenMap = { preventAppStylesOverwriting: withDefault(BoolControl, true), customShortcuts: CustomShortcutsComp, disableCollision: valueComp(false), + lowcoderCompVersion: withDefault(StringControl, 'latest'), }; type ChildrenInstance = RecordConstructorToComp & { themeList: ThemeType[]; @@ -196,6 +199,7 @@ type ChildrenInstance = RecordConstructorToComp & { }; function AppSettingsModal(props: ChildrenInstance) { + const [lowcoderCompVersions, setLowcoderCompVersions] = useState(['latest']); const { themeList, defaultTheme, @@ -207,11 +211,14 @@ function AppSettingsModal(props: ChildrenInstance) { category, showHeaderInPublic, preventAppStylesOverwriting, + lowcoderCompVersion, } = props; + const THEME_OPTIONS = themeList?.map((theme) => ({ label: theme.name, value: theme.id + "", })); + const themeWithDefault = ( themeId.getView() === DEFAULT_THEMEID || (!!themeId.getView() && @@ -225,6 +232,17 @@ function AppSettingsModal(props: ChildrenInstance) { themeId.dispatchChangeValueAction(themeWithDefault); } }, [themeWithDefault]); + + useEffect(() => { + const fetchCompsPackageMeta = async () => { + const packageMeta = await getNpmPackageMeta('lowcoder-comps'); + if (packageMeta?.versions) { + setLowcoderCompVersions(Object.keys(packageMeta.versions).reverse()) + } + } + fetchCompsPackageMeta(); + }, []) + const DropdownItem = (params: { value: string }) => { const themeItem = themeList.find((theme) => theme.id === params.value); @@ -308,6 +326,31 @@ function AppSettingsModal(props: ChildrenInstance) { })} + + + ({label: version, value: version})) + } + label={'Lowcoder Comps Version'} + placement="bottom" + allowClear + onChange={async (value) => { + await getPromiseAfterDispatch( + lowcoderCompVersion.dispatch, + lowcoderCompVersion.changeValueAction(value), { + autoHandleAfterReduce: true, + } + ) + setTimeout(() => { + window.location.reload(); + }, 1000); + }} + /> + + {props.customShortcuts.getPropertyView()} ); diff --git a/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx b/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx index be0f9aae2..64f018582 100644 --- a/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx @@ -5,12 +5,13 @@ import { GreyTextColor } from "constants/style"; import log from "loglevel"; import { Comp, CompAction, CompParams, customAction, isCustomAction } from "lowcoder-core"; import { WhiteLoading } from "lowcoder-design"; -import { useState } from "react"; +import { useContext, useState } from "react"; import { useMount } from "react-use"; import styled from "styled-components"; import { RemoteCompInfo, RemoteCompLoader } from "types/remoteComp"; import { loaders } from "./loaders"; import { withErrorBoundary } from "comps/generators/withErrorBoundary"; +import { EditorContext } from "@lowcoder-ee/comps/editorState"; const ViewError = styled.div` display: flex; @@ -45,18 +46,22 @@ interface RemoteCompReadyAction { } interface RemoteCompViewProps { - loadComp: () => Promise; + isLowcoderComp?: boolean; + loadComp: (packageVersion?: string) => Promise; loadingElement?: () => React.ReactNode; errorElement?: (error: any) => React.ReactNode; } function RemoteCompView(props: React.PropsWithChildren) { - const { loadComp, loadingElement, errorElement } = props; + const { loadComp, loadingElement, errorElement, isLowcoderComp } = props; const [error, setError] = useState(""); - + const editorState = useContext(EditorContext); + const lowcoderCompPackageVersion = editorState?.getAppSettings().lowcoderCompVersion || 'latest'; + const packageVersion = isLowcoderComp ? lowcoderCompPackageVersion : 'latest'; + useMount(() => { setError(""); - loadComp().catch((e) => { + loadComp(packageVersion).catch((e) => { setError(String(e)); }); }); @@ -96,7 +101,7 @@ export function remoteComp( this.compValue = params.value; } - private async load() { + private async load(packageVersion = 'latest') { if (!remoteInfo) { return; } @@ -108,7 +113,7 @@ export function remoteComp( log.error("loader not found, remote info:", remoteInfo); return; } - const RemoteExportedComp = await finalLoader(remoteInfo); + const RemoteExportedComp = await finalLoader({...remoteInfo, packageVersion}); if (!RemoteExportedComp) { return; } @@ -135,7 +140,12 @@ export function remoteComp( getView() { const key = `${remoteInfo?.packageName}-${remoteInfo?.packageVersion}-${remoteInfo?.compName}`; return ( - this.load()} loadingElement={loadingElement} /> + this.load(packageVersion)} + loadingElement={loadingElement} + /> ); } From 868faf540a258766ecf5b8fd01e1c74b1da2de29 Mon Sep 17 00:00:00 2001 From: RAHEEL Date: Wed, 17 Jul 2024 23:57:40 +0500 Subject: [PATCH 08/40] add version change dropdown for comp plugins --- .../lowcoder/src/components/CompName.tsx | 10 ++-- .../src/comps/comps/appSettingsComp.tsx | 1 - .../src/comps/comps/remoteComp/remoteComp.tsx | 15 ++++- .../src/comps/generators/uiCompBuilder.tsx | 59 ++++++++++++++++++- client/packages/lowcoder/src/comps/index.tsx | 6 ++ .../src/constants/compPluginConstants.ts | 8 +++ 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 client/packages/lowcoder/src/constants/compPluginConstants.ts diff --git a/client/packages/lowcoder/src/components/CompName.tsx b/client/packages/lowcoder/src/components/CompName.tsx index b350cf746..0e11d10e2 100644 --- a/client/packages/lowcoder/src/components/CompName.tsx +++ b/client/packages/lowcoder/src/components/CompName.tsx @@ -121,12 +121,12 @@ export const CompName = (props: Iprops) => { onClick: () => { }, }); - items.push({ - text: trans("history.currentVersion") + ": " + compInfo.packageVersion, - onClick: () => { + // items.push({ + // text: trans("history.currentVersion") + ": " + compInfo.packageVersion, + // onClick: () => { - }, - }); + // }, + // }); items.push({ text: trans("comp.menuUpgradeToLatest"), diff --git a/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx b/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx index 1f8016ced..667c2b9ae 100644 --- a/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx @@ -336,7 +336,6 @@ function AppSettingsModal(props: ChildrenInstance) { } label={'Lowcoder Comps Version'} placement="bottom" - allowClear onChange={async (value) => { await getPromiseAfterDispatch( lowcoderCompVersion.dispatch, diff --git a/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx b/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx index 64f018582..ce3611793 100644 --- a/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/remoteComp/remoteComp.tsx @@ -12,6 +12,7 @@ import { RemoteCompInfo, RemoteCompLoader } from "types/remoteComp"; import { loaders } from "./loaders"; import { withErrorBoundary } from "comps/generators/withErrorBoundary"; import { EditorContext } from "@lowcoder-ee/comps/editorState"; +import { CompContext } from "@lowcoder-ee/comps/utils/compContext"; const ViewError = styled.div` display: flex; @@ -56,9 +57,19 @@ function RemoteCompView(props: React.PropsWithChildren) { const { loadComp, loadingElement, errorElement, isLowcoderComp } = props; const [error, setError] = useState(""); const editorState = useContext(EditorContext); + const compState = useContext(CompContext); const lowcoderCompPackageVersion = editorState?.getAppSettings().lowcoderCompVersion || 'latest'; - const packageVersion = isLowcoderComp ? lowcoderCompPackageVersion : 'latest'; - + + let packageVersion = 'latest'; + // lowcoder-comps's package version + if (isLowcoderComp) { + packageVersion = lowcoderCompPackageVersion; + } + // component plugin's package version + else if (compState.comp?.comp.version) { + packageVersion = compState.comp?.comp.version; + } + useMount(() => { setError(""); loadComp(packageVersion).catch((e) => { diff --git a/client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx b/client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx index 559f93945..cbfea61ef 100644 --- a/client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx +++ b/client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx @@ -1,5 +1,5 @@ import { BoolCodeControl, StringControl } from "comps/controls/codeControl"; -import React, { ReactNode, useContext, useRef } from "react"; +import React, { ReactNode, useContext, useEffect, useRef, useState } from "react"; import { ExternalEditorContext } from "util/context/ExternalEditorContext"; import { Comp, CompParams, MultiBaseComp } from "lowcoder-core"; import { @@ -22,10 +22,17 @@ import { MethodConfigsType, withMethodExposing, } from "./withMethodExposing"; -import { Section } from "lowcoder-design"; +import {Section, controlItem } from "lowcoder-design"; import { trans } from "i18n"; import { BoolControl } from "../controls/boolControl"; import { valueComp, withDefault } from "./simpleGenerators"; +import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils"; +import { EditorContext } from "../editorState"; +import { values } from "lodash"; +import { UICompType, uiCompRegistry } from "../uiCompRegistry"; +import { getNpmPackageMeta } from "../utils/remote"; +import { compPluginsList } from "constants/compPluginConstants"; +import Select from "antd/es/select"; export type NewChildren>> = ChildrenCompMap & { @@ -33,6 +40,7 @@ export type NewChildren>> = className: InstanceType; dataTestId: InstanceType; preventStyleOverwriting: InstanceType; + version: InstanceType; }; export function HidableView(props: { @@ -64,6 +72,28 @@ export function ExtendedPropertyView< childrenMap: NewChildren } ) { + const [compVersions, setCompVersions] = useState(['latest']); + const [compName, setCompName] = useState(''); + const editorState = useContext(EditorContext); + const selectedComp = values(editorState.selectedComps())[0]; + const compType = selectedComp.children.compType.getView() as UICompType; + + useEffect(() => { + setCompName(uiCompRegistry[compType].compName || ''); + }, [compType]); + + useEffect(() => { + const fetchCompsPackageMeta = async () => { + const packageMeta = await getNpmPackageMeta(compName); + if (packageMeta?.versions) { + setCompVersions(Object.keys(packageMeta.versions).reverse()) + } + } + if (Boolean(compName) && compPluginsList.includes(compName)) { + fetchCompsPackageMeta(); + } + }, [compName]); + return ( <> {props.children} @@ -72,6 +102,30 @@ export function ExtendedPropertyView< {props.childrenMap.dataTestId?.propertyView({ label: trans("prop.dataTestId") })} {props.childrenMap.preventStyleOverwriting?.propertyView({ label: trans("prop.preventOverwriting") })} + {compPluginsList.includes(compName) && ( +
+ {controlItem({}, ( +