Remove validation behavior UI option, keep truncation as default

Based on feedback, removed the validation behavior selection from the import dialog.
The backend still supports all three behaviors (Skip, Truncate, Abort) but now
defaults to Truncate behavior without exposing the option in the UI.

This makes the import dialog cleaner and simpler for users while still providing
the improved validation handling behind the scenes.
This commit is contained in:
codegen-sh[bot] committed 2025-06-11 03:28:20 +00:00
1 parent cc849be25e
commit f686edbcf4
2 files changed
+3 -43

No files matched your search

@@ -6,15 +6,10 @@ import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import styled from "styled-components";
import { s } from "@shared/styles";
import {
AttachmentPreset,
CollectionPermission,
ImportValidationBehavior,
} from "@shared/types";
import { AttachmentPreset, CollectionPermission } from "@shared/types";
import { bytesToHumanReadable } from "@shared/utils/files";
import Button from "~/components/Button";
import Flex from "~/components/Flex";
import InputSelect from "~/components/InputSelect";
import InputSelectPermission from "~/components/InputSelectPermission";
import LoadingIndicator from "~/components/LoadingIndicator";
import Text from "~/components/Text";
@@ -38,12 +33,10 @@ function DropToImport({ disabled, onSubmit, children, format }: Props) {
const [permission, setPermission] = useState<CollectionPermission | null>(
CollectionPermission.ReadWrite
);
const [validationBehavior, setValidationBehavior] =
useState<ImportValidationBehavior>(ImportValidationBehavior.Truncate);
const handleFiles = (files: File[]) => {
if (files.length > 1) {
toast.error(t("Please choose a single file to import"));
toast.error(t("You can only import one file at a time."));
return;
}
setFile(files[0]);
@@ -63,7 +56,6 @@ function DropToImport({ disabled, onSubmit, children, format }: Props) {
await collections.import(attachment.id, {
format,
permission,
validationBehavior,
});
onSubmit();
toast.message(file.name, {
@@ -128,37 +120,6 @@ function DropToImport({ disabled, onSubmit, children, format }: Props) {
.
</Text>
</div>
<div>
<InputSelect
value={validationBehavior}
ariaLabel={t("Import validation behavior")}
options={[
{
label: t("Skip invalid documents"),
value: ImportValidationBehavior.Skip,
},
{
label: t("Truncate oversized documents"),
value: ImportValidationBehavior.Truncate,
},
{
label: t("Abort import on validation errors"),
value: ImportValidationBehavior.Abort,
},
]}
onChange={(value) => {
if (value) {
setValidationBehavior(value as ImportValidationBehavior);
}
}}
/>
<Text as="span" type="secondary">
{t(
"Choose how to handle documents that fail validation during import"
)}
.
</Text>
</div>
<Flex justify="flex-end">
<Button disabled={!file || isImporting} onClick={handleStartImport}>
{isImporting ? t("Uploading") + "…" : t("Start import")}
@@ -197,3 +158,4 @@ const DropzoneContainer = styled.div<{
`;
export default observer(DropToImport);
-2
View File
@@ -8,7 +8,6 @@ import {
CollectionPermission,
CollectionStatusFilter,
FileOperationFormat,
ImportValidationBehavior,
SubscriptionType,
} from "@shared/types";
import Collection from "~/models/Collection";
@@ -92,7 +91,6 @@ export default class CollectionsStore extends Store<Collection> {
options: {
format?: string;
permission?: CollectionPermission | null;
validationBehavior?: ImportValidationBehavior;
}
) => {
await client.post("/collections.import", {