Skip to content

Commit

Permalink
clean up & build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anishsapkota committed Oct 21, 2024
1 parent cd94169 commit 9028c94
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import ImageUpload from '@/components/image-upload';
import { EntityType } from '@/lib/helpers/fileManagerHelpers';
import { useFileManager } from '@/lib/useFileManager';
import { enableUseFileManager } from 'FeatureFlags';
import { updateFileDeletableStatus } from '@/lib/data/file-manager-facade';

type ImageProps = {
businessObjectId: string;
Expand Down Expand Up @@ -45,21 +44,7 @@ const Image: UserComponent<ImageProps> = ({ src, reloadParam, width, businessObj
const environment = useEnvironment();

const baseUrl = `/api/private/${environment.spaceId}/processes/${params.processId}/images`;

const currentSrcRef = useRef(src);

// useEffect(() => {
// if (src !== currentSrcRef.current) {
// if (currentSrcRef.current) {
// console.log('decrease', currentSrcRef.current);
// }
// currentSrcRef.current = src;
// }

// if (currentSrcRef.current && src === currentSrcRef.current) {
// console.log('increase', currentSrcRef.current);
// }
// }, [src]);
console.log(src);

useEffect(() => {
if (enableUseFileManager && src) {
Expand Down
8 changes: 4 additions & 4 deletions src/management-system-v2/components/image-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ interface ImageUploadProps {
putEndpoint?: string;
};
config: {
entityType: EntityType;
entityId: string;
useDefaultRemoveFunction: boolean;
entityType: EntityType; // to decide where to save the file
entityId: string; // needed for folder hierarchy
useDefaultRemoveFunction: boolean; //set true if delete should be automatically handled by file maanger
fileName?: string;
businessObjectId?: string;
businessObjectId?: string; // to track artifacts referenced by this
};
}

Expand Down
34 changes: 1 addition & 33 deletions src/management-system-v2/lib/data/file-manager-facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import {
import { contentTypeNotAllowed } from './content-upload-error';
import { deleteFile, retrieveFile, saveFile } from './file-manager/file-manager';
import db from '@/lib/data/db';
import Ability from '../ability/abilityHelper';
import { stat } from 'fs';
import { getAbilityForUser } from '../authorization/authorization';

// Allowed content types for files
const ALLOWED_CONTENT_TYPES = [
Expand Down Expand Up @@ -324,25 +321,6 @@ export async function updateFileRefCounter(
throw new Error(`ProcessArtifact with fileName "${fileName}" not found.`);
}

// if (!artifact) throw new Error('File not found');

// let updateData: Prisma.ProcessArtifactUpdateInput = {};

// // If refCounter >= 1, deletable must remain false
// if (artifact.refCounter > 1) {
// updateData = {
// deletable: false,
// refCounter: status ? { decrement: 1 } : { increment: 1 },
// };
// } else if (artifact.refCounter <= 1) {
// // If refCounter < 1, allow deletable to change based on the provided status
// updateData = {
// deletable: status,
// deletedOn: new Date(),
// refCounter: status ? { decrement: 1 } : { increment: 1 },
// };
// }

if (!status) {
if (await checkIfArtifactRefAlreadyExists(artifact.id, processId, businessObjectId ?? '')) {
return;
Expand All @@ -365,15 +343,5 @@ export async function updateFileRefCounter(
});
}

//Handled by db triggers

// const refCounter = await db.artifactReference.count({
// where: { processArtifactId: artifact.id },
// });
// await db.processArtifact.update({
// data: { refCounter: refCounter },
// where: {
// id: artifact.id,
// },
// });
// refCounter handled by db triggers
}
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export async function prepareExport(
const json = await getProcessUserTaskData(definitionId, filename, spaceId);

if (typeof json !== 'string') {
throw json.error;
throw json!.error;
}

const html = toHtml(json);
Expand Down

0 comments on commit 9028c94

Please sign in to comment.