/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { Settings as ActionSettings } from '@/components/common/icons/ActionIcons'; import React, { useState } from 'react'; import { Alert, Button, Checkbox, Modal, Tooltip, theme } from 'antd'; import { useTranslation } from 'react-i18next'; import './column-settings.css'; const titleText = (title) => React.Children.toArray(title) .map((child) => React.isValidElement(child) ? titleText(child.props.children) : child, ) .join(''); const columnOptions = (columns) => columns.map((column) => ({ value: column.key, label: column.label ?? titleText(column.title), disabled: column.disabled, })); const selectedKeys = (options, value) => options .filter((option) => value.includes(option.value)) .map((option) => option.value); export function ColumnSettingsButton({ onClick, open = false }) { const { t } = useTranslation(); return ( } >
0 && checkedCount === selectable.length} indeterminate={checkedCount > 0 && checkedCount < selectable.length} disabled={!selectable.length} onChange={(event) => changeDraft( options .filter((option) => option.disabled ? draft.includes(option.value) : event.target.checked, ) .map((option) => option.value), ) } > {t('全选')}
{session.error && ( )} ); } export function ColumnVisibilitySettings({ showColumnSelector, setShowColumnSelector, columns, visibleColumns, setVisibleColumns, getDefaultColumnVisibility, }) { const defaults = getDefaultColumnVisibility(); return ( setShowColumnSelector(false)} columns={columns} value={columns .filter((column) => visibleColumns[column.key]) .map((column) => column.key)} defaultValue={columns .filter((column) => defaults[column.key]) .map((column) => column.key)} onConfirm={(keys) => setVisibleColumns((current) => ({ ...current, ...Object.fromEntries( columns.map((column) => [column.key, keys.includes(column.key)]), ), })) } /> ); } export default function TableColumnSettings({ columns, value, defaultValue, onChange, }) { const [open, setOpen] = useState(false); return ( <> setOpen(true)} /> setOpen(false)} columns={columns} value={value} defaultValue={defaultValue} onConfirm={onChange} /> ); }