Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat: introducing ability to set custom collection import size limit (#4440)
Joel Jacob Stephen0e00eeb950ac
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.jsonindex 10d5b42e3..9273f6a73 100644--- a/packages/hoppscotch-common/locales/en.json+++ b/packages/hoppscotch-common/locales/en.json@@ -513,8 +513,8 @@"postman_environment": "Postman Environment","postman_environment_description": "Import Postman Environment from a JSON file","title": "Import",- "file_size_limit_exceeded_warning_multiple_files": "Chosen files exceed the recommended limit of 10MB. Only the first {files} selected will be imported",- "file_size_limit_exceeded_warning_single_file": "The currently chosen file exceeds the recommended limit of 10MB. Please select another file.",+ "file_size_limit_exceeded_warning_multiple_files": "Chosen files exceed the recommended limit of {sizeLimit}MB. Only the first {files} selected will be imported",+ "file_size_limit_exceeded_warning_single_file": "The currently chosen file exceeds the recommended limit of {sizeLimit}MB. Please select another file.","success": "Successfully imported"},"inspections": {diff --git a/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/FileImport.vue b/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/FileImport.vueindex ce83fa8b9..2f2f30a5d 100644--- a/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/FileImport.vue+++ b/packages/hoppscotch-common/src/components/importExport/ImportExportSteps/FileImport.vue@@ -33,6 +33,7 @@<template v-if="importFilesCount">{{t("import.file_size_limit_exceeded_warning_multiple_files", {+ sizeLimit: ALLOWED_FILE_SIZE_LIMIT,files:importFilesCount === 1 ? "file" : `${importFilesCount} files`,})@@ -40,7 +41,11 @@</template><template v-else>- {{ t("import.file_size_limit_exceeded_warning_single_file") }}+ {{+ t("import.file_size_limit_exceeded_warning_single_file", {+ sizeLimit: ALLOWED_FILE_SIZE_LIMIT,+ })+ }}</template></p><div>@@ -59,6 +64,7 @@import { useI18n } from "@composables/i18n"import { useToast } from "@composables/toast"import { computed, ref } from "vue"+import { platform } from "~/platform"const props = withDefaults(defineProps<{@@ -74,7 +80,7 @@ const props = withDefaults(const t = useI18n()const toast = useToast()-const ALLOWED_FILE_SIZE_LIMIT = 10 // 10 MB+const ALLOWED_FILE_SIZE_LIMIT = platform.limits?.collectionImportSizeLimit ?? 10 // Default to 10 MBconst importFilesCount = ref(0)diff --git a/packages/hoppscotch-common/src/platform/index.ts b/packages/hoppscotch-common/src/platform/index.tsindex fb144c262..2550a5a59 100644--- a/packages/hoppscotch-common/src/platform/index.ts+++ b/packages/hoppscotch-common/src/platform/index.ts@@ -1,19 +1,20 @@+import { ServiceClassInstance } from "dioc"+import { Ref } from "vue"+import { HoppModule } from "~/modules"+import { AnalyticsPlatformDef } from "./analytics"import { AuthPlatformDef } from "./auth"-import { UIPlatformDef } from "./ui"-import { EnvironmentsPlatformDef } from "./environments"import { CollectionsPlatformDef } from "./collections"-import { SettingsPlatformDef } from "./settings"+import { EnvironmentsPlatformDef } from "./environments"+import { ExperimentsPlatformDef } from "./experiments"import { HistoryPlatformDef } from "./history"-import { AnalyticsPlatformDef } from "./analytics"-import { InterceptorsPlatformDef } from "./interceptors"-import { HoppModule } from "~/modules"+import { InfraPlatformDef } from "./infra"import { InspectorsPlatformDef } from "./inspectors"-import { ServiceClassInstance } from "dioc"+import { InterceptorsPlatformDef } from "./interceptors"import { IOPlatformDef } from "./io"+import { LimitsPlatformDef } from "./limits"+import { SettingsPlatformDef } from "./settings"import { SpotlightPlatformDef } from "./spotlight"-import { InfraPlatformDef } from "./infra"-import { ExperimentsPlatformDef } from "./experiments"-import { Ref } from "vue"+import { UIPlatformDef } from "./ui"export type PlatformDef = {ui?: UIPlatformDef@@ -54,6 +55,7 @@ export type PlatformDef = {*/workspaceSwitcherLogin?: Ref<boolean>}+ limits?: LimitsPlatformDefinfra?: InfraPlatformDefexperiments?: ExperimentsPlatformDef}diff --git a/packages/hoppscotch-common/src/platform/limits.ts b/packages/hoppscotch-common/src/platform/limits.tsnew file mode 100644index 000000000..0e185d585--- /dev/null+++ b/packages/hoppscotch-common/src/platform/limits.ts@@ -0,0 +1,7 @@+// Define various limits for the platform+export type LimitsPlatformDef = {+ /**+ * Assign an import size limit when importing collections+ */+ collectionImportSizeLimit?: number+}diff --git a/packages/hoppscotch-selfhost-web/src/main.ts b/packages/hoppscotch-selfhost-web/src/main.tsindex 6729c0423..3d5839d4e 100644--- a/packages/hoppscotch-selfhost-web/src/main.ts+++ b/packages/hoppscotch-selfhost-web/src/main.ts@@ -43,5 +43,8 @@ createHoppApp("#app", {exportAsGIST: false,hasTelemetry: false,},+ limits: {+ collectionImportSizeLimit: 50,+ },infra: InfraPlatform,})