mirror of
https://github.com/hoppscotch/hoppscotch
synced 2024-11-21 14:38:47 +00:00
feat: introducing ability to set custom collection import size limit (#4440)
This commit is contained in:
parent
f10fac9f44
commit
0e00eeb950
@ -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": {
|
||||
|
@ -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 MB
|
||||
|
||||
const importFilesCount = ref(0)
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { AuthPlatformDef } from "./auth"
|
||||
import { UIPlatformDef } from "./ui"
|
||||
import { EnvironmentsPlatformDef } from "./environments"
|
||||
import { CollectionsPlatformDef } from "./collections"
|
||||
import { SettingsPlatformDef } from "./settings"
|
||||
import { HistoryPlatformDef } from "./history"
|
||||
import { AnalyticsPlatformDef } from "./analytics"
|
||||
import { InterceptorsPlatformDef } from "./interceptors"
|
||||
import { HoppModule } from "~/modules"
|
||||
import { InspectorsPlatformDef } from "./inspectors"
|
||||
import { ServiceClassInstance } from "dioc"
|
||||
import { IOPlatformDef } from "./io"
|
||||
import { SpotlightPlatformDef } from "./spotlight"
|
||||
import { InfraPlatformDef } from "./infra"
|
||||
import { ExperimentsPlatformDef } from "./experiments"
|
||||
import { Ref } from "vue"
|
||||
import { HoppModule } from "~/modules"
|
||||
import { AnalyticsPlatformDef } from "./analytics"
|
||||
import { AuthPlatformDef } from "./auth"
|
||||
import { CollectionsPlatformDef } from "./collections"
|
||||
import { EnvironmentsPlatformDef } from "./environments"
|
||||
import { ExperimentsPlatformDef } from "./experiments"
|
||||
import { HistoryPlatformDef } from "./history"
|
||||
import { InfraPlatformDef } from "./infra"
|
||||
import { InspectorsPlatformDef } from "./inspectors"
|
||||
import { InterceptorsPlatformDef } from "./interceptors"
|
||||
import { IOPlatformDef } from "./io"
|
||||
import { LimitsPlatformDef } from "./limits"
|
||||
import { SettingsPlatformDef } from "./settings"
|
||||
import { SpotlightPlatformDef } from "./spotlight"
|
||||
import { UIPlatformDef } from "./ui"
|
||||
|
||||
export type PlatformDef = {
|
||||
ui?: UIPlatformDef
|
||||
@ -54,6 +55,7 @@ export type PlatformDef = {
|
||||
*/
|
||||
workspaceSwitcherLogin?: Ref<boolean>
|
||||
}
|
||||
limits?: LimitsPlatformDef
|
||||
infra?: InfraPlatformDef
|
||||
experiments?: ExperimentsPlatformDef
|
||||
}
|
||||
|
7
packages/hoppscotch-common/src/platform/limits.ts
Normal file
7
packages/hoppscotch-common/src/platform/limits.ts
Normal file
@ -0,0 +1,7 @@
|
||||
// Define various limits for the platform
|
||||
export type LimitsPlatformDef = {
|
||||
/**
|
||||
* Assign an import size limit when importing collections
|
||||
*/
|
||||
collectionImportSizeLimit?: number
|
||||
}
|
@ -43,5 +43,8 @@ createHoppApp("#app", {
|
||||
exportAsGIST: false,
|
||||
hasTelemetry: false,
|
||||
},
|
||||
limits: {
|
||||
collectionImportSizeLimit: 50,
|
||||
},
|
||||
infra: InfraPlatform,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user