"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/hoppscotch-app/components/collections/graphql/Folder.vue" between
hoppscotch-2.2.1.tar.gz and hoppscotch-3.0.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

Folder.vue  (hoppscotch-2.2.1):Folder.vue  (hoppscotch-3.0.0)
<template> <template>
<div class="flex flex-col" :class="[{ 'bg-primaryLight': dragging }]"> <div class="flex flex-col" :class="[{ 'bg-primaryLight': dragging }]">
<div <div
class="flex items-stretch group" class="flex items-stretch group"
@dragover.prevent @dragover.prevent
@drop.prevent="dropEvent" @drop.prevent="dropEvent"
@dragover="dragging = true" @dragover="dragging = true"
@drop="dragging = false" @drop="dragging = false"
@dragleave="dragging = false" @dragleave="dragging = false"
@dragend="dragging = false" @dragend="dragging = false"
@contextmenu.prevent="options.tippy().show()" @contextmenu.prevent="options.tippy.show()"
> >
<span <span
class="cursor-pointer flex px-4 items-center justify-center" class="flex items-center justify-center px-4 cursor-pointer"
@click="toggleShowChildren()" @click="toggleShowChildren()"
> >
<SmartIcon <component
:is="collectionIcon"
class="svg-icons" class="svg-icons"
:class="{ 'text-accent': isSelected }" :class="{ 'text-accent': isSelected }"
:name="getCollectionIcon"
/> />
</span> </span>
<span <span
class="cursor-pointer flex flex-1 min-w-0 py-2 pr-2 transition group-hov er:text-secondaryDark" class="flex flex-1 min-w-0 py-2 pr-2 cursor-pointer transition group-hov er:text-secondaryDark"
@click="toggleShowChildren()" @click="toggleShowChildren()"
> >
<span class="truncate" :class="{ 'text-accent': isSelected }"> <span class="truncate" :class="{ 'text-accent': isSelected }">
{{ folder.name ? folder.name : folder.title }} {{ folder.name ? folder.name : folder.title }}
</span> </span>
</span> </span>
<div class="flex"> <div class="flex">
<ButtonSecondary <ButtonSecondary
v-tippy="{ theme: 'tooltip' }" v-tippy="{ theme: 'tooltip' }"
svg="folder-plus" :icon="IconFilePlus"
:title="$t('folder.new')" :title="t('request.new')"
class="hidden group-hover:inline-flex" class="hidden group-hover:inline-flex"
@click.native="$emit('add-folder', { folder, path: folderPath })" @click="emit('add-request', { path: folderPath })"
/>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:icon="IconFolderPlus"
:title="t('folder.new')"
class="hidden group-hover:inline-flex"
@click="emit('add-folder', { folder, path: folderPath })"
/> />
<span> <span>
<tippy <tippy
ref="options" ref="options"
interactive interactive
trigger="click" trigger="click"
theme="popover" theme="popover"
arrow arrow
:on-shown="() => tippyActions.focus()" :on-shown="() => tippyActions.focus()"
> >
<template #trigger> <ButtonSecondary
<ButtonSecondary v-tippy="{ theme: 'tooltip' }"
v-tippy="{ theme: 'tooltip' }" :title="t('action.more')"
:title="$t('action.more')" :icon="IconMoreVertical"
svg="more-vertical" />
/> <template #content="{ hide }">
<div
ref="tippyActions"
class="flex flex-col focus:outline-none"
tabindex="0"
role="menu"
@keyup.r="requestAction.$el.click()"
@keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()"
@keyup.escape="hide()"
>
<SmartItem
ref="requestAction"
:icon="IconFilePlus"
:label="`${t('request.new')}`"
:shortcut="['R']"
@click="
() => {
emit('add-request', { path: folderPath })
hide()
}
"
/>
<SmartItem
ref="folderAction"
:icon="IconFolderPlus"
:label="`${t('folder.new')}`"
:shortcut="['N']"
@click="
() => {
emit('add-folder', { folder, path: folderPath })
hide()
}
"
/>
<SmartItem
ref="edit"
:icon="IconEdit"
:label="`${t('action.edit')}`"
:shortcut="['E']"
@click="
() => {
emit('edit-folder', { folder, folderPath })
hide()
}
"
/>
<SmartItem
ref="deleteAction"
:icon="IconTrash2"
:label="`${t('action.delete')}`"
:shortcut="['⌫']"
@click="
() => {
confirmRemove = true
hide()
}
"
/>
</div>
</template> </template>
<div
ref="tippyActions"
class="flex flex-col focus:outline-none"
tabindex="0"
@keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()"
@keyup.escape="options.tippy().hide()"
>
<SmartItem
ref="folderAction"
svg="folder-plus"
:label="`${$t('folder.new')}`"
:shortcut="['N']"
@click.native="
() => {
$emit('add-folder', { folder, path: folderPath })
options.tippy().hide()
}
"
/>
<SmartItem
ref="edit"
svg="edit"
:label="`${$t('action.edit')}`"
:shortcut="['E']"
@click.native="
() => {
$emit('edit-folder', { folder, folderPath })
options.tippy().hide()
}
"
/>
<SmartItem
ref="deleteAction"
svg="trash-2"
:label="`${$t('action.delete')}`"
:shortcut="['⌫']"
@click.native="
() => {
confirmRemove = true
options.tippy().hide()
}
"
/>
</div>
</tippy> </tippy>
</span> </span>
</div> </div>
</div> </div>
<div v-if="showChildren || isFiltered" class="flex"> <div v-if="showChildren || isFiltered" class="flex">
<div <div
class="bg-dividerLight cursor-nsResize flex ml-5.5 transform transition w-1 hover:bg-dividerDark hover:scale-x-125" class="bg-dividerLight cursor-nsResize flex ml-5.5 transform transition w-1 hover:bg-dividerDark hover:scale-x-125"
@click="toggleShowChildren()" @click="toggleShowChildren()"
></div> ></div>
<div class="flex flex-col flex-1 truncate"> <div class="flex flex-col flex-1 truncate">
<CollectionsGraphqlFolder <!-- Referring to this component only (this is recursive) -->
<Folder
v-for="(subFolder, subFolderIndex) in folder.folders" v-for="(subFolder, subFolderIndex) in folder.folders"
:key="`subFolder-${String(subFolderIndex)}`" :key="`subFolder-${String(subFolderIndex)}`"
:picked="picked" :picked="picked"
:saving-mode="savingMode" :saving-mode="savingMode"
:folder="subFolder" :folder="subFolder"
:folder-index="subFolderIndex" :folder-index="subFolderIndex"
:folder-path="`${folderPath}/${String(subFolderIndex)}`" :folder-path="`${folderPath}/${String(subFolderIndex)}`"
:collection-index="collectionIndex" :collection-index="collectionIndex"
:doc="doc"
:is-filtered="isFiltered" :is-filtered="isFiltered"
@add-folder="$emit('add-folder', $event)" @add-request="emit('add-request', $event)"
@edit-folder="$emit('edit-folder', $event)" @add-folder="emit('add-folder', $event)"
@edit-request="$emit('edit-request', $event)" @edit-folder="emit('edit-folder', $event)"
@duplicate-request="$emit('duplicate-request', $event)" @edit-request="emit('edit-request', $event)"
@select="$emit('select', $event)" @duplicate-request="emit('duplicate-request', $event)"
@select="emit('select', $event)"
/> />
<CollectionsGraphqlRequest <CollectionsGraphqlRequest
v-for="(request, index) in folder.requests" v-for="(request, index) in folder.requests"
:key="`request-${String(index)}`" :key="`request-${String(index)}`"
:picked="picked" :picked="picked"
:saving-mode="savingMode" :saving-mode="savingMode"
:request="request" :request="request"
:collection-index="collectionIndex" :collection-index="collectionIndex"
:folder-index="folderIndex" :folder-index="folderIndex"
:folder-path="folderPath" :folder-path="folderPath"
:folder-name="folder.name" :folder-name="folder.name"
:request-index="index" :request-index="index"
:doc="doc" @edit-request="emit('edit-request', $event)"
@edit-request="$emit('edit-request', $event)" @duplicate-request="emit('duplicate-request', $event)"
@duplicate-request="$emit('duplicate-request', $event)" @select="emit('select', $event)"
@select="$emit('select', $event)"
/> />
<div <div
v-if=" v-if="
folder.folders && folder.folders &&
folder.folders.length === 0 && folder.folders.length === 0 &&
folder.requests && folder.requests &&
folder.requests.length === 0 folder.requests.length === 0
" "
class="flex flex-col text-secondaryLight p-4 items-center justify-cent er" class="flex flex-col items-center justify-center p-4 text-secondaryLig ht"
> >
<img <img
:src="`/images/states/${$colorMode.value}/pack.svg`" :src="`/images/states/${colorMode.value}/pack.svg`"
loading="lazy" loading="lazy"
class="flex-col object-contain object-center h-16 mb-4 w-16 inline-f class="inline-flex flex-col object-contain object-center w-16 h-16 m
lex" b-4"
:alt="`${$t('empty.folder')}`" :alt="`${t('empty.folder')}`"
/> />
<span class="text-center"> <span class="text-center">
{{ $t("empty.folder") }} {{ t("empty.folder") }}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<SmartConfirmModal <SmartConfirmModal
:show="confirmRemove" :show="confirmRemove"
:title="`${$t('confirm.remove_folder')}`" :title="`${t('confirm.remove_folder')}`"
@hide-modal="confirmRemove = false" @hide-modal="confirmRemove = false"
@resolve="removeFolder" @resolve="removeFolder"
/> />
</div> </div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import { defineComponent, ref } from "@nuxtjs/composition-api" import IconEdit from "~icons/lucide/edit"
import IconTrash2 from "~icons/lucide/trash-2"
import IconFolderPlus from "~icons/lucide/folder-plus"
import IconFilePlus from "~icons/lucide/file-plus"
import IconMoreVertical from "~icons/lucide/more-vertical"
import IconCheckCircle from "~icons/lucide/check-circle"
import IconFolder from "~icons/lucide/folder"
import IconFolderOpen from "~icons/lucide/folder-open"
import { useToast } from "@composables/toast"
import { useI18n } from "@composables/i18n"
import { useColorMode } from "@composables/theming"
import { removeGraphqlFolder, moveGraphqlRequest } from "~/newstore/collections" import { removeGraphqlFolder, moveGraphqlRequest } from "~/newstore/collections"
import { computed, ref } from "vue"
export default defineComponent({ const toast = useToast()
name: "Folder", const t = useI18n()
props: { const colorMode = useColorMode()
picked: { type: Object, default: null },
// Whether the request is in a selectable mode (activates 'select' event)
savingMode: { type: Boolean, default: false },
folder: { type: Object, default: () => {} },
folderIndex: { type: Number, default: null },
collectionIndex: { type: Number, default: null },
folderPath: { type: String, default: null },
doc: Boolean,
isFiltered: Boolean,
},
setup() {
return {
tippyActions: ref<any | null>(null),
options: ref<any | null>(null),
folderAction: ref<any | null>(null),
edit: ref<any | null>(null),
deleteAction: ref<any | null>(null),
}
},
data() {
return {
showChildren: false,
dragging: false,
confirmRemove: false,
}
},
computed: {
isSelected(): boolean {
return (
this.picked &&
this.picked.pickedType === "gql-my-folder" &&
this.picked.folderPath === this.folderPath
)
},
getCollectionIcon() {
if (this.isSelected) return "check-circle"
else if (!this.showChildren && !this.isFiltered) return "folder"
else if (this.showChildren || this.isFiltered) return "folder-open"
else return "folder"
},
},
methods: {
pick() {
this.$emit("select", {
picked: {
pickedType: "gql-my-folder",
folderPath: this.folderPath,
},
})
},
toggleShowChildren() {
if (this.savingMode) {
this.pick()
}
this.showChildren = !this.showChildren const props = defineProps({
}, picked: { type: Object, default: null },
removeFolder() { // Whether the request is in a selectable mode (activates 'select' event)
// Cancel pick if the picked folder is deleted savingMode: { type: Boolean, default: false },
if ( folder: { type: Object, default: () => ({}) },
this.picked && folderIndex: { type: Number, default: null },
this.picked.pickedType === "gql-my-folder" && collectionIndex: { type: Number, default: null },
this.picked.folderPath === this.folderPath folderPath: { type: String, default: null },
) { isFiltered: Boolean,
this.$emit("select", { picked: null }) })
}
removeGraphqlFolder(this.folderPath) const emit = defineEmits([
this.$toast.success(`${this.$t("state.deleted")}`) "select",
}, "add-request",
dropEvent({ dataTransfer }: any) { "edit-request",
this.dragging = !this.dragging "add-folder",
const folderPath = dataTransfer.getData("folderPath") "edit-folder",
const requestIndex = dataTransfer.getData("requestIndex") "duplicate-request",
moveGraphqlRequest(folderPath, requestIndex, this.folderPath) ])
},
}, const tippyActions = ref<any | null>(null)
const options = ref<any | null>(null)
const requestAction = ref<any | null>(null)
const folderAction = ref<any | null>(null)
const edit = ref<any | null>(null)
const deleteAction = ref<any | null>(null)
const showChildren = ref(false)
const dragging = ref(false)
const confirmRemove = ref(false)
const isSelected = computed(
() =>
props.picked?.pickedType === "gql-my-folder" &&
props.picked?.folderPath === props.folderPath
)
const collectionIcon = computed(() => {
if (isSelected.value) return IconCheckCircle
else if (!showChildren.value && !props.isFiltered) return IconFolder
else if (showChildren.value || !props.isFiltered) return IconFolderOpen
else return IconFolder
}) })
const pick = () => {
emit("select", {
picked: {
pickedType: "gql-my-folder",
folderPath: props.folderPath,
},
})
}
const toggleShowChildren = () => {
if (props.savingMode) {
pick()
}
showChildren.value = !showChildren.value
}
const removeFolder = () => {
// Cancel pick if the picked folder is deleted
if (
props.picked?.pickedType === "gql-my-folder" &&
props.picked?.folderPath === props.folderPath
) {
emit("select", { picked: null })
}
removeGraphqlFolder(props.folderPath)
toast.success(t("state.deleted"))
}
const dropEvent = ({ dataTransfer }: any) => {
dragging.value = !dragging.value
const folderPath = dataTransfer.getData("folderPath")
const requestIndex = dataTransfer.getData("requestIndex")
moveGraphqlRequest(folderPath, requestIndex, props.folderPath)
}
</script> </script>
 End of changes. 24 change blocks. 
158 lines changed or deleted 192 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)