From 21c6c07b3970252f10e3a5269e8372991b7dd2ca Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Mon, 24 Feb 2020 16:12:02 -0500 Subject: [PATCH 01/34] Save GraphQL schema and response in state Allows the user to go to the settings page, and back to the GraphQL page, without having to re-request the schema or response. --- pages/graphql.vue | 43 +++++++++++++++++++++++++++------------ store/state.js | 52 ++++++++++++++++++++++++----------------------- 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index fe21b2674..7430500f3 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -140,7 +140,7 @@ file_copy', downloadButton: 'get_app', doneButton: 'done', @@ -404,6 +402,22 @@ export default { this.$store.commit("setGQLState", { value, attribute: "query" }); } }, + response: { + get() { + return this.$store.state.gql.response; + }, + set(value) { + this.$store.commit("setGQLState", { value, attribute: "response" }); + } + }, + schema: { + get() { + return this.$store.state.gql.schema; + }, + set(value) { + this.$store.commit("setGQLState", { value, attribute: "schema" }); + } + }, variableString: { get() { return this.$store.state.gql.variablesJSONString; @@ -445,7 +459,7 @@ export default { copySchema() { this.$refs.copySchemaCode.innerHTML = this.doneButton; const aux = document.createElement("textarea"); - aux.innerText = this.schemaString; + aux.innerText = this.schema; document.body.appendChild(aux); aux.select(); document.execCommand("copy"); @@ -477,7 +491,7 @@ export default { copyResponse() { this.$refs.copyResponseButton.innerHTML = this.doneButton; const aux = document.createElement("textarea"); - aux.innerText = this.responseString; + aux.innerText = this.response; document.body.appendChild(aux); aux.select(); document.execCommand("copy"); @@ -519,7 +533,7 @@ export default { const data = await sendNetworkRequest(reqOptions, this.$store); - this.responseString = JSON.stringify(data.data, null, 2); + this.response = JSON.stringify(data.data, null, 2); this.$nuxt.$loading.finish(); const duration = Date.now() - startTime; @@ -537,7 +551,7 @@ export default { }, async getSchema() { const startTime = Date.now(); - this.schemaString = this.$t("loading"); + this.schema = this.$t("loading"); this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED && this.scrollInto("schema"); @@ -565,8 +579,6 @@ export default { data: query }; - // console.log(reqOptions); - const reqConfig = this.$store.state.postwoman.settings.PROXY_ENABLED ? { method: "post", @@ -584,9 +596,14 @@ export default { : res; const schema = gql.buildClientSchema(data.data.data); - this.schemaString = gql.printSchema(schema, { + this.schema = gql.printSchema(schema, { commentDescriptions: true }); + console.log( + gql.printSchema(schema, { + commentDescriptions: true + }) + ); if (schema.getQueryType()) { const fields = schema.getQueryType().getFields(); @@ -648,7 +665,7 @@ export default { }); } catch (error) { this.$nuxt.$loading.finish(); - this.schemaString = `${error}. ${this.$t("check_console_details")}`; + this.schema = `${error}. ${this.$t("check_console_details")}`; this.$toast.error(`${error} ${this.$t("f12_details")}`, { icon: "error" }); @@ -661,7 +678,7 @@ export default { this.responseBodyMaxLines == Infinity ? 16 : Infinity; }, downloadResponse() { - const dataToWrite = JSON.stringify(this.schemaString, null, 2); + const dataToWrite = JSON.stringify(this.schema, null, 2); const file = new Blob([dataToWrite], { type: "application/json" }); const a = document.createElement("a"); const url = URL.createObjectURL(file); diff --git a/store/state.js b/store/state.js index 25d04f6fd..271cf48ef 100644 --- a/store/state.js +++ b/store/state.js @@ -1,38 +1,40 @@ export default () => ({ request: { - method: "GET", - url: "https://httpbin.org", - path: "/get", - label: "", - auth: "None", - httpUser: "", - httpPassword: "", - passwordFieldType: "password", - bearerToken: "", + method: 'GET', + url: 'https://httpbin.org', + path: '/get', + label: '', + auth: 'None', + httpUser: '', + httpPassword: '', + passwordFieldType: 'password', + bearerToken: '', headers: [], params: [], bodyParams: [], - rawParams: "", + rawParams: '', rawInput: false, - requestType: "", - contentType: "" + requestType: '', + contentType: '', }, gql: { - url: "https://rickandmortyapi.com/graphql", + url: 'https://rickandmortyapi.com/graphql', headers: [], - variablesJSONString: "{}", - query: "" + schema: '', + variablesJSONString: '{}', + query: '', + response: '' }, oauth2: { tokens: [], tokenReqs: [], - tokenReqSelect: "", - tokenReqName: "", - accessTokenName: "", - oidcDiscoveryUrl: "", - authUrl: "", - accessTokenUrl: "", - clientId: "", - scope: "" - } -}); + tokenReqSelect: '', + tokenReqName: '', + accessTokenName: '', + oidcDiscoveryUrl: '', + authUrl: '', + accessTokenUrl: '', + clientId: '', + scope: '', + }, +}) \ No newline at end of file From 403254a983986b8afa20435b0a48f496c06c9637 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Mon, 24 Feb 2020 16:16:06 -0500 Subject: [PATCH 02/34] Change from v-model to value as this is not set by the user --- pages/graphql.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 7430500f3..a430d4ff0 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -140,7 +140,7 @@ {{ label }} - {{ isCollapsed ? "expand_more" : "expand_less" }} + {{ isCollapsed(label) ? "expand_more" : "expand_less" }} -
+
@@ -26,15 +29,12 @@ export default { computed: { frameColorsEnabled() { return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false; + }, + sectionString() { + return `${this.$route.path}/${this.label}`; } }, - data() { - return { - isCollapsed: false - }; - }, - props: { label: { type: String, @@ -49,7 +49,15 @@ export default { collapse({ target }) { const parent = target.parentNode.parentNode; parent.querySelector(".collapsible").classList.toggle("hidden"); - this.isCollapsed = !this.isCollapsed; + // Save collapsed section to local state + this.$store.commit("setCollapsedSection", this.sectionString); + }, + isCollapsed(label) { + return ( + this.$store.state.theme.collapsedSections.includes( + this.sectionString + ) || false + ); } } }; diff --git a/pages/graphql.vue b/pages/graphql.vue index a430d4ff0..465e5fbdb 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -6,12 +6,7 @@
  • - +
  • @@ -31,11 +26,7 @@
    -
    @@ -60,7 +51,7 @@ @input=" $store.commit('setGQLHeaderKey', { index, - value: $event + value: $event, }) " autofocus @@ -74,7 +65,7 @@ @change=" $store.commit('setGQLHeaderValue', { index, - value: $event.target.value + value: $event.target.value, }) " autofocus @@ -112,9 +103,7 @@ @click="ToggleExpandResponse" ref="ToggleExpandResponse" v-tooltip="{ - content: !expandResponse - ? $t('expand_response') - : $t('collapse_response') + content: !expandResponse ? $t('expand_response') : $t('collapse_response'), }" > @@ -149,20 +138,16 @@ autoScrollEditorIntoView: true, readOnly: true, showPrintMargin: false, - useWorker: false + useWorker: false, }" /> -
    +
    -
    @@ -51,7 +61,7 @@ @input=" $store.commit('setGQLHeaderKey', { index, - value: $event, + value: $event }) " autofocus @@ -65,7 +75,7 @@ @change=" $store.commit('setGQLHeaderValue', { index, - value: $event.target.value, + value: $event.target.value }) " autofocus @@ -103,7 +113,9 @@ @click="ToggleExpandResponse" ref="ToggleExpandResponse" v-tooltip="{ - content: !expandResponse ? $t('expand_response') : $t('collapse_response'), + content: !expandResponse + ? $t('expand_response') + : $t('collapse_response') }" > @@ -138,7 +150,7 @@ autoScrollEditorIntoView: true, readOnly: true, showPrintMargin: false, - useWorker: false, + useWorker: false }" /> @@ -169,7 +181,7 @@ fontSize: '16px', autoScrollEditorIntoView: true, showPrintMargin: false, - useWorker: false, + useWorker: false }" /> @@ -184,7 +196,7 @@ fontSize: '16px', autoScrollEditorIntoView: true, showPrintMargin: false, - useWorker: false, + useWorker: false }" /> @@ -213,7 +225,7 @@ autoScrollEditorIntoView: true, readOnly: true, showPrintMargin: false, - useWorker: false, + useWorker: false }" /> @@ -233,7 +245,10 @@
    - +
    @@ -249,7 +264,10 @@
    - +
    @@ -265,7 +283,10 @@
    - +
    @@ -280,8 +301,15 @@ {{ $t("types") }}
    -
    - +
    +
    @@ -314,17 +342,17 @@ diff --git a/pages/index.vue b/pages/index.vue index 47ac184d5..352499042 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -187,6 +187,7 @@ id="url" name="url" type="url" + spellcheck="false" v-model="url" />
  • @@ -197,6 +198,7 @@ id="path" name="path" v-model="path" + spellcheck="false" @input="pathInputHandler" /> @@ -207,6 +209,7 @@ name="label" type="text" v-model="label" + spellcheck="false" :placeholder="$t('optional')" /> diff --git a/pages/realtime.vue b/pages/realtime.vue index 9e97c4d06..2acc9a62a 100644 --- a/pages/realtime.vue +++ b/pages/realtime.vue @@ -11,6 +11,7 @@ Date: Tue, 25 Feb 2020 02:04:10 -0500 Subject: [PATCH 09/34] Re-trigger build --- components/section.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/section.vue b/components/section.vue index 056d7ed4b..3da3d819d 100644 --- a/components/section.vue +++ b/components/section.vue @@ -49,7 +49,7 @@ export default { collapse({ target }) { const parent = target.parentNode.parentNode; parent.querySelector(".collapsible").classList.toggle("hidden"); - // Save collapsed section to local state + // Save collapsed section into the collapsedSections array this.$store.commit("setCollapsedSection", this.sectionString); }, isCollapsed(label) { From 5779cddf221557c3bd6c29248cab34d059804716 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Mon, 24 Feb 2020 16:12:02 -0500 Subject: [PATCH 10/34] Save GraphQL schema and response in state Allows the user to go to the settings page, and back to the GraphQL page, without having to re-request the schema or response. --- pages/graphql.vue | 96 ++++++++++++++++++++++++++++------------------- store/state.js | 50 ++++++++++++------------ 2 files changed, 83 insertions(+), 63 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index ddf6353f5..2e5527e21 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -129,7 +129,7 @@
file_copy', downloadButton: 'get_app', doneButton: 'done', @@ -373,6 +371,22 @@ export default { this.$store.commit("setGQLState", { value, attribute: "query" }) }, }, + response: { + get() { + return this.$store.state.gql.response; + }, + set(value) { + this.$store.commit("setGQLState", { value, attribute: "response" }); + } + }, + schema: { + get() { + return this.$store.state.gql.schema; + }, + set(value) { + this.$store.commit("setGQLState", { value, attribute: "schema" }); + } + }, variableString: { get() { return this.$store.state.gql.variablesJSONString @@ -412,13 +426,13 @@ export default { return t }, copySchema() { - this.$refs.copySchemaCode.innerHTML = this.doneButton - const aux = document.createElement("textarea") - aux.innerText = this.schemaString - document.body.appendChild(aux) - aux.select() - document.execCommand("copy") - document.body.removeChild(aux) + this.$refs.copySchemaCode.innerHTML = this.doneButton; + const aux = document.createElement("textarea"); + aux.innerText = this.schema; + document.body.appendChild(aux); + aux.select(); + document.execCommand("copy"); + document.body.removeChild(aux); this.$toast.success(this.$t("copied_to_clipboard"), { icon: "done", }) @@ -438,13 +452,13 @@ export default { setTimeout(() => (this.$refs.copyQueryButton.innerHTML = this.copyButton), 1000) }, copyResponse() { - this.$refs.copyResponseButton.innerHTML = this.doneButton - const aux = document.createElement("textarea") - aux.innerText = this.responseString - document.body.appendChild(aux) - aux.select() - document.execCommand("copy") - document.body.removeChild(aux) + this.$refs.copyResponseButton.innerHTML = this.doneButton; + const aux = document.createElement("textarea"); + aux.innerText = this.response; + document.body.appendChild(aux); + aux.select(); + document.execCommand("copy"); + document.body.removeChild(aux); this.$toast.success(this.$t("copied_to_clipboard"), { icon: "done", }) @@ -478,7 +492,7 @@ export default { const data = await sendNetworkRequest(reqOptions, this.$store) - this.responseString = JSON.stringify(data.data, null, 2) + this.response = JSON.stringify(data.data, null, 2); this.$nuxt.$loading.finish() const duration = Date.now() - startTime @@ -495,9 +509,10 @@ export default { } }, async getSchema() { - const startTime = Date.now() - this.schemaString = this.$t("loading") - this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED && this.scrollInto("schema") + const startTime = Date.now(); + this.schema = this.$t("loading"); + this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED && + this.scrollInto("schema"); // Start showing the loading bar as soon as possible. // The nuxt axios module will hide it when the request is made. @@ -523,8 +538,6 @@ export default { data: query, } - // console.log(reqOptions); - const reqConfig = this.$store.state.postwoman.settings.PROXY_ENABLED ? { method: "post", @@ -538,10 +551,15 @@ export default { const data = this.$store.state.postwoman.settings.PROXY_ENABLED ? res.data : res - const schema = gql.buildClientSchema(data.data.data) - this.schemaString = gql.printSchema(schema, { - commentDescriptions: true, - }) + const schema = gql.buildClientSchema(data.data.data); + this.schema = gql.printSchema(schema, { + commentDescriptions: true + }); + console.log( + gql.printSchema(schema, { + commentDescriptions: true + }) + ); if (schema.getQueryType()) { const fields = schema.getQueryType().getFields() @@ -596,8 +614,8 @@ export default { icon: "done", }) } catch (error) { - this.$nuxt.$loading.finish() - this.schemaString = `${error}. ${this.$t("check_console_details")}` + this.$nuxt.$loading.finish(); + this.schema = `${error}. ${this.$t("check_console_details")}`; this.$toast.error(`${error} ${this.$t("f12_details")}`, { icon: "error", }) @@ -609,15 +627,15 @@ export default { this.responseBodyMaxLines = this.responseBodyMaxLines == Infinity ? 16 : Infinity }, downloadResponse() { - const dataToWrite = JSON.stringify(this.schemaString, null, 2) - const file = new Blob([dataToWrite], { type: "application/json" }) - const a = document.createElement("a") - const url = URL.createObjectURL(file) - a.href = url - a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]") - document.body.appendChild(a) - a.click() - this.$refs.downloadResponse.innerHTML = this.doneButton + const dataToWrite = JSON.stringify(this.schema, null, 2); + const file = new Blob([dataToWrite], { type: "application/json" }); + const a = document.createElement("a"); + const url = URL.createObjectURL(file); + a.href = url; + a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]"); + document.body.appendChild(a); + a.click(); + this.$refs.downloadResponse.innerHTML = this.doneButton; this.$toast.success(this.$t("download_started"), { icon: "done", }) diff --git a/store/state.js b/store/state.js index 1df17674a..271cf48ef 100644 --- a/store/state.js +++ b/store/state.js @@ -1,38 +1,40 @@ export default () => ({ request: { - method: "GET", - url: "https://httpbin.org", - path: "/get", - label: "", - auth: "None", - httpUser: "", - httpPassword: "", - passwordFieldType: "password", - bearerToken: "", + method: 'GET', + url: 'https://httpbin.org', + path: '/get', + label: '', + auth: 'None', + httpUser: '', + httpPassword: '', + passwordFieldType: 'password', + bearerToken: '', headers: [], params: [], bodyParams: [], - rawParams: "", + rawParams: '', rawInput: false, - requestType: "", - contentType: "", + requestType: '', + contentType: '', }, gql: { - url: "https://rickandmortyapi.com/graphql", + url: 'https://rickandmortyapi.com/graphql', headers: [], - variablesJSONString: "{}", - query: "", + schema: '', + variablesJSONString: '{}', + query: '', + response: '' }, oauth2: { tokens: [], tokenReqs: [], - tokenReqSelect: "", - tokenReqName: "", - accessTokenName: "", - oidcDiscoveryUrl: "", - authUrl: "", - accessTokenUrl: "", - clientId: "", - scope: "", + tokenReqSelect: '', + tokenReqName: '', + accessTokenName: '', + oidcDiscoveryUrl: '', + authUrl: '', + accessTokenUrl: '', + clientId: '', + scope: '', }, -}) +}) \ No newline at end of file From 6b675d5def1ed58601aa1f5c794b4a92926b13a6 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Mon, 24 Feb 2020 16:16:06 -0500 Subject: [PATCH 11/34] Change from v-model to value as this is not set by the user --- pages/graphql.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 2e5527e21..5f8307704 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -129,7 +129,7 @@ {{ label }} - {{ isCollapsed ? "expand_more" : "expand_less" }} + {{ isCollapsed(label) ? "expand_more" : "expand_less" }} -
+
@@ -22,13 +25,10 @@ fieldset.no-colored-frames legend { export default { computed: { frameColorsEnabled() { - return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false + return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false; }, - }, - - data() { - return { - isCollapsed: false, + sectionString() { + return `${this.$route.path}/${this.label}`; } }, @@ -44,10 +44,18 @@ export default { methods: { collapse({ target }) { - const parent = target.parentNode.parentNode - parent.querySelector(".collapsible").classList.toggle("hidden") - this.isCollapsed = !this.isCollapsed + const parent = target.parentNode.parentNode; + parent.querySelector(".collapsible").classList.toggle("hidden"); + // Save collapsed section to local state + this.$store.commit("setCollapsedSection", this.sectionString); }, - }, -} + isCollapsed(label) { + return ( + this.$store.state.theme.collapsedSections.includes( + this.sectionString + ) || false + ); + } + } +}; diff --git a/pages/graphql.vue b/pages/graphql.vue index 5f8307704..465e5fbdb 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -144,10 +144,10 @@ -
+
-
@@ -61,7 +57,7 @@ @input=" $store.commit('setGQLHeaderKey', { index, - value: $event + value: $event, }) " autofocus @@ -75,7 +71,7 @@ @change=" $store.commit('setGQLHeaderValue', { index, - value: $event.target.value + value: $event.target.value, }) " autofocus @@ -113,9 +109,7 @@ @click="ToggleExpandResponse" ref="ToggleExpandResponse" v-tooltip="{ - content: !expandResponse - ? $t('expand_response') - : $t('collapse_response') + content: !expandResponse ? $t('expand_response') : $t('collapse_response'), }" > @@ -150,7 +144,7 @@ autoScrollEditorIntoView: true, readOnly: true, showPrintMargin: false, - useWorker: false + useWorker: false, }" /> @@ -181,7 +175,7 @@ fontSize: '16px', autoScrollEditorIntoView: true, showPrintMargin: false, - useWorker: false + useWorker: false, }" /> @@ -196,7 +190,7 @@ fontSize: '16px', autoScrollEditorIntoView: true, showPrintMargin: false, - useWorker: false + useWorker: false, }" /> @@ -225,7 +219,7 @@ autoScrollEditorIntoView: true, readOnly: true, showPrintMargin: false, - useWorker: false + useWorker: false, }" /> @@ -245,10 +239,7 @@
- +
@@ -264,10 +255,7 @@
- +
@@ -283,10 +271,7 @@
- +
@@ -301,15 +286,8 @@ {{ $t("types") }}
-
- +
+
@@ -342,17 +320,17 @@ diff --git a/pages/index.vue b/pages/index.vue index d2a46209c..9626c78cc 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1443,12 +1443,11 @@ export default { settings: { SCROLL_INTO_ENABLED: - typeof this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED !== - "undefined" + typeof this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED !== "undefined" ? this.$store.state.postwoman.settings.SCROLL_INTO_ENABLED - : true - } - }; + : true, + }, + } }, watch: { urlExcludes: { @@ -1970,21 +1969,14 @@ export default { behavior: "smooth", }) }, - handleUseHistory({ - label, - method, - url, - path, - usesScripts, - preRequestScript - }) { - this.label = label; - this.method = method; - this.url = url; - this.path = path; - this.showPreRequestScript = usesScripts; - this.preRequestScript = preRequestScript; - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("request"); + handleUseHistory({ label, method, url, path, usesScripts, preRequestScript }) { + this.label = label + this.method = method + this.url = url + this.path = path + this.showPreRequestScript = usesScripts + this.preRequestScript = preRequestScript + this.settings.SCROLL_INTO_ENABLED && this.scrollInto("request") }, getVariablesFromPreRequestScript() { if (!this.preRequestScript) { @@ -2019,8 +2011,8 @@ export default { return await sendNetworkRequest(requestOptions, this.$store) }, async sendRequest() { - this.$toast.clear(); - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("response"); + this.$toast.clear() + this.settings.SCROLL_INTO_ENABLED && this.scrollInto("response") if (!this.isValidURL) { this.$toast.error(this.$t("url_invalid_format"), { From fb0c6d42eb0dc54096d1d61169b47ab04fcf8123 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 11:32:40 -0500 Subject: [PATCH 21/34] Remove trailing slash from url if it exists --- components/section.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/section.vue b/components/section.vue index 46aa973d6..2119f9064 100644 --- a/components/section.vue +++ b/components/section.vue @@ -25,7 +25,7 @@ export default { return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false }, sectionString() { - return `${this.$route.path}/${this.label}` + return `${this.$route.path.replace(/\/+$/, '')}/${this.label}` }, }, From 2a0322541d12d61a29caa39e0355fdb48d079890 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 11:33:02 -0500 Subject: [PATCH 22/34] Re-push formatted files --- components/section.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/section.vue b/components/section.vue index 2119f9064..70883a7ce 100644 --- a/components/section.vue +++ b/components/section.vue @@ -25,7 +25,7 @@ export default { return this.$store.state.postwoman.settings.FRAME_COLORS_ENABLED || false }, sectionString() { - return `${this.$route.path.replace(/\/+$/, '')}/${this.label}` + return `${this.$route.path.replace(/\/+$/, "")}/${this.label}` }, }, From 0cfcfa0026ede8495dcbef9933e391ba76d6b6ab Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 11:40:36 -0500 Subject: [PATCH 23/34] Final push for WIP --- components/section.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/components/section.vue b/components/section.vue index 70883a7ce..14ec3de29 100644 --- a/components/section.vue +++ b/components/section.vue @@ -43,6 +43,7 @@ export default { collapse({ target }) { const parent = target.parentNode.parentNode parent.querySelector(".collapsible").classList.toggle("hidden") + // Save collapsed section into the collapsedSections array this.$store.commit("setCollapsedSection", this.sectionString) }, From 3d32377cb939774506313253ab1ef68bb1d157f1 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 11:41:02 -0500 Subject: [PATCH 24/34] Final push for WIP --- components/section.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/section.vue b/components/section.vue index 14ec3de29..68f107c95 100644 --- a/components/section.vue +++ b/components/section.vue @@ -43,7 +43,7 @@ export default { collapse({ target }) { const parent = target.parentNode.parentNode parent.querySelector(".collapsible").classList.toggle("hidden") - + // Save collapsed section into the collapsedSections array this.$store.commit("setCollapsedSection", this.sectionString) }, From 68c749b37833f6ab42d8638e638858fac30cd9ac Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 20:43:34 -0500 Subject: [PATCH 25/34] Allow the passing of a lint prop to disable linting on an editor --- components/ace-editor.vue | 97 +++++++++++++++++++++------------------ pages/graphql.vue | 6 ++- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/components/ace-editor.vue b/components/ace-editor.vue index b348126cf..92de05e4e 100644 --- a/components/ace-editor.vue +++ b/components/ace-editor.vue @@ -5,26 +5,26 @@ diff --git a/pages/graphql.vue b/pages/graphql.vue index 5634bdc11..61ef95ed7 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -212,6 +212,7 @@ Date: Tue, 25 Feb 2020 20:44:03 -0500 Subject: [PATCH 26/34] Pretty-quick commited files --- functions/jsonParse.js | 250 ++++++++++++++++++++--------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/functions/jsonParse.js b/functions/jsonParse.js index 3ccfb055d..bc4b5d008 100644 --- a/functions/jsonParse.js +++ b/functions/jsonParse.js @@ -20,152 +20,152 @@ * */ export default function jsonParse(str) { - string = str; - strLen = str.length; - start = end = lastEnd = -1; - ch(); - lex(); - const ast = parseObj(); - expect('EOF'); - return ast; + string = str + strLen = str.length + start = end = lastEnd = -1 + ch() + lex() + const ast = parseObj() + expect("EOF") + return ast } -let string; -let strLen; -let start; -let end; -let lastEnd; -let code; -let kind; +let string +let strLen +let start +let end +let lastEnd +let code +let kind function parseObj() { - const nodeStart = start; - const members = []; - expect('{'); - if (!skip('}')) { + const nodeStart = start + const members = [] + expect("{") + if (!skip("}")) { do { - members.push(parseMember()); - } while (skip(',')); - expect('}'); + members.push(parseMember()) + } while (skip(",")) + expect("}") } return { - kind: 'Object', + kind: "Object", start: nodeStart, end: lastEnd, members, - }; + } } function parseMember() { - const nodeStart = start; - const key = kind === 'String' ? curToken() : null; - expect('String'); - expect(':'); - const value = parseVal(); + const nodeStart = start + const key = kind === "String" ? curToken() : null + expect("String") + expect(":") + const value = parseVal() return { - kind: 'Member', + kind: "Member", start: nodeStart, end: lastEnd, key, value, - }; + } } function parseArr() { - const nodeStart = start; - const values = []; - expect('['); - if (!skip(']')) { + const nodeStart = start + const values = [] + expect("[") + if (!skip("]")) { do { - values.push(parseVal()); - } while (skip(',')); - expect(']'); + values.push(parseVal()) + } while (skip(",")) + expect("]") } return { - kind: 'Array', + kind: "Array", start: nodeStart, end: lastEnd, values, - }; + } } function parseVal() { switch (kind) { - case '[': - return parseArr(); - case '{': - return parseObj(); - case 'String': - case 'Number': - case 'Boolean': - case 'Null': - const token = curToken(); - lex(); - return token; + case "[": + return parseArr() + case "{": + return parseObj() + case "String": + case "Number": + case "Boolean": + case "Null": + const token = curToken() + lex() + return token } - return expect('Value'); + return expect("Value") } function curToken() { - return { kind, start, end, value: JSON.parse(string.slice(start, end)) }; + return { kind, start, end, value: JSON.parse(string.slice(start, end)) } } function expect(str) { if (kind === str) { - lex(); - return; + lex() + return } - let found; - if (kind === 'EOF') { - found = '[end of file]'; + let found + if (kind === "EOF") { + found = "[end of file]" } else if (end - start > 1) { - found = '`' + string.slice(start, end) + '`'; + found = "`" + string.slice(start, end) + "`" } else { - const match = string.slice(start).match(/^.+?\b/); - found = '`' + (match ? match[0] : string[start]) + '`'; + const match = string.slice(start).match(/^.+?\b/) + found = "`" + (match ? match[0] : string[start]) + "`" } - throw syntaxError(`Expected ${str} but found ${found}.`); + throw syntaxError(`Expected ${str} but found ${found}.`) } function syntaxError(message) { - return { message, start, end }; + return { message, start, end } } function skip(k) { if (kind === k) { - lex(); - return true; + lex() + return true } } function ch() { if (end < strLen) { - end++; - code = end === strLen ? 0 : string.charCodeAt(end); + end++ + code = end === strLen ? 0 : string.charCodeAt(end) } } function lex() { - lastEnd = end; + lastEnd = end while (code === 9 || code === 10 || code === 13 || code === 32) { - ch(); + ch() } if (code === 0) { - kind = 'EOF'; - return; + kind = "EOF" + return } - start = end; + start = end switch (code) { // " case 34: - kind = 'String'; - return readString(); + kind = "String" + return readString() // -, 0-9 case 45: case 48: @@ -178,50 +178,50 @@ function lex() { case 55: case 56: case 57: - kind = 'Number'; - return readNumber(); + kind = "Number" + return readNumber() // f case 102: - if (string.slice(start, start + 5) !== 'false') { - break; + if (string.slice(start, start + 5) !== "false") { + break } - end += 4; - ch(); + end += 4 + ch() - kind = 'Boolean'; - return; + kind = "Boolean" + return // n case 110: - if (string.slice(start, start + 4) !== 'null') { - break; + if (string.slice(start, start + 4) !== "null") { + break } - end += 3; - ch(); + end += 3 + ch() - kind = 'Null'; - return; + kind = "Null" + return // t case 116: - if (string.slice(start, start + 4) !== 'true') { - break; + if (string.slice(start, start + 4) !== "true") { + break } - end += 3; - ch(); + end += 3 + ch() - kind = 'Boolean'; - return; + kind = "Boolean" + return } - kind = string[start]; - ch(); + kind = string[start] + ch() } function readString() { - ch(); + ch() while (code !== 34 && code > 31) { if (code === 92) { // \ - ch(); + ch() switch (code) { case 34: // " case 47: // / @@ -231,31 +231,31 @@ function readString() { case 110: // n case 114: // r case 116: // t - ch(); - break; + ch() + break case 117: // u - ch(); - readHex(); - readHex(); - readHex(); - readHex(); - break; + ch() + readHex() + readHex() + readHex() + readHex() + break default: - throw syntaxError('Bad character escape sequence.'); + throw syntaxError("Bad character escape sequence.") } } else if (end === strLen) { - throw syntaxError('Unterminated string.'); + throw syntaxError("Unterminated string.") } else { - ch(); + ch() } } if (code === 34) { - ch(); - return; + ch() + return } - throw syntaxError('Unterminated string.'); + throw syntaxError("Unterminated string.") } function readHex() { @@ -264,47 +264,47 @@ function readHex() { (code >= 65 && code <= 70) || // A-F (code >= 97 && code <= 102) // a-f ) { - return ch(); + return ch() } - throw syntaxError('Expected hexadecimal digit.'); + throw syntaxError("Expected hexadecimal digit.") } function readNumber() { if (code === 45) { // - - ch(); + ch() } if (code === 48) { // 0 - ch(); + ch() } else { - readDigits(); + readDigits() } if (code === 46) { // . - ch(); - readDigits(); + ch() + readDigits() } if (code === 69 || code === 101) { // E e - ch(); + ch() if (code === 43 || code === 45) { // + - - ch(); + ch() } - readDigits(); + readDigits() } } function readDigits() { if (code < 48 || code > 57) { // 0 - 9 - throw syntaxError('Expected decimal digit.'); + throw syntaxError("Expected decimal digit.") } do { - ch(); - } while (code >= 48 && code <= 57); // 0 - 9 + ch() + } while (code >= 48 && code <= 57) // 0 - 9 } From 590403650ea8d985d457163514ec2e9dcebda892 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 20:48:48 -0500 Subject: [PATCH 27/34] Remove unnecessary variable --- components/ace-editor.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/ace-editor.vue b/components/ace-editor.vue index 92de05e4e..9477bdb65 100644 --- a/components/ace-editor.vue +++ b/components/ace-editor.vue @@ -55,7 +55,6 @@ export default { return { initialized: false, editor: null, - shouldLint: true, cacheValue: "", } }, @@ -65,7 +64,7 @@ export default { if (value !== this.cacheValue) { this.editor.session.setValue(value, 1) this.cacheValue = value - if (this.shouldLint) this.provideLinting(value) + if (this.lint) this.provideLinting(value) } }, theme() { @@ -109,11 +108,11 @@ export default { const content = editor.getValue() this.$emit("input", content) this.cacheValue = content - if (this.shouldLint) this.provideLinting(content) + if (this.lint) this.provideLinting(content) }) // Disable linting, if lint prop is false - if (this.shouldLint) this.provideLinting(this.value) + if (this.lint) this.provideLinting(this.value) }, methods: { From 8d7c6f46b75d25875dad2223028e985dc9d16820 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 20:49:19 -0500 Subject: [PATCH 28/34] Remove shouldLint variable --- components/ace-editor.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/ace-editor.vue b/components/ace-editor.vue index 9477bdb65..0ac6b2369 100644 --- a/components/ace-editor.vue +++ b/components/ace-editor.vue @@ -84,9 +84,6 @@ export default { }, mounted() { - // Set whether or not we should lint the editors contents - this.shouldLint = this.lint - const editor = ace.edit(this.$refs.editor, { mode: `ace/mode/${this.lang}`, ...this.options, From 60f2482082b892453a666d42d9309b0beacc1c41 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 21:22:32 -0500 Subject: [PATCH 29/34] Set response to proper error message Was setting the response to an empty string. But this makes it show the correct error. --- pages/graphql.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 61ef95ed7..3ee2ba047 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -520,10 +520,7 @@ export default { icon: "done", }) } catch (error) { - // Reset response back to empty string - // Note: We're specifically setting this to an empty string, as - // returning {} could could give the impression that the query succeeded - this.response = "" + this.response = `${error}. ${this.$t("check_console_details")}` this.$nuxt.$loading.finish() this.$toast.error(`${error} ${this.$t("f12_details")}`, { From f36b91c3cc4df0171572adf24924ee006ef0ac31 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 21:38:54 -0500 Subject: [PATCH 30/34] Switch to semantic if checks Should stick to semantic code here.. rather than doing the shorthand way --- pages/graphql.vue | 4 ++-- pages/index.vue | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 3ee2ba047..a11888ba5 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -489,7 +489,7 @@ export default { this.$nuxt.$loading.start() this.response = this.$t("loading") - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("response") + if (this.settings.SCROLL_INTO_ENABLED) this.scrollInto("response") try { let headers = {} @@ -537,7 +537,7 @@ export default { this.$nuxt.$loading.start() this.schema = this.$t("loading") - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("schema") + if (this.settings.SCROLL_INTO_ENABLED) this.scrollInto("schema") try { const query = JSON.stringify({ diff --git a/pages/index.vue b/pages/index.vue index 9626c78cc..de7536cd2 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1976,7 +1976,7 @@ export default { this.path = path this.showPreRequestScript = usesScripts this.preRequestScript = preRequestScript - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("request") + if (this.settings.SCROLL_INTO_ENABLED) this.scrollInto("request") }, getVariablesFromPreRequestScript() { if (!this.preRequestScript) { @@ -2012,7 +2012,7 @@ export default { }, async sendRequest() { this.$toast.clear() - this.settings.SCROLL_INTO_ENABLED && this.scrollInto("response") + if (this.settings.SCROLL_INTO_ENABLED) this.scrollInto("response") if (!this.isValidURL) { this.$toast.error(this.$t("url_invalid_format"), { From 2802e0468875a61072e4f61d49a6cc626db9c922 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 22:40:50 -0500 Subject: [PATCH 31/34] Re-trigger build --- pages/graphql.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/graphql.vue b/pages/graphql.vue index a11888ba5..933bf392e 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -630,6 +630,7 @@ export default { }) } catch (error) { this.$nuxt.$loading.finish() + this.schema = `${error}. ${this.$t("check_console_details")}` this.$toast.error(`${error} ${this.$t("f12_details")}`, { icon: "error", From dddd8f32e84fecb00cc131c83be004646078c895 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 22:41:08 -0500 Subject: [PATCH 32/34] Re-trigger build --- pages/graphql.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/graphql.vue b/pages/graphql.vue index 933bf392e..e2b5f7c37 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -630,7 +630,7 @@ export default { }) } catch (error) { this.$nuxt.$loading.finish() - + this.schema = `${error}. ${this.$t("check_console_details")}` this.$toast.error(`${error} ${this.$t("f12_details")}`, { icon: "error", From 50339a2480205cd46c866aa314cb57d8d689b9c0 Mon Sep 17 00:00:00 2001 From: Dmitry Yankowski Date: Tue, 25 Feb 2020 22:48:36 -0500 Subject: [PATCH 33/34] Moved both prettier config and husky config into package.json --- .huskyrc | 5 ----- .prettierrc | 6 ------ package.json | 11 +++++++++++ 3 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 .huskyrc delete mode 100644 .prettierrc diff --git a/.huskyrc b/.huskyrc deleted file mode 100644 index 2543db718..000000000 --- a/.huskyrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "hooks": { - "pre-commit": "npm run pretty-quick" - } -} \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 8684950aa..000000000 --- a/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "trailingComma": "es5", - "semi": false, - "singleQuote": false, - "printWidth": 100 -} diff --git a/package.json b/package.json index 80f59be06..46283ee7b 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,17 @@ "pretty-quick": "pretty-quick --pattern \"**/*.*(html|js|json|vue)\"", "test": "start-server-and-test start http-get://localhost:3000 e2e" }, + "husky": { + "hooks": { + "pre-commit": "npm run pretty-quick" + } + }, + "prettier": { + "trailingComma": "es5", + "semi": false, + "singleQuote": false, + "printWidth": 100 + }, "dependencies": { "@nuxtjs/axios": "^5.9.5", "@nuxtjs/google-analytics": "^2.2.3", From 4239b1358e5ba53d7956664dd472c277cb72553e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2020 06:45:23 +0000 Subject: [PATCH 34/34] chore(deps-dev): bump lint-staged from 10.0.7 to 10.0.8 Bumps [lint-staged](https://github.com/okonet/lint-staged) from 10.0.7 to 10.0.8. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v10.0.7...v10.0.8) Signed-off-by: dependabot-preview[bot] --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e4d7ce096..8733be693 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7344,9 +7344,9 @@ "dev": true }, "lint-staged": { - "version": "10.0.7", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.0.7.tgz", - "integrity": "sha512-Byj0F4l7GYUpYYHEqyFH69NiI6ICTg0CeCKbhRorL+ickbzILKUlZLiyCkljZV02wnoh7yH7PmFyYm9PRNwk9g==", + "version": "10.0.8", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.0.8.tgz", + "integrity": "sha512-Oa9eS4DJqvQMVdywXfEor6F4vP+21fPHF8LUXgBbVWUSWBddjqsvO6Bv1LwMChmgQZZqwUvgJSHlu8HFHAPZmA==", "dev": true, "requires": { "chalk": "^3.0.0", diff --git a/package.json b/package.json index 46283ee7b..8e7e2baec 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "devDependencies": { "cypress": "^4.0.2", "husky": "^4.2.3", - "lint-staged": "^10.0.7", + "lint-staged": "^10.0.8", "node-sass": "^4.13.1", "prettier": "^1.19.1", "pretty-quick": "^2.0.1",