Skip to content

Commit

Permalink
Merge pull request #767 from Lowcoder-Pro/dev
Browse files Browse the repository at this point in the history
Lowcoder Plugin System
  • Loading branch information
FalkWolsky authored Mar 24, 2024
2 parents 7758d4a + 348c98e commit 3476223
Show file tree
Hide file tree
Showing 117 changed files with 2,998 additions and 924 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ client/node_modules/
client/packages/lowcoder-plugin-demo/.yarn/install-state.gz
client/packages/lowcoder-plugin-demo/yarn.lock
client/packages/lowcoder-plugin-demo/.yarn/cache/@types-node-npm-16.18.68-56f72825c0-094ae9ed80.zip
application-dev.yml
2 changes: 1 addition & 1 deletion client/packages/lowcoder-comps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lowcoder-comps",
"version": "0.0.26",
"version": "0.0.27",
"type": "module",
"license": "MIT",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import {

import { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";

const getStyle = (style: InputLikeStyleType) => {
return css`
Expand Down Expand Up @@ -372,7 +374,7 @@ const CustomInputNumber = (props: RecordConstructorToView<typeof childrenMap>) =
);
};

const NumberInputTmpComp = (function () {
let NumberInputTmpComp = (function () {
return new UICompBuilder(childrenMap, (props) => {
return props.label({
required: props.required,
Expand Down Expand Up @@ -434,6 +436,8 @@ const NumberInputTmpComp = (function () {
.build();
})();

NumberInputTmpComp = migrateOldData(NumberInputTmpComp, fixOldInputCompData);

const NumberInputTmp2Comp = withMethodExposing(
NumberInputTmpComp,
refMethods([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { ValueFromOption } from "lowcoder-design";
import { EllipsisTextCss } from "lowcoder-design";
import { trans } from "i18n";
import { RefControl } from "comps/controls/refControl";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";

export const getStyle = (style: CheckboxStyleType) => {
return css`
Expand Down Expand Up @@ -126,7 +128,7 @@ const CheckboxGroup = styled(AntdCheckboxGroup) <{
}}
`;

const CheckboxBasicComp = (function () {
let CheckboxBasicComp = (function () {
const childrenMap = {
defaultValue: arrayStringExposingStateControl("defaultValue"),
value: arrayStringExposingStateControl("value"),
Expand Down Expand Up @@ -176,6 +178,8 @@ const CheckboxBasicComp = (function () {
.build();
})();

CheckboxBasicComp = migrateOldData(CheckboxBasicComp, fixOldInputCompData);

export const CheckboxComp = withExposingConfigs(CheckboxBasicComp, [
new NameConfig("value", trans("selectInput.valueDesc")),
SelectInputInvalidConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import { SelectInputInvalidConfig, useSelectInputValidate } from "./selectInputC

import { PaddingControl } from "../../controls/paddingControl";
import { MarginControl } from "../../controls/marginControl";
import { useEffect, useRef } from "react";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";

const MultiSelectBasicComp = (function () {
let MultiSelectBasicComp = (function () {
const childrenMap = {
...SelectChildrenMap,
defaultValue: arrayStringExposingStateControl("defaultValue", ["1", "2"]),
Expand Down Expand Up @@ -52,6 +53,8 @@ const MultiSelectBasicComp = (function () {
.build();
})();

MultiSelectBasicComp = migrateOldData(MultiSelectBasicComp, fixOldInputCompData);

export const MultiSelectComp = withExposingConfigs(MultiSelectBasicComp, [
new NameConfig("value", trans("selectInput.valueDesc")),
new NameConfig("inputValue", trans("select.inputValueDesc")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from "./selectInputConstants";
import { EllipsisTextCss, ValueFromOption } from "lowcoder-design";
import { trans } from "i18n";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";
import { migrateOldData } from "comps/generators/simpleGenerators";

const getStyle = (style: RadioStyleType) => {
return css`
Expand Down Expand Up @@ -93,7 +95,7 @@ const Radio = styled(AntdRadioGroup)<{
}}
`;

const RadioBasicComp = (function () {
let RadioBasicComp = (function () {
return new UICompBuilder(RadioChildrenMap, (props) => {
const [
validateState,
Expand Down Expand Up @@ -129,6 +131,8 @@ const RadioBasicComp = (function () {
.build();
})();

RadioBasicComp = migrateOldData(RadioBasicComp, fixOldInputCompData);

export const RadioComp = withExposingConfigs(RadioBasicComp, [
new NameConfig("value", trans("selectInput.valueDesc")),
SelectInputInvalidConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { RefControl } from "comps/controls/refControl";

import { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { migrateOldData } from "comps/generators/simpleGenerators";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";


const getStyle = (style: SegmentStyleType) => {
return css`
Expand Down Expand Up @@ -83,7 +86,7 @@ const SegmentChildrenMap = {
...formDataChildren,
};

const SegmentedControlBasicComp = (function () {
let SegmentedControlBasicComp = (function () {
return new UICompBuilder(SegmentChildrenMap, (props) => {
const [
validateState,
Expand Down Expand Up @@ -147,6 +150,8 @@ const SegmentedControlBasicComp = (function () {
.build();
})();

SegmentedControlBasicComp = migrateOldData(SegmentedControlBasicComp, fixOldInputCompData);

export const SegmentedControlComp = withExposingConfigs(SegmentedControlBasicComp, [
new NameConfig("value", trans("selectInput.valueDesc")),
SelectInputInvalidConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import {
} from "./selectInputConstants";
import { useRef } from "react";
import { RecordConstructorToView } from "lowcoder-core";
import { fixOldInputCompData } from "../textInputComp/textInputConstants";
import { migrateOldData } from "comps/generators/simpleGenerators";

const SelectBasicComp = (function () {
let SelectBasicComp = (function () {
const childrenMap = {
...SelectChildrenMap,
defaultValue: stringExposingStateControl("defaultValue"),
Expand Down Expand Up @@ -55,6 +57,8 @@ const SelectBasicComp = (function () {
.build();
})();

SelectBasicComp = migrateOldData(SelectBasicComp, fixOldInputCompData);

export const SelectComp = withExposingConfigs(SelectBasicComp, [
new NameConfig("value", trans("selectInput.valueDesc")),
new NameConfig("inputValue", trans("select.inputValueDesc")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import styled from "styled-components";
import { UICompBuilder } from "../../generators";
import { FormDataPropertyView } from "../formComp/formDataConstants";
import {
fixOldInputCompData,
getStyle,
inputRefMethods,
TextInputBasicSection,
Expand All @@ -30,6 +31,7 @@ import { IconControl } from "comps/controls/iconControl";
import { hasIcon } from "comps/utils";
import { InputRef } from "antd/es/input";
import { RefControl } from "comps/controls/refControl";
import { migrateOldData } from "comps/generators/simpleGenerators";

import React, { useContext } from "react";
import { EditorContext } from "comps/editorState";
Expand All @@ -52,7 +54,7 @@ const childrenMap = {
suffixIcon: IconControl,
};

export const InputComp = new UICompBuilder(childrenMap, (props) => {
let InputBasicComp = new UICompBuilder(childrenMap, (props) => {
const [inputProps, validateState] = useTextInputProps(props);
return props.label({
required: props.required,
Expand Down Expand Up @@ -108,3 +110,8 @@ export const InputComp = new UICompBuilder(childrenMap, (props) => {
...TextInputConfigs,
])
.build();


const InputComp = migrateOldData(InputBasicComp, fixOldInputCompData);

export { InputComp };
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { UICompBuilder } from "../../generators";
import { FormDataPropertyView } from "../formComp/formDataConstants";
import {
checkMentionListData,
fixOldInputCompData,
textInputChildren,
} from "./textInputConstants";
import {
Expand Down Expand Up @@ -42,7 +43,7 @@ import { blurMethod, focusWithOptions } from "comps/utils/methodUtils";
import {
textInputValidate,
} from "../textInputComp/textInputConstants";
import { jsonControl } from "@lowcoder-ee/comps/controls/codeControl";
import { jsonControl } from "comps/controls/codeControl";
import {
submitEvent,
eventHandlerControl,
Expand All @@ -54,6 +55,7 @@ import {

import React, { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { migrateOldData } from "comps/generators/simpleGenerators";

const Wrapper = styled.div<{
$style: InputLikeStyleType;
Expand Down Expand Up @@ -267,12 +269,15 @@ let MentionTmpComp = (function () {
.build();
})();


MentionTmpComp = class extends MentionTmpComp {
override autoHeight(): boolean {
return this.children.autoHeight.getView();
}
};

MentionTmpComp = migrateOldData(MentionTmpComp, fixOldInputCompData);

const TextareaTmp2Comp = withMethodExposing(
MentionTmpComp,
refMethods([focusWithOptions, blurMethod])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { LabelControl } from "../../controls/labelControl";
import { UICompBuilder, withDefault } from "../../generators";
import { FormDataPropertyView } from "../formComp/formDataConstants";
import {
fixOldInputCompData,
getStyle,
inputRefMethods,
TextInputBasicSection,
Expand Down Expand Up @@ -40,14 +41,15 @@ import { hasIcon } from "comps/utils";
import { RefControl } from "comps/controls/refControl";
import React, { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { migrateOldData } from "comps/generators/simpleGenerators";

const PasswordStyle = styled(InputPassword)<{
$style: InputLikeStyleType;
}>`
${(props) => props.$style && getStyle(props.$style)}
`;

const PasswordTmpComp = (function () {
let PasswordTmpComp = (function () {
const childrenMap = {
...textInputChildren,
viewRef: RefControl<InputRef>,
Expand Down Expand Up @@ -111,6 +113,8 @@ const PasswordTmpComp = (function () {
.build();
})();

PasswordTmpComp = migrateOldData(PasswordTmpComp, fixOldInputCompData);

const PasswordTmp2Comp = withMethodExposing(PasswordTmpComp, inputRefMethods);

export const PasswordComp = withExposingConfigs(PasswordTmp2Comp, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AutoHeightControl } from "../../controls/autoHeightControl";
import { UICompBuilder, withDefault } from "../../generators";
import { FormDataPropertyView } from "../formComp/formDataConstants";
import {
fixOldInputCompData,
getStyle,
TextInputBasicSection,
textInputChildren,
Expand All @@ -35,6 +36,7 @@ import { blurMethod, focusWithOptions } from "comps/utils/methodUtils";

import React, { useContext } from "react";
import { EditorContext } from "comps/editorState";
import { migrateOldData } from "comps/generators/simpleGenerators";

const TextAreaStyled = styled(TextArea)<{
$style: InputLikeStyleType;
Expand Down Expand Up @@ -126,6 +128,8 @@ TextAreaTmpComp = class extends TextAreaTmpComp {
}
};

TextAreaTmpComp = migrateOldData(TextAreaTmpComp, fixOldInputCompData);

const TextareaTmp2Comp = withMethodExposing(
TextAreaTmpComp,
refMethods([focusWithOptions, blurMethod])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,17 @@ export function checkMentionListData(data: any) {
}
return data
}

// separate defaultValue and value for old components
export function fixOldInputCompData(oldData: any) {
if (!oldData) return oldData;
if (Boolean(oldData.value) && !Boolean(oldData.defaultValue)) {
const value = oldData.value;
return {
...oldData,
defaultValue: value,
value: '',
};
}
return oldData;
}
20 changes: 11 additions & 9 deletions deploy/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@
## Build Lowcoder api-service application
##
FROM maven:3.9-eclipse-temurin-17 AS build-api-service

# Build lowcoder-api
COPY ./server/api-service /lowcoder-server
WORKDIR /lowcoder-server
RUN --mount=type=cache,target=/root/.m2 mvn -f pom.xml clean package -DskipTests

# Create required folder structure
RUN mkdir -p /lowcoder/api-service/plugins /lowcoder/api-service/config /lowcoder/api-service/logs

# Define lowcoder main jar and plugin jars
ARG JAR_FILE=/lowcoder-server/lowcoder-server/target/lowcoder-server-*.jar
ARG PLUGIN_JARS=/lowcoder-server/lowcoder-plugins/*/target/*.jar

# Copy lowcoder server application and plugins
RUN cp ${JAR_FILE} /lowcoder/api-service/server.jar \
&& cp ${PLUGIN_JARS} /lowcoder/api-service/plugins/
RUN mkdir -p /lowcoder/api-service/config /lowcoder/api-service/logs /lowcoder/plugins

# Copy lowcoder server configuration
COPY server/api-service/lowcoder-server/src/main/resources/selfhost/ce/application.yml /lowcoder/api-service/config/
Expand Down Expand Up @@ -43,6 +37,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends gosu \
# Copy lowcoder server configuration
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder/api-service /lowcoder/api-service

# Copy lowcoder api service app, dependencies and libs
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder-server/distribution/target/lowcoder-api-service-bin/app /lowcoder/api-service/app
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder-server/distribution/target/lowcoder-api-service-bin/dependencies /lowcoder/api-service/dependencies
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder-server/distribution/target/lowcoder-api-service-bin/libs /lowcoder/api-service/libs
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder-server/distribution/target/lowcoder-api-service-bin/plugins /lowcoder/api-service/plugins
COPY --chown=lowcoder:lowcoder --from=build-api-service /lowcoder-server/distribution/target/lowcoder-api-service-bin/set-classpath.sh /lowcoder/api-service/set-classpath.sh

EXPOSE 8080
CMD [ "sh" , "/lowcoder/api-service/entrypoint.sh" ]

Expand Down Expand Up @@ -202,6 +203,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-instal

# Add lowcoder api-service
COPY --chown=lowcoder:lowcoder --from=lowcoder-ce-api-service /lowcoder/api-service /lowcoder/api-service
RUN mkdir -p /lowcoder/plugins/ && chown lowcoder:lowcoder /lowcoder/plugins/

# Add lowcoder node-service
COPY --chown=lowcoder:lowcoder --from=lowcoder-ce-node-service /lowcoder/node-service /lowcoder/node-service
Expand Down
6 changes: 5 additions & 1 deletion deploy/docker/api-service/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ ${JAVA_HOME}/bin/java -version
echo

cd /lowcoder/api-service
source set-classpath.sh

exec gosu ${USER_ID}:${GROUP_ID} ${JAVA_HOME}/bin/java \
-Djava.util.prefs.userRoot=/tmp \
-Djava.security.egd=file:/dev/./urandom \
-Dhttps.protocols=TLSv1.1,TLSv1.2 \
-Dlog4j2.formatMsgNoLookups=true \
-Dspring.config.location="file:///lowcoder/api-service/config/application.yml,file:///lowcoder/api-service/config/application-selfhost.yml" \
--add-opens java.base/java.nio=ALL-UNNAMED \
-cp "${LOWCODER_CLASSPATH:=.}" \
${JAVA_OPTS} \
-jar "${APP_JAR}" --spring.webflux.base-path=${CONTEXT_PATH} ${CUSTOM_APP_PROPERTIES}
org.lowcoder.api.ServerApplication --spring.webflux.base-path=${CONTEXT_PATH} ${CUSTOM_APP_PROPERTIES}

6 changes: 3 additions & 3 deletions server/api-service/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ dependency-reduced-pom.xml
.run/**
logs/**
tmp/**
/openblocks-server/logs/

# Ignore plugin.properties which are generated dynamically
**/plugin.properties

# to ignore the node_modeules folder
node_modules
Expand All @@ -34,5 +35,4 @@ package-lock.json
# test coverage
coverage-summary.json
app/client/cypress/locators/Widgets.json
/openblocks-domain/logs/
application-lowcoder.yml
application-lowcoder.yml
Loading

0 comments on commit 3476223

Please sign in to comment.