From ad7b3f05b1bd1153a1051e2573e5dd86523fe607 Mon Sep 17 00:00:00 2001 From: nivedin Date: Mon, 4 Dec 2023 14:15:46 +0530 Subject: [PATCH] chore: update graphql with ts and setup --- .../components/collections/graphql/Add.vue | 85 ++-- .../collections/graphql/AddFolder.vue | 78 +-- .../components/collections/graphql/Edit.vue | 13 +- .../collections/graphql/EditFolder.vue | 83 ++-- .../collections/graphql/EditRequest.vue | 92 ++-- .../components/collections/graphql/Folder.vue | 31 +- .../collections/graphql/Request.vue | 51 +- .../components/collections/graphql/index.vue | 450 ++++++++++-------- .../src/components/graphql/Headers.vue | 10 +- .../src/components/graphql/RequestOptions.vue | 17 +- 10 files changed, 468 insertions(+), 442 deletions(-) diff --git a/packages/hoppscotch-common/src/components/collections/graphql/Add.vue b/packages/hoppscotch-common/src/components/collections/graphql/Add.vue index b5d287e22..c03c145fa 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/Add.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/Add.vue @@ -32,58 +32,53 @@ - diff --git a/packages/hoppscotch-common/src/components/collections/graphql/AddFolder.vue b/packages/hoppscotch-common/src/components/collections/graphql/AddFolder.vue index 968ea8d30..71dd41a9c 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/AddFolder.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/AddFolder.vue @@ -3,7 +3,7 @@ v-if="show" dialog :title="t('folder.new')" - @close="$emit('hide-modal')" + @close="hideModal" > - diff --git a/packages/hoppscotch-common/src/components/collections/graphql/Edit.vue b/packages/hoppscotch-common/src/components/collections/graphql/Edit.vue index c6bc7c5a4..3cf1af32d 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/Edit.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/Edit.vue @@ -37,13 +37,14 @@ import { ref, watch } from "vue" import { editGraphqlCollection } from "~/newstore/collections" import { useToast } from "@composables/toast" import { useI18n } from "@composables/i18n" +import { HoppCollection, HoppGQLRequest } from "@hoppscotch/data" -const props = defineProps({ - show: Boolean, - editingCollection: { type: Object, default: () => ({}) }, - editingCollectionIndex: { type: Number, default: null }, - editingCollectionName: { type: String, default: null }, -}) +const props = defineProps<{ + show: boolean + editingCollectionIndex: number | null + editingCollection: HoppCollection | null + editingCollectionName: string +}>() const emit = defineEmits<{ (e: "hide-modal"): void diff --git a/packages/hoppscotch-common/src/components/collections/graphql/EditFolder.vue b/packages/hoppscotch-common/src/components/collections/graphql/EditFolder.vue index c6810a7a3..f9aef64aa 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/EditFolder.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/EditFolder.vue @@ -32,52 +32,47 @@ - diff --git a/packages/hoppscotch-common/src/components/collections/graphql/EditRequest.vue b/packages/hoppscotch-common/src/components/collections/graphql/EditRequest.vue index 76c5295d2..38c087df9 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/EditRequest.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/EditRequest.vue @@ -32,61 +32,55 @@ - diff --git a/packages/hoppscotch-common/src/components/collections/graphql/Folder.vue b/packages/hoppscotch-common/src/components/collections/graphql/Folder.vue index 4735bde16..cb7cb9c23 100644 --- a/packages/hoppscotch-common/src/components/collections/graphql/Folder.vue +++ b/packages/hoppscotch-common/src/components/collections/graphql/Folder.vue @@ -10,24 +10,25 @@ @dragend="dragging = false" @contextmenu.prevent="options.tippy.show()" > - - - - - - {{ folder.name ? folder.name : folder.title }} + + - + + + {{ folder.name ? folder.name : folder.title }} + + +
- - - - - - {{ request.name }} + + - + + {{ request.name }} + v-if="isActive" + v-tippy="{ theme: 'tooltip' }" + class="relative mx-3 flex h-1.5 w-1.5 flex-shrink-0" + :title="`${t('collection.request_in_use')}`" + > + + + + - +
- diff --git a/packages/hoppscotch-common/src/components/graphql/Headers.vue b/packages/hoppscotch-common/src/components/graphql/Headers.vue index 7b9207b1f..03f0823e7 100644 --- a/packages/hoppscotch-common/src/components/graphql/Headers.vue +++ b/packages/hoppscotch-common/src/components/graphql/Headers.vue @@ -271,6 +271,7 @@ import { useCodemirror } from "@composables/codemirror" import { objRemoveKey } from "~/helpers/functional/object" import { useVModel } from "@vueuse/core" import { HoppGQLHeader } from "~/helpers/graphql" +import { throwError } from "~/helpers/functional/error" const colorMode = useColorMode() const t = useI18n() @@ -386,7 +387,6 @@ watch(workingHeaders, (newWorkingHeaders) => { ) ) - console.log("not-equal", workingHeaders.value) if (!isEqual(request.value.headers, fixedHeaders)) { request.value.headers = cloneDeep(fixedHeaders) } @@ -479,7 +479,11 @@ const deleteHeader = (index: number) => { }) } - workingHeaders.value.splice(index, 1) + workingHeaders.value = pipe( + workingHeaders.value, + A.deleteAt(index), + O.getOrElseW(() => throwError("Working Headers Deletion Out of Bounds")) + ) } const clearContent = () => { @@ -577,6 +581,4 @@ const mask = (header: any) => { // if (tab === "auth") emit("change-tab", "authorization") // else emit("change-tab", "bodyParams") // } - -console.log("compoyed-header", computedHeaders.value) diff --git a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue index 77c674a59..aa82c2a32 100644 --- a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue +++ b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue @@ -99,18 +99,15 @@ const props = withDefaults( optionTab: "query", } ) -const emit = defineEmits(["update:modelValue", "update:response"]) +const emit = defineEmits<{ + (e: "update:modelValue", value: HoppGQLRequest): void + (e: "update:optionTab", value: GQLOptionTabs): void + (e: "update:response", value: GQLResponseEvent[]): void +}>() + const selectedOptionTab = useVModel(props, "optionTab", emit) -const request = ref(props.modelValue) - -watch( - () => request.value, - (newVal) => { - emit("update:modelValue", newVal) - }, - { deep: true } -) +const request = useVModel(props, "modelValue", emit) const url = computedWithControl( () => tabs.currentActiveTab.value,