ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: filestorage upload и preview вложений
This commit is contained in:
@@ -8,16 +8,30 @@
|
||||
import { MAX_FILE_SIZE } from "@plane/constants";
|
||||
// hooks
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
import { useWorkspace } from "@/hooks/store/use-workspace";
|
||||
|
||||
type TReturnProps = {
|
||||
maxFileSize: number;
|
||||
fileSizeLimitEnabled: boolean;
|
||||
};
|
||||
|
||||
export const useFileSize = (): TReturnProps => {
|
||||
// store hooks
|
||||
const { config } = useInstance();
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
|
||||
const workspaceLimitEnabled = currentWorkspace?.storage_file_size_limit_enabled ?? true;
|
||||
const workspaceLimit = currentWorkspace?.storage_file_size_limit;
|
||||
const fallbackLimit = config?.file_size_limit ?? MAX_FILE_SIZE;
|
||||
const maxFileSize =
|
||||
workspaceLimitEnabled && workspaceLimit && workspaceLimit > 0
|
||||
? workspaceLimit
|
||||
: workspaceLimitEnabled
|
||||
? fallbackLimit
|
||||
: Number.MAX_SAFE_INTEGER;
|
||||
|
||||
return {
|
||||
maxFileSize: config?.file_size_limit ?? MAX_FILE_SIZE,
|
||||
maxFileSize,
|
||||
fileSizeLimitEnabled: workspaceLimitEnabled,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user