Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-import-status-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Updated the workspace import history to correctly reflect an error status when file validation fails.
10 changes: 8 additions & 2 deletions apps/meteor/app/importer/server/methods/getImportFileData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ export const executeGetImportFileData = async (): Promise<IImporterSelection | {
ProgressStep.PREPARING_CONTACTS,
ProgressStep.PREPARING_STARTED,
];

if (waitingSteps.indexOf(instance.progress.step) >= 0) {
if (instance.importRecord?.valid) {
const validCsvContentTypes = ['text/csv', 'text/plain', 'application/csv', 'application/vnd.ms-excel'];
const isInvalidCSV = operation.importerKey === 'csv' && !validCsvContentTypes.includes(operation.contentType ?? '');

if (instance.importRecord?.valid && !isInvalidCSV) {
return { waiting: true };
}
await Imports.updateOne(
{ _id: operation._id },
{ $set: { status: ProgressStep.ERROR, valid: false } }
);
throw new Meteor.Error('error-import-operation-invalid', 'Invalid Import Operation', 'getImportFileData');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ImportOperationSummaryProps = {
file?: string;
user: string;
small?: boolean;
contentType?: string;
count?: {
users?: number;
channels?: number;
Expand All @@ -39,6 +40,7 @@ function ImportOperationSummary({
file = '',
user,
small,
contentType,
count: { users = 0, channels = 0, messages = 0, total = 0, contacts = 0 } = {},
valid,
}: ImportOperationSummaryProps) {
Expand Down Expand Up @@ -87,11 +89,11 @@ function ImportOperationSummary({

const props = hasAction
? {
tabIndex: 0,
role: 'link',
action: true,
onClick: handleClick,
}
tabIndex: 0,
role: 'link',
action: true,
onClick: handleClick,
}
: {};

return (
Expand All @@ -100,7 +102,12 @@ function ImportOperationSummary({
<TableCell>{formatDateAndTime(_updatedAt)}</TableCell>
{!small && (
<>
<TableCell>{status && t(status.replace('importer_', 'importer_status_') as TranslationKey)}</TableCell>
<TableCell>
{status && (valid === false
? t('importer_status_import_failed' as TranslationKey)
: t(status.replace('importer_', 'importer_status_') as TranslationKey)
)}
</TableCell>
<TableCell>{fileName}</TableCell>
<TableCell align='center'>{users}</TableCell>
<TableCell align='center'>{contacts}</TableCell>
Expand Down