Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/feature upgrade action group #637

Open
wants to merge 1 commit into
base: feature
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions packages/ui/src/Action/Group.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Dropdown, Menu, Space, Tooltip, Typography } from '@oceanbase/design';
import { Button, Dropdown, Space, Tooltip, Typography } from '@oceanbase/design';
import { EllipsisOutlined, LoadingOutlined } from '@oceanbase/icons';
import { isBoolean, max, omit } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -111,36 +111,36 @@ export default ({
{ellipsisActions.length > 0 && (
<Dropdown
placement={dropDownPlacement}
overlay={
<Menu>
{ellipsisActions.map((action, index) => {
const actionKey = action.key;
let disabled = false;
if (isBoolean(action.props.disabled)) disabled = action.props.disabled;
else if (shouldDisabled) disabled = shouldDisabled(action.key as string);
// 当用户传入loading 或者 传入 disabled 的情况都要禁用按钮
const actionDisabled =
action.props.loading ||
(isBoolean(action.props.disabled)
? action.props.disabled
: getDefaultDisabled(action.key as string));
return (
// @ts-ignore
<Menu.Item
menu={{
items: ellipsisActions.map((action, index) => {
const actionKey = action.key;
custs21113 marked this conversation as resolved.
Show resolved Hide resolved
let disabled = false;
if (isBoolean(action.props.disabled)) disabled = action.props.disabled;
else if (shouldDisabled) disabled = shouldDisabled(action.key as string);
// 当用户传入loading 或者 传入 disabled 的情况都要禁用按钮
const actionDisabled =
action.props.loading ||
(isBoolean(action.props.disabled)
? action.props.disabled
: getDefaultDisabled(action.key as string));
return {
key: (actionKey as string) ?? index.toString(),
disabled: actionDisabled,
label: (
<div
key={(actionKey as string) ?? index.toString()}
onClick={action.props.onClick}
style={{ minWidth: 120 }}
{...omit(action.props, 'disabled')}
disabled={actionDisabled}
{...omit(action.props, 'disabled', 'onClick')}
style={{ minWidth: 120, cursor: actionDisabled ? 'not-allowed' : 'pointer' }}
>
<Tooltip title={action.props.tooltip}>
{action.props.loading && <LoadingOutlined />} {action.props.children}
</Tooltip>
</Menu.Item>
);
})}
</Menu>
}
</div>
),
onClick: actionDisabled ? () => {} : action.props.onClick,
};
}),
}}
>
{moreDom}
</Dropdown>
Expand Down
Loading