fix: stop storing form data files in local session

This commit is contained in:
liyasthomas
2022-01-01 12:37:39 +05:30
parent 312bc98c53
commit 4770b86948
4 changed files with 50 additions and 17 deletions

View File

@@ -91,7 +91,7 @@
:name="`attachment${index}`" :name="`attachment${index}`"
type="file" type="file"
multiple multiple
class="p-1 transition cursor-pointer file:transition file:cursor-pointer text-secondaryLight hover:text-secondaryDark file:mr-4 file:py-1 file:px-4 file:rounded file:border-0 file:text-tiny text-tiny file:text-secondary hover:file:text-secondaryDark file:bg-primaryLight hover:file:bg-primaryDark" class="p-1 transition cursor-pointer file:transition file:cursor-pointer text-secondaryLight hover:text-secondaryDark file:mr-2 file:py-1 file:px-4 file:rounded file:border-0 file:text-tiny text-tiny file:text-secondary hover:file:text-secondaryDark file:bg-primaryLight hover:file:bg-primaryDark"
@change="setRequestAttachment(index, param, $event)" @change="setRequestAttachment(index, param, $event)"
/> />
</label> </label>

View File

@@ -21,8 +21,19 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col space-y-2">
<div class="sticky top-0">
<input
v-model="searchQuery"
type="search"
autocomplete="off"
class="flex w-full p-4 py-2 !bg-popover input"
:placeholder="`${t('action.search')}`"
/>
</div>
<div class="flex flex-col">
<SmartItem <SmartItem
v-for="codegen in CodegenDefinitions" v-for="codegen in filteredCodegenDefinitions"
:key="codegen.name" :key="codegen.name"
:label="codegen.caption" :label="codegen.caption"
:info-icon="codegen.name === codegenType ? 'done' : ''" :info-icon="codegen.name === codegenType ? 'done' : ''"
@@ -34,6 +45,8 @@
} }
" "
/> />
</div>
</div>
</tippy> </tippy>
<div class="flex justify-between flex-1"> <div class="flex justify-between flex-1">
<label for="generatedCode" class="p-4"> <label for="generatedCode" class="p-4">
@@ -147,4 +160,12 @@ const copyRequestCode = () => {
toast.success(`${t("state.copied_to_clipboard")}`) toast.success(`${t("state.copied_to_clipboard")}`)
setTimeout(() => (copyIcon.value = "copy"), 1000) setTimeout(() => (copyIcon.value = "copy"), 1000)
} }
const searchQuery = ref("")
const filteredCodegenDefinitions = computed(() => {
return CodegenDefinitions.filter((obj) =>
Object.values(obj).some((val) => val.includes(searchQuery.value))
)
})
</script> </script>

View File

@@ -13,7 +13,6 @@
@apply rounded; @apply rounded;
@apply pl-2; @apply pl-2;
@apply pr-0.5; @apply pr-0.5;
@apply bg-transparent; @apply bg-primaryDark;
@apply border border-divider;
} }
</style> </style>

View File

@@ -6,6 +6,7 @@ import isEmpty from "lodash/isEmpty"
import * as O from "fp-ts/Option" import * as O from "fp-ts/Option"
import { pipe } from "fp-ts/function" import { pipe } from "fp-ts/function"
import { translateToNewRequest } from "@hoppscotch/data" import { translateToNewRequest } from "@hoppscotch/data"
import { cloneDeep } from "lodash"
import { import {
settingsStore, settingsStore,
bulkApplySettings, bulkApplySettings,
@@ -284,7 +285,19 @@ function setupRequestPersistence() {
} }
restRequest$.subscribe((req) => { restRequest$.subscribe((req) => {
window.localStorage.setItem("restRequest", JSON.stringify(req)) const reqClone = cloneDeep(req)
if (reqClone.body.contentType === "multipart/form-data") {
reqClone.body.body = reqClone.body.body.map((x) => {
if (x.isFile)
return {
...x,
isFile: false,
value: "",
}
else return x
})
}
window.localStorage.setItem("restRequest", JSON.stringify(reqClone))
}) })
} }