feat: add expand all rows

This commit is contained in:
jialin
2025-03-05 14:05:12 +08:00
parent 3fdde5f8c4
commit fd7ce9027a
12 changed files with 92 additions and 33 deletions
@@ -84,6 +84,7 @@ interface ModelsProps {
handleCategoryChange: (val: any) => void;
onViewLogs: () => void;
onCancelViewLogs: () => void;
handleOnToggleExpandAll: () => void;
queryParams: {
page: number;
perPage: number;
@@ -172,6 +173,7 @@ const Models: React.FC<ModelsProps> = ({
onViewLogs,
onCancelViewLogs,
handleCategoryChange,
handleOnToggleExpandAll,
deleteIds,
dataSource,
workerList,
@@ -202,6 +204,7 @@ const Models: React.FC<ModelsProps> = ({
const rowSelection = useTableRowSelection();
const {
handleExpandChange,
handleExpandAll,
updateExpandedRowKeys,
removeExpandedRowKey,
expandedRowKeys
@@ -843,6 +846,18 @@ const Models: React.FC<ModelsProps> = ({
setIsLoading(false);
}
};
const handleToggleExpandAll = useCallback(
(expanded: boolean) => {
const keys = dataSource.map((item) => item.id);
handleExpandAll(expanded, keys);
if (expanded) {
handleOnToggleExpandAll();
}
},
[dataSource]
);
const renderEmpty = useMemo(() => {
if (dataSource.length || !isFirstLogin || !catalogList?.length) {
return null;
@@ -990,6 +1005,7 @@ const Models: React.FC<ModelsProps> = ({
rowSelection={rowSelection}
expandedRowKeys={expandedRowKeys}
onExpand={handleExpandChange}
onExpandAll={handleToggleExpandAll}
loading={loading}
loadend={loadend}
rowKey="id"
@@ -15,15 +15,10 @@ type ViewModalProps = {
onCancel: () => void;
};
const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
const viewportHeight = window.innerHeight;
const ViewLogsModal: React.FC<ViewModalProps> = (props) => {
const intl = useIntl();
const { setChunkRequest } = useSetChunkRequest();
const { open, url, onCancel, tail } = props || {};
const [modalSize] = useState<any>({
width: '100%',
height: viewportHeight - 86
});
const [enableScorllLoad, setEnableScorllLoad] = useState(true);
const logsViewerRef = React.useRef<any>(null);
const requestRef = React.useRef<any>(null);
@@ -106,13 +101,12 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
borderRadius: 0
}
}}
width={modalSize.width}
width="100%"
footer={null}
>
<div className="viewer-wrapper" ref={contentRef}>
<LogsViewer
ref={logsViewerRef}
height={modalSize.height}
diffHeight={93}
url={url}
tail={tail}
@@ -126,4 +120,4 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
);
};
export default React.memo(ViewCodeModal);
export default ViewLogsModal;