Skip to content

Commit b0453f7

Browse files
ggbond2077QIQI03
authored andcommitted
1. feat: import query library
2. refactor(table): refactor withContext to withParams in table 3. feat: trans comp doc
1 parent dd7c832 commit b0453f7

File tree

81 files changed

+6447
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+6447
-136
lines changed

client/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
},
1212
"scripts": {
1313
"start": "yarn workspace openblocks start",
14+
"start:ee": "REACT_APP_EDITION=enterprise yarn workspace openblocks start",
1415
"build": "yarn node ./scripts/build.js",
15-
"build:skip-main": "yarn node ./scripts/build.mjs --skip-main",
16-
"build:legacy": "yarn workspace openblocks build:legacy",
1716
"test": "jest",
1817
"prepare": "yarn workspace openblocks prepare",
1918
"build:core": "yarn workspace openblocks-core build",

client/packages/openblocks-design/src/components/control.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const LabelWrapper = styled.div<{
8181
}}
8282
`;
8383
const ChildrenWrapper = styled.div<{ layout: ControlLayout }>`
84+
min-width: 0;
8485
${(props) => {
8586
switch (props.layout) {
8687
case "horizontal":

client/packages/openblocks-design/src/components/query.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const QueryConfigLabel = (props: { children?: ReactNode; tooltip?: ReactN
6868
);
6969

7070
export const QueryConfigItemWrapper = styled.div<{ direction?: "row" | "column" }>`
71+
min-width: 0;
7172
flex-grow: 1;
7273
${(props) => {
7374
if (props.direction === "row") {

client/packages/openblocks/src/app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import { isFetchUserFinished } from "redux/selectors/usersSelectors";
4646

4747
const LazyUserAuthComp = React.lazy(() => import("@openblocks-ee/pages/userAuth"));
4848
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
49-
const LazyComponentDoc = React.lazy(() => import("@openblocks-ee/pages/ComponentDoc"));
49+
const LazyComponentDoc = React.lazy(() => import("pages/ComponentDoc"));
50+
const LazyComponentPlayground = React.lazy(() => import("pages/ComponentPlayground"));
5051
const LazyDebugComp = React.lazy(() => import("./debug"));
5152
const LazyDebugNewComp = React.lazy(() => import("./debugNew"));
5253

@@ -128,6 +129,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
128129
<LazyRoute path={USER_AUTH_URL} component={LazyUserAuthComp} />
129130
<LazyRoute path={INVITE_LANDING_URL} component={LazyInviteLanding} />
130131
<LazyRoute path={`${COMPONENT_DOC_URL}/:name`} component={LazyComponentDoc} />
132+
<LazyRoute path={`/playground/:name/:dsl`} component={LazyComponentPlayground} />
131133
<Redirect to={`${COMPONENT_DOC_URL}/input`} path="/components" />
132134

133135
{developEnv() && (

client/packages/openblocks/src/appView/AppView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ export function AppView(props: AppViewProps) {
5757
return true;
5858
},
5959
}),
60+
// eslint-disable-next-line react-hooks/exhaustive-deps
6061
[appId]
6162
);
6263

6364
const [comp] = useCompInstance(params);
6465

6566
useEffect(() => {
6667
onCompChange?.(comp);
68+
// eslint-disable-next-line react-hooks/exhaustive-deps
6769
}, [comp]);
6870

6971
useEffect(() => {
@@ -82,6 +84,7 @@ export function AppView(props: AppViewProps) {
8284
);
8385
}
8486
});
87+
// eslint-disable-next-line react-hooks/exhaustive-deps
8588
}, [moduleInputs]);
8689

8790
return (

client/packages/openblocks/src/appView/OpenblocksAppView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function OpenblocksAppViewBase<I = any, O = any>(
3131
return;
3232
}
3333
bootstrapAppAt<I>(appId, node, options).then(setInstance);
34+
// eslint-disable-next-line react-hooks/exhaustive-deps
3435
}, [appId]);
3536

3637
useEffect(() => {

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { AddIcon, CloseIcon, CustomModalProps, ScrollBar } from "openblocks-design";
1+
import { AddIcon, CloseIcon, CustomModalProps, ImportIconV2, ScrollBar } from "openblocks-design";
22
import { BottomShadow, GreyTextColor, TabActiveColor } from "constants/style";
33
import { trans } from "i18n";
44
import _, { noop } from "lodash";
55
import { CreateDataSourceModal } from "pages/datasource/datasourceModal";
66
import { DataSourceButton } from "pages/datasource/pluginPanel";
7-
import { useState } from "react";
7+
import React, { useState } from "react";
88
import { useResizeDetector } from "react-resize-detector";
99
import styled, { css } from "styled-components";
1010
import { BottomResTypeEnum } from "types/bottomRes";
@@ -20,6 +20,7 @@ import {
2020
QUICK_REST_API_ID,
2121
} from "../constants/datasourceConstants";
2222
import { ResourceType } from "@openblocks-ee/constants/queryConstants";
23+
import { Upload } from "antd";
2324

2425
const Wrapper = styled.div<{ placement: PageType }>`
2526
width: 100%;
@@ -174,6 +175,7 @@ interface ResCreateModalProps extends CustomModalProps {
174175
onSelect: (type: BottomResTypeEnum, extraInfo?: any) => void;
175176
onClose: () => void;
176177
placement?: PageType;
178+
onImport?: (options: any) => void;
177179
}
178180

179181
export function ResCreatePanel(props: ResCreateModalProps) {
@@ -246,6 +248,29 @@ export function ResCreatePanel(props: ResCreateModalProps) {
246248
</>
247249
)}
248250

251+
{placement === "queryLibrary" && props.onImport && (
252+
<>
253+
<div className="section-title">{trans("home.import")}</div>
254+
<div className="section">
255+
<DataSourceListWrapper placement={placement}>
256+
<Upload
257+
accept=".json"
258+
showUploadList={false}
259+
customRequest={(options) => {
260+
props.onImport!(options);
261+
}}
262+
multiple={false}
263+
>
264+
<DataSourceButton size={buttonSize}>
265+
<ImportIconV2 width="20px" height="20px" style={{ marginRight: "8px" }} />
266+
{trans("query.importFromFile")}
267+
</DataSourceButton>
268+
</Upload>
269+
</DataSourceListWrapper>
270+
</div>
271+
</>
272+
)}
273+
249274
<div className="section-title">{trans("query.datasource")}</div>
250275
<div className="section">
251276
<DataSourceListWrapper placement={placement}>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function getFormOptions(editorState: EditorState) {
3838
}
3939

4040
function getForm(editorState: EditorState, formName: string) {
41-
const comp = editorState.getUICompByName(formName);
41+
const comp = editorState?.getUICompByName(formName);
4242
if (comp && comp.children.compType.getView() === "form") {
4343
return comp.children.comp as unknown as IForm;
4444
}

client/packages/openblocks/src/comps/comps/dateComp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export const datePickerControl = (function () {
286286
}}
287287
onFocus={() => props.onEvent("focus")}
288288
onBlur={() => props.onEvent("blur")}
289-
inputReadOnly={checkIsMobile(editorState.getAppSettings().maxWidth)}
289+
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}
290290
/>
291291
</>
292292
);
@@ -375,7 +375,7 @@ export const dateRangeControl = (function () {
375375
}}
376376
onFocus={() => props.onEvent("focus")}
377377
onBlur={() => props.onEvent("blur")}
378-
inputReadOnly={checkIsMobile(editorState.getAppSettings().maxWidth)}
378+
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}
379379
/>
380380
</>
381381
);

client/packages/openblocks/src/comps/comps/moduleContainerComp/moduleMethodListComp.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { EmptyContent } from "components/EmptyContent";
22
import { KeyValueItem, KeyValueItemListWithNewCreateState } from "components/KeyValueItemList";
3-
import { ActionSelectorControl } from "comps/controls/actionSelector/actionSelectorControl";
43
import CompNameControl from "comps/controls/compNameControl";
54
import { list } from "comps/generators/list";
65
import { NameGenerator } from "comps/utils";
7-
import { Section, TacoButton } from "openblocks-design";
6+
import { GreyTextColor } from "constants/style";
87
import { trans } from "i18n";
8+
import { Section, TacoButton } from "openblocks-design";
9+
import styled from "styled-components";
910
import { ModuleMethodListItemComp, WithParamsActionControl } from "./moduleMethodListItemComp";
10-
import { ConfigViewSection } from "./styled";
1111
import ModuleMethodParamListComp from "./moduleMethodParamListComp";
12-
import styled from "styled-components";
13-
import { GreyTextColor } from "constants/style";
12+
import { ConfigViewSection } from "./styled";
1413

1514
const MethodName = styled.div`
1615
color: ${GreyTextColor};
@@ -128,7 +127,7 @@ function PropertyView(props: PropertyViewProps) {
128127
interface MethodItemProps {
129128
name: InstanceType<typeof CompNameControl>;
130129
params: InstanceType<typeof ModuleMethodParamListComp>;
131-
action: InstanceType<typeof ActionSelectorControl>;
130+
action: InstanceType<typeof WithParamsActionControl>;
132131
onDelete: () => void;
133132
showPopover: boolean;
134133
}
@@ -144,15 +143,15 @@ function MethodItem(props: MethodItemProps) {
144143
<>
145144
{name.propertyView({ label: trans("module.name") })}
146145
{params.propertyView({ onParamsConfigChange: handleOnParamsConfigChange })}
147-
{action.propertyView({ label: trans("module.action") })}
146+
{action.getComp().propertyView({ label: trans("module.action") })}
148147
</>
149148
);
150149

151150
return (
152151
<KeyValueItem
153152
del={onDelete}
154153
name={name.getView()}
155-
value={action.displayName()}
154+
value={action.getComp().displayName()}
156155
clickPopoverContent={content}
157156
defaultShowPopover={props.showPopover}
158157
/>

client/packages/openblocks/src/comps/comps/timeComp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const timePickerControl = (function () {
164164
}}
165165
onFocus={() => props.onEvent("focus")}
166166
onBlur={() => props.onEvent("blur")}
167-
inputReadOnly={checkIsMobile(editorState.getAppSettings().maxWidth)}
167+
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}
168168
/>
169169
</>
170170
);
@@ -237,7 +237,7 @@ export const timeRangeControl = (function () {
237237
}}
238238
onFocus={() => props.onEvent("focus")}
239239
onBlur={() => props.onEvent("blur")}
240-
inputReadOnly={checkIsMobile(editorState.getAppSettings().maxWidth)}
240+
inputReadOnly={checkIsMobile(editorState?.getAppSettings().maxWidth)}
241241
/>
242242
</>
243243
);

client/packages/openblocks/src/comps/editorState.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ export class EditorState {
432432
getAppType(): UiLayoutType {
433433
return this.getUIComp().children.compType.getView();
434434
}
435-
436435
}
437436

438437
export const EditorContext = React.createContext<EditorState>(undefined as any);

client/packages/openblocks/src/comps/generators/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ export { withContext } from "./withContext";
1313
export { withType, withTypeAndChildren } from "./withType";
1414
export { withIsLoading } from "./withIsLoading";
1515
export { UICompBuilder } from "./uiCompBuilder";
16+
export { withParams } from "./withParams";
17+
export { map } from "./map";
18+
export { withParamsForMap, withParamsForMapWithDefault } from "./withParamsForMap";
1619

1720
// Note: Do not change the order of the above imports, there are dependencies between modules, and will be studied in detail in the future

client/packages/openblocks/src/comps/generators/map.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ export type ClearAction = {
3131
type: "clear";
3232
};
3333

34-
export function map<ChildComp extends CompConstructor<any, any>>(childConstructor: ChildComp) {
35-
type Comp = ConstructorToComp<ChildComp>;
36-
type DataType = ConstructorToDataType<ChildComp>;
34+
export function map<ChildCompCtor extends CompConstructor<any, any>>(
35+
childConstructor: ChildCompCtor
36+
) {
37+
type Comp = ConstructorToComp<ChildCompCtor>;
38+
type DataType = ConstructorToDataType<ChildCompCtor>;
3739
type MapDataType = Record<string, DataType>;
38-
type NodeValue = NodeToValue<ConstructorToNodeType<ChildComp>>;
40+
type NodeValue = NodeToValue<ConstructorToNodeType<ChildCompCtor>>;
3941

4042
function newChild(
4143
dispatch: (action: CompAction) => void,

0 commit comments

Comments
 (0)