Files - Migrate attachments in activities (#17808)

As attachment files have migrated from fullPath to file files field,
need to migrate richText logic to fit to new attachment file handling +
data migration
This commit is contained in:
Etienne
2026-02-13 10:11:23 +01:00
committed by GitHub
parent 90a30263ac
commit 5c2c588885
31 changed files with 798 additions and 141 deletions
@@ -15,11 +15,10 @@ import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useState } from 'react';
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
import { isDefined } from 'twenty-shared/utils';
import { FileIcon } from '@/file/components/FileIcon';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { t } from '@lingui/core/macro';
import { IconCalendar, OverflowingTextWithTooltip } from 'twenty-ui/display';
import { isNavigationModifierPressed } from 'twenty-ui/utilities';
import {
@@ -107,11 +106,9 @@ export const AttachmentRow = ({
: attachment.fileCategory;
const fileUrl = isFilesFieldMigrated
? attachment.file?.[0]?.url
? (attachment.file?.[0]?.url as string) // TODO : fix attachment.file type after Files field migration
: attachment.fullPath;
assertIsDefinedOrThrow(fileUrl, new Error(t`File URL is not defined`));
const { destroyOneRecord: destroyOneAttachment } = useDestroyOneRecord({
objectNameSingular: CoreObjectNameSingular.Attachment,
});
@@ -50,6 +50,7 @@ export const useUploadAttachmentFile = () => {
) => {
let attachmentPath: string;
let fileId: string | undefined;
let fileUrl: string | undefined;
if (isFilesFieldMigrated) {
assertIsDefinedOrThrow(
@@ -69,6 +70,7 @@ export const useUploadAttachmentFile = () => {
attachmentPath = uploadedFile.path;
fileId = uploadedFile.id;
fileUrl = uploadedFile.url;
} else {
const result = await uploadFile({
variables: {
@@ -93,7 +95,7 @@ export const useUploadAttachmentFile = () => {
const attachmentToCreate = {
name: file.name,
fullPath: attachmentPath,
fullPath: isFilesFieldMigrated ? null : attachmentPath,
fileCategory: getFileType(file.name),
[targetableObjectFieldIdName]: targetableObject.id,
...(isFilesFieldMigrated && isDefined(fileId)
@@ -110,7 +112,12 @@ export const useUploadAttachmentFile = () => {
const createdAttachment = await createOneAttachment(attachmentToCreate);
return { attachmentAbsoluteURL: createdAttachment.fullPath };
return {
attachmentAbsoluteURL: isFilesFieldMigrated
? fileUrl
: createdAttachment.fullPath,
attachmentFileId: fileId,
};
};
return { uploadAttachmentFile };