From b179731359b2c67adae7f991a43a0c00a2307068 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 20 Oct 2020 16:59:54 +0530 Subject: [PATCH 1/7] sponsor ad --- assets/scss/styles.scss | 3 +- components/layout/pw-header.vue | 56 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/assets/scss/styles.scss b/assets/scss/styles.scss index 85089dc42..90c98aea8 100644 --- a/assets/scss/styles.scss +++ b/assets/scss/styles.scss @@ -815,7 +815,8 @@ section { @apply rounded-lg; text-transform: none !important; padding: 12px 16px !important; - font-weight: 500 !important; + // font-weight: 500 !important; + @apply font-bold; font-size: 16px !important; margin: 0 !important; margin-left: 8px !important; diff --git a/components/layout/pw-header.vue b/components/layout/pw-header.vue index 008ac2c98..d802ea101 100644 --- a/components/layout/pw-header.vue +++ b/components/layout/pw-header.vue @@ -359,34 +359,34 @@ export default { }) } - // let showAd = localStorage.getItem("showAd") === "no" - // if (!showAd) { - // setTimeout(() => { - // this.$toast.clear() - // this.$toast.show( - // "Postwoman is now Hoppscotch 🎉
Read the announcement →
Whoosh this away to dismiss.
", - // { - // icon: "", - // duration: 0, - // theme: "toasted-ad", - // action: [ - // { - // text: "GitHub", - // icon: "chevron_right", - // onClick: (e, toastObject) => { - // // localStorage.setItem("showAd", "no") - // toastObject.goAway(0) - // window.open("https://github.com/hoppscotch/hoppscotch") - // }, - // }, - // ], - // onComplete() { - // // localStorage.setItem("showAd", "no") - // }, - // } - // ) - // }, 8000) - // } + let showAd = localStorage.getItem("showAd") === "no" + if (!showAd) { + setTimeout(() => { + this.$toast.clear() + this.$toast.show( + "Make a donation to support Hoppscotch open source project 🎉
Whoosh this away to dismiss.
", + { + icon: "", + duration: 0, + theme: "toasted-ad", + action: [ + { + text: "DONATE", + icon: "favorite", + onClick: (e, toastObject) => { + localStorage.setItem("showAd", "no") + toastObject.goAway(0) + window.open("https://github.com/sponsors/hoppscotch") + }, + }, + ], + onComplete() { + localStorage.setItem("showAd", "no") + }, + } + ) + }, 8000) + } let showExtensionsToast = localStorage.getItem("showExtensionsToast") === "yes" From 7e30a4a3d460f3011696002b09e188fb8f97204d Mon Sep 17 00:00:00 2001 From: Farhan Tariq Date: Wed, 21 Oct 2020 06:11:45 +0500 Subject: [PATCH 2/7] Subfolder functionality (#1194) * Added functionality for sub-folders * Edit Request name only. Drag and drop to move requests * Refactor * Move requests between folder or collections * Functionality to save request in multiple folders * Unnecessary Lang Co-authored-by: Liyas Thomas --- components/collections/add-folder.vue | 15 +- components/collections/collection.vue | 50 +++-- components/collections/edit-folder.vue | 2 +- components/collections/edit-request.vue | 80 ++----- components/collections/folder.vue | 75 +++++-- .../collections/import-export-collections.vue | 94 +++----- components/collections/index.vue | 35 +-- components/collections/request.vue | 34 ++- components/collections/save-request-as.vue | 107 +++++---- components/ui/autocomplete.vue | 8 +- store/postwoman.js | 207 +++++++++--------- 11 files changed, 362 insertions(+), 345 deletions(-) diff --git a/components/collections/add-folder.vue b/components/collections/add-folder.vue index d81823319..28aca4a0d 100644 --- a/components/collections/add-folder.vue +++ b/components/collections/add-folder.vue @@ -21,7 +21,7 @@ type="text" v-model="name" :placeholder="$t('my_new_folder')" - @keyup.enter="addNewFolder" + @keyup.enter="addFolder" /> @@ -33,7 +33,7 @@ - @@ -45,14 +45,13 @@ diff --git a/components/collections/import-export-collections.vue b/components/collections/import-export-collections.vue index dbba1f8f2..cbab58714 100644 --- a/components/collections/import-export-collections.vue +++ b/components/collections/import-export-collections.vue @@ -117,7 +117,7 @@ export default { // Do nothing } } else if (collections.info && collections.info.schema.includes("v2.1.0")) { - collections = this.parsePostmanCollection(collections) + collections = [this.parsePostmanCollection(collections)] } else { return this.failedImport() } @@ -141,8 +141,7 @@ export default { } else if (collections.info && collections.info.schema.includes("v2.1.0")) { //replace the variables, postman uses {{var}}, Hoppscotch uses <> collections = JSON.parse(content.replaceAll(/{{([a-z]+)}}/gi, "<<$1>>")) - collections.item = this.flattenPostmanFolders(collections) - collections = this.parsePostmanCollection(collections) + collections = [this.parsePostmanCollection(collections)] } else { return this.failedImport() } @@ -192,36 +191,31 @@ export default { icon: "error", }) }, - parsePostmanCollection(collection, folders = true) { - let postwomanCollection = folders - ? [ - { - name: "", - folders: [], - requests: [], - }, - ] - : { - name: "", - requests: [], - } - if (folders) { - //pick up collection name even when all children are folders - postwomanCollection[0].name = collection.info ? collection.info.name : "" - } - for (let collectionItem of collection.item) { - if (collectionItem.request) { - if (postwomanCollection[0]) { - postwomanCollection[0].name = collection.info ? collection.info.name : "" - postwomanCollection[0].requests.push(this.parsePostmanRequest(collectionItem)) + parsePostmanCollection(collection) { + let postwomanCollection = + { + name: "", + folders: [], + requests: [], + } + + postwomanCollection.name = collection.info ? collection.info.name : collection.name + + if (collection.item && collection.item.length > 0) { + for (let collectionItem of collection.item) { + if (collectionItem.request) { + if (postwomanCollection.hasOwnProperty('folders')) { + postwomanCollection.name = collection.info ? collection.info.name : collection.name + postwomanCollection.requests.push(this.parsePostmanRequest(collectionItem)) + } else { + postwomanCollection.name = collection.name ? collection.name : "" + postwomanCollection.requests.push(this.parsePostmanRequest(collectionItem)) + } + } else if (this.hasFolder(collectionItem)) { + postwomanCollection.folders.push(this.parsePostmanCollection(collectionItem)) } else { - postwomanCollection.name = collection.name ? collection.name : "" postwomanCollection.requests.push(this.parsePostmanRequest(collectionItem)) } - } else if (collectionItem.item) { - if (collectionItem.item[0]) { - postwomanCollection[0].folders.push(this.parsePostmanCollection(collectionItem, false)) - } } } return postwomanCollection @@ -300,46 +294,8 @@ export default { } return pwRequest }, - flattenPostmanFolders(collection) { - let items = [] - - for (let collectionItem of collection.item) { - if (this.hasFolder(collectionItem)) { - let newFolderItems = [] - for (let folderItem of collectionItem.item) { - if (this.isSubFolder(folderItem)) { - newFolderItems = newFolderItems.concat(this.flattenPostmanItem(folderItem)) - } else { - newFolderItems.push(folderItem) - } - } - collectionItem.item = newFolderItems - } - items.push(collectionItem) - } - return items - }, hasFolder(item) { - return Object.prototype.hasOwnProperty.call(item, "item") - }, - isSubFolder(item) { - return ( - Object.prototype.hasOwnProperty.call(item, "_postman_isSubFolder") && - item._postman_isSubFolder - ) - }, - flattenPostmanItem(subFolder, subFolderGlue = " -- ") { - delete subFolder._postman_isSubFolder - let flattenedItems = [] - for (let subFolderItem of subFolder.item) { - subFolderItem.name = subFolder.name + subFolderGlue + subFolderItem.name - if (this.isSubFolder(subFolderItem)) { - flattenedItems = flattenedItems.concat(this.flattenPostmanItem(subFolderItem)) - } else { - flattenedItems.push(subFolderItem) - } - } - return flattenedItems + return item.hasOwnProperty('item') }, }, } diff --git a/components/collections/index.vue b/components/collections/index.vue index aca710adc..9406983e5 100644 --- a/components/collections/index.vue +++ b/components/collections/index.vue @@ -14,30 +14,29 @@ TODO:
  • -
    +