From 5655288dacdc0b3a7323f4fe5925e483093e0360 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Thu, 28 Mar 2024 18:51:56 +0600 Subject: [PATCH] fix: proper type for vue files --- .../src/components/collections/Properties.vue | 15 ++++++++------- .../src/components/graphql/Authorization.vue | 2 +- .../src/components/http/Authorization.vue | 2 +- .../src/components/http/OAuth2Authorization.vue | 14 ++++++++------ packages/hoppscotch-common/src/pages/oauth.vue | 9 +++++---- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/packages/hoppscotch-common/src/components/collections/Properties.vue b/packages/hoppscotch-common/src/components/collections/Properties.vue index 5f5035c9310..0db2eb59fc8 100644 --- a/packages/hoppscotch-common/src/components/collections/Properties.vue +++ b/packages/hoppscotch-common/src/components/collections/Properties.vue @@ -131,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({ - collection: updatedEditableCollection, - isRootCollection: props.editingProperties?.isRootCollection, - path: props.editingProperties?.path, - inheritedProperties: props.editingProperties?.inheritedProperties, - }) + JSON.stringify(unsavedCollectionProperties) ) } }, diff --git a/packages/hoppscotch-common/src/components/graphql/Authorization.vue b/packages/hoppscotch-common/src/components/graphql/Authorization.vue index b98cffc8505..d35fd83e3aa 100644 --- a/packages/hoppscotch-common/src/components/graphql/Authorization.vue +++ b/packages/hoppscotch-common/src/components/graphql/Authorization.vue @@ -299,7 +299,7 @@ const selectOAuth2AuthType = () => { ? existingGrantTypeInfo : defaultGrantTypeInfo - auth.value = { + auth.value = { ...auth.value, authType: "oauth-2", addTo: "HEADERS", diff --git a/packages/hoppscotch-common/src/components/http/Authorization.vue b/packages/hoppscotch-common/src/components/http/Authorization.vue index bdd426e4f8c..7f04db26477 100644 --- a/packages/hoppscotch-common/src/components/http/Authorization.vue +++ b/packages/hoppscotch-common/src/components/http/Authorization.vue @@ -307,7 +307,7 @@ const selectOAuth2AuthType = () => { ? existingGrantTypeInfo : defaultGrantTypeInfo - auth.value = { + auth.value = { ...auth.value, authType: "oauth-2", addTo: "HEADERS", diff --git a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue b/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue index 614a1a954de..bdeed0e7e5d 100644 --- a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue +++ b/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue @@ -913,14 +913,16 @@ const generateOAuthToken = async () => { if ( grantTypesInvolvingRedirect.includes(auth.value.grantTypeInfo.grantType) ) { + const authConfig: PersistedOAuthConfig = { + source: props.source, + context: props.isCollectionProperty + ? { type: "collection-properties", metadata: {} } + : { type: "request-tab", metadata: {} }, + grant_type: auth.value.grantTypeInfo.grantType, + } persistenceService.setLocalConfig( "oauth_temp_config", - JSON.stringify({ - source: props.source, - context: props.isCollectionProperty - ? { type: "collection-properties", metadata: {} } - : { type: "request-tab" }, - }) + JSON.stringify(authConfig) ) } diff --git a/packages/hoppscotch-common/src/pages/oauth.vue b/packages/hoppscotch-common/src/pages/oauth.vue index 912d7848e9c..ac6aa3fce8a 100644 --- a/packages/hoppscotch-common/src/pages/oauth.vue +++ b/packages/hoppscotch-common/src/pages/oauth.vue @@ -93,12 +93,13 @@ onMounted(async () => { // Indicates the access token generation flow originated from the modal for setting authorization/headers at the collection level if (context?.type === "collection-properties") { // Set the access token in `localStorage` to retrieve from the modal while redirecting back + const authConfig: PersistedOAuthConfig = { + ...persistedOAuthConfig, + token: tokenInfo.right.access_token, + } persistenceService.setLocalConfig( "oauth_temp_config", - JSON.stringify({ - ...persistedOAuthConfig, - token: tokenInfo.right.access_token, - }) + JSON.stringify(authConfig) ) toast.success(t("authorization.oauth.token_fetched_successfully"))