style: hidden expand button when no replicas
This commit is contained in:
@@ -104,7 +104,7 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
|
||||
{children}
|
||||
</TitleTip>
|
||||
) : (
|
||||
''
|
||||
false
|
||||
)
|
||||
}
|
||||
{...tooltipProps}
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
import IconFont from '@/components/icon-font';
|
||||
import { Button, Checkbox } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
const ButtonWrapper = styled.div`
|
||||
width: 30px;
|
||||
margin-right: 5px;
|
||||
&.disable-expand {
|
||||
.ant-btn {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
interface RowPrefixProps {
|
||||
expandable?: boolean | React.ReactNode;
|
||||
enableSelection?: boolean;
|
||||
expanded?: boolean;
|
||||
checked?: boolean;
|
||||
disableExpand?: boolean;
|
||||
handleRowExpand?: () => void;
|
||||
handleSelectChange?: (e: any) => void;
|
||||
}
|
||||
@@ -18,26 +31,33 @@ const RowPrefix: React.FC<RowPrefixProps> = (props) => {
|
||||
enableSelection,
|
||||
expanded,
|
||||
checked,
|
||||
disableExpand,
|
||||
handleRowExpand,
|
||||
handleSelectChange
|
||||
} = props;
|
||||
|
||||
const isExpanded = useMemo(() => {
|
||||
return expanded;
|
||||
}, [expanded]);
|
||||
|
||||
if (expandable && enableSelection) {
|
||||
return (
|
||||
<div className="row-prefix-wrapper">
|
||||
<span style={{ marginRight: 5 }}>
|
||||
<ButtonWrapper
|
||||
className={classNames({ 'disable-expand': disableExpand })}
|
||||
>
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button type="text" size="small" onClick={handleRowExpand}>
|
||||
<IconFont
|
||||
type="icon-down"
|
||||
rotate={expanded ? 0 : -90}
|
||||
rotate={isExpanded ? 0 : -90}
|
||||
className="size-14"
|
||||
></IconFont>
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
</span>
|
||||
</ButtonWrapper>
|
||||
<Checkbox onChange={handleSelectChange} checked={checked}></Checkbox>
|
||||
</div>
|
||||
);
|
||||
@@ -45,17 +65,26 @@ const RowPrefix: React.FC<RowPrefixProps> = (props) => {
|
||||
if (expandable) {
|
||||
return (
|
||||
<div className="row-prefix-wrapper">
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button type="text" size="small" onClick={handleRowExpand}>
|
||||
<IconFont
|
||||
type="icon-down"
|
||||
rotate={expanded ? 0 : -90}
|
||||
className="size-14"
|
||||
></IconFont>
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
<ButtonWrapper
|
||||
className={classNames({ 'disable-expand': disableExpand })}
|
||||
>
|
||||
{_.isBoolean(expandable) ? (
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
onClick={handleRowExpand}
|
||||
disabled={disableExpand}
|
||||
>
|
||||
<IconFont
|
||||
type="icon-down"
|
||||
rotate={isExpanded ? 0 : -90}
|
||||
className="size-14"
|
||||
></IconFont>
|
||||
</Button>
|
||||
) : (
|
||||
expandable
|
||||
)}
|
||||
</ButtonWrapper>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ const TableRow: React.FC<
|
||||
const tableContext: any = React.useContext<{
|
||||
allChildren?: any[];
|
||||
allSubChildren?: any[];
|
||||
setDisableExpand?: (record: any) => boolean;
|
||||
}>(TableContext);
|
||||
const { setChunkRequest } = useSetChunkRequest();
|
||||
const [childrenData, setChildrenData] = useState<any[]>([]);
|
||||
@@ -206,6 +207,10 @@ const TableRow: React.FC<
|
||||
}
|
||||
};
|
||||
|
||||
const disableExpand = useMemo(() => {
|
||||
return tableContext.setDisableExpand?.(record);
|
||||
}, [tableContext.setDisableExpand, record]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleVisibilityChange = async () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
@@ -249,6 +254,7 @@ const TableRow: React.FC<
|
||||
checked={checked}
|
||||
handleRowExpand={handleRowExpand}
|
||||
handleSelectChange={handleSelectChange}
|
||||
disableExpand={disableExpand}
|
||||
></RowPrefix>
|
||||
<Row className="seal-table-row">
|
||||
{columns?.map((columnProps) => {
|
||||
|
||||
Reference in New Issue
Block a user