fix: lint errors removed by using satisfies or as for type (#3934)
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com> Co-authored-by: amk-dev <akash.k.mohan98@gmail.com>
This commit is contained in:
@@ -65,14 +65,20 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "@composables/i18n"
|
||||
import { HoppCollection, HoppRESTAuth, HoppRESTHeaders } from "@hoppscotch/data"
|
||||
import { clone } from "lodash-es"
|
||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||
import { PersistenceService } from "~/services/persistence"
|
||||
import {
|
||||
GQLHeader,
|
||||
HoppCollection,
|
||||
HoppGQLAuth,
|
||||
HoppRESTAuth,
|
||||
HoppRESTHeaders,
|
||||
} from "@hoppscotch/data"
|
||||
import { useVModel } from "@vueuse/core"
|
||||
import { useService } from "dioc/vue"
|
||||
import { clone } from "lodash-es"
|
||||
import { ref, watch } from "vue"
|
||||
|
||||
import { useVModel } from "@vueuse/core"
|
||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||
import { PersistenceService } from "~/services/persistence"
|
||||
|
||||
const persistenceService = useService(PersistenceService)
|
||||
const t = useI18n()
|
||||
@@ -84,6 +90,9 @@ export type EditingProperties = {
|
||||
inheritedProperties?: HoppInheritedProperty
|
||||
}
|
||||
|
||||
type HoppCollectionAuth = HoppRESTAuth | HoppGQLAuth
|
||||
type HoppCollectionHeaders = HoppRESTHeaders | GQLHeader[]
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
show: boolean
|
||||
@@ -109,8 +118,8 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const editableCollection = ref<{
|
||||
headers: HoppRESTHeaders
|
||||
auth: HoppRESTAuth
|
||||
headers: HoppCollectionHeaders
|
||||
auth: HoppCollectionAuth
|
||||
}>({
|
||||
headers: [],
|
||||
auth: {
|
||||
@@ -122,15 +131,16 @@ const editableCollection = ref<{
|
||||
watch(
|
||||
editableCollection,
|
||||
(updatedEditableCollection) => {
|
||||
if (props.show) {
|
||||
if (props.show && props.editingProperties) {
|
||||
const unsavedCollectionProperties: EditingProperties = {
|
||||
collection: updatedEditableCollection,
|
||||
isRootCollection: props.editingProperties?.isRootCollection ?? false,
|
||||
path: props.editingProperties?.path,
|
||||
inheritedProperties: props.editingProperties?.inheritedProperties,
|
||||
}
|
||||
persistenceService.setLocalConfig(
|
||||
"unsaved_collection_properties",
|
||||
JSON.stringify(<EditingProperties>{
|
||||
collection: updatedEditableCollection,
|
||||
isRootCollection: props.editingProperties?.isRootCollection,
|
||||
path: props.editingProperties?.path,
|
||||
inheritedProperties: props.editingProperties?.inheritedProperties,
|
||||
})
|
||||
JSON.stringify(unsavedCollectionProperties)
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -146,10 +156,10 @@ watch(
|
||||
(show) => {
|
||||
if (show && props.editingProperties?.collection) {
|
||||
editableCollection.value.auth = clone(
|
||||
props.editingProperties.collection.auth as HoppRESTAuth
|
||||
props.editingProperties.collection.auth as HoppCollectionAuth
|
||||
)
|
||||
editableCollection.value.headers = clone(
|
||||
props.editingProperties.collection.headers as HoppRESTHeaders
|
||||
props.editingProperties.collection.headers as HoppCollectionHeaders
|
||||
)
|
||||
} else {
|
||||
editableCollection.value = {
|
||||
|
||||
@@ -180,7 +180,6 @@ import { GQLTabService } from "~/services/tab/graphql"
|
||||
import { computed } from "vue"
|
||||
import {
|
||||
HoppCollection,
|
||||
HoppGQLAuth,
|
||||
HoppGQLRequest,
|
||||
makeGQLRequest,
|
||||
} from "@hoppscotch/data"
|
||||
@@ -226,7 +225,7 @@ const editingRequest = ref<HoppGQLRequest | null>(null)
|
||||
const editingRequestIndex = ref<number | null>(null)
|
||||
|
||||
const editingProperties = ref<{
|
||||
collection: HoppCollection | null
|
||||
collection: Partial<HoppCollection> | null
|
||||
isRootCollection: boolean
|
||||
path: string
|
||||
inheritedProperties?: HoppInheritedProperty
|
||||
@@ -265,8 +264,9 @@ onMounted(() => {
|
||||
)
|
||||
|
||||
if (unsavedCollectionPropertiesString) {
|
||||
const unsavedCollectionProperties: EditingProperties<"GraphQL"> =
|
||||
JSON.parse(unsavedCollectionPropertiesString)
|
||||
const unsavedCollectionProperties: EditingProperties = JSON.parse(
|
||||
unsavedCollectionPropertiesString
|
||||
)
|
||||
|
||||
const auth = unsavedCollectionProperties.collection?.auth
|
||||
|
||||
@@ -610,7 +610,7 @@ const editProperties = ({
|
||||
if (collectionIndex === null || collection === null) return
|
||||
|
||||
const parentIndex = collectionIndex.split("/").slice(0, -1).join("/") // remove last folder to get parent folder
|
||||
let inheritedProperties = {}
|
||||
let inheritedProperties = undefined
|
||||
|
||||
if (parentIndex) {
|
||||
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
||||
@@ -621,7 +621,7 @@ const editProperties = ({
|
||||
inheritedProperties = {
|
||||
auth,
|
||||
headers,
|
||||
} as HoppInheritedProperty
|
||||
}
|
||||
}
|
||||
|
||||
editingProperties.value = {
|
||||
@@ -635,11 +635,15 @@ const editProperties = ({
|
||||
}
|
||||
|
||||
const setCollectionProperties = (newCollection: {
|
||||
collection: HoppCollection
|
||||
collection: Partial<HoppCollection> | null
|
||||
path: string
|
||||
isRootCollection: boolean
|
||||
}) => {
|
||||
const { collection, path, isRootCollection } = newCollection
|
||||
if (!collection) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isRootCollection) {
|
||||
editGraphqlCollection(parseInt(path), collection)
|
||||
} else {
|
||||
|
||||
@@ -381,7 +381,7 @@ watch(
|
||||
const selectedTeamID = collectionsType.value.selectedTeam?.id
|
||||
|
||||
selectedTeamID &&
|
||||
debouncedSearch(newFilterText, selectedTeamID)?.catch((_) => {})
|
||||
debouncedSearch(newFilterText, selectedTeamID)?.catch(() => {})
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -414,14 +414,11 @@ onMounted(() => {
|
||||
)
|
||||
|
||||
if (unsavedCollectionPropertiesString) {
|
||||
const unsavedCollectionProperties: EditingProperties<"REST"> = JSON.parse(
|
||||
const unsavedCollectionProperties: EditingProperties = JSON.parse(
|
||||
unsavedCollectionPropertiesString
|
||||
)
|
||||
|
||||
// casting because the type `EditingProperties["collection"]["auth"] and the usage in Properties.vue is different. there it's casted as an any.
|
||||
// FUTURE-TODO: look into this
|
||||
// @ts-expect-error because of the above reason
|
||||
const auth = unsavedCollectionProperties.collection?.auth as HoppRESTAuth
|
||||
const auth = unsavedCollectionProperties.collection?.auth
|
||||
|
||||
if (auth?.authType === "oauth-2") {
|
||||
const grantTypeInfo = auth.grantTypeInfo
|
||||
|
||||
Reference in New Issue
Block a user