Merge branch 'refactor'

This commit is contained in:
Liyas Thomas
2020-09-24 21:39:14 +05:30
15 changed files with 27 additions and 51 deletions

View File

@@ -8,7 +8,7 @@ const PW_BUILD_DATA_DIR = "./.hoppscotch"
// const IS_DEV_MODE = process.argv.includes("--dev") // const IS_DEV_MODE = process.argv.includes("--dev")
try { try {
;(async () => { (async () => {
// Create the build data directory if it does not exist. // Create the build data directory if it does not exist.
if (!fs.existsSync(PW_BUILD_DATA_DIR)) { if (!fs.existsSync(PW_BUILD_DATA_DIR)) {
fs.mkdirSync(PW_BUILD_DATA_DIR) fs.mkdirSync(PW_BUILD_DATA_DIR)

View File

@@ -320,10 +320,10 @@ export default {
return items return items
}, },
hasFolder(item) { hasFolder(item) {
return item.hasOwnProperty("item") return Object.prototype.hasOwnProperty.call(item, "item")
}, },
isSubFolder(item) { isSubFolder(item) {
return item.hasOwnProperty("_postman_isSubFolder") && item._postman_isSubFolder return Object.prototype.hasOwnProperty.call(item, "_postman_isSubFolder") && item._postman_isSubFolder
}, },
flattenPostmanItem(subFolder, subFolderGlue = " -- ") { flattenPostmanItem(subFolder, subFolderGlue = " -- ") {
delete subFolder._postman_isSubFolder delete subFolder._postman_isSubFolder

View File

@@ -36,6 +36,7 @@ export default {
theme: { theme: {
type: String, type: String,
required: false, required: false,
default: null,
}, },
onRunGQLQuery: { onRunGQLQuery: {
type: Function, type: Function,

View File

@@ -312,7 +312,6 @@ import {
hasFirefoxExtensionInstalled, hasFirefoxExtensionInstalled,
} from "~/helpers/strategies/ExtensionStrategy" } from "~/helpers/strategies/ExtensionStrategy"
import { getPlatformSpecialKey } from "~/helpers/platformutils" import { getPlatformSpecialKey } from "~/helpers/platformutils"
import firebase from "firebase/app"
import { fb } from "~/helpers/fb" import { fb } from "~/helpers/fb"
import closeIcon from "~/static/icons/close-24px.svg?inline" import closeIcon from "~/static/icons/close-24px.svg?inline"

View File

@@ -33,6 +33,7 @@ export default {
theme: { theme: {
type: String, type: String,
required: false, required: false,
default: null,
}, },
lang: { lang: {
type: String, type: String,

View File

@@ -21,7 +21,6 @@
<script> <script>
import ace from "ace-builds" import ace from "ace-builds"
import "ace-builds/webpack-resolver" import "ace-builds/webpack-resolver"
import jsonParse from "~/helpers/jsonParse"
import debounce from "~/helpers/utils/debounce" import debounce from "~/helpers/utils/debounce"
import * as esprima from "esprima" import * as esprima from "esprima"
@@ -35,6 +34,7 @@ export default {
theme: { theme: {
type: String, type: String,
required: false, required: false,
default: null,
}, },
options: { options: {
type: Object, type: Object,

View File

@@ -7,10 +7,11 @@
<script> <script>
export default { export default {
props: { props: {
label: { type: String }, label: { type: String, default: "" },
icon: { type: String }, icon: { type: String, default: "" },
id: { required: true }, id: { required: true },
selected: { selected: {
type: Boolean,
default: false, default: false,
}, },
}, },

View File

@@ -18,7 +18,7 @@
<script> <script>
export default { export default {
props: { props: {
value: { type: String }, value: { type: String, default: "" },
}, },
data() { data() {
return { return {

View File

@@ -1,9 +0,0 @@
{
"baseUrl": "http://localhost:3000",
"integrationFolder": "tests/e2e/integration",
"screenshotsFolder": "tests/e2e/screenshots",
"fixturesFolder": "tests/e2e/fixtures",
"supportFile": "tests/e2e/support",
"pluginsFile": false,
"video": false
}

View File

@@ -102,7 +102,7 @@ class Expectation {
: this._fail(this._fmtNot(`Expected ${this.expectValue} (not)to be ${value}`)) : this._fail(this._fmtNot(`Expected ${this.expectValue} (not)to be ${value}`))
} }
toHaveProperty(value) { toHaveProperty(value) {
return this._satisfies(this.expectValue.hasOwnProperty(value), true) return this._satisfies(Object.prototype.hasOwnProperty.call(this.expectValue, value), true)
? this._pass() ? this._pass()
: this._fail( : this._fail(
this._fmtNot(`Expected object ${this.expectValue} to (not)have property ${value}`) this._fmtNot(`Expected object ${this.expectValue} to (not)have property ${value}`)

View File

@@ -1,9 +1,3 @@
[build] [build]
command = "npm run generate" command = "npm run generate"
functions = "netlify/" functions = "netlify/"
[[redirects]]
from = "https://postwoman.io"
to = "https://hoppscotch.io"
status = 301
force = true

View File

@@ -329,7 +329,6 @@
</style> </style>
<script> <script>
import axios from "axios"
import * as gql from "graphql" import * as gql from "graphql"
import { commonHeaders } from "~/helpers/headers" import { commonHeaders } from "~/helpers/headers"
import { getPlatformSpecialKey } from "~/helpers/platformutils" import { getPlatformSpecialKey } from "~/helpers/platformutils"

View File

@@ -171,7 +171,6 @@
<i class="material-icons">send</i> <i class="material-icons">send</i>
</span> </span>
</button> </button>
<button v-else @click="cancelRequest" id="send" ref="sendButton"> <button v-else @click="cancelRequest" id="send" ref="sendButton">
{{ $t("cancel") }} {{ $t("cancel") }}
<span> <span>
@@ -1297,20 +1296,6 @@ const statusCategories = [
className: "missing-data-response", className: "missing-data-response",
}, },
] ]
const parseHeaders = (xhr) => {
const headers = xhr
.getAllResponseHeaders()
.trim()
.split(/[\r\n]+/)
const headerMap = {}
headers.forEach((line) => {
const parts = line.split(": ")
const header = parts.shift().toLowerCase()
const value = parts.join(": ")
headerMap[header] = value
})
return headerMap
}
export const findStatusGroup = (responseStatus) => export const findStatusGroup = (responseStatus) =>
statusCategories.find(({ statusCodeRegex }) => statusCodeRegex.test(responseStatus)) statusCategories.find(({ statusCodeRegex }) => statusCodeRegex.test(responseStatus))
@@ -2071,14 +2056,14 @@ export default {
icon: "done", icon: "done",
}) })
;(() => { ;(() => {
const status = (this.response.status = payload.status) this.response.status = payload.status
const headers = (this.response.headers = payload.headers) this.response.headers = payload.headers
// We don't need to bother parsing JSON, axios already handles it for us! // We don't need to bother parsing JSON, axios already handles it for us!
const body = (this.response.body = payload.data) this.response.body = payload.data
// Addition of an entry to the history component. // Addition of an entry to the history component.
const entry = { const entry = {
label: this.requestName, label: this.requestName,
status, status: this.response.status,
date: new Date().toLocaleDateString(), date: new Date().toLocaleDateString(),
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
method: this.method, method: this.method,
@@ -2222,7 +2207,7 @@ export default {
getQueryStringFromPath() { getQueryStringFromPath() {
let queryString let queryString
const pathParsed = url.parse(this.uri) const pathParsed = url.parse(this.uri)
return (queryString = pathParsed.query ? pathParsed.query : "") return pathParsed.query ? pathParsed.query : ""
}, },
queryStringToArray(queryString) { queryStringToArray(queryString) {
const queryParsed = querystring.parse(queryString) const queryParsed = querystring.parse(queryString)
@@ -2619,7 +2604,7 @@ export default {
}, },
async oauthRedirectReq() { async oauthRedirectReq() {
const tokenInfo = await oauthRedirect() const tokenInfo = await oauthRedirect()
if (tokenInfo.hasOwnProperty("access_token")) { if (Object.prototype.hasOwnProperty.call(tokenInfo, "access_token")) {
this.bearerToken = tokenInfo.access_token this.bearerToken = tokenInfo.access_token
this.addOAuthToken({ this.addOAuthToken({
name: this.accessTokenName, name: this.accessTokenName,
@@ -2735,7 +2720,7 @@ export default {
if ((e.key === "u" || e.key === "U") && e.altKey) { if ((e.key === "u" || e.key === "U") && e.altKey) {
this.method = "PUT" this.method = "PUT"
} }
if ((e.key === "x" || e.key === "x") && e.altKey) { if ((e.key === "x" || e.key === "X") && e.altKey) {
this.method = "DELETE" this.method = "DELETE"
} }
if (e.key == "ArrowUp" && e.altKey && this.currentMethodIndex > 0) { if (e.key == "ArrowUp" && e.altKey && this.currentMethodIndex > 0) {

View File

@@ -217,7 +217,6 @@
</template> </template>
<script> <script>
import firebase from "firebase/app"
import { fb } from "~/helpers/fb" import { fb } from "~/helpers/fb"
import { hasExtensionInstalled } from "../helpers/strategies/ExtensionStrategy" import { hasExtensionInstalled } from "../helpers/strategies/ExtensionStrategy"

View File

@@ -301,9 +301,12 @@ export const mutations = {
const { request } = payload const { request } = payload
// Remove the old request from collection // Remove the old request from collection
if (request.hasOwnProperty("oldCollection") && request.oldCollection > -1) { if (
Object.prototype.hasOwnProperty.call(request, "oldCollection") &&
request.oldCollection > -1
) {
const folder = const folder =
request.hasOwnProperty("oldFolder") && request.oldFolder >= -1 Object.prototype.hasOwnProperty.call(request, "oldFolder") && request.oldFolder >= -1
? request.oldFolder ? request.oldFolder
: request.folder : request.folder
if (folder > -1) { if (folder > -1) {
@@ -311,7 +314,10 @@ export const mutations = {
} else { } else {
collections[request.oldCollection].requests.splice(request.requestIndex, 1) collections[request.oldCollection].requests.splice(request.requestIndex, 1)
} }
} else if (request.hasOwnProperty("oldFolder") && request.oldFolder !== -1) { } else if (
Object.prototype.hasOwnProperty.call(request, "oldFolder") &&
request.oldFolder !== -1
) {
collections[request.collection].folders[folder].requests.splice(request.requestIndex, 1) collections[request.collection].folders[folder].requests.splice(request.requestIndex, 1)
} }