({
sheetDefinition,
rowData,
selectedRows,
setSelectedRows,
viewMode,
setViewMode,
searchPhrase,
setSearchPhrase,
errorColumnFilter,
setErrorColumnFilter,
removeRows,
addEmptyRow,
sheetValidationErrors,
rowValidationSummary,
resetState,
enumLabelDict,
}: Props)
| 48 | } |
| 49 | |
| 50 | export default function SheetDataEditorActions({ |
| 51 | sheetDefinition, |
| 52 | rowData, |
| 53 | selectedRows, |
| 54 | setSelectedRows, |
| 55 | viewMode, |
| 56 | setViewMode, |
| 57 | searchPhrase, |
| 58 | setSearchPhrase, |
| 59 | errorColumnFilter, |
| 60 | setErrorColumnFilter, |
| 61 | removeRows, |
| 62 | addEmptyRow, |
| 63 | sheetValidationErrors, |
| 64 | rowValidationSummary, |
| 65 | resetState, |
| 66 | enumLabelDict, |
| 67 | }: Props) { |
| 68 | const { csvDownloadMode, availableActions } = useImporterDefinition(); |
| 69 | const { t } = useTranslations(); |
| 70 | |
| 71 | const { validationInProgress } = useImporterState(); |
| 72 | |
| 73 | const [removeConfirmationModalOpen, setRemoveConfirmationModalOpen] = |
| 74 | useState(false); |
| 75 | const [resetConfirmationModalOpen, setResetConfirmationModalOpen] = |
| 76 | useState(false); |
| 77 | |
| 78 | const disabledButtonClasses = |
| 79 | 'pointer-events-none cursor-not-allowed opacity-50'; |
| 80 | |
| 81 | function errorFilterOption(columnId: string) { |
| 82 | const columnDefinition = sheetDefinition.columns.find( |
| 83 | (c) => c.id === columnId |
| 84 | ); |
| 85 | |
| 86 | const count = removeDuplicates( |
| 87 | sheetValidationErrors |
| 88 | .filter((error) => error.columnId === columnId) |
| 89 | .map((row) => row.rowIndex) |
| 90 | ).length; |
| 91 | |
| 92 | return { |
| 93 | label: `${columnDefinition?.label || columnId} (${count})`, |
| 94 | value: columnId, |
| 95 | }; |
| 96 | } |
| 97 | |
| 98 | const filterByErrorOptions = removeDuplicates( |
| 99 | sheetValidationErrors.map((error) => error.columnId) |
| 100 | ).map((columnId) => errorFilterOption(columnId)); |
| 101 | |
| 102 | if ( |
| 103 | errorColumnFilter != null && |
| 104 | filterByErrorOptions.find((option) => option.value === errorColumnFilter) == |
| 105 | null |
| 106 | ) { |
| 107 | filterByErrorOptions.push(errorFilterOption(errorColumnFilter)); |
nothing calls this directly
no test coverage detected