chore: update graphql with ts and setup
This commit is contained in:
@@ -32,58 +32,53 @@
|
|||||||
</HoppSmartModal>
|
</HoppSmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "vue"
|
import { ref } from "vue"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
import { HoppGQLRequest, makeCollection } from "@hoppscotch/data"
|
import { HoppGQLRequest, makeCollection } from "@hoppscotch/data"
|
||||||
import { addGraphqlCollection } from "~/newstore/collections"
|
import { addGraphqlCollection } from "~/newstore/collections"
|
||||||
import { platform } from "~/platform"
|
import { platform } from "~/platform"
|
||||||
|
|
||||||
export default defineComponent({
|
const t = useI18n()
|
||||||
props: {
|
const toast = useToast()
|
||||||
show: Boolean,
|
|
||||||
},
|
|
||||||
emits: ["hide-modal"],
|
|
||||||
setup() {
|
|
||||||
return {
|
|
||||||
toast: useToast(),
|
|
||||||
t: useI18n(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
name: null as string | null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addNewCollection() {
|
|
||||||
if (!this.name) {
|
|
||||||
this.toast.error(`${this.t("collection.invalid_name")}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
addGraphqlCollection(
|
defineProps<{
|
||||||
makeCollection<HoppGQLRequest>({
|
show: boolean
|
||||||
name: this.name,
|
}>()
|
||||||
folders: [],
|
|
||||||
requests: [],
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
this.hideModal()
|
const emit = defineEmits<{
|
||||||
|
(e: "hide-modal"): void
|
||||||
|
}>()
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
const name = ref<string | null>(null)
|
||||||
type: "HOPP_CREATE_COLLECTION",
|
|
||||||
isRootCollection: true,
|
const addNewCollection = () => {
|
||||||
platform: "gql",
|
if (!name.value) {
|
||||||
workspaceType: "personal",
|
toast.error(`${t("collection.invalid_name")}`)
|
||||||
})
|
return
|
||||||
},
|
}
|
||||||
hideModal() {
|
|
||||||
this.name = null
|
addGraphqlCollection(
|
||||||
this.$emit("hide-modal")
|
makeCollection<HoppGQLRequest>({
|
||||||
},
|
name: name.value,
|
||||||
},
|
folders: [],
|
||||||
})
|
requests: [],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
hideModal()
|
||||||
|
|
||||||
|
platform.analytics?.logEvent({
|
||||||
|
type: "HOPP_CREATE_COLLECTION",
|
||||||
|
isRootCollection: true,
|
||||||
|
platform: "gql",
|
||||||
|
workspaceType: "personal",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
name.value = null
|
||||||
|
emit("hide-modal")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
v-if="show"
|
v-if="show"
|
||||||
dialog
|
dialog
|
||||||
:title="t('folder.new')"
|
:title="t('folder.new')"
|
||||||
@close="$emit('hide-modal')"
|
@close="hideModal"
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<HoppSmartInput
|
<HoppSmartInput
|
||||||
@@ -32,47 +32,49 @@
|
|||||||
</HoppSmartModal>
|
</HoppSmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from "vue"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
import { defineComponent } from "vue"
|
|
||||||
|
|
||||||
export default defineComponent({
|
const t = useI18n()
|
||||||
props: {
|
const toast = useToast()
|
||||||
show: Boolean,
|
|
||||||
folderPath: { type: String, default: null },
|
const props = defineProps<{
|
||||||
collectionIndex: { type: Number, default: null },
|
show: boolean
|
||||||
},
|
folderPath?: string
|
||||||
emits: ["hide-modal", "add-folder"],
|
collectionIndex: number
|
||||||
setup() {
|
}>()
|
||||||
return {
|
|
||||||
toast: useToast(),
|
const emit = defineEmits<{
|
||||||
t: useI18n(),
|
(e: "hide-modal"): void
|
||||||
|
(
|
||||||
|
e: "add-folder",
|
||||||
|
v: {
|
||||||
|
name: string
|
||||||
|
path: string | undefined
|
||||||
}
|
}
|
||||||
},
|
): void
|
||||||
data() {
|
}>()
|
||||||
return {
|
|
||||||
name: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addFolder() {
|
|
||||||
if (!this.name) {
|
|
||||||
this.toast.error(`${this.t("folder.name_length_insufficient")}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit("add-folder", {
|
const name = ref<string | null>(null)
|
||||||
name: this.name,
|
|
||||||
path: this.folderPath || `${this.collectionIndex}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
this.hideModal()
|
const addFolder = () => {
|
||||||
},
|
if (!name.value) {
|
||||||
hideModal() {
|
toast.error(`${t("folder.name_length_insufficient")}`)
|
||||||
this.name = null
|
return
|
||||||
this.$emit("hide-modal")
|
}
|
||||||
},
|
|
||||||
},
|
emit("add-folder", {
|
||||||
})
|
name: name.value,
|
||||||
|
path: props.folderPath || `${props.collectionIndex}`,
|
||||||
|
})
|
||||||
|
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
name.value = null
|
||||||
|
emit("hide-modal")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -37,13 +37,14 @@ import { ref, watch } from "vue"
|
|||||||
import { editGraphqlCollection } from "~/newstore/collections"
|
import { editGraphqlCollection } from "~/newstore/collections"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
|
import { HoppCollection, HoppGQLRequest } from "@hoppscotch/data"
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps<{
|
||||||
show: Boolean,
|
show: boolean
|
||||||
editingCollection: { type: Object, default: () => ({}) },
|
editingCollectionIndex: number | null
|
||||||
editingCollectionIndex: { type: Number, default: null },
|
editingCollection: HoppCollection<HoppGQLRequest> | null
|
||||||
editingCollectionName: { type: String, default: null },
|
editingCollectionName: string
|
||||||
})
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "hide-modal"): void
|
(e: "hide-modal"): void
|
||||||
|
|||||||
@@ -32,52 +32,47 @@
|
|||||||
</HoppSmartModal>
|
</HoppSmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent } from "vue"
|
import { ref, watch } from "vue"
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { editGraphqlFolder } from "~/newstore/collections"
|
import { editGraphqlFolder } from "~/newstore/collections"
|
||||||
|
|
||||||
export default defineComponent({
|
const t = useI18n()
|
||||||
props: {
|
const toast = useToast()
|
||||||
show: Boolean,
|
|
||||||
folder: { type: Object, default: () => ({}) },
|
const props = defineProps<{
|
||||||
folderPath: { type: String, default: null },
|
show: boolean
|
||||||
editingFolderName: { type: String, default: null },
|
folderPath?: string
|
||||||
},
|
folder: any
|
||||||
emits: ["hide-modal"],
|
editingFolderName: string
|
||||||
setup() {
|
}>()
|
||||||
return {
|
|
||||||
toast: useToast(),
|
const emit = defineEmits(["hide-modal"])
|
||||||
t: useI18n(),
|
|
||||||
}
|
const name = ref("")
|
||||||
},
|
|
||||||
data() {
|
watch(
|
||||||
return {
|
() => props.editingFolderName,
|
||||||
name: "",
|
(val) => {
|
||||||
}
|
name.value = val
|
||||||
},
|
}
|
||||||
watch: {
|
)
|
||||||
editingFolderName(val) {
|
|
||||||
this.name = val
|
const editFolder = () => {
|
||||||
},
|
if (!name.value) {
|
||||||
},
|
toast.error(`${t("collection.invalid_name")}`)
|
||||||
methods: {
|
return
|
||||||
editFolder() {
|
}
|
||||||
if (!this.name) {
|
editGraphqlFolder(props.folderPath, {
|
||||||
this.toast.error(`${this.t("collection.invalid_name")}`)
|
...(props.folder as any),
|
||||||
return
|
name: name.value,
|
||||||
}
|
})
|
||||||
editGraphqlFolder(this.folderPath, {
|
hideModal()
|
||||||
...(this.folder as any),
|
}
|
||||||
name: this.name,
|
|
||||||
})
|
const hideModal = () => {
|
||||||
this.hideModal()
|
name.value = ""
|
||||||
},
|
emit("hide-modal")
|
||||||
hideModal() {
|
}
|
||||||
this.name = ""
|
|
||||||
this.$emit("hide-modal")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -32,61 +32,55 @@
|
|||||||
</HoppSmartModal>
|
</HoppSmartModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent, PropType } from "vue"
|
import { ref, watch } from "vue"
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { HoppGQLRequest } from "@hoppscotch/data"
|
import { HoppGQLRequest } from "@hoppscotch/data"
|
||||||
import { editGraphqlRequest } from "~/newstore/collections"
|
import { editGraphqlRequest } from "~/newstore/collections"
|
||||||
|
|
||||||
export default defineComponent({
|
const t = useI18n()
|
||||||
props: {
|
const toast = useToast()
|
||||||
show: Boolean,
|
|
||||||
folderPath: { type: String, default: null },
|
|
||||||
request: { type: Object as PropType<HoppGQLRequest>, default: () => ({}) },
|
|
||||||
requestIndex: { type: Number, default: null },
|
|
||||||
editingRequestName: { type: String, default: null },
|
|
||||||
},
|
|
||||||
emits: ["hide-modal"],
|
|
||||||
setup() {
|
|
||||||
return {
|
|
||||||
toast: useToast(),
|
|
||||||
t: useI18n(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
requestUpdateData: {
|
|
||||||
name: null as any | null,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
editingRequestName(val) {
|
|
||||||
this.requestUpdateData.name = val
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
saveRequest() {
|
|
||||||
if (!this.requestUpdateData.name) {
|
|
||||||
this.toast.error(`${this.t("collection.invalid_name")}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Type safety goes brrrr. Proper typing plz
|
const props = defineProps<{
|
||||||
const requestUpdated = {
|
show: boolean
|
||||||
...this.$props.request,
|
folderPath?: string
|
||||||
name: this.$data.requestUpdateData.name || this.$props.request.name,
|
requestIndex: number | null
|
||||||
}
|
request: HoppGQLRequest | null
|
||||||
|
editingRequestName: string
|
||||||
|
}>()
|
||||||
|
|
||||||
editGraphqlRequest(this.folderPath, this.requestIndex, requestUpdated)
|
const emit = defineEmits<{
|
||||||
|
(e: "hide-modal"): void
|
||||||
|
}>()
|
||||||
|
|
||||||
this.hideModal()
|
const requestUpdateData = ref({ name: null as string | null })
|
||||||
},
|
|
||||||
hideModal() {
|
watch(
|
||||||
this.requestUpdateData = { name: null }
|
() => props.editingRequestName,
|
||||||
this.$emit("hide-modal")
|
(val) => {
|
||||||
},
|
requestUpdateData.value.name = val
|
||||||
},
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
|
const saveRequest = () => {
|
||||||
|
if (!requestUpdateData.value.name) {
|
||||||
|
toast.error(`${t("collection.invalid_name")}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestUpdated = {
|
||||||
|
...(props.request as any),
|
||||||
|
name: requestUpdateData.value.name || (props.request as any).name,
|
||||||
|
}
|
||||||
|
|
||||||
|
editGraphqlRequest(props.folderPath, props.requestIndex, requestUpdated)
|
||||||
|
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideModal = () => {
|
||||||
|
requestUpdateData.value = { name: null }
|
||||||
|
emit("hide-modal")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -10,24 +10,25 @@
|
|||||||
@dragend="dragging = false"
|
@dragend="dragging = false"
|
||||||
@contextmenu.prevent="options.tippy.show()"
|
@contextmenu.prevent="options.tippy.show()"
|
||||||
>
|
>
|
||||||
<span
|
<div
|
||||||
class="flex cursor-pointer items-center justify-center px-4"
|
class="flex min-w-0 flex-1 items-center justify-center cursor-pointer"
|
||||||
@click="toggleShowChildren()"
|
@click="toggleShowChildren()"
|
||||||
>
|
>
|
||||||
<component
|
<span class="pointer-events-none flex items-center justify-center px-4">
|
||||||
:is="collectionIcon"
|
<component
|
||||||
class="svg-icons"
|
:is="collectionIcon"
|
||||||
:class="{ 'text-accent': isSelected }"
|
class="svg-icons"
|
||||||
/>
|
:class="{ 'text-accent': isSelected }"
|
||||||
</span>
|
/>
|
||||||
<span
|
|
||||||
class="flex min-w-0 flex-1 cursor-pointer py-2 pr-2 transition group-hover:text-secondaryDark"
|
|
||||||
@click="toggleShowChildren()"
|
|
||||||
>
|
|
||||||
<span class="truncate" :class="{ 'text-accent': isSelected }">
|
|
||||||
{{ folder.name ? folder.name : folder.title }}
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
<span
|
||||||
|
class="pointer-events-none flex min-w-0 flex-1 cursor-pointer py-2 pr-2 transition group-hover:text-secondaryDark"
|
||||||
|
>
|
||||||
|
<span class="truncate" :class="{ 'text-accent': isSelected }">
|
||||||
|
{{ folder.name ? folder.name : folder.title }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<HoppButtonSecondary
|
<HoppButtonSecondary
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
|
|||||||
@@ -9,38 +9,41 @@
|
|||||||
@dragend="dragging = false"
|
@dragend="dragging = false"
|
||||||
@contextmenu.prevent="options.tippy.show()"
|
@contextmenu.prevent="options.tippy.show()"
|
||||||
>
|
>
|
||||||
<span
|
<div
|
||||||
class="flex w-16 cursor-pointer items-center justify-center truncate px-2"
|
class="pointer-events-auto flex min-w-0 flex-1 cursor-pointer items-center justify-center"
|
||||||
@click="selectRequest()"
|
@click="selectRequest()"
|
||||||
>
|
>
|
||||||
<component
|
<span
|
||||||
:is="isSelected ? IconCheckCircle : IconFile"
|
class="pointer-events-none flex w-8 items-center justify-center truncate px-6"
|
||||||
class="svg-icons"
|
>
|
||||||
:class="{ 'text-accent': isSelected }"
|
<component
|
||||||
/>
|
:is="isSelected ? IconCheckCircle : IconFile"
|
||||||
</span>
|
class="svg-icons"
|
||||||
<span
|
:class="{ 'text-accent': isSelected }"
|
||||||
class="flex min-w-0 flex-1 cursor-pointer items-center py-2 pr-2 transition group-hover:text-secondaryDark"
|
/>
|
||||||
@click="selectRequest()"
|
|
||||||
>
|
|
||||||
<span class="truncate" :class="{ 'text-accent': isSelected }">
|
|
||||||
{{ request.name }}
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="isActive"
|
class="pointer-events-none flex min-w-0 flex-1 items-center py-2 pr-2 transition group-hover:text-secondaryDark"
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
|
||||||
class="relative mx-3 flex h-1.5 w-1.5 flex-shrink-0"
|
|
||||||
:title="`${t('collection.request_in_use')}`"
|
|
||||||
>
|
>
|
||||||
<span
|
<span class="truncate" :class="{ 'text-accent': isSelected }">
|
||||||
class="absolute inline-flex h-full w-full flex-shrink-0 animate-ping rounded-full bg-green-500 opacity-75"
|
{{ request.name }}
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
class="relative inline-flex h-1.5 w-1.5 flex-shrink-0 rounded-full bg-green-500"
|
v-if="isActive"
|
||||||
></span>
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
|
class="relative mx-3 flex h-1.5 w-1.5 flex-shrink-0"
|
||||||
|
:title="`${t('collection.request_in_use')}`"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="absolute inline-flex h-full w-full flex-shrink-0 animate-ping rounded-full bg-green-500 opacity-75"
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="relative inline-flex h-1.5 w-1.5 flex-shrink-0 rounded-full bg-green-500"
|
||||||
|
></span>
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</div>
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<span>
|
<span>
|
||||||
<tippy
|
<tippy
|
||||||
|
|||||||
@@ -145,16 +145,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
// TODO: TypeScript + Script Setup this :)
|
import { ref } from "vue"
|
||||||
import { defineComponent } from "vue"
|
import { clone, cloneDeep } from "lodash-es"
|
||||||
import { cloneDeep, clone } from "lodash-es"
|
|
||||||
import {
|
import {
|
||||||
graphqlCollections$,
|
graphqlCollections$,
|
||||||
addGraphqlFolder,
|
addGraphqlFolder,
|
||||||
saveGraphqlRequestAs,
|
saveGraphqlRequestAs,
|
||||||
} from "~/newstore/collections"
|
} from "~/newstore/collections"
|
||||||
|
|
||||||
import IconPlus from "~icons/lucide/plus"
|
import IconPlus from "~icons/lucide/plus"
|
||||||
import IconHelpCircle from "~icons/lucide/help-circle"
|
import IconHelpCircle from "~icons/lucide/help-circle"
|
||||||
import IconImport from "~icons/lucide/folder-down"
|
import IconImport from "~icons/lucide/folder-down"
|
||||||
@@ -164,213 +162,251 @@ import { useColorMode } from "@composables/theming"
|
|||||||
import { platform } from "~/platform"
|
import { platform } from "~/platform"
|
||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
|
import { computed } from "vue"
|
||||||
|
import { HoppCollection, HoppGQLRequest } from "@hoppscotch/data"
|
||||||
|
import { Picked } from "~/helpers/types/HoppPicked"
|
||||||
|
|
||||||
export default defineComponent({
|
const t = useI18n()
|
||||||
props: {
|
|
||||||
// Whether to activate the ability to pick items (activates 'select' events)
|
|
||||||
saveRequest: { type: Boolean, default: false },
|
|
||||||
picked: { type: Object, default: null },
|
|
||||||
},
|
|
||||||
emits: ["select", "use-collection"],
|
|
||||||
setup() {
|
|
||||||
const collections = useReadonlyStream(graphqlCollections$, [], "deep")
|
|
||||||
const colorMode = useColorMode()
|
|
||||||
const t = useI18n()
|
|
||||||
const tabs = useService(GQLTabService)
|
|
||||||
|
|
||||||
return {
|
defineProps<{
|
||||||
collections,
|
// Whether to activate the ability to pick items (activates 'select' events)
|
||||||
colorMode,
|
saveRequest: boolean
|
||||||
t,
|
picked: Picked
|
||||||
tabs,
|
}>()
|
||||||
IconPlus,
|
|
||||||
IconHelpCircle,
|
const collections = useReadonlyStream(graphqlCollections$, [], "deep")
|
||||||
IconImport,
|
const colorMode = useColorMode()
|
||||||
|
const tabs = useService(GQLTabService)
|
||||||
|
|
||||||
|
const showModalAdd = ref(false)
|
||||||
|
const showModalEdit = ref(false)
|
||||||
|
const showModalImportExport = ref(false)
|
||||||
|
const showModalAddRequest = ref(false)
|
||||||
|
const showModalAddFolder = ref(false)
|
||||||
|
const showModalEditFolder = ref(false)
|
||||||
|
const showModalEditRequest = ref(false)
|
||||||
|
|
||||||
|
const editingCollection = ref<HoppCollection<HoppGQLRequest> | null>(null)
|
||||||
|
const editingCollectionIndex = ref<number | null>(null)
|
||||||
|
const editingFolder = ref<HoppCollection<HoppGQLRequest> | null>(null)
|
||||||
|
const editingFolderName = ref("")
|
||||||
|
const editingFolderIndex = ref<number | null>(null)
|
||||||
|
const editingFolderPath = ref("")
|
||||||
|
const editingRequest = ref<HoppGQLRequest | null>(null)
|
||||||
|
const editingRequestIndex = ref<number | null>(null)
|
||||||
|
|
||||||
|
const filterText = ref("")
|
||||||
|
|
||||||
|
const filteredCollections = computed(() => {
|
||||||
|
const collectionsClone = clone(collections.value)
|
||||||
|
|
||||||
|
if (!filterText.value) return collectionsClone
|
||||||
|
|
||||||
|
const filterTextLower = filterText.value.toLowerCase()
|
||||||
|
const filteredCollections = []
|
||||||
|
|
||||||
|
for (const collection of collectionsClone) {
|
||||||
|
const filteredRequests = []
|
||||||
|
const filteredFolders = []
|
||||||
|
|
||||||
|
for (const request of collection.requests) {
|
||||||
|
if (request.name.toLowerCase().includes(filterTextLower))
|
||||||
|
filteredRequests.push(request)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
data() {
|
for (const folder of collection.folders) {
|
||||||
return {
|
const filteredFolderRequests = []
|
||||||
showModalAdd: false,
|
for (const request of folder.requests) {
|
||||||
showModalEdit: false,
|
if (request.name.toLowerCase().includes(filterTextLower))
|
||||||
showModalImportExport: false,
|
filteredFolderRequests.push(request)
|
||||||
showModalAddRequest: false,
|
}
|
||||||
showModalAddFolder: false,
|
if (filteredFolderRequests.length > 0) {
|
||||||
showModalEditFolder: false,
|
const filteredFolder = { ...folder }
|
||||||
showModalEditRequest: false,
|
filteredFolder.requests = filteredFolderRequests
|
||||||
editingCollection: undefined,
|
filteredFolders.push(filteredFolder)
|
||||||
editingCollectionIndex: undefined,
|
}
|
||||||
editingFolder: undefined,
|
|
||||||
editingFolderName: undefined,
|
|
||||||
editingFolderIndex: undefined,
|
|
||||||
editingFolderPath: undefined,
|
|
||||||
editingRequest: undefined,
|
|
||||||
editingRequestIndex: undefined,
|
|
||||||
filterText: "",
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
filteredCollections() {
|
|
||||||
const collections = clone(this.collections)
|
|
||||||
|
|
||||||
if (!this.filterText) return collections
|
if (filteredRequests.length + filteredFolders.length > 0) {
|
||||||
|
const filteredCollection = { ...collection }
|
||||||
|
filteredCollection.requests = filteredRequests
|
||||||
|
filteredCollection.folders = filteredFolders
|
||||||
|
filteredCollections.push(filteredCollection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const filterText = this.filterText.toLowerCase()
|
return filteredCollections
|
||||||
const filteredCollections = []
|
|
||||||
|
|
||||||
for (const collection of collections) {
|
|
||||||
const filteredRequests = []
|
|
||||||
const filteredFolders = []
|
|
||||||
for (const request of collection.requests) {
|
|
||||||
if (request.name.toLowerCase().includes(filterText))
|
|
||||||
filteredRequests.push(request)
|
|
||||||
}
|
|
||||||
for (const folder of collection.folders) {
|
|
||||||
const filteredFolderRequests = []
|
|
||||||
for (const request of folder.requests) {
|
|
||||||
if (request.name.toLowerCase().includes(filterText))
|
|
||||||
filteredFolderRequests.push(request)
|
|
||||||
}
|
|
||||||
if (filteredFolderRequests.length > 0) {
|
|
||||||
const filteredFolder = Object.assign({}, folder)
|
|
||||||
filteredFolder.requests = filteredFolderRequests
|
|
||||||
filteredFolders.push(filteredFolder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filteredRequests.length + filteredFolders.length > 0) {
|
|
||||||
const filteredCollection = Object.assign({}, collection)
|
|
||||||
filteredCollection.requests = filteredRequests
|
|
||||||
filteredCollection.folders = filteredFolders
|
|
||||||
filteredCollections.push(filteredCollection)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredCollections
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
displayModalAdd(shouldDisplay) {
|
|
||||||
this.showModalAdd = shouldDisplay
|
|
||||||
},
|
|
||||||
displayModalEdit(shouldDisplay) {
|
|
||||||
this.showModalEdit = shouldDisplay
|
|
||||||
|
|
||||||
if (!shouldDisplay) this.resetSelectedData()
|
|
||||||
},
|
|
||||||
displayModalImportExport(shouldDisplay) {
|
|
||||||
this.showModalImportExport = shouldDisplay
|
|
||||||
},
|
|
||||||
displayModalAddRequest(shouldDisplay) {
|
|
||||||
this.showModalAddRequest = shouldDisplay
|
|
||||||
|
|
||||||
if (!shouldDisplay) this.resetSelectedData()
|
|
||||||
},
|
|
||||||
displayModalAddFolder(shouldDisplay) {
|
|
||||||
this.showModalAddFolder = shouldDisplay
|
|
||||||
|
|
||||||
if (!shouldDisplay) this.resetSelectedData()
|
|
||||||
},
|
|
||||||
displayModalEditFolder(shouldDisplay) {
|
|
||||||
this.showModalEditFolder = shouldDisplay
|
|
||||||
|
|
||||||
if (!shouldDisplay) this.resetSelectedData()
|
|
||||||
},
|
|
||||||
displayModalEditRequest(shouldDisplay) {
|
|
||||||
this.showModalEditRequest = shouldDisplay
|
|
||||||
|
|
||||||
if (!shouldDisplay) this.resetSelectedData()
|
|
||||||
},
|
|
||||||
editCollection(collection, collectionIndex) {
|
|
||||||
this.$data.editingCollection = collection
|
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
|
||||||
this.displayModalEdit(true)
|
|
||||||
},
|
|
||||||
onAddRequest({ name, path, index }) {
|
|
||||||
const newRequest = {
|
|
||||||
...this.tabs.currentActiveTab.value.document.request,
|
|
||||||
name,
|
|
||||||
}
|
|
||||||
|
|
||||||
saveGraphqlRequestAs(path, newRequest)
|
|
||||||
|
|
||||||
this.tabs.createNewTab({
|
|
||||||
saveContext: {
|
|
||||||
originLocation: "user-collection",
|
|
||||||
folderPath: path,
|
|
||||||
requestIndex: index,
|
|
||||||
},
|
|
||||||
request: newRequest,
|
|
||||||
isDirty: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
|
||||||
type: "HOPP_SAVE_REQUEST",
|
|
||||||
platform: "gql",
|
|
||||||
createdNow: true,
|
|
||||||
workspaceType: "personal",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.displayModalAddRequest(false)
|
|
||||||
},
|
|
||||||
addRequest(payload) {
|
|
||||||
const { path } = payload
|
|
||||||
this.$data.editingFolderPath = path
|
|
||||||
this.displayModalAddRequest(true)
|
|
||||||
},
|
|
||||||
onAddFolder({ name, path }) {
|
|
||||||
addGraphqlFolder(name, path)
|
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
|
||||||
type: "HOPP_CREATE_COLLECTION",
|
|
||||||
isRootCollection: false,
|
|
||||||
platform: "gql",
|
|
||||||
workspaceType: "personal",
|
|
||||||
})
|
|
||||||
|
|
||||||
this.displayModalAddFolder(false)
|
|
||||||
},
|
|
||||||
addFolder(payload) {
|
|
||||||
const { path } = payload
|
|
||||||
this.$data.editingFolderPath = path
|
|
||||||
this.displayModalAddFolder(true)
|
|
||||||
},
|
|
||||||
editFolder(payload) {
|
|
||||||
const { folder, folderPath } = payload
|
|
||||||
this.editingFolder = folder
|
|
||||||
this.editingFolderPath = folderPath
|
|
||||||
this.displayModalEditFolder(true)
|
|
||||||
},
|
|
||||||
editRequest(payload) {
|
|
||||||
const {
|
|
||||||
collectionIndex,
|
|
||||||
folderIndex,
|
|
||||||
folderName,
|
|
||||||
request,
|
|
||||||
requestIndex,
|
|
||||||
folderPath,
|
|
||||||
} = payload
|
|
||||||
this.$data.editingFolderPath = folderPath
|
|
||||||
this.$data.editingCollectionIndex = collectionIndex
|
|
||||||
this.$data.editingFolderIndex = folderIndex
|
|
||||||
this.$data.editingFolderName = folderName
|
|
||||||
this.$data.editingRequest = request
|
|
||||||
this.$data.editingRequestIndex = requestIndex
|
|
||||||
this.displayModalEditRequest(true)
|
|
||||||
},
|
|
||||||
resetSelectedData() {
|
|
||||||
this.$data.editingCollection = undefined
|
|
||||||
this.$data.editingCollectionIndex = undefined
|
|
||||||
this.$data.editingFolder = undefined
|
|
||||||
this.$data.editingFolderIndex = undefined
|
|
||||||
this.$data.editingRequest = undefined
|
|
||||||
this.$data.editingRequestIndex = undefined
|
|
||||||
},
|
|
||||||
duplicateRequest({ folderPath, request }) {
|
|
||||||
saveGraphqlRequestAs(folderPath, {
|
|
||||||
...cloneDeep(request),
|
|
||||||
name: `${request.name} - ${this.t("action.duplicate")}`,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const displayModalAdd = (shouldDisplay: boolean) => {
|
||||||
|
showModalAdd.value = shouldDisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalEdit = (shouldDisplay: boolean) => {
|
||||||
|
showModalEdit.value = shouldDisplay
|
||||||
|
|
||||||
|
if (!shouldDisplay) resetSelectedData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalImportExport = (shouldDisplay: boolean) => {
|
||||||
|
showModalImportExport.value = shouldDisplay
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalAddRequest = (shouldDisplay: boolean) => {
|
||||||
|
showModalAddRequest.value = shouldDisplay
|
||||||
|
|
||||||
|
if (!shouldDisplay) resetSelectedData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalAddFolder = (shouldDisplay: boolean) => {
|
||||||
|
showModalAddFolder.value = shouldDisplay
|
||||||
|
|
||||||
|
if (!shouldDisplay) resetSelectedData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalEditFolder = (shouldDisplay: boolean) => {
|
||||||
|
showModalEditFolder.value = shouldDisplay
|
||||||
|
|
||||||
|
if (!shouldDisplay) resetSelectedData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const displayModalEditRequest = (shouldDisplay: boolean) => {
|
||||||
|
showModalEditRequest.value = shouldDisplay
|
||||||
|
|
||||||
|
if (!shouldDisplay) resetSelectedData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const editCollection = (
|
||||||
|
collection: HoppCollection<HoppGQLRequest>,
|
||||||
|
collectionIndex: number
|
||||||
|
) => {
|
||||||
|
editingCollection.value = collection
|
||||||
|
editingCollectionIndex.value = collectionIndex
|
||||||
|
displayModalEdit(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onAddRequest = ({
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
index,
|
||||||
|
}: {
|
||||||
|
name: string
|
||||||
|
path: string
|
||||||
|
index: number
|
||||||
|
}) => {
|
||||||
|
console.log("onAddRequest", name, path, index)
|
||||||
|
const newRequest = {
|
||||||
|
...tabs.currentActiveTab.value.document.request,
|
||||||
|
name,
|
||||||
|
}
|
||||||
|
|
||||||
|
saveGraphqlRequestAs(path, newRequest)
|
||||||
|
|
||||||
|
tabs.createNewTab({
|
||||||
|
saveContext: {
|
||||||
|
originLocation: "user-collection",
|
||||||
|
folderPath: path,
|
||||||
|
requestIndex: index,
|
||||||
|
},
|
||||||
|
request: newRequest,
|
||||||
|
isDirty: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
platform.analytics?.logEvent({
|
||||||
|
type: "HOPP_SAVE_REQUEST",
|
||||||
|
platform: "gql",
|
||||||
|
createdNow: true,
|
||||||
|
workspaceType: "personal",
|
||||||
|
})
|
||||||
|
|
||||||
|
displayModalAddRequest(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const addRequest = (payload: { path: string }) => {
|
||||||
|
const { path } = payload
|
||||||
|
editingFolderPath.value = path
|
||||||
|
displayModalAddRequest(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onAddFolder = ({
|
||||||
|
name,
|
||||||
|
path,
|
||||||
|
}: {
|
||||||
|
name: string
|
||||||
|
path: string | undefined
|
||||||
|
}) => {
|
||||||
|
addGraphqlFolder(name, path ?? "0")
|
||||||
|
|
||||||
|
platform.analytics?.logEvent({
|
||||||
|
type: "HOPP_CREATE_COLLECTION",
|
||||||
|
isRootCollection: false,
|
||||||
|
platform: "gql",
|
||||||
|
workspaceType: "personal",
|
||||||
|
})
|
||||||
|
|
||||||
|
displayModalAddFolder(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
const addFolder = (payload: { path: string }) => {
|
||||||
|
const { path } = payload
|
||||||
|
editingFolderPath.value = path
|
||||||
|
displayModalAddFolder(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const editFolder = (payload: {
|
||||||
|
folder: HoppCollection<HoppGQLRequest>
|
||||||
|
folderPath: string
|
||||||
|
}) => {
|
||||||
|
const { folder, folderPath } = payload
|
||||||
|
editingFolder.value = folder
|
||||||
|
editingFolderPath.value = folderPath
|
||||||
|
displayModalEditFolder(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const editRequest = (payload: {
|
||||||
|
collectionIndex: number
|
||||||
|
folderIndex: number
|
||||||
|
folderName: string
|
||||||
|
request: HoppGQLRequest
|
||||||
|
requestIndex: number
|
||||||
|
folderPath: string
|
||||||
|
}) => {
|
||||||
|
const {
|
||||||
|
collectionIndex,
|
||||||
|
folderIndex,
|
||||||
|
folderName,
|
||||||
|
request,
|
||||||
|
requestIndex,
|
||||||
|
folderPath,
|
||||||
|
} = payload
|
||||||
|
editingFolderPath.value = folderPath
|
||||||
|
editingCollectionIndex.value = collectionIndex
|
||||||
|
editingFolderIndex.value = folderIndex
|
||||||
|
editingFolderName.value = folderName
|
||||||
|
editingRequest.value = request
|
||||||
|
editingRequestIndex.value = requestIndex
|
||||||
|
displayModalEditRequest(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const duplicateRequest = ({
|
||||||
|
folderPath,
|
||||||
|
request,
|
||||||
|
}: {
|
||||||
|
folderPath: string
|
||||||
|
request: HoppGQLRequest
|
||||||
|
}) => {
|
||||||
|
saveGraphqlRequestAs(folderPath, {
|
||||||
|
...cloneDeep(request),
|
||||||
|
name: `${request.name} - ${t("action.duplicate")}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetSelectedData = () => {
|
||||||
|
editingCollection.value = null
|
||||||
|
editingCollectionIndex.value = null
|
||||||
|
editingFolder.value = null
|
||||||
|
editingFolderIndex.value = null
|
||||||
|
editingRequest.value = null
|
||||||
|
editingRequestIndex.value = null
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ import { useCodemirror } from "@composables/codemirror"
|
|||||||
import { objRemoveKey } from "~/helpers/functional/object"
|
import { objRemoveKey } from "~/helpers/functional/object"
|
||||||
import { useVModel } from "@vueuse/core"
|
import { useVModel } from "@vueuse/core"
|
||||||
import { HoppGQLHeader } from "~/helpers/graphql"
|
import { HoppGQLHeader } from "~/helpers/graphql"
|
||||||
|
import { throwError } from "~/helpers/functional/error"
|
||||||
|
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
@@ -386,7 +387,6 @@ watch(workingHeaders, (newWorkingHeaders) => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log("not-equal", workingHeaders.value)
|
|
||||||
if (!isEqual(request.value.headers, fixedHeaders)) {
|
if (!isEqual(request.value.headers, fixedHeaders)) {
|
||||||
request.value.headers = cloneDeep(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 = () => {
|
const clearContent = () => {
|
||||||
@@ -577,6 +581,4 @@ const mask = (header: any) => {
|
|||||||
// if (tab === "auth") emit("change-tab", "authorization")
|
// if (tab === "auth") emit("change-tab", "authorization")
|
||||||
// else emit("change-tab", "bodyParams")
|
// else emit("change-tab", "bodyParams")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log("compoyed-header", computedHeaders.value)
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -99,18 +99,15 @@ const props = withDefaults(
|
|||||||
optionTab: "query",
|
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 selectedOptionTab = useVModel(props, "optionTab", emit)
|
||||||
|
|
||||||
const request = ref(props.modelValue)
|
const request = useVModel(props, "modelValue", emit)
|
||||||
|
|
||||||
watch(
|
|
||||||
() => request.value,
|
|
||||||
(newVal) => {
|
|
||||||
emit("update:modelValue", newVal)
|
|
||||||
},
|
|
||||||
{ deep: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
const url = computedWithControl(
|
const url = computedWithControl(
|
||||||
() => tabs.currentActiveTab.value,
|
() => tabs.currentActiveTab.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user