Skip to content

Commit a3606cb

Browse files
refactor: updated dropdown
1 parent 9e60dc0 commit a3606cb

File tree

9 files changed

+85
-74
lines changed

9 files changed

+85
-74
lines changed

client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const DropdownTmpComp = (function () {
8282
icon: hasIcon && <span>{option.prefixIcon}</span>,
8383
onEvent: option.onEvent,
8484
}));
85+
8586
const menu = (
8687
<Menu
8788
items={items}
@@ -93,15 +94,18 @@ const DropdownTmpComp = (function () {
9394
<ButtonCompWrapper disabled={props.disabled}>
9495
{console.log("props,", props)}
9596
{props.onlyMenu ? (
96-
<Dropdown disabled={props.disabled} overlay={menu}>
97+
<Dropdown
98+
disabled={props.disabled}
99+
dropdownRender={() => menu}
100+
>
97101
<Button100 $buttonStyle={props.style} disabled={props.disabled}>
98102
{props.text || " " /* Avoid button disappearing */}
99103
</Button100>
100104
</Dropdown>
101105
) : (
102106
<DropdownButton
103107
disabled={props.disabled}
104-
overlay={menu}
108+
dropdownRender={() => menu}
105109
onClick={() => props.onEvent("click")}
106110
buttonsRender={([left, right]) => [
107111
<LeftButtonWrapper $buttonStyle={props.style}>

client/packages/lowcoder/src/comps/comps/buttonComp/scannerComp.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const ScannerTmpComp = (function () {
147147
<CustomModalStyled
148148
showOkButton={false}
149149
showCancelButton={false}
150-
visible={showModal}
150+
open={showModal}
151151
maskClosable={props.maskClosable}
152152
destroyOnClose
153153
onCancel={() => {
@@ -178,16 +178,16 @@ const ScannerTmpComp = (function () {
178178
<Dropdown
179179
placement="bottomRight"
180180
trigger={["click"]}
181-
visible={dropdownShow}
182-
onVisibleChange={(value) => setDropdownShow(value)}
183-
overlay={
181+
open={dropdownShow}
182+
onOpenChange={(value) => setDropdownShow(value)}
183+
dropdownRender={() => (
184184
<Menu
185185
items={modeList}
186186
onClick={(value) =>
187187
setVideoConstraints({ ...videoConstraints, deviceId: value.key })
188188
}
189189
/>
190-
}
190+
)}
191191
>
192192
<Button
193193
style={{ float: "right", marginTop: "10px" }}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ const NavCompBase = new UICompBuilder(childrenMap, (props) => {
158158
/>
159159
);
160160
return (
161-
<Dropdown key={idx} overlay={subMenu}>
161+
<Dropdown
162+
key={idx}
163+
dropdownRender={() => subMenu}
164+
>
162165
{item}
163166
</Dropdown>
164167
);

client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps/columnLinksComp.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ export const ColumnLinksComp = (function () {
101101
/>
102102
))}
103103
{menu && (
104-
<Dropdown overlay={menu} trigger={["hover"]}>
104+
<Dropdown
105+
trigger={["hover"]}
106+
dropdownRender={() => menu}
107+
>
105108
<EllipsisOutlined onClick={(e) => e.preventDefault()} />
106109
</Dropdown>
107110
)}

client/packages/lowcoder/src/pages/ApplicationV2/CreateDropdown.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function NavLayoutPickModal(props: {
150150
const { visible, setVisible, onCreate } = props;
151151
return (
152152
<CustomModal
153-
visible={visible}
153+
open={visible}
154154
footer={null}
155155
onCancel={() => setVisible(false)}
156156
title={trans("home.createNavigation")}
@@ -238,11 +238,11 @@ export const CreateDropdown = (props: { defaultVisible?: boolean; mode: HomeLayo
238238
setVisible={setLayoutPickerVisible}
239239
/>
240240
<Dropdown
241-
visible={createDropdownVisible || defaultVisible}
241+
open={createDropdownVisible || defaultVisible}
242242
trigger={["hover"]}
243243
getPopupContainer={(node) => node}
244-
onVisibleChange={() => setCreateDropdownVisible(!createDropdownVisible)}
245-
overlay={
244+
onOpenChange={() => setCreateDropdownVisible(!createDropdownVisible)}
245+
dropdownRender={() => (
246246
<CreateDropdownMenu
247247
items={[
248248
getCreateMenuItem(HomeResTypeEnum.Application, mode),
@@ -265,7 +265,7 @@ export const CreateDropdown = (props: { defaultVisible?: boolean; mode: HomeLayo
265265
: null,
266266
]}
267267
/>
268-
}
268+
)}
269269
>
270270
<CreateBtn buttonType={"primary"}>
271271
{isCreating ? trans("home.creating") : trans("newItem")}

client/packages/lowcoder/src/pages/common/header.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dropdown, message, Skeleton } from "antd";
1+
import { Dropdown, Skeleton } from "antd";
22
import LayoutHeader from "components/layout/Header";
33
import { SHARE_TITLE } from "constants/apiConstants";
44
import { AppTypeEnum } from "constants/applicationConstants";
@@ -17,7 +17,7 @@ import {
1717
TacoButton,
1818
} from "lowcoder-design";
1919
import { trans } from "i18n";
20-
import moment from "moment";
20+
import dayjs from "dayjs";
2121
import { useContext, useState } from "react";
2222
import { useDispatch, useSelector } from "react-redux";
2323
import { publishApplication, updateAppMetaAction } from "redux/reduxActions/applicationActions";
@@ -38,6 +38,7 @@ import { Logo, LogoHome, LogoWithName } from "@lowcoder-ee/assets/images";
3838
import { HeaderStartDropdown } from "./headerStartDropdown";
3939
import { AppPermissionDialog } from "../../components/PermissionDialog/AppPermissionDialog";
4040
import { getBrandingConfig } from "../../redux/selectors/configSelectors";
41+
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
4142

4243
const StyledLink = styled.a`
4344
display: flex;
@@ -301,7 +302,7 @@ export default function Header(props: HeaderProps) {
301302
editing={editing}
302303
onFinish={(value) => {
303304
if (!value.trim()) {
304-
message.warn(trans("header.nameCheckMessage"));
305+
messageInstance.warning(trans("header.nameCheckMessage"));
305306
return;
306307
}
307308
dispatch(updateAppMetaAction({ applicationId: applicationId, name: value }));
@@ -342,7 +343,7 @@ export default function Header(props: HeaderProps) {
342343
CustomModal.confirm({
343344
title: trans("header.recoverAppSnapshotTitle"),
344345
content: trans("header.recoverAppSnapshotContent", {
345-
time: moment(selectedSnapshot.createTime).format("YYYY-MM-DD HH:mm"),
346+
time: dayjs(selectedSnapshot.createTime).format("YYYY-MM-DD HH:mm"),
346347
}),
347348
onConfirm: () => {
348349
dispatch(
@@ -388,7 +389,7 @@ export default function Header(props: HeaderProps) {
388389
className="cypress-header-dropdown"
389390
placement="bottomRight"
390391
trigger={["click"]}
391-
overlay={
392+
dropdownRender={() => (
392393
<DropdownMenuStyled
393394
style={{ minWidth: "110px", borderRadius: "4px" }}
394395
onClick={(e) => {
@@ -409,7 +410,7 @@ export default function Header(props: HeaderProps) {
409410
},
410411
]}
411412
/>
412-
}
413+
)}
413414
>
414415
<PackUpBtn buttonType="primary">
415416
<PackUpIcon />

client/packages/lowcoder/src/pages/common/headerStartDropdown.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dropdown, message } from "antd";
1+
import { Dropdown } from "antd";
22
import { BASE_URL } from "constants/routesURL";
33
import {
44
CommonTextLabel,
@@ -22,6 +22,7 @@ import { AppTypeEnum } from "constants/applicationConstants";
2222
import { recycleApplication } from "redux/reduxActions/applicationActions";
2323
import { CopyModal } from "./copyModal";
2424
import { ExternalEditorContext } from "util/context/ExternalEditorContext";
25+
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
2526

2627
const PackUpIconStyled = styled(PackUpIcon)`
2728
transform: rotate(180deg);
@@ -81,7 +82,7 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
8182
placement="bottomLeft"
8283
trigger={["click"]}
8384
disabled={showAppSnapshot}
84-
overlay={
85+
dropdownRender={() => (
8586
<DropdownMenuStyled
8687
style={{ minWidth: "136px", maxWidth: "288px", borderRadius: "4px" }}
8788
onClick={(e) => {
@@ -103,10 +104,10 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
103104
recycleApplication(
104105
{ applicationId: applicationId, folderId: "" },
105106
() => {
106-
message.success(trans("success"));
107+
messageInstance.success(trans("success"));
107108
history.push(BASE_URL);
108109
},
109-
() => message.error(trans("home.deleteErrorMsg"))
110+
() => messageInstance.error(trans("home.deleteErrorMsg"))
110111
)
111112
),
112113
confirmBtnType: "delete",
@@ -139,7 +140,7 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
139140
},
140141
]}
141142
/>
142-
}
143+
)}
143144
>
144145
<EditTextWrapper
145146
style={{ width: "fit-content", maxWidth: "288px", padding: "0 8px" }}

client/packages/lowcoder/src/pages/common/help.tsx

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -399,50 +399,48 @@ export function HelpDropdown(props: HelpDropdownProps) {
399399
return null;
400400
}
401401

402-
return (
403-
<>
404-
{introVideoUrl && (
405-
<VideoDialog
406-
visible={videoVisible}
407-
setVisible={(v) => setVideoVisible(v)}
408-
videoSrc={introVideoUrl}
409-
/>
402+
return (<>
403+
{introVideoUrl && (
404+
<VideoDialog
405+
visible={videoVisible}
406+
setVisible={(v) => setVideoVisible(v)}
407+
videoSrc={introVideoUrl}
408+
/>
409+
)}
410+
<HelpWrapper>
411+
{toolTipContent && (
412+
<Popover
413+
content={toolTipContent}
414+
open={true}
415+
align={{
416+
points: ["br", "cc"],
417+
offset: [-16, 24],
418+
}}
419+
placement="left"
420+
>
421+
<span />
422+
</Popover>
410423
)}
411-
<HelpWrapper>
412-
{toolTipContent && (
413-
<Popover
414-
content={toolTipContent}
415-
visible
416-
align={{
417-
points: ["br", "cc"],
418-
offset: [-16, 24],
419-
}}
420-
placement="left"
421-
>
422-
<span />
423-
</Popover>
424-
)}
425-
{props.showShortcutList && props.setShowShortcutList && (
426-
<ShortcutListPopup setShowShortcutList={props.setShowShortcutList} />
424+
{props.showShortcutList && props.setShowShortcutList && (
425+
<ShortcutListPopup setShowShortcutList={props.setShowShortcutList} />
426+
)}
427+
<Dropdown
428+
dropdownRender={() => overlayMenus}
429+
placement="topRight"
430+
trigger={["click"]}
431+
open={showDropdown}
432+
onOpenChange={(open: boolean) => setShowDropdown(open)}
433+
>
434+
{props.isEdit ? (
435+
<SpanStyled selected={showDropdown}>
436+
<LeftHelpIcon />
437+
</SpanStyled>
438+
) : (
439+
<HelpDiv>
440+
<HelpIcon />
441+
</HelpDiv>
427442
)}
428-
<Dropdown
429-
overlay={overlayMenus}
430-
placement="topRight"
431-
trigger={["click"]}
432-
visible={showDropdown}
433-
onVisibleChange={(open: boolean) => setShowDropdown(open)}
434-
>
435-
{props.isEdit ? (
436-
<SpanStyled selected={showDropdown}>
437-
<LeftHelpIcon />
438-
</SpanStyled>
439-
) : (
440-
<HelpDiv>
441-
<HelpIcon />
442-
</HelpDiv>
443-
)}
444-
</Dropdown>
445-
</HelpWrapper>
446-
</>
447-
);
443+
</Dropdown>
444+
</HelpWrapper>
445+
</>);
448446
}

client/packages/lowcoder/src/pages/setting/theme/themeList.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Dropdown, Empty, Menu, message, Table, Typography } from "antd";
1+
import { Button, Dropdown, Empty, Menu, Table, Typography } from "antd";
22
import { timestampToHumanReadable } from "util/dateTimeUtils";
33
import { MENU_TYPE } from "./themeConstant";
44
import React, { useState } from "react";
@@ -16,6 +16,7 @@ import {
1616
} from "./styledComponents";
1717
import { ThemeType } from "api/commonSettingApi";
1818
import { trans } from "i18n";
19+
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
1920

2021
const { Column } = Table;
2122

@@ -100,13 +101,13 @@ function ThemeList(props: ThemeListProp) {
100101
triggerType: ["text"],
101102
onChange: (value) => {
102103
if (!value.trim()) {
103-
message.warn(trans("home.nameCheckMessage"));
104+
messageInstance.warning(trans("home.nameCheckMessage"));
104105
return;
105106
}
106107
// check duplicate names
107108
const isExist = themeList?.find((theme) => theme.name === value);
108109
if (isExist && value !== theme.name) {
109-
message.error(trans("theme.checkDuplicateNames"));
110+
messageInstance.error(trans("theme.checkDuplicateNames"));
110111
return;
111112
}
112113
clickMenu({ key: MENU_TYPE.RENAME, themeId: theme.id, name: value });
@@ -153,7 +154,7 @@ function ThemeList(props: ThemeListProp) {
153154
<Dropdown
154155
trigger={["click"]}
155156
getPopupContainer={() => tableRef.current!}
156-
overlay={
157+
dropdownRender={() => (
157158
<Menu
158159
onClick={(params) => {
159160
if (params.key !== MENU_TYPE.RENAME) {
@@ -186,7 +187,7 @@ function ThemeList(props: ThemeListProp) {
186187
},
187188
]}
188189
/>
189-
}
190+
)}
190191
>
191192
<MoreIconDiv>
192193
<StyledMoreActionIcon />

0 commit comments

Comments
 (0)