Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb5ff45

Browse files
committed
Removed additional props from multi
1 parent 2b9de40 commit cb5ff45

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

‎client/packages/lowcoder/src/comps/comps/appSettingsComp.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import { DEFAULT_THEMEID } from "comps/utils/themeUtil";
1717
import { NumberControl, RangeControl, StringControl } from "comps/controls/codeControl";
1818
import { IconControl } from "comps/controls/iconControl";
1919
import { dropdownControl } from "comps/controls/dropdownControl";
20-
import { ApplicationCategoriesEnum } from "constants/applicationConstants";
20+
import { ApplicationCategoriesEnum, AppUILayoutType } from "constants/applicationConstants";
2121
import { BoolControl } from "../controls/boolControl";
22-
import { getNpmPackageMeta } from "../utils/remote";
2322
import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils";
2423
import type { AppState } from "@lowcoder-ee/redux/reducers";
2524
import { ColorControl } from "../controls/colorControl";
2625
import { DEFAULT_ROW_COUNT } from "@lowcoder-ee/layout/calculateUtils";
2726
import { AppSettingContext } from "../utils/appSettingContext";
28-
import { isPublicApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
27+
import { currentApplication, isPublicApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
28+
import { isAggregationApp } from "util/appUtils";
2929

3030
const TITLE = trans("appSetting.title");
3131
const USER_DEFINE = "__USER_DEFINE";
@@ -233,11 +233,8 @@ type ChildrenInstance = RecordConstructorToComp<typeof childrenMap> & {
233233
defaultTheme: string;
234234
};
235235

236-
type AppSettingsExtraProps = { isAggregationApp?: boolean };
237-
type AppGeneralSettingsModalProps = ChildrenInstance & AppSettingsExtraProps;
238-
type AppCanvasSettingsModalProps = ChildrenInstance & AppSettingsExtraProps;
239-
240-
function AppGeneralSettingsModal(props: AppGeneralSettingsModalProps) {
236+
function AppGeneralSettingsModal(props: ChildrenInstance) {
237+
const application = useSelector(currentApplication);
241238
const lowcoderCompsMeta = useSelector((state: AppState) => state.npmPlugin.packageMeta['lowcoder-comps']);
242239
const [lowcoderCompVersions, setLowcoderCompVersions] = useState(['latest']);
243240
const {
@@ -247,7 +244,6 @@ function AppGeneralSettingsModal(props: AppGeneralSettingsModalProps) {
247244
category,
248245
showHeaderInPublic,
249246
lowcoderCompVersion,
250-
isAggregationApp
251247
} = props;
252248

253249
useEffect(() => {
@@ -293,7 +289,7 @@ function AppGeneralSettingsModal(props: AppGeneralSettingsModalProps) {
293289
</div>
294290
</DivStyled>
295291
</BaseSection>
296-
{!isAggregationApp &&
292+
{application && !isAggregationApp(AppUILayoutType[application.applicationType]) &&
297293
<BaseSection
298294
name={"Lowcoder Comps"}
299295
width={288}
@@ -325,7 +321,8 @@ function AppGeneralSettingsModal(props: AppGeneralSettingsModalProps) {
325321
}}
326322
/>
327323
</DivStyled>
328-
</BaseSection>}
324+
</BaseSection>
325+
}
329326
<BaseSection
330327
name={"Shortcuts"}
331328
width={288}
@@ -343,7 +340,7 @@ function AppGeneralSettingsModal(props: AppGeneralSettingsModalProps) {
343340
);
344341
}
345342

346-
function AppCanvasSettingsModal(props: AppCanvasSettingsModalProps) {
343+
function AppCanvasSettingsModal(props: ChildrenInstance) {
347344
const isPublicApp = useSelector(isPublicApplication);
348345
const {
349346
themeList,
@@ -522,12 +519,12 @@ export const AppSettingsComp = new MultiCompBuilder(childrenMap, (props) => {
522519
maxWidth: Number(props.maxWidth),
523520
};
524521
})
525-
.setPropertyViewFn((children, extraProps) => {
522+
.setPropertyViewFn((children) => {
526523
const { settingType } = useContext(AppSettingContext);
527524
const themeList = useSelector(getThemeList) || [];
528525
const defaultTheme = (useSelector(getDefaultTheme) || "").toString();
529526
return settingType === 'canvas'
530-
? <AppCanvasSettingsModal {...children} themeList={themeList} defaultTheme={defaultTheme} {...(extraProps || {})} />
531-
: <AppGeneralSettingsModal {...children} themeList={themeList} defaultTheme={defaultTheme} {...(extraProps || {})} />;
527+
? <AppCanvasSettingsModal {...children} themeList={themeList} defaultTheme={defaultTheme} />
528+
: <AppGeneralSettingsModal {...children} themeList={themeList} defaultTheme={defaultTheme} />;
532529
})
533530
.build();

‎client/packages/lowcoder/src/comps/generators/multi.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ export type ViewFnTypeForComp<ViewReturn, ChildrenCompMap> = ViewFnType<
5151
ViewReturn,
5252
ToViewReturn<ChildrenCompMap>
5353
>;
54-
export type PropertyViewFnTypeForComp<ChildrenCompMap, ExtraProps = any> = (
54+
export type PropertyViewFnTypeForComp<ChildrenCompMap> = (
5555
children: ChildrenCompMap,
56-
dispatch: (action: CompAction) => void,
57-
extraProps?: ExtraProps
56+
dispatch: (action: CompAction) => void
5857
) => ReactNode;
5958

6059
export function parseChildrenFromValueAndChildrenMap<
@@ -84,10 +83,10 @@ export function parseChildrenFromValueAndChildrenMap<
8483
* Building comp this way can use typescript's type inference capabilities.
8584
* Using ChildrenCompMap as a generic is to retain the information of each class, such as not wanting StringControl to degenerate into Comp<string>
8685
*/
87-
export class MultiCompBuilder<ViewReturn, ChildrenCompMap extends Record<string, Comp<unknown>>, ExtraProps = any> {
86+
export class MultiCompBuilder<ViewReturn, ChildrenCompMap extends Record<string, Comp<unknown>>> {
8887
private childrenMap: ToConstructor<ChildrenCompMap>;
8988
private viewFn: ViewFnTypeForComp<ViewReturn, ChildrenCompMap>;
90-
private propertyViewFn?: PropertyViewFnTypeForComp<ChildrenCompMap, ExtraProps>;
89+
private propertyViewFn?: PropertyViewFnTypeForComp<ChildrenCompMap>;
9190

9291
/**
9392
* If viewFn is not placed in the constructor, the type of ViewReturn cannot be inferred
@@ -100,7 +99,7 @@ export class MultiCompBuilder<ViewReturn, ChildrenCompMap extends Record<string,
10099
this.viewFn = viewFn;
101100
}
102101

103-
setPropertyViewFn(propertyViewFn: PropertyViewFnTypeForComp<ChildrenCompMap, ExtraProps>) {
102+
setPropertyViewFn(propertyViewFn: PropertyViewFnTypeForComp<ChildrenCompMap>) {
104103
this.propertyViewFn = propertyViewFn;
105104
return this;
106105
}
@@ -130,8 +129,8 @@ export class MultiCompBuilder<ViewReturn, ChildrenCompMap extends Record<string,
130129
);
131130
}
132131

133-
override getPropertyView(extraProps?: ExtraProps): ReactNode {
134-
return <PropertyView comp={this} propertyViewFn={builder.propertyViewFn} extraProps={extraProps} />;
132+
override getPropertyView(): ReactNode {
133+
return <PropertyView comp={this} propertyViewFn={builder.propertyViewFn} />;
135134
}
136135
}
137136

@@ -142,12 +141,12 @@ export class MultiCompBuilder<ViewReturn, ChildrenCompMap extends Record<string,
142141
/**
143142
* Guaranteed to be in a react component, so that react hooks can be used internally
144143
*/
145-
export function PropertyView(props: { comp: any; propertyViewFn: any; extraProps?: any }) {
144+
export function PropertyView(props: { comp: any; propertyViewFn: any }) {
146145
const comp = props.comp;
147146
if (!props.propertyViewFn) {
148147
return null;
149148
}
150-
return props.propertyViewFn(comp.children, comp.dispatch, props.extraProps);
149+
return props.propertyViewFn(comp.children, comp.dispatch);
151150
}
152151

153152
export function childrenToProps<ChildrenCompMap extends Record<string, Comp<unknown>>>(

‎client/packages/lowcoder/src/pages/editor/editorView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ function EditorView(props: EditorViewProps) {
712712
{application &&
713713
(
714714
<>
715-
{appSettingsComp.getPropertyView({ isAggregationApp: isAggregationApp(AppUILayoutType[application.applicationType]) })}
715+
{appSettingsComp.getPropertyView()}
716716
</>
717717
)}
718718
</ScrollBar>
@@ -726,7 +726,7 @@ function EditorView(props: EditorViewProps) {
726726
AppUILayoutType[application.applicationType]
727727
) && (
728728
<>
729-
{appSettingsComp.getPropertyView({ isAggregationApp: isAggregationApp(AppUILayoutType[application.applicationType]) })}
729+
{appSettingsComp.getPropertyView()}
730730
</>
731731
)}
732732
</ScrollBar>

‎client/packages/lowcoder/src/redux/sagas/orgSagas.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ export function* fetchWorkspacesSaga(action: ReduxAction<{page: number, pageSize
346346

347347
if (validateResponse(response)) {
348348
const apiData = response.data.data;
349-
console.log("apiData", apiData);
350349

351350
// Transform orgId/orgName to match Org interface
352351
const transformedItems = apiData.data.map(item => ({

0 commit comments

Comments
 (0)