File storage cleaning (#18381)
- Remove feature flag - Remove legacy methods in file-upload and file-service - Migrate AI Chat to new file management --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+11
-33
@@ -1,21 +1,13 @@
|
||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
|
||||
import { ImageInput } from '@/ui/input/components/ImageInput';
|
||||
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||
import { buildSignedPath } from 'twenty-shared/utils';
|
||||
import {
|
||||
FeatureFlagKey,
|
||||
useUpdateWorkspaceMutation,
|
||||
useUploadWorkspaceLogoLegacyMutation,
|
||||
useUploadWorkspaceLogoMutation,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
export const WorkspaceLogoUploader = () => {
|
||||
const isCorePictureMigrated = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IS_CORE_PICTURE_MIGRATED,
|
||||
);
|
||||
const [uploadLogoLegacy] = useUploadWorkspaceLogoLegacyMutation();
|
||||
const [uploadLogo] = useUploadWorkspaceLogoMutation();
|
||||
const [updateWorkspace] = useUpdateWorkspaceMutation();
|
||||
const [currentWorkspace, setCurrentWorkspace] = useAtomState(
|
||||
@@ -30,31 +22,17 @@ export const WorkspaceLogoUploader = () => {
|
||||
throw new Error('Workspace id not found');
|
||||
}
|
||||
|
||||
if (isCorePictureMigrated) {
|
||||
await uploadLogo({
|
||||
variables: {
|
||||
file,
|
||||
},
|
||||
onCompleted: (data) => {
|
||||
setCurrentWorkspace({
|
||||
...currentWorkspace,
|
||||
logo: data.uploadWorkspaceLogo.url,
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await uploadLogoLegacy({
|
||||
variables: {
|
||||
file,
|
||||
},
|
||||
onCompleted: (data) => {
|
||||
setCurrentWorkspace({
|
||||
...currentWorkspace,
|
||||
logo: buildSignedPath(data.uploadWorkspaceLogoLegacy),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
await uploadLogo({
|
||||
variables: {
|
||||
file,
|
||||
},
|
||||
onCompleted: (data) => {
|
||||
setCurrentWorkspace({
|
||||
...currentWorkspace,
|
||||
logo: data.uploadWorkspaceLogo.url,
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onRemove = async () => {
|
||||
|
||||
Reference in New Issue
Block a user