fix: collection auth headers active tab update bug and type fix (#3899)
This commit is contained in:
@@ -66,19 +66,18 @@
|
||||
<script setup lang="ts">
|
||||
import { watch, ref } from "vue"
|
||||
import { useI18n } from "@composables/i18n"
|
||||
import { HoppCollection } from "@hoppscotch/data"
|
||||
import { HoppCollection, HoppRESTAuth, HoppRESTHeaders } from "@hoppscotch/data"
|
||||
import { RESTOptionTabs } from "../http/RequestOptions.vue"
|
||||
import { TeamCollection } from "~/helpers/teams/TeamCollection"
|
||||
import { clone } from "lodash-es"
|
||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||
|
||||
const t = useI18n()
|
||||
|
||||
type EditingProperties = {
|
||||
collection: HoppCollection | TeamCollection | null
|
||||
collection: Partial<HoppCollection> | null
|
||||
isRootCollection: boolean
|
||||
path: string
|
||||
inheritedProperties: HoppInheritedProperty | undefined
|
||||
inheritedProperties?: HoppInheritedProperty
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
@@ -95,21 +94,23 @@ const props = withDefaults(
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "set-collection-properties", newCollection: any): void
|
||||
(
|
||||
e: "set-collection-properties",
|
||||
newCollection: Omit<EditingProperties, "inheritedProperties">
|
||||
): void
|
||||
(e: "hide-modal"): void
|
||||
}>()
|
||||
|
||||
const editableCollection = ref({
|
||||
body: {
|
||||
contentType: null,
|
||||
body: null,
|
||||
},
|
||||
const editableCollection = ref<{
|
||||
headers: HoppRESTHeaders
|
||||
auth: HoppRESTAuth
|
||||
}>({
|
||||
headers: [],
|
||||
auth: {
|
||||
authType: "inherit",
|
||||
authActive: false,
|
||||
},
|
||||
}) as any
|
||||
})
|
||||
|
||||
const selectedOptionTab = ref("headers")
|
||||
|
||||
@@ -122,17 +123,13 @@ watch(
|
||||
(show) => {
|
||||
if (show && props.editingProperties?.collection) {
|
||||
editableCollection.value.auth = clone(
|
||||
props.editingProperties.collection.auth
|
||||
props.editingProperties.collection.auth as HoppRESTAuth
|
||||
)
|
||||
editableCollection.value.headers = clone(
|
||||
props.editingProperties.collection.headers
|
||||
props.editingProperties.collection.headers as HoppRESTHeaders
|
||||
)
|
||||
} else {
|
||||
editableCollection.value = {
|
||||
body: {
|
||||
contentType: null,
|
||||
body: null,
|
||||
},
|
||||
headers: [],
|
||||
auth: {
|
||||
authType: "inherit",
|
||||
@@ -146,7 +143,6 @@ watch(
|
||||
const saveEditedCollection = () => {
|
||||
if (!props.editingProperties) return
|
||||
const finalCollection = clone(editableCollection.value)
|
||||
delete finalCollection.body
|
||||
const collection = {
|
||||
path: props.editingProperties.path,
|
||||
collection: {
|
||||
@@ -155,7 +151,7 @@ const saveEditedCollection = () => {
|
||||
},
|
||||
isRootCollection: props.editingProperties.isRootCollection,
|
||||
}
|
||||
emit("set-collection-properties", collection)
|
||||
emit("set-collection-properties", collection as EditingProperties)
|
||||
}
|
||||
|
||||
const hideModal = () => {
|
||||
|
||||
@@ -292,7 +292,7 @@ const editingRequestIndex = ref<number | null>(null)
|
||||
const editingRequestID = ref<string | null>(null)
|
||||
|
||||
const editingProperties = ref<{
|
||||
collection: Omit<HoppCollection, "v"> | TeamCollection | null
|
||||
collection: Partial<HoppCollection> | null
|
||||
isRootCollection: boolean
|
||||
path: string
|
||||
inheritedProperties?: HoppInheritedProperty
|
||||
@@ -739,7 +739,7 @@ const onAddRequest = (requestName: string) => {
|
||||
saveContext: {
|
||||
originLocation: "team-collection",
|
||||
requestID: createRequestInCollection.id,
|
||||
collectionID: createRequestInCollection.collection.id,
|
||||
collectionID: path,
|
||||
teamID: createRequestInCollection.collection.team.id,
|
||||
},
|
||||
inheritedProperties: {
|
||||
@@ -2021,7 +2021,7 @@ const editProperties = (payload: {
|
||||
{
|
||||
parentID: "",
|
||||
parentName: "",
|
||||
inheritedHeaders: [],
|
||||
inheritedHeader: {},
|
||||
},
|
||||
],
|
||||
} as HoppInheritedProperty
|
||||
@@ -2039,7 +2039,7 @@ const editProperties = (payload: {
|
||||
}
|
||||
|
||||
editingProperties.value = {
|
||||
collection,
|
||||
collection: collection as Partial<HoppCollection>,
|
||||
isRootCollection: isAlreadyInRoot(collectionIndex),
|
||||
path: collectionIndex,
|
||||
inheritedProperties,
|
||||
@@ -2083,7 +2083,7 @@ const editProperties = (payload: {
|
||||
}
|
||||
|
||||
editingProperties.value = {
|
||||
collection: coll,
|
||||
collection: coll as unknown as Partial<HoppCollection>,
|
||||
isRootCollection: isAlreadyInRoot(collectionIndex),
|
||||
path: collectionIndex,
|
||||
inheritedProperties,
|
||||
@@ -2094,11 +2094,12 @@ const editProperties = (payload: {
|
||||
}
|
||||
|
||||
const setCollectionProperties = (newCollection: {
|
||||
collection: HoppCollection
|
||||
path: string
|
||||
collection: Partial<HoppCollection> | null
|
||||
isRootCollection: boolean
|
||||
path: string
|
||||
}) => {
|
||||
const { collection, path, isRootCollection } = newCollection
|
||||
if (!collection) return
|
||||
|
||||
if (collectionsType.value.type === "my-collections") {
|
||||
if (isRootCollection) {
|
||||
@@ -2148,8 +2149,7 @@ const setCollectionProperties = (newCollection: {
|
||||
auth,
|
||||
headers,
|
||||
},
|
||||
"rest",
|
||||
"team"
|
||||
"rest"
|
||||
)
|
||||
}, 200)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user