refactor: lint
This commit is contained in:
@@ -6,9 +6,9 @@
|
|||||||
<label for="reqParamList">{{ $t("request_body") }}</label>
|
<label for="reqParamList">{{ $t("request_body") }}</label>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('clear')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="clearContent('bodyParams', $event)"
|
@click="clearContent('bodyParams', $event)"
|
||||||
v-tooltip.bottom="$t('clear')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">clear_all</i>
|
<i class="material-icons">clear_all</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -34,9 +34,9 @@
|
|||||||
:placeholder="`key ${index + 1}`"
|
:placeholder="`key ${index + 1}`"
|
||||||
:name="`bparam ${index}`"
|
:name="`bparam ${index}`"
|
||||||
:value="param.key"
|
:value="param.key"
|
||||||
|
autofocus
|
||||||
@change="updateBodyParams($event, index, `setKeyBodyParams`)"
|
@change="updateBodyParams($event, index, `setKeyBodyParams`)"
|
||||||
@keyup.prevent="setRouteQueryState"
|
@keyup.prevent="setRouteQueryState"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -66,8 +66,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
@click="toggleActive(index, param)"
|
|
||||||
v-tooltip.bottom="{
|
v-tooltip.bottom="{
|
||||||
content: param.hasOwnProperty('active')
|
content: param.hasOwnProperty('active')
|
||||||
? param.active
|
? param.active
|
||||||
@@ -75,6 +73,8 @@
|
|||||||
: $t('turn_on')
|
: $t('turn_on')
|
||||||
: $t('turn_off'),
|
: $t('turn_off'),
|
||||||
}"
|
}"
|
||||||
|
class="icon"
|
||||||
|
@click="toggleActive(index, param)"
|
||||||
>
|
>
|
||||||
<i class="material-icons">
|
<i class="material-icons">
|
||||||
{{
|
{{
|
||||||
@@ -91,7 +91,10 @@
|
|||||||
<div v-if="contentType === 'multipart/form-data'">
|
<div v-if="contentType === 'multipart/form-data'">
|
||||||
<li>
|
<li>
|
||||||
<label for="attachment" class="p-0">
|
<label for="attachment" class="p-0">
|
||||||
<button class="w-full icon" @click="$refs.attachment[index].click()">
|
<button
|
||||||
|
class="w-full icon"
|
||||||
|
@click="$refs.attachment[index].click()"
|
||||||
|
>
|
||||||
<i class="material-icons">attach_file</i>
|
<i class="material-icons">attach_file</i>
|
||||||
</button>
|
</button>
|
||||||
</label>
|
</label>
|
||||||
@@ -99,17 +102,17 @@
|
|||||||
ref="attachment"
|
ref="attachment"
|
||||||
name="attachment"
|
name="attachment"
|
||||||
type="file"
|
type="file"
|
||||||
@change="setRequestAttachment($event, index)"
|
|
||||||
multiple
|
multiple
|
||||||
|
@change="setRequestAttachment($event, index)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="removeRequestBodyParam(index)"
|
@click="removeRequestBodyParam(index)"
|
||||||
v-tooltip.bottom="$t('delete')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -118,7 +121,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<button class="icon" @click="addRequestBodyParam" name="addrequest">
|
<button class="icon" name="addrequest" @click="addRequestBodyParam">
|
||||||
<i class="material-icons">add</i>
|
<i class="material-icons">add</i>
|
||||||
<span>{{ $t("add_new") }}</span>
|
<span>{{ $t("add_new") }}</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -127,26 +130,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.file-chips-container {
|
|
||||||
@apply flex;
|
|
||||||
@apply flex-1;
|
|
||||||
@apply whitespace-nowrap;
|
|
||||||
@apply overflow-auto;
|
|
||||||
@apply bg-bgDarkColor;
|
|
||||||
|
|
||||||
.file-chips-wrapper {
|
|
||||||
@apply flex;
|
|
||||||
@apply w-0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
bodyParams: { type: Array, default: () => [] },
|
bodyParams: { type: Array, default: () => [] },
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
contentType() {
|
||||||
|
return this.$store.state.request.contentType
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clearContent(bodyParams, $event) {
|
clearContent(bodyParams, $event) {
|
||||||
this.$emit("clear-content", bodyParams, $event)
|
this.$emit("clear-content", bodyParams, $event)
|
||||||
@@ -157,7 +150,10 @@ export default {
|
|||||||
removeRequestBodyParam(index) {
|
removeRequestBodyParam(index) {
|
||||||
const paramArr = this.$store.state.request.bodyParams.filter(
|
const paramArr = this.$store.state.request.bodyParams.filter(
|
||||||
(item, itemIndex) =>
|
(item, itemIndex) =>
|
||||||
itemIndex !== index && (item.hasOwnProperty("active") ? item.active == true : true)
|
itemIndex !== index &&
|
||||||
|
(Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true)
|
||||||
)
|
)
|
||||||
this.setRawParams(paramArr)
|
this.setRawParams(paramArr)
|
||||||
this.$emit("remove-request-body-param", index)
|
this.$emit("remove-request-body-param", index)
|
||||||
@@ -188,26 +184,34 @@ export default {
|
|||||||
index,
|
index,
|
||||||
value: event.target.value,
|
value: event.target.value,
|
||||||
})
|
})
|
||||||
let paramArr = this.$store.state.request.bodyParams.filter((item) =>
|
const paramArr = this.$store.state.request.bodyParams.filter((item) =>
|
||||||
item.hasOwnProperty("active") ? item.active == true : true
|
Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true
|
||||||
)
|
)
|
||||||
|
|
||||||
this.setRawParams(paramArr)
|
this.setRawParams(paramArr)
|
||||||
},
|
},
|
||||||
toggleActive(index, param) {
|
toggleActive(index, param) {
|
||||||
let paramArr = this.$store.state.request.bodyParams.filter((item, itemIndex) => {
|
const paramArr = this.$store.state.request.bodyParams.filter(
|
||||||
if (index === itemIndex) {
|
(item, itemIndex) => {
|
||||||
return !param.active
|
if (index === itemIndex) {
|
||||||
} else {
|
return !param.active
|
||||||
return item.hasOwnProperty("active") ? item.active == true : true
|
} else {
|
||||||
|
return Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
this.setRawParams(paramArr)
|
this.setRawParams(paramArr)
|
||||||
|
|
||||||
this.$store.commit("setActiveBodyParams", {
|
this.$store.commit("setActiveBodyParams", {
|
||||||
index,
|
index,
|
||||||
value: param.hasOwnProperty("active") ? !param.active : false,
|
value: Object.prototype.hasOwnProperty.call(param, "active")
|
||||||
|
? !param.active
|
||||||
|
: false,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setRawParams(filteredParamArr) {
|
setRawParams(filteredParamArr) {
|
||||||
@@ -219,13 +223,26 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const rawParamsStr = JSON.stringify(rawParams, null, 2)
|
const rawParamsStr = JSON.stringify(rawParams, null, 2)
|
||||||
this.$store.commit("setState", { value: rawParamsStr, attribute: "rawParams" })
|
this.$store.commit("setState", {
|
||||||
},
|
value: rawParamsStr,
|
||||||
},
|
attribute: "rawParams",
|
||||||
computed: {
|
})
|
||||||
contentType() {
|
|
||||||
return this.$store.state.request.contentType
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.file-chips-container {
|
||||||
|
@apply flex;
|
||||||
|
@apply flex-1;
|
||||||
|
@apply whitespace-nowrap;
|
||||||
|
@apply overflow-auto;
|
||||||
|
@apply bg-bgDarkColor;
|
||||||
|
|
||||||
|
.file-chips-wrapper {
|
||||||
|
@apply flex;
|
||||||
|
@apply w-0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -14,7 +14,9 @@
|
|||||||
<label for="requestType">{{ $t("choose_language") }}</label>
|
<label for="requestType">{{ $t("choose_language") }}</label>
|
||||||
<span class="select-wrapper">
|
<span class="select-wrapper">
|
||||||
<v-popover>
|
<v-popover>
|
||||||
<pre v-if="requestType">{{ codegens.find((x) => x.id === requestType).name }}</pre>
|
<pre v-if="requestType">{{
|
||||||
|
codegens.find((x) => x.id === requestType).name
|
||||||
|
}}</pre>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
id="requestType"
|
id="requestType"
|
||||||
@@ -26,7 +28,11 @@
|
|||||||
/>
|
/>
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
<div v-for="gen in codegens" :key="gen.id">
|
<div v-for="gen in codegens" :key="gen.id">
|
||||||
<button class="icon" @click="requestType = gen.id" v-close-popover>
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="requestType = gen.id"
|
||||||
|
>
|
||||||
{{ gen.name }}
|
{{ gen.name }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,10 +43,10 @@
|
|||||||
<label for="generatedCode">{{ $t("generated_code") }}</label>
|
<label for="generatedCode">{{ $t("generated_code") }}</label>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
@click="copyRequestCode"
|
|
||||||
ref="copyRequestCode"
|
ref="copyRequestCode"
|
||||||
v-tooltip="$t('copy_code')"
|
v-tooltip="$t('copy_code')"
|
||||||
|
class="icon"
|
||||||
|
@click="copyRequestCode"
|
||||||
>
|
>
|
||||||
<i class="material-icons">content_copy</i>
|
<i class="material-icons">content_copy</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -48,6 +54,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<SmartAceEditor
|
<SmartAceEditor
|
||||||
v-if="requestType"
|
v-if="requestType"
|
||||||
|
ref="generatedCode"
|
||||||
:value="requestCode"
|
:value="requestCode"
|
||||||
:lang="codegens.find((x) => x.id === requestType).language"
|
:lang="codegens.find((x) => x.id === requestType).language"
|
||||||
:options="{
|
:options="{
|
||||||
@@ -60,7 +67,6 @@
|
|||||||
useWorker: false,
|
useWorker: false,
|
||||||
}"
|
}"
|
||||||
styles="rounded-b-lg"
|
styles="rounded-b-lg"
|
||||||
ref="generatedCode"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</SmartModal>
|
</SmartModal>
|
||||||
@@ -72,7 +78,7 @@ import { codegens } from "~/helpers/codegen/codegen"
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
requestCode: String,
|
requestCode: { type: String, default: "" },
|
||||||
requestTypeProp: { type: String, default: "curl" },
|
requestTypeProp: { type: String, default: "curl" },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -107,7 +113,10 @@ export default {
|
|||||||
this.$refs.generatedCode.editor.selectAll()
|
this.$refs.generatedCode.editor.selectAll()
|
||||||
this.$refs.generatedCode.editor.focus()
|
this.$refs.generatedCode.editor.focus()
|
||||||
document.execCommand("copy")
|
document.execCommand("copy")
|
||||||
setTimeout(() => (this.$refs.copyRequestCode.innerHTML = this.copyButton), 1000)
|
setTimeout(
|
||||||
|
() => (this.$refs.copyRequestCode.innerHTML = this.copyButton),
|
||||||
|
1000
|
||||||
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection label="Headers" ref="headers" no-legend>
|
<AppSection ref="headers" label="Headers" no-legend>
|
||||||
<ul v-if="headers.length !== 0">
|
<ul v-if="headers.length !== 0">
|
||||||
<li>
|
<li>
|
||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
<label for="headerList">{{ $t("header_list") }}</label>
|
<label for="headerList">{{ $t("header_list") }}</label>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('clear')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="clearContent('headers', $event)"
|
@click="clearContent('headers', $event)"
|
||||||
v-tooltip.bottom="$t('clear')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">clear_all</i>
|
<i class="material-icons">clear_all</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
:source="commonHeaders"
|
:source="commonHeaders"
|
||||||
:spellcheck="false"
|
:spellcheck="false"
|
||||||
:value="header.key"
|
:value="header.key"
|
||||||
|
autofocus
|
||||||
@input="
|
@input="
|
||||||
$store.commit('setKeyHeader', {
|
$store.commit('setKeyHeader', {
|
||||||
index,
|
index,
|
||||||
@@ -42,7 +43,6 @@
|
|||||||
})
|
})
|
||||||
"
|
"
|
||||||
@keyup.prevent="setRouteQueryState"
|
@keyup.prevent="setRouteQueryState"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -62,13 +62,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
@click="
|
|
||||||
$store.commit('setActiveHeader', {
|
|
||||||
index,
|
|
||||||
value: header.hasOwnProperty('active') ? !header.active : false,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
v-tooltip.bottom="{
|
v-tooltip.bottom="{
|
||||||
content: header.hasOwnProperty('active')
|
content: header.hasOwnProperty('active')
|
||||||
? header.active
|
? header.active
|
||||||
@@ -76,6 +69,13 @@
|
|||||||
: $t('turn_on')
|
: $t('turn_on')
|
||||||
: $t('turn_off'),
|
: $t('turn_off'),
|
||||||
}"
|
}"
|
||||||
|
class="icon"
|
||||||
|
@click="
|
||||||
|
$store.commit('setActiveHeader', {
|
||||||
|
index,
|
||||||
|
value: header.hasOwnProperty('active') ? !header.active : false,
|
||||||
|
})
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<i class="material-icons">
|
<i class="material-icons">
|
||||||
{{
|
{{
|
||||||
@@ -91,7 +91,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button class="icon" @click="removeRequestHeader(index)" v-tooltip.bottom="$t('delete')">
|
<button
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
|
class="icon"
|
||||||
|
@click="removeRequestHeader(index)"
|
||||||
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -11,7 +11,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div slot="body" class="flex flex-col">
|
<div slot="body" class="flex flex-col">
|
||||||
<textarea id="import-curl" autofocus rows="8" :placeholder="$t('enter_curl')"></textarea>
|
<textarea
|
||||||
|
id="import-curl"
|
||||||
|
autofocus
|
||||||
|
rows="8"
|
||||||
|
:placeholder="$t('enter_curl')"
|
||||||
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection :label="$t('notes')" ref="sync" no-legend>
|
<AppSection ref="sync" :label="$t('notes')" no-legend>
|
||||||
<div v-if="fb.currentUser">
|
<div v-if="fb.currentUser">
|
||||||
<FirebaseInputform />
|
<FirebaseInputform />
|
||||||
<FirebaseFeeds />
|
<FirebaseFeeds />
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection label="Parameters" ref="parameters" no-legend>
|
<AppSection ref="parameters" label="Parameters" no-legend>
|
||||||
<ul v-if="params.length !== 0">
|
<ul v-if="params.length !== 0">
|
||||||
<li>
|
<li>
|
||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
<label for="paramList">{{ $t("parameter_list") }}</label>
|
<label for="paramList">{{ $t("parameter_list") }}</label>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('clear')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="clearContent('parameters', $event)"
|
@click="clearContent('parameters', $event)"
|
||||||
v-tooltip.bottom="$t('clear')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">clear_all</i>
|
<i class="material-icons">clear_all</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -34,13 +34,13 @@
|
|||||||
:placeholder="$t('parameter_count', { count: index + 1 })"
|
:placeholder="$t('parameter_count', { count: index + 1 })"
|
||||||
:name="'param' + index"
|
:name="'param' + index"
|
||||||
:value="param.key"
|
:value="param.key"
|
||||||
|
autofocus
|
||||||
@change="
|
@change="
|
||||||
$store.commit('setKeyParams', {
|
$store.commit('setKeyParams', {
|
||||||
index,
|
index,
|
||||||
value: $event.target.value,
|
value: $event.target.value,
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
autofocus
|
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -79,13 +79,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
@click="
|
|
||||||
$store.commit('setActiveParams', {
|
|
||||||
index,
|
|
||||||
value: param.hasOwnProperty('active') ? !param.active : false,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
v-tooltip.bottom="{
|
v-tooltip.bottom="{
|
||||||
content: param.hasOwnProperty('active')
|
content: param.hasOwnProperty('active')
|
||||||
? param.active
|
? param.active
|
||||||
@@ -93,6 +86,13 @@
|
|||||||
: $t('turn_on')
|
: $t('turn_on')
|
||||||
: $t('turn_off'),
|
: $t('turn_off'),
|
||||||
}"
|
}"
|
||||||
|
class="icon"
|
||||||
|
@click="
|
||||||
|
$store.commit('setActiveParams', {
|
||||||
|
index,
|
||||||
|
value: param.hasOwnProperty('active') ? !param.active : false,
|
||||||
|
})
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<i class="material-icons">
|
<i class="material-icons">
|
||||||
{{
|
{{
|
||||||
@@ -108,7 +108,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button class="icon" @click="removeRequestParam(index)" v-tooltip.bottom="$t('delete')">
|
<button
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
|
class="icon"
|
||||||
|
@click="removeRequestParam(index)"
|
||||||
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -6,24 +6,33 @@
|
|||||||
<label for="rawBody">{{ $t("raw_request_body") }}</label>
|
<label for="rawBody">{{ $t("raw_request_body") }}</label>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
ref="prettifyRequest"
|
|
||||||
@click="prettifyRequestBody"
|
|
||||||
v-tooltip="$t('prettify_body')"
|
|
||||||
v-if="rawInput && contentType.endsWith('json')"
|
v-if="rawInput && contentType.endsWith('json')"
|
||||||
|
ref="prettifyRequest"
|
||||||
|
v-tooltip="$t('prettify_body')"
|
||||||
|
class="icon"
|
||||||
|
@click="prettifyRequestBody"
|
||||||
>
|
>
|
||||||
<i class="material-icons">photo_filter</i>
|
<i class="material-icons">photo_filter</i>
|
||||||
</button>
|
</button>
|
||||||
<label for="payload" class="p-0">
|
<label for="payload" class="p-0">
|
||||||
<button class="icon" @click="$refs.payload.click()" v-tooltip="$t('import_json')">
|
<button
|
||||||
|
v-tooltip="$t('import_json')"
|
||||||
|
class="icon"
|
||||||
|
@click="$refs.payload.click()"
|
||||||
|
>
|
||||||
<i class="material-icons">post_add</i>
|
<i class="material-icons">post_add</i>
|
||||||
</button>
|
</button>
|
||||||
</label>
|
</label>
|
||||||
<input ref="payload" name="payload" type="file" @change="uploadPayload" />
|
<input
|
||||||
|
ref="payload"
|
||||||
|
name="payload"
|
||||||
|
type="file"
|
||||||
|
@change="uploadPayload"
|
||||||
|
/>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('clear')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="clearContent('rawParams', $event)"
|
@click="clearContent('rawParams', $event)"
|
||||||
v-tooltip.bottom="$t('clear')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">clear_all</i>
|
<i class="material-icons">clear_all</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -102,7 +111,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const jsonObj = JSON.parse(this.rawParamsBody)
|
const jsonObj = JSON.parse(this.rawParamsBody)
|
||||||
this.rawParamsBody = JSON.stringify(jsonObj, null, 2)
|
this.rawParamsBody = JSON.stringify(jsonObj, null, 2)
|
||||||
let oldIcon = this.$refs.prettifyRequest.innerHTML
|
const oldIcon = this.$refs.prettifyRequest.innerHTML
|
||||||
this.$refs.prettifyRequest.innerHTML = this.doneButton
|
this.$refs.prettifyRequest.innerHTML = this.doneButton
|
||||||
setTimeout(() => (this.$refs.prettifyRequest.innerHTML = oldIcon), 1000)
|
setTimeout(() => (this.$refs.prettifyRequest.innerHTML = oldIcon), 1000)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection id="response" :label="$t('response')" ref="response" no-legend>
|
<AppSection id="response" ref="response" :label="$t('response')" no-legend>
|
||||||
<HttpResponseMeta :response="response" :active="active" />
|
<HttpResponseMeta :response="response" :active="active" />
|
||||||
<div v-if="response.body && response.body !== $t('loading')">
|
<div v-if="response.body && response.body !== $t('loading')">
|
||||||
<LensesResponseBodyRenderer :response="response" />
|
<LensesResponseBodyRenderer :response="response" />
|
||||||
@@ -12,7 +12,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
response: {
|
response: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
active: {
|
active: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<label>{{ $t("response") }}</label>
|
<label>{{ $t("response") }}</label>
|
||||||
<label v-if="active"><i class="animate-spin material-icons">refresh</i></label>
|
<label v-if="active"
|
||||||
|
><i class="animate-spin material-icons">refresh</i></label
|
||||||
|
>
|
||||||
<label v-else :class="statusCategory ? statusCategory.className : ''">
|
<label v-else :class="statusCategory ? statusCategory.className : ''">
|
||||||
<i class="material-icons">fiber_manual_record</i>
|
<i class="material-icons">fiber_manual_record</i>
|
||||||
</label>
|
</label>
|
||||||
@@ -31,7 +33,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
response: {
|
response: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
active: {
|
active: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
<label>{{ $t("token_list") }}</label>
|
<label>{{ $t("token_list") }}</label>
|
||||||
<div v-if="tokens.length != 0">
|
<div v-if="tokens.length != 0">
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('clear')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="clearContent('tokens', $event)"
|
@click="clearContent('tokens', $event)"
|
||||||
v-tooltip.bottom="$t('clear')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">clear_all</i>
|
<i class="material-icons">clear_all</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -42,15 +42,19 @@
|
|||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.bottom="$t('use_token')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="useOAuthToken(token.value)"
|
@click="useOAuthToken(token.value)"
|
||||||
v-tooltip.bottom="$t('use_token')"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">input</i>
|
<i class="material-icons">input</i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="icon" @click="removeOAuthToken(index)" v-tooltip.bottom="$t('delete')">
|
<button
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
|
class="icon"
|
||||||
|
@click="removeOAuthToken(index)"
|
||||||
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label>{{ $t("color") }}: {{ active.charAt(0).toUpperCase() + active.slice(1) }}</label>
|
<label
|
||||||
|
>{{ $t("color") }}:
|
||||||
|
{{ active.charAt(0).toUpperCase() + active.slice(1) }}</label
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<!-- text-blue-400 -->
|
<!-- text-blue-400 -->
|
||||||
<!-- text-green-400 -->
|
<!-- text-green-400 -->
|
||||||
@@ -56,16 +59,16 @@ export default {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
active(color) {
|
||||||
|
localStorage.setItem("THEME_COLOR", color)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setActiveColor(color) {
|
setActiveColor(color) {
|
||||||
document.documentElement.setAttribute("data-accent", color)
|
document.documentElement.setAttribute("data-accent", color)
|
||||||
this.active = color
|
this.active = color
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
active(color) {
|
|
||||||
localStorage.setItem("THEME_COLOR", color)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="show-if-initialized" :class="{ initialized }">
|
<div class="show-if-initialized" :class="{ initialized }">
|
||||||
<div class="outline" v-if="lang == 'json'">
|
<div v-if="lang == 'json'" class="outline">
|
||||||
<div class="block" v-for="(p, index) in currPath" :key="index">
|
<div v-for="(p, index) in currPath" :key="index" class="block">
|
||||||
<div class="label" @click="onBlockClick(index)">
|
<div class="label" @click="onBlockClick(index)">
|
||||||
{{ p }}
|
{{ p }}
|
||||||
</div>
|
</div>
|
||||||
<i v-if="index + 1 !== currPath.length" class="material-icons">chevron_right</i>
|
<i v-if="index + 1 !== currPath.length" class="material-icons"
|
||||||
<div
|
>chevron_right</i
|
||||||
class="siblings"
|
|
||||||
v-if="sibDropDownIndex == index"
|
|
||||||
@mouseleave="clearSibList"
|
|
||||||
:ref="`sibling-${index}`"
|
|
||||||
>
|
>
|
||||||
<div class="sib" v-for="(sib, i) in currSib" :key="i" @click="goToSib(sib)">
|
<div
|
||||||
|
v-if="sibDropDownIndex == index"
|
||||||
|
:ref="`sibling-${index}`"
|
||||||
|
class="siblings"
|
||||||
|
@mouseleave="clearSibList"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(sib, i) in currSib"
|
||||||
|
:key="i"
|
||||||
|
class="sib"
|
||||||
|
@click="goToSib(sib)"
|
||||||
|
>
|
||||||
{{ sib.key ? sib.key.value : i }}
|
{{ sib.key ? sib.key.value : i }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,6 +29,220 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ace from "ace-builds"
|
||||||
|
import "ace-builds/webpack-resolver"
|
||||||
|
import jsonParse from "~/helpers/jsonParse"
|
||||||
|
import debounce from "~/helpers/utils/debounce"
|
||||||
|
import outline from "~/helpers/outline"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
provideJSONOutline: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
lang: {
|
||||||
|
type: String,
|
||||||
|
default: "json",
|
||||||
|
},
|
||||||
|
lint: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
styles: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
initialized: false,
|
||||||
|
editor: null,
|
||||||
|
cacheValue: "",
|
||||||
|
outline: outline(),
|
||||||
|
currPath: [],
|
||||||
|
currSib: [],
|
||||||
|
sibDropDownIndex: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
value(value) {
|
||||||
|
if (value !== this.cacheValue) {
|
||||||
|
this.editor.session.setValue(value, 1)
|
||||||
|
this.cacheValue = value
|
||||||
|
if (this.lint) this.provideLinting(value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
theme() {
|
||||||
|
this.initialized = false
|
||||||
|
this.editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
lang(value) {
|
||||||
|
this.editor.getSession().setMode(`ace/mode/${value}`)
|
||||||
|
},
|
||||||
|
options(value) {
|
||||||
|
this.editor.setOptions(value)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
const editor = ace.edit(this.$refs.editor, {
|
||||||
|
mode: `ace/mode/${this.lang}`,
|
||||||
|
...this.options,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Set the theme and show the editor only after it's been set to prevent FOUC.
|
||||||
|
editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
||||||
|
this.$nextTick().then(() => {
|
||||||
|
this.initialized = true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.value) editor.setValue(this.value, 1)
|
||||||
|
|
||||||
|
this.editor = editor
|
||||||
|
this.cacheValue = this.value
|
||||||
|
|
||||||
|
if (this.lang === "json" && this.provideJSONOutline)
|
||||||
|
this.initOutline(this.value)
|
||||||
|
|
||||||
|
editor.on("change", () => {
|
||||||
|
const content = editor.getValue()
|
||||||
|
this.$emit("input", content)
|
||||||
|
this.cacheValue = content
|
||||||
|
|
||||||
|
if (this.provideJSONOutline) debounce(this.initOutline(content), 500)
|
||||||
|
|
||||||
|
if (this.lint) this.provideLinting(content)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.lang === "json" && this.provideJSONOutline) {
|
||||||
|
editor.session.selection.on("changeCursor", () => {
|
||||||
|
const index = editor.session.doc.positionToIndex(
|
||||||
|
editor.selection.getCursor(),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
const path = this.outline.genPath(index)
|
||||||
|
if (path.success) {
|
||||||
|
this.currPath = path.res
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.addEventListener("touchstart", this.onTouchStart)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable linting, if lint prop is false
|
||||||
|
if (this.lint) this.provideLinting(this.value)
|
||||||
|
},
|
||||||
|
|
||||||
|
destroyed() {
|
||||||
|
this.editor.destroy()
|
||||||
|
document.removeEventListener("touchstart", this.onTouchStart)
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
defineTheme() {
|
||||||
|
if (this.theme) {
|
||||||
|
return this.theme
|
||||||
|
}
|
||||||
|
const strip = (str) =>
|
||||||
|
str.replace(/#/g, "").replace(/ /g, "").replace(/"/g, "")
|
||||||
|
return strip(
|
||||||
|
window
|
||||||
|
.getComputedStyle(document.documentElement)
|
||||||
|
.getPropertyValue("--editor-theme")
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
provideLinting: debounce(function (code) {
|
||||||
|
if (this.lang === "json") {
|
||||||
|
try {
|
||||||
|
jsonParse(code)
|
||||||
|
this.editor.session.setAnnotations([])
|
||||||
|
} catch (e) {
|
||||||
|
const pos = this.editor.session
|
||||||
|
.getDocument()
|
||||||
|
.indexToPosition(e.start, 0)
|
||||||
|
this.editor.session.setAnnotations([
|
||||||
|
{
|
||||||
|
row: pos.row,
|
||||||
|
column: pos.column,
|
||||||
|
text: e.message,
|
||||||
|
type: "error",
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2000),
|
||||||
|
onBlockClick(index) {
|
||||||
|
if (this.sibDropDownIndex === index) {
|
||||||
|
this.clearSibList()
|
||||||
|
} else {
|
||||||
|
this.currSib = this.outline.getSiblings(index)
|
||||||
|
if (this.currSib.length) this.sibDropDownIndex = index
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clearSibList() {
|
||||||
|
this.currSib = []
|
||||||
|
this.sibDropDownIndex = null
|
||||||
|
},
|
||||||
|
goToSib(obj) {
|
||||||
|
this.clearSibList()
|
||||||
|
if (obj.start) {
|
||||||
|
const pos = this.editor.session.doc.indexToPosition(obj.start, 0)
|
||||||
|
if (pos) {
|
||||||
|
this.editor.session.selection.moveCursorTo(pos.row, pos.column, true)
|
||||||
|
this.editor.session.selection.clearSelection()
|
||||||
|
this.editor.scrollToLine(pos.row, false, true, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initOutline: debounce(function (content) {
|
||||||
|
if (this.lang === "json") {
|
||||||
|
try {
|
||||||
|
this.outline.init(content)
|
||||||
|
|
||||||
|
if (content[0] === "[") this.currPath.push("[]")
|
||||||
|
else this.currPath.push("{}")
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Outline error: ", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
onTouchStart(e) {
|
||||||
|
if (
|
||||||
|
this.sibDropDownIndex !== null &&
|
||||||
|
e.target.parentElement !==
|
||||||
|
this.$refs[`sibling-${this.sibDropDownIndex}`][0]
|
||||||
|
) {
|
||||||
|
this.clearSibList()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.show-if-initialized {
|
.show-if-initialized {
|
||||||
@apply opacity-0;
|
@apply opacity-0;
|
||||||
@@ -90,206 +311,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
import ace from "ace-builds"
|
|
||||||
import "ace-builds/webpack-resolver"
|
|
||||||
import jsonParse from "~/helpers/jsonParse"
|
|
||||||
import debounce from "~/helpers/utils/debounce"
|
|
||||||
import outline from "~/helpers/outline"
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
provideJSONOutline: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
theme: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
lang: {
|
|
||||||
type: String,
|
|
||||||
default: "json",
|
|
||||||
},
|
|
||||||
lint: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
type: Object,
|
|
||||||
default: {},
|
|
||||||
},
|
|
||||||
styles: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
initialized: false,
|
|
||||||
editor: null,
|
|
||||||
cacheValue: "",
|
|
||||||
outline: outline(),
|
|
||||||
currPath: [],
|
|
||||||
currSib: [],
|
|
||||||
sibDropDownIndex: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
value(value) {
|
|
||||||
if (value !== this.cacheValue) {
|
|
||||||
this.editor.session.setValue(value, 1)
|
|
||||||
this.cacheValue = value
|
|
||||||
if (this.lint) this.provideLinting(value)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
theme() {
|
|
||||||
this.initialized = false
|
|
||||||
this.editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
|
||||||
this.$nextTick().then(() => {
|
|
||||||
this.initialized = true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
lang(value) {
|
|
||||||
this.editor.getSession().setMode(`ace/mode/${value}`)
|
|
||||||
},
|
|
||||||
options(value) {
|
|
||||||
this.editor.setOptions(value)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
const editor = ace.edit(this.$refs.editor, {
|
|
||||||
mode: `ace/mode/${this.lang}`,
|
|
||||||
...this.options,
|
|
||||||
})
|
|
||||||
|
|
||||||
// Set the theme and show the editor only after it's been set to prevent FOUC.
|
|
||||||
editor.setTheme(`ace/theme/${this.defineTheme()}`, () => {
|
|
||||||
this.$nextTick().then(() => {
|
|
||||||
this.initialized = true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.value) editor.setValue(this.value, 1)
|
|
||||||
|
|
||||||
this.editor = editor
|
|
||||||
this.cacheValue = this.value
|
|
||||||
|
|
||||||
if (this.lang === "json" && this.provideJSONOutline) this.initOutline(this.value)
|
|
||||||
|
|
||||||
editor.on("change", () => {
|
|
||||||
const content = editor.getValue()
|
|
||||||
this.$emit("input", content)
|
|
||||||
this.cacheValue = content
|
|
||||||
|
|
||||||
if (this.provideJSONOutline) debounce(this.initOutline(content), 500)
|
|
||||||
|
|
||||||
if (this.lint) this.provideLinting(content)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.lang === "json" && this.provideJSONOutline) {
|
|
||||||
editor.session.selection.on("changeCursor", (e) => {
|
|
||||||
const index = editor.session.doc.positionToIndex(editor.selection.getCursor(), 0)
|
|
||||||
const path = this.outline.genPath(index)
|
|
||||||
if (path.success) {
|
|
||||||
this.currPath = path.res
|
|
||||||
}
|
|
||||||
})
|
|
||||||
document.addEventListener("touchstart", this.onTouchStart)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable linting, if lint prop is false
|
|
||||||
if (this.lint) this.provideLinting(this.value)
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
defineTheme() {
|
|
||||||
if (this.theme) {
|
|
||||||
return this.theme
|
|
||||||
}
|
|
||||||
const strip = (str) => str.replace(/#/g, "").replace(/ /g, "").replace(/"/g, "")
|
|
||||||
return strip(
|
|
||||||
window.getComputedStyle(document.documentElement).getPropertyValue("--editor-theme")
|
|
||||||
)
|
|
||||||
},
|
|
||||||
|
|
||||||
provideLinting: debounce(function (code) {
|
|
||||||
if (this.lang === "json") {
|
|
||||||
try {
|
|
||||||
jsonParse(code)
|
|
||||||
this.editor.session.setAnnotations([])
|
|
||||||
} catch (e) {
|
|
||||||
const pos = this.editor.session.getDocument().indexToPosition(e.start, 0)
|
|
||||||
this.editor.session.setAnnotations([
|
|
||||||
{
|
|
||||||
row: pos.row,
|
|
||||||
column: pos.column,
|
|
||||||
text: e.message,
|
|
||||||
type: "error",
|
|
||||||
},
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 2000),
|
|
||||||
onBlockClick(index) {
|
|
||||||
if (this.sibDropDownIndex == index) {
|
|
||||||
this.clearSibList()
|
|
||||||
} else {
|
|
||||||
this.currSib = this.outline.getSiblings(index)
|
|
||||||
if (this.currSib.length) this.sibDropDownIndex = index
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clearSibList() {
|
|
||||||
this.currSib = []
|
|
||||||
this.sibDropDownIndex = null
|
|
||||||
},
|
|
||||||
goToSib(obj) {
|
|
||||||
this.clearSibList()
|
|
||||||
if (obj.start) {
|
|
||||||
let pos = this.editor.session.doc.indexToPosition(obj.start, 0)
|
|
||||||
if (pos) {
|
|
||||||
this.editor.session.selection.moveCursorTo(pos.row, pos.column, true)
|
|
||||||
this.editor.session.selection.clearSelection()
|
|
||||||
this.editor.scrollToLine(pos.row, false, true, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
initOutline: debounce(function (content) {
|
|
||||||
if (this.lang == "json") {
|
|
||||||
try {
|
|
||||||
this.outline.init(content)
|
|
||||||
|
|
||||||
if (content[0] == "[") this.currPath.push("[]")
|
|
||||||
else this.currPath.push("{}")
|
|
||||||
} catch (e) {
|
|
||||||
console.log("Outline error: ", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
onTouchStart(e) {
|
|
||||||
if (this.sibDropDownIndex == null) return
|
|
||||||
else {
|
|
||||||
if (e.target.parentElement != this.$refs[`sibling-${this.sibDropDownIndex}`][0]) {
|
|
||||||
this.clearSibList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
destroyed() {
|
|
||||||
this.editor.destroy()
|
|
||||||
document.removeEventListener("touchstart", this.onTouchStart)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="autocomplete-wrapper">
|
<div class="autocomplete-wrapper">
|
||||||
<input
|
<input
|
||||||
|
ref="acInput"
|
||||||
|
v-model="text"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
v-model="text"
|
|
||||||
@input="updateSuggestions"
|
|
||||||
@keyup="updateSuggestions"
|
|
||||||
@click="updateSuggestions"
|
|
||||||
@keydown="handleKeystroke"
|
|
||||||
ref="acInput"
|
|
||||||
:spellcheck="spellcheck"
|
:spellcheck="spellcheck"
|
||||||
:autocapitalize="autocapitalize"
|
:autocapitalize="autocapitalize"
|
||||||
:autocorrect="spellcheck"
|
:autocorrect="spellcheck"
|
||||||
:class="styles"
|
:class="styles"
|
||||||
|
@input="updateSuggestions"
|
||||||
|
@keyup="updateSuggestions"
|
||||||
|
@click="updateSuggestions"
|
||||||
|
@keydown="handleKeystroke"
|
||||||
/>
|
/>
|
||||||
<ul
|
<ul
|
||||||
class="suggestions"
|
|
||||||
v-if="suggestions.length > 0 && suggestionsVisible"
|
v-if="suggestions.length > 0 && suggestionsVisible"
|
||||||
|
class="suggestions"
|
||||||
:style="{ transform: `translate(${suggestionsOffsetLeft}px, 0)` }"
|
:style="{ transform: `translate(${suggestionsOffsetLeft}px, 0)` }"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
v-for="(suggestion, index) in suggestions"
|
v-for="(suggestion, index) in suggestions"
|
||||||
@click.prevent="forceSuggestion(suggestion)"
|
|
||||||
:class="{ active: currentSuggestionIndex === index }"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
|
:class="{ active: currentSuggestionIndex === index }"
|
||||||
|
@click.prevent="forceSuggestion(suggestion)"
|
||||||
>
|
>
|
||||||
{{ suggestion }}
|
{{ suggestion }}
|
||||||
</li>
|
</li>
|
||||||
@@ -31,6 +31,155 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
spellcheck: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
autocapitalize: {
|
||||||
|
type: String,
|
||||||
|
default: "off",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
source: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
styles: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
text: this.value,
|
||||||
|
selectionStart: 0,
|
||||||
|
suggestionsOffsetLeft: 0,
|
||||||
|
currentSuggestionIndex: -1,
|
||||||
|
suggestionsVisible: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
/**
|
||||||
|
* Gets the suggestions list to be displayed under the input box.
|
||||||
|
*
|
||||||
|
* @returns {default.props.source|{type, required}}
|
||||||
|
*/
|
||||||
|
suggestions() {
|
||||||
|
const input = this.text.substring(0, this.selectionStart)
|
||||||
|
|
||||||
|
return (
|
||||||
|
this.source
|
||||||
|
.filter(
|
||||||
|
(entry) =>
|
||||||
|
entry.toLowerCase().startsWith(input.toLowerCase()) &&
|
||||||
|
input.toLowerCase() !== entry.toLowerCase()
|
||||||
|
)
|
||||||
|
// Cut off the part that's already been typed.
|
||||||
|
.map((entry) => entry.substring(this.selectionStart))
|
||||||
|
// We only want the top 6 suggestions.
|
||||||
|
.slice(0, 6)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
text() {
|
||||||
|
this.$emit("input", this.text)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.updateSuggestions({
|
||||||
|
target: this.$refs.acInput,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
updateSuggestions(event) {
|
||||||
|
// Hide suggestions if ESC pressed.
|
||||||
|
if (event.code && event.code === "Escape") {
|
||||||
|
event.preventDefault()
|
||||||
|
this.suggestionsVisible = false
|
||||||
|
this.currentSuggestionIndex = -1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// As suggestions is a reactive property, this implicitly
|
||||||
|
// causes suggestions to update.
|
||||||
|
this.selectionStart = this.$refs.acInput.selectionStart
|
||||||
|
this.suggestionsOffsetLeft = 12 * this.selectionStart
|
||||||
|
this.suggestionsVisible = true
|
||||||
|
},
|
||||||
|
|
||||||
|
forceSuggestion(text) {
|
||||||
|
const input = this.text.substring(0, this.selectionStart)
|
||||||
|
this.text = input + text
|
||||||
|
|
||||||
|
this.selectionStart = this.text.length
|
||||||
|
this.suggestionsVisible = true
|
||||||
|
this.currentSuggestionIndex = -1
|
||||||
|
},
|
||||||
|
|
||||||
|
handleKeystroke(event) {
|
||||||
|
switch (event.code) {
|
||||||
|
case "ArrowUp":
|
||||||
|
event.preventDefault()
|
||||||
|
this.currentSuggestionIndex =
|
||||||
|
this.currentSuggestionIndex - 1 >= 0
|
||||||
|
? this.currentSuggestionIndex - 1
|
||||||
|
: 0
|
||||||
|
break
|
||||||
|
|
||||||
|
case "ArrowDown":
|
||||||
|
event.preventDefault()
|
||||||
|
this.currentSuggestionIndex =
|
||||||
|
this.currentSuggestionIndex < this.suggestions.length - 1
|
||||||
|
? this.currentSuggestionIndex + 1
|
||||||
|
: this.suggestions.length - 1
|
||||||
|
break
|
||||||
|
|
||||||
|
case "Tab": {
|
||||||
|
const activeSuggestion =
|
||||||
|
this.suggestions[
|
||||||
|
this.currentSuggestionIndex >= 0 ? this.currentSuggestionIndex : 0
|
||||||
|
]
|
||||||
|
|
||||||
|
if (!activeSuggestion) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault()
|
||||||
|
const input = this.text.substring(0, this.selectionStart)
|
||||||
|
this.text = input + activeSuggestion
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.autocomplete-wrapper {
|
.autocomplete-wrapper {
|
||||||
@apply relative;
|
@apply relative;
|
||||||
@@ -78,147 +227,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
spellcheck: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
autocapitalize: {
|
|
||||||
type: String,
|
|
||||||
default: "off",
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
source: {
|
|
||||||
type: Array,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
styles: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
text() {
|
|
||||||
this.$emit("input", this.text)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
text: this.value,
|
|
||||||
selectionStart: 0,
|
|
||||||
suggestionsOffsetLeft: 0,
|
|
||||||
currentSuggestionIndex: -1,
|
|
||||||
suggestionsVisible: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
updateSuggestions(event) {
|
|
||||||
// Hide suggestions if ESC pressed.
|
|
||||||
if (event.code && event.code === "Escape") {
|
|
||||||
event.preventDefault()
|
|
||||||
this.suggestionsVisible = false
|
|
||||||
this.currentSuggestionIndex = -1
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// As suggestions is a reactive property, this implicitly
|
|
||||||
// causes suggestions to update.
|
|
||||||
this.selectionStart = this.$refs.acInput.selectionStart
|
|
||||||
this.suggestionsOffsetLeft = 12 * this.selectionStart
|
|
||||||
this.suggestionsVisible = true
|
|
||||||
},
|
|
||||||
|
|
||||||
forceSuggestion(text) {
|
|
||||||
let input = this.text.substring(0, this.selectionStart)
|
|
||||||
this.text = input + text
|
|
||||||
|
|
||||||
this.selectionStart = this.text.length
|
|
||||||
this.suggestionsVisible = true
|
|
||||||
this.currentSuggestionIndex = -1
|
|
||||||
},
|
|
||||||
|
|
||||||
handleKeystroke(event) {
|
|
||||||
switch (event.code) {
|
|
||||||
case "ArrowUp":
|
|
||||||
event.preventDefault()
|
|
||||||
this.currentSuggestionIndex =
|
|
||||||
this.currentSuggestionIndex - 1 >= 0 ? this.currentSuggestionIndex - 1 : 0
|
|
||||||
break
|
|
||||||
|
|
||||||
case "ArrowDown":
|
|
||||||
event.preventDefault()
|
|
||||||
this.currentSuggestionIndex =
|
|
||||||
this.currentSuggestionIndex < this.suggestions.length - 1
|
|
||||||
? this.currentSuggestionIndex + 1
|
|
||||||
: this.suggestions.length - 1
|
|
||||||
break
|
|
||||||
|
|
||||||
case "Tab":
|
|
||||||
let activeSuggestion =
|
|
||||||
this.suggestions[this.currentSuggestionIndex >= 0 ? this.currentSuggestionIndex : 0]
|
|
||||||
|
|
||||||
if (!activeSuggestion) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
event.preventDefault()
|
|
||||||
let input = this.text.substring(0, this.selectionStart)
|
|
||||||
this.text = input + activeSuggestion
|
|
||||||
break
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
/**
|
|
||||||
* Gets the suggestions list to be displayed under the input box.
|
|
||||||
*
|
|
||||||
* @returns {default.props.source|{type, required}}
|
|
||||||
*/
|
|
||||||
suggestions() {
|
|
||||||
let input = this.text.substring(0, this.selectionStart)
|
|
||||||
|
|
||||||
return (
|
|
||||||
this.source
|
|
||||||
.filter(
|
|
||||||
(entry) =>
|
|
||||||
entry.toLowerCase().startsWith(input.toLowerCase()) &&
|
|
||||||
input.toLowerCase() !== entry.toLowerCase()
|
|
||||||
)
|
|
||||||
// Cut off the part that's already been typed.
|
|
||||||
.map((entry) => entry.substring(this.selectionStart))
|
|
||||||
// We only want the top 6 suggestions.
|
|
||||||
.slice(0, 6)
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
this.updateSuggestions({
|
|
||||||
target: this.$refs.acInput,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
<label>
|
<label>
|
||||||
<ColorScheme placeholder="..." tag="span">
|
<ColorScheme placeholder="..." tag="span">
|
||||||
{{ $t("background") }}:
|
{{ $t("background") }}:
|
||||||
{{ $colorMode.preference.charAt(0).toUpperCase() + $colorMode.preference.slice(1) }}
|
{{
|
||||||
|
$colorMode.preference.charAt(0).toUpperCase() +
|
||||||
|
$colorMode.preference.slice(1)
|
||||||
|
}}
|
||||||
<span v-if="$colorMode.preference === 'system'">
|
<span v-if="$colorMode.preference === 'system'">
|
||||||
({{ $colorMode.value }} mode detected)
|
({{ $colorMode.value }} mode detected)
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -33,21 +33,21 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
title: "",
|
title: { type: String, default: "" },
|
||||||
yes: {
|
yes: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default() {
|
||||||
return this.$t("yes")
|
return this.$t("yes")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
no: {
|
no: {
|
||||||
type: String,
|
type: String,
|
||||||
default: function () {
|
default() {
|
||||||
return this.$t("no")
|
return this.$t("no")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async mounted() {
|
mounted() {
|
||||||
this._keyListener = function (e) {
|
this._keyListener = function (e) {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -56,6 +56,9 @@ export default {
|
|||||||
}
|
}
|
||||||
document.addEventListener("keydown", this._keyListener.bind(this))
|
document.addEventListener("keydown", this._keyListener.bind(this))
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
document.removeEventListener("keydown", this._keyListener)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hideModal() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
@@ -64,8 +67,5 @@ export default {
|
|||||||
this.$emit("resolve")
|
this.$emit("resolve")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
|
||||||
document.removeEventListener("keydown", this._keyListener)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="container">
|
<div ref="container">
|
||||||
<slot />
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
@@ -4,25 +4,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.show-if-initialized {
|
|
||||||
@apply opacity-0;
|
|
||||||
|
|
||||||
&.initialized {
|
|
||||||
@apply opacity-100;
|
|
||||||
}
|
|
||||||
|
|
||||||
& > * {
|
|
||||||
@apply transition-none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ace from "ace-builds"
|
import ace from "ace-builds"
|
||||||
import "ace-builds/webpack-resolver"
|
import "ace-builds/webpack-resolver"
|
||||||
import "ace-builds/src-noconflict/ext-language_tools"
|
import "ace-builds/src-noconflict/ext-language_tools"
|
||||||
import "ace-builds/src-noconflict/mode-graphqlschema"
|
import "ace-builds/src-noconflict/mode-graphqlschema"
|
||||||
|
import * as esprima from "esprima"
|
||||||
import debounce from "~/helpers/utils/debounce"
|
import debounce from "~/helpers/utils/debounce"
|
||||||
import {
|
import {
|
||||||
getPreRequestScriptCompletions,
|
getPreRequestScriptCompletions,
|
||||||
@@ -30,8 +17,6 @@ import {
|
|||||||
performPreRequestLinting,
|
performPreRequestLinting,
|
||||||
} from "~/helpers/tern"
|
} from "~/helpers/tern"
|
||||||
|
|
||||||
import * as esprima from "esprima"
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
@@ -45,7 +30,7 @@ export default {
|
|||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
styles: {
|
styles: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -115,7 +100,13 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const completer = {
|
const completer = {
|
||||||
getCompletions: (editor, _session, { row, column }, _prefix, callback) => {
|
getCompletions: (
|
||||||
|
editor,
|
||||||
|
_session,
|
||||||
|
{ row, column },
|
||||||
|
_prefix,
|
||||||
|
callback
|
||||||
|
) => {
|
||||||
if (this.completeMode === "pre") {
|
if (this.completeMode === "pre") {
|
||||||
getPreRequestScriptCompletions(editor.getValue(), row, column)
|
getPreRequestScriptCompletions(editor.getValue(), row, column)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -165,14 +156,21 @@ export default {
|
|||||||
this.provideLinting(this.value)
|
this.provideLinting(this.value)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroyed() {
|
||||||
|
this.editor.destroy()
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
defineTheme() {
|
defineTheme() {
|
||||||
if (this.theme) {
|
if (this.theme) {
|
||||||
return this.theme
|
return this.theme
|
||||||
}
|
}
|
||||||
const strip = (str) => str.replace(/#/g, "").replace(/ /g, "").replace(/"/g, "")
|
const strip = (str) =>
|
||||||
|
str.replace(/#/g, "").replace(/ /g, "").replace(/"/g, "")
|
||||||
return strip(
|
return strip(
|
||||||
window.getComputedStyle(document.documentElement).getPropertyValue("--editor-theme")
|
window
|
||||||
|
.getComputedStyle(document.documentElement)
|
||||||
|
.getPropertyValue("--editor-theme")
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -195,7 +193,9 @@ export default {
|
|||||||
if (res.errors && res.errors.length > 0) {
|
if (res.errors && res.errors.length > 0) {
|
||||||
results = results.concat(
|
results = results.concat(
|
||||||
res.errors.map((err) => {
|
res.errors.map((err) => {
|
||||||
const pos = this.editor.session.getDocument().indexToPosition(err.index, 0)
|
const pos = this.editor.session
|
||||||
|
.getDocument()
|
||||||
|
.indexToPosition(err.index, 0)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
row: pos.row,
|
row: pos.row,
|
||||||
@@ -207,7 +207,9 @@ export default {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const pos = this.editor.session.getDocument().indexToPosition(e.index, 0)
|
const pos = this.editor.session
|
||||||
|
.getDocument()
|
||||||
|
.indexToPosition(e.index, 0)
|
||||||
results = results.concat([
|
results = results.concat([
|
||||||
{
|
{
|
||||||
row: pos.row,
|
row: pos.row,
|
||||||
@@ -226,7 +228,9 @@ export default {
|
|||||||
if (res.errors && res.errors.length > 0) {
|
if (res.errors && res.errors.length > 0) {
|
||||||
results = results.concat(
|
results = results.concat(
|
||||||
res.errors.map((err) => {
|
res.errors.map((err) => {
|
||||||
const pos = this.editor.session.getDocument().indexToPosition(err.index, 0)
|
const pos = this.editor.session
|
||||||
|
.getDocument()
|
||||||
|
.indexToPosition(err.index, 0)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
row: pos.row,
|
row: pos.row,
|
||||||
@@ -238,7 +242,9 @@ export default {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const pos = this.editor.session.getDocument().indexToPosition(e.index, 0)
|
const pos = this.editor.session
|
||||||
|
.getDocument()
|
||||||
|
.indexToPosition(e.index, 0)
|
||||||
results = results.concat([
|
results = results.concat([
|
||||||
{
|
{
|
||||||
row: pos.row,
|
row: pos.row,
|
||||||
@@ -253,9 +259,19 @@ export default {
|
|||||||
})
|
})
|
||||||
}, 2000),
|
}, 2000),
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyed() {
|
|
||||||
this.editor.destroy()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.show-if-initialized {
|
||||||
|
@apply opacity-0;
|
||||||
|
|
||||||
|
&.initialized {
|
||||||
|
@apply opacity-100;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > * {
|
||||||
|
@apply transition-none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -20,6 +20,16 @@
|
|||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
computed: {
|
||||||
|
hasFooterSlot() {
|
||||||
|
return !!this.$slots.footer
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.modal-backdrop {
|
.modal-backdrop {
|
||||||
@apply fixed;
|
@apply fixed;
|
||||||
@@ -118,13 +128,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
computed: {
|
|
||||||
hasFooterSlot() {
|
|
||||||
return !!this.$slots.footer
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
label: { type: String, default: "" },
|
label: { type: String, default: "" },
|
||||||
icon: { type: String, default: "" },
|
icon: { type: String, default: "" },
|
||||||
id: { required: true },
|
id: { type: String, default: "", required: true },
|
||||||
selected: {
|
selected: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="(tab, index) in tabs"
|
v-for="(tab, index) in tabs"
|
||||||
:class="{ 'is-active': tab.isActive }"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
|
:class="{ 'is-active': tab.isActive }"
|
||||||
:tabindex="0"
|
:tabindex="0"
|
||||||
@keyup.enter="selectTab(tab)"
|
@keyup.enter="selectTab(tab)"
|
||||||
>
|
>
|
||||||
@@ -24,6 +24,36 @@
|
|||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
styles: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tabs: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.tabs = this.$children
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
selectTab({ id }) {
|
||||||
|
this.tabs.forEach((tab) => {
|
||||||
|
tab.isActive = tab.id === id
|
||||||
|
})
|
||||||
|
this.$emit("tab-changed", id)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.tabs-wrapper {
|
.tabs-wrapper {
|
||||||
@apply flex;
|
@apply flex;
|
||||||
@@ -90,35 +120,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
import Section from "../app/Section.vue"
|
|
||||||
export default {
|
|
||||||
components: { Section },
|
|
||||||
props: {
|
|
||||||
styles: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
tabs: [],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.tabs = this.$children
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
selectTab({ id }) {
|
|
||||||
this.tabs.forEach((tab) => {
|
|
||||||
tab.isActive = tab.id == id
|
|
||||||
})
|
|
||||||
this.$emit("tab-changed", id)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -1,14 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div @click="toggle()" class="inline-block cursor-pointer">
|
<div class="inline-block cursor-pointer" @click="toggle()">
|
||||||
<label class="toggle" :class="{ on: on }" ref="toggle">
|
<label ref="toggle" class="toggle" :class="{ on: on }">
|
||||||
<span class="handle"></span>
|
<span class="handle"></span>
|
||||||
</label>
|
</label>
|
||||||
<label class="pl-0 align-middle cursor-pointer">
|
<label class="pl-0 align-middle cursor-pointer">
|
||||||
<slot />
|
<slot></slot>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
on: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
toggle() {
|
||||||
|
const containsOnClass = this.$refs.toggle.classList.toggle("on")
|
||||||
|
this.$emit("change", containsOnClass)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
$useBorder: false;
|
$useBorder: false;
|
||||||
$borderColor: var(--fg-light-color);
|
$borderColor: var(--fg-light-color);
|
||||||
@@ -63,21 +81,3 @@ $transition: all 0.2s ease-in-out;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
on: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
toggle() {
|
|
||||||
const containsOnClass = this.$refs.toggle.classList.toggle("on")
|
|
||||||
this.$emit("change", containsOnClass)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
@@ -1,31 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div contenteditable class="url-field" ref="editor" spellcheck="false"></div>
|
<div ref="editor" contenteditable class="url-field" spellcheck="false"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.url-field {
|
|
||||||
@apply border-dashed;
|
|
||||||
@apply md:border-l;
|
|
||||||
@apply border-brdColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-VAR {
|
|
||||||
@apply font-bold;
|
|
||||||
@apply text-acColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-TEXT {
|
|
||||||
@apply overflow-auto;
|
|
||||||
@apply break-all;
|
|
||||||
|
|
||||||
height: 22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight-TEXT::-webkit-scrollbar {
|
|
||||||
@apply hidden;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -80,7 +56,11 @@ export default {
|
|||||||
let index = 0
|
let index = 0
|
||||||
while ((match = text.substring(index).match(regex))) {
|
while ((match = text.substring(index).match(regex))) {
|
||||||
map.push([index, index + (match.index - 1), "TEXT"])
|
map.push([index, index + (match.index - 1), "TEXT"])
|
||||||
map.push([index + match.index, index + match.index + match[0].length - 1, "VAR"])
|
map.push([
|
||||||
|
index + match.index,
|
||||||
|
index + match.index + match[0].length - 1,
|
||||||
|
"VAR",
|
||||||
|
])
|
||||||
index += match.index + match[0].length
|
index += match.index + match[0].length
|
||||||
|
|
||||||
if (index >= text.length - 1) break
|
if (index >= text.length - 1) break
|
||||||
@@ -101,7 +81,11 @@ export default {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case Node.ELEMENT_NODE:
|
case Node.ELEMENT_NODE:
|
||||||
textSegments.splice(textSegments.length, 0, ...this.getTextSegments(node))
|
textSegments.splice(
|
||||||
|
textSegments.length,
|
||||||
|
0,
|
||||||
|
...this.getTextSegments(node)
|
||||||
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -118,11 +102,17 @@ export default {
|
|||||||
textSegments.forEach(({ text, node }) => {
|
textSegments.forEach(({ text, node }) => {
|
||||||
const startIndexOfNode = currentIndex
|
const startIndexOfNode = currentIndex
|
||||||
const endIndexOfNode = startIndexOfNode + text.length
|
const endIndexOfNode = startIndexOfNode + text.length
|
||||||
if (startIndexOfNode <= absoluteAnchorIndex && absoluteAnchorIndex <= endIndexOfNode) {
|
if (
|
||||||
|
startIndexOfNode <= absoluteAnchorIndex &&
|
||||||
|
absoluteAnchorIndex <= endIndexOfNode
|
||||||
|
) {
|
||||||
anchorNode = node
|
anchorNode = node
|
||||||
anchorIndex = absoluteAnchorIndex - startIndexOfNode
|
anchorIndex = absoluteAnchorIndex - startIndexOfNode
|
||||||
}
|
}
|
||||||
if (startIndexOfNode <= absoluteFocusIndex && absoluteFocusIndex <= endIndexOfNode) {
|
if (
|
||||||
|
startIndexOfNode <= absoluteFocusIndex &&
|
||||||
|
absoluteFocusIndex <= endIndexOfNode
|
||||||
|
) {
|
||||||
focusNode = node
|
focusNode = node
|
||||||
focusIndex = absoluteFocusIndex - startIndexOfNode
|
focusIndex = absoluteFocusIndex - startIndexOfNode
|
||||||
}
|
}
|
||||||
@@ -161,3 +151,27 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.url-field {
|
||||||
|
@apply border-dashed;
|
||||||
|
@apply md:border-l;
|
||||||
|
@apply border-brdColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-VAR {
|
||||||
|
@apply font-bold;
|
||||||
|
@apply text-acColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-TEXT {
|
||||||
|
@apply overflow-auto;
|
||||||
|
@apply break-all;
|
||||||
|
|
||||||
|
height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight-TEXT::-webkit-scrollbar {
|
||||||
|
@apply hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import autocomplete from "../AutoComplete"
|
|
||||||
import { mount } from "@vue/test-utils"
|
import { mount } from "@vue/test-utils"
|
||||||
|
import autocomplete from "../AutoComplete"
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
@@ -9,7 +9,9 @@ const props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ["pp", "pple", "ppliance", "lice"]
|
// ["pp", "pple", "ppliance", "lice"]
|
||||||
const suggestionStr = props.source.filter((str) => str.startsWith("a")).map((str) => str.slice(1))
|
const suggestionStr = props.source
|
||||||
|
.filter((str) => str.startsWith("a"))
|
||||||
|
.map((str) => str.slice(1))
|
||||||
|
|
||||||
const factory = (props) =>
|
const factory = (props) =>
|
||||||
mount(autocomplete, {
|
mount(autocomplete, {
|
||||||
@@ -118,7 +120,9 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(0).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(0).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing down arrow when nothing is selected selects the first in the list", async () => {
|
test("pressing down arrow when nothing is selected selects the first in the list", async () => {
|
||||||
@@ -134,7 +138,9 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(0).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(0).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing down arrow moves down the selection list", async () => {
|
test("pressing down arrow moves down the selection list", async () => {
|
||||||
@@ -154,7 +160,9 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(1).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(1).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing up arrow moves up the selection list", async () => {
|
test("pressing up arrow moves up the selection list", async () => {
|
||||||
@@ -179,7 +187,9 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(0).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(0).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing down arrow at the end of the list doesn't update the selection", async () => {
|
test("pressing down arrow at the end of the list doesn't update the selection", async () => {
|
||||||
@@ -199,14 +209,18 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(1).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(1).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
|
|
||||||
await input.trigger("keydown", {
|
await input.trigger("keydown", {
|
||||||
code: "ArrowDown",
|
code: "ArrowDown",
|
||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(1).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(1).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing up arrow at the top of the list doesn't update the selection", async () => {
|
test("pressing up arrow at the top of the list doesn't update the selection", async () => {
|
||||||
@@ -226,14 +240,18 @@ describe("autocomplete", () => {
|
|||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(0).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(0).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
|
|
||||||
await input.trigger("keydown", {
|
await input.trigger("keydown", {
|
||||||
code: "ArrowUp",
|
code: "ArrowUp",
|
||||||
})
|
})
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.findAll("li").at(0).element.classList.contains("active")).toEqual(true)
|
expect(
|
||||||
|
wrapper.findAll("li").at(0).element.classList.contains("active")
|
||||||
|
).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("pressing tab performs the current completion", async () => {
|
test("pressing tab performs the current completion", async () => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import tab from "../Tab"
|
|
||||||
import { mount } from "@vue/test-utils"
|
import { mount } from "@vue/test-utils"
|
||||||
|
import tab from "../Tab"
|
||||||
|
|
||||||
const factory = (props, data) => {
|
const factory = (props, data) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
import { mount } from "@vue/test-utils"
|
||||||
import tabs from "../Tabs"
|
import tabs from "../Tabs"
|
||||||
import tab from "../Tab"
|
import tab from "../Tab"
|
||||||
|
|
||||||
import { mount } from "@vue/test-utils"
|
|
||||||
|
|
||||||
const factory = () =>
|
const factory = () =>
|
||||||
mount(tabs, {
|
mount(tabs, {
|
||||||
slots: {
|
slots: {
|
||||||
@@ -13,7 +12,7 @@ const factory = () =>
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
stubs: {
|
stubs: {
|
||||||
"Tab": tab,
|
Tab: tab,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import pwToggle from "../Toggle"
|
|
||||||
import { mount } from "@vue/test-utils"
|
import { mount } from "@vue/test-utils"
|
||||||
|
import pwToggle from "../Toggle"
|
||||||
|
|
||||||
const factory = (props, slot) =>
|
const factory = (props, slot) =>
|
||||||
mount(pwToggle, {
|
mount(pwToggle, {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import urlField from "../UrlField"
|
|
||||||
import { mount } from "@vue/test-utils"
|
import { mount } from "@vue/test-utils"
|
||||||
|
import urlField from "../UrlField"
|
||||||
|
|
||||||
const factory = (props) =>
|
const factory = (props) =>
|
||||||
mount(urlField, {
|
mount(urlField, {
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<input
|
<input
|
||||||
type="text"
|
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
type="text"
|
||||||
:placeholder="$t('my_new_team')"
|
:placeholder="$t('my_new_team')"
|
||||||
@keyup.enter="addNewTeam"
|
@keyup.enter="addNewTeam"
|
||||||
/>
|
/>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -67,9 +67,9 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Call to the graphql mutation
|
// Call to the graphql mutation
|
||||||
team_utils
|
teamUtils
|
||||||
.createTeam(this.$apollo, name)
|
.createTeam(this.$apollo, name)
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.hideModal()
|
this.hideModal()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<input
|
<input
|
||||||
type="text"
|
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
type="text"
|
||||||
:placeholder="editingTeam.name"
|
:placeholder="editingTeam.name"
|
||||||
@keyup.enter="saveTeam"
|
@keyup.enter="saveTeam"
|
||||||
/>
|
/>
|
||||||
@@ -60,22 +60,38 @@
|
|||||||
<input
|
<input
|
||||||
:placeholder="$t('permissions')"
|
:placeholder="$t('permissions')"
|
||||||
:name="'value' + index"
|
:name="'value' + index"
|
||||||
:value="typeof member.role === 'string' ? member.role : JSON.stringify(member.role)"
|
:value="
|
||||||
|
typeof member.role === 'string'
|
||||||
|
? member.role
|
||||||
|
: JSON.stringify(member.role)
|
||||||
|
"
|
||||||
readonly
|
readonly
|
||||||
/>
|
/>
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="updateRole(index, 'OWNER')">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="updateRole(index, 'OWNER')"
|
||||||
|
>
|
||||||
OWNER
|
OWNER
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="updateRole(index, 'EDITOR')">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="updateRole(index, 'EDITOR')"
|
||||||
|
>
|
||||||
EDITOR
|
EDITOR
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="updateRole(index, 'VIEWER')">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="updateRole(index, 'VIEWER')"
|
||||||
|
>
|
||||||
VIEWER
|
VIEWER
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,10 +102,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
|
id="member"
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="removeExistingTeamMember(member.user.uid)"
|
@click="removeExistingTeamMember(member.user.uid)"
|
||||||
v-tooltip.bottom="$t('delete')"
|
|
||||||
id="member"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -110,9 +126,9 @@
|
|||||||
>
|
>
|
||||||
<li>
|
<li>
|
||||||
<input
|
<input
|
||||||
|
v-model="member.key"
|
||||||
:placeholder="$t('email')"
|
:placeholder="$t('email')"
|
||||||
:name="'param' + index"
|
:name="'param' + index"
|
||||||
v-model="member.key"
|
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
@@ -123,23 +139,37 @@
|
|||||||
:placeholder="$t('permissions')"
|
:placeholder="$t('permissions')"
|
||||||
:name="'value' + index"
|
:name="'value' + index"
|
||||||
:value="
|
:value="
|
||||||
typeof member.value === 'string' ? member.value : JSON.stringify(member.value)
|
typeof member.value === 'string'
|
||||||
|
? member.value
|
||||||
|
: JSON.stringify(member.value)
|
||||||
"
|
"
|
||||||
readonly
|
readonly
|
||||||
/>
|
/>
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="member.value = 'OWNER'">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="member.value = 'OWNER'"
|
||||||
|
>
|
||||||
OWNER
|
OWNER
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="member.value = 'EDITOR'">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="member.value = 'EDITOR'"
|
||||||
|
>
|
||||||
EDITOR
|
EDITOR
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="icon" v-close-popover @click="member.value = 'VIEWER'">
|
<button
|
||||||
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
|
@click="member.value = 'VIEWER'"
|
||||||
|
>
|
||||||
VIEWER
|
VIEWER
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -150,10 +180,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
|
id="member"
|
||||||
|
v-tooltip.bottom="$t('delete')"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="removeTeamMember(index)"
|
@click="removeTeamMember(index)"
|
||||||
v-tooltip.bottom="$t('delete')"
|
|
||||||
id="member"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
</button>
|
</button>
|
||||||
@@ -186,15 +216,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
|
||||||
import cloneDeep from "lodash/cloneDeep"
|
import cloneDeep from "lodash/cloneDeep"
|
||||||
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
import TeamMemberAdapter from "~/helpers/teams/TeamMemberAdapter"
|
import TeamMemberAdapter from "~/helpers/teams/TeamMemberAdapter"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
editingTeam: Object,
|
editingTeam: { type: Object, default: () => {} },
|
||||||
editingteamID: String,
|
editingteamID: { type: String, default: null },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -205,16 +235,6 @@ export default {
|
|||||||
membersAdapter: new TeamMemberAdapter(null),
|
membersAdapter: new TeamMemberAdapter(null),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.membersAdapter.members$.subscribe((list) => {
|
|
||||||
this.members = cloneDeep(list)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
editingteamID(teamID) {
|
|
||||||
this.membersAdapter.changeTeamID(teamID)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
editingTeamCopy() {
|
editingTeamCopy() {
|
||||||
return this.editingTeam
|
return this.editingTeam
|
||||||
@@ -228,18 +248,28 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
editingteamID(teamID) {
|
||||||
|
this.membersAdapter.changeTeamID(teamID)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.membersAdapter.members$.subscribe((list) => {
|
||||||
|
this.members = cloneDeep(list)
|
||||||
|
})
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateRole(id, role) {
|
updateRole(id, role) {
|
||||||
this.members[id].role = role
|
this.members[id].role = role
|
||||||
},
|
},
|
||||||
addTeamMember() {
|
addTeamMember() {
|
||||||
let value = { key: "", value: "" }
|
const value = { key: "", value: "" }
|
||||||
this.newMembers.push(value)
|
this.newMembers.push(value)
|
||||||
},
|
},
|
||||||
removeExistingTeamMember(userID) {
|
removeExistingTeamMember(userID) {
|
||||||
team_utils
|
teamUtils
|
||||||
.removeTeamMember(this.$apollo, userID, this.editingteamID)
|
.removeTeamMember(this.$apollo, userID, this.editingteamID)
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("user_removed"), {
|
this.$toast.success(this.$t("user_removed"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
@@ -258,13 +288,20 @@ export default {
|
|||||||
this.newMembers.splice(index, 1)
|
this.newMembers.splice(index, 1)
|
||||||
},
|
},
|
||||||
validateEmail(emailID) {
|
validateEmail(emailID) {
|
||||||
if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(emailID)) {
|
if (
|
||||||
|
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
|
||||||
|
emailID
|
||||||
|
)
|
||||||
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
saveTeam() {
|
saveTeam() {
|
||||||
if (this.$data.rename !== null && this.$data.rename.replace(/\s/g, "").length < 6) {
|
if (
|
||||||
|
this.$data.rename !== null &&
|
||||||
|
this.$data.rename.replace(/\s/g, "").length < 6
|
||||||
|
) {
|
||||||
this.$toast.error(this.$t("string_length_insufficient"), {
|
this.$toast.error(this.$t("string_length_insufficient"), {
|
||||||
icon: "error",
|
icon: "error",
|
||||||
})
|
})
|
||||||
@@ -275,14 +312,18 @@ export default {
|
|||||||
this.$toast.error(this.$t("invalid_emailID_format"), {
|
this.$toast.error(this.$t("invalid_emailID_format"), {
|
||||||
icon: "error",
|
icon: "error",
|
||||||
})
|
})
|
||||||
return
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.$data.newMembers.forEach((element) => {
|
this.$data.newMembers.forEach((element) => {
|
||||||
// Call to the graphql mutation
|
// Call to the graphql mutation
|
||||||
team_utils
|
teamUtils
|
||||||
.addTeamMemberByEmail(this.$apollo, element.value, element.key, this.editingteamID)
|
.addTeamMemberByEmail(
|
||||||
.then((data) => {
|
this.$apollo,
|
||||||
|
element.value,
|
||||||
|
element.key,
|
||||||
|
this.editingteamID
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("team_saved"), {
|
this.$toast.success(this.$t("team_saved"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
@@ -299,9 +340,14 @@ export default {
|
|||||||
})
|
})
|
||||||
let messageShown = true
|
let messageShown = true
|
||||||
this.members.forEach((element) => {
|
this.members.forEach((element) => {
|
||||||
team_utils
|
teamUtils
|
||||||
.updateTeamMemberRole(this.$apollo, element.user.uid, element.role, this.editingteamID)
|
.updateTeamMemberRole(
|
||||||
.then((data) => {
|
this.$apollo,
|
||||||
|
element.user.uid,
|
||||||
|
element.role,
|
||||||
|
this.editingteamID
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
if (messageShown) {
|
if (messageShown) {
|
||||||
this.$toast.success(this.$t("role_updated"), {
|
this.$toast.success(this.$t("role_updated"), {
|
||||||
@@ -323,16 +369,17 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
if (this.$data.rename !== null) {
|
if (this.$data.rename !== null) {
|
||||||
const newName = this.name === this.$data.rename ? this.name : this.$data.rename
|
const newName =
|
||||||
|
this.name === this.$data.rename ? this.name : this.$data.rename
|
||||||
if (!/\S/.test(newName))
|
if (!/\S/.test(newName))
|
||||||
return this.$toast.error(this.$t("team_name_empty"), {
|
return this.$toast.error(this.$t("team_name_empty"), {
|
||||||
icon: "error",
|
icon: "error",
|
||||||
})
|
})
|
||||||
// Call to the graphql mutation
|
// Call to the graphql mutation
|
||||||
if (this.name !== this.rename)
|
if (this.name !== this.rename)
|
||||||
team_utils
|
teamUtils
|
||||||
.renameTeam(this.$apollo, newName, this.editingteamID)
|
.renameTeam(this.$apollo, newName, this.editingteamID)
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("team_saved"), {
|
this.$toast.success(this.$t("team_saved"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
|
|||||||
@@ -2,42 +2,45 @@
|
|||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
v-tooltip.right="team.myRole === 'OWNER' ? $t('edit') : ''"
|
||||||
class="icon"
|
class="icon"
|
||||||
@click="team.myRole === 'OWNER' ? $emit('edit-team') : ''"
|
@click="team.myRole === 'OWNER' ? $emit('edit-team') : ''"
|
||||||
v-tooltip.right="team.myRole === 'OWNER' ? $t('edit') : ''"
|
|
||||||
>
|
>
|
||||||
<i class="material-icons">group</i>
|
<i class="material-icons">group</i>
|
||||||
<span>{{ team.name }}</span>
|
<span>{{ team.name }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<v-popover>
|
<v-popover>
|
||||||
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
|
<button v-tooltip.left="$t('more')" class="tooltip-target icon">
|
||||||
<i class="material-icons">more_vert</i>
|
<i class="material-icons">more_vert</i>
|
||||||
</button>
|
</button>
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
<div v-if="team.myRole === 'OWNER'">
|
<div v-if="team.myRole === 'OWNER'">
|
||||||
<button class="icon" @click="$emit('edit-team')" v-close-popover>
|
<button v-close-popover class="icon" @click="$emit('edit-team')">
|
||||||
<i class="material-icons">create</i>
|
<i class="material-icons">create</i>
|
||||||
<span>{{ $t("edit") }}</span>
|
<span>{{ $t("edit") }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="team.myRole === 'OWNER'">
|
<div v-if="team.myRole === 'OWNER'">
|
||||||
<button class="icon" @click="deleteTeam" v-close-popover>
|
<button v-close-popover class="icon" @click="deleteTeam">
|
||||||
<i class="material-icons">delete</i>
|
<i class="material-icons">delete</i>
|
||||||
<span>{{ $t("delete") }}</span>
|
<span>{{ $t("delete") }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
class="icon"
|
|
||||||
@click="exitTeam"
|
|
||||||
v-close-popover
|
v-close-popover
|
||||||
|
class="icon"
|
||||||
:disabled="team.myRole === 'OWNER' && team.ownersCount == 1"
|
:disabled="team.myRole === 'OWNER' && team.ownersCount == 1"
|
||||||
|
@click="exitTeam"
|
||||||
>
|
>
|
||||||
<i class="material-icons">remove</i>
|
<i class="material-icons">remove</i>
|
||||||
<div
|
<div
|
||||||
v-tooltip.left="{
|
v-tooltip.left="{
|
||||||
content: team.myRole === 'OWNER' && team.ownersCount == 1 ? $t('disable_exit') : '',
|
content:
|
||||||
|
team.myRole === 'OWNER' && team.ownersCount == 1
|
||||||
|
? $t('disable_exit')
|
||||||
|
: '',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span>{{ $t("exit") }}</span>
|
<span>{{ $t("exit") }}</span>
|
||||||
@@ -49,34 +52,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
ul {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul li {
|
|
||||||
display: flex;
|
|
||||||
padding-left: 16px;
|
|
||||||
border-left: 1px solid var(--brd-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as team_utils from "~/helpers/teams/utils"
|
import * as teamUtils from "~/helpers/teams/utils"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
team: Object,
|
team: { type: Object, default: () => {} },
|
||||||
teamID: String,
|
teamID: { type: String, default: null },
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
deleteTeam() {
|
deleteTeam() {
|
||||||
if (!confirm("Are you sure you want to remove this team?")) return
|
if (!confirm("Are you sure you want to remove this team?")) return
|
||||||
// Call to the graphql mutation
|
// Call to the graphql mutation
|
||||||
team_utils
|
teamUtils
|
||||||
.deleteTeam(this.$apollo, this.teamID)
|
.deleteTeam(this.$apollo, this.teamID)
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("new_team_created"), {
|
this.$toast.success(this.$t("new_team_created"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
@@ -92,9 +82,9 @@ export default {
|
|||||||
},
|
},
|
||||||
exitTeam() {
|
exitTeam() {
|
||||||
if (!confirm("Are you sure you want to exit this team?")) return
|
if (!confirm("Are you sure you want to exit this team?")) return
|
||||||
team_utils
|
teamUtils
|
||||||
.exitTeam(this.$apollo, this.teamID)
|
.exitTeam(this.$apollo, this.teamID)
|
||||||
.then((data) => {
|
.then(() => {
|
||||||
// Result
|
// Result
|
||||||
this.$toast.success(this.$t("team_exited"), {
|
this.$toast.success(this.$t("team_exited"), {
|
||||||
icon: "done",
|
icon: "done",
|
||||||
@@ -111,3 +101,16 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
ul {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
display: flex;
|
||||||
|
padding-left: 16px;
|
||||||
|
border-left: 1px solid var(--brd-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection class="green" icon="history" :label="$t('teams')" ref="teams" no-legend>
|
<AppSection
|
||||||
|
ref="teams"
|
||||||
|
class="green"
|
||||||
|
icon="history"
|
||||||
|
:label="$t('teams')"
|
||||||
|
no-legend
|
||||||
|
>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<label>{{ $t("teams") }}</label>
|
<label>{{ $t("teams") }}</label>
|
||||||
<div v-if="fb.currentUser"></div>
|
<div v-if="fb.currentUser"></div>
|
||||||
@@ -15,8 +21,8 @@
|
|||||||
<TeamsEdit
|
<TeamsEdit
|
||||||
:team="myTeams[0]"
|
:team="myTeams[0]"
|
||||||
:show="showModalEdit"
|
:show="showModalEdit"
|
||||||
:editingTeam="editingTeam"
|
:editing-team="editingTeam"
|
||||||
:editingteamID="editingteamID"
|
:editingteam-i-d="editingteamID"
|
||||||
@hide-modal="displayModalEdit(false)"
|
@hide-modal="displayModalEdit(false)"
|
||||||
/>
|
/>
|
||||||
<div class="row-wrapper">
|
<div class="row-wrapper">
|
||||||
@@ -27,31 +33,26 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="$apollo.queries.myTeams.loading" class="info">{{ $t("loading") }}</p>
|
<p v-if="$apollo.queries.myTeams.loading" class="info">
|
||||||
|
{{ $t("loading") }}
|
||||||
|
</p>
|
||||||
<p v-if="myTeams.length === 0" class="info">
|
<p v-if="myTeams.length === 0" class="info">
|
||||||
<i class="material-icons">help_outline</i> {{ $t("create_new_team") }}
|
<i class="material-icons">help_outline</i> {{ $t("create_new_team") }}
|
||||||
</p>
|
</p>
|
||||||
<div v-else class="virtual-list">
|
<div v-else class="virtual-list">
|
||||||
<ul class="flex-col">
|
<ul class="flex-col">
|
||||||
<li v-for="(team, index) in myTeams" :key="`team-${index}`">
|
<li v-for="(team, index) in myTeams" :key="`team-${index}`">
|
||||||
<TeamsTeam :teamID="team.id" :team="team" @edit-team="editTeam(team, team.id)" />
|
<TeamsTeam
|
||||||
|
:team-i-d="team.id"
|
||||||
|
:team="team"
|
||||||
|
@edit-team="editTeam(team, team.id)"
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</AppSection>
|
</AppSection>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.virtual-list {
|
|
||||||
max-height: calc(100vh - 241px);
|
|
||||||
}
|
|
||||||
|
|
||||||
ul {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import gql from "graphql-tag"
|
import gql from "graphql-tag"
|
||||||
import { fb } from "~/helpers/fb"
|
import { fb } from "~/helpers/fb"
|
||||||
@@ -102,6 +103,9 @@ export default {
|
|||||||
pollInterval: 10000,
|
pollInterval: 10000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
document.removeEventListener("keydown", this._keyListener)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
displayModalAdd(shouldDisplay) {
|
displayModalAdd(shouldDisplay) {
|
||||||
this.showModalAdd = shouldDisplay
|
this.showModalAdd = shouldDisplay
|
||||||
@@ -113,7 +117,7 @@ export default {
|
|||||||
},
|
},
|
||||||
editTeam(team, teamID) {
|
editTeam(team, teamID) {
|
||||||
this.editingTeam = team
|
this.editingTeam = team
|
||||||
this.editingteamID = team.id
|
this.editingteamID = teamID
|
||||||
this.displayModalEdit(true)
|
this.displayModalEdit(true)
|
||||||
},
|
},
|
||||||
resetSelectedData() {
|
resetSelectedData() {
|
||||||
@@ -121,8 +125,16 @@ export default {
|
|||||||
this.$data.editingteamID = undefined
|
this.$data.editingteamID = undefined
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
|
||||||
document.removeEventListener("keydown", this._keyListener)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.virtual-list {
|
||||||
|
max-height: calc(100vh - 241px);
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { cancelRunningRequest, sendNetworkRequest } from "../network"
|
import { cancelRunningRequest, sendNetworkRequest } from "../network"
|
||||||
|
|
||||||
import AxiosStrategy, { cancelRunningAxiosRequest } from "../strategies/AxiosStrategy"
|
import AxiosStrategy, {
|
||||||
|
cancelRunningAxiosRequest,
|
||||||
|
} from "../strategies/AxiosStrategy"
|
||||||
import ExtensionStrategy, {
|
import ExtensionStrategy, {
|
||||||
cancelRunningExtensionRequest,
|
cancelRunningExtensionRequest,
|
||||||
hasExtensionInstalled,
|
hasExtensionInstalled,
|
||||||
@@ -23,9 +25,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
return {
|
return {
|
||||||
settingsStore: {
|
settingsStore: {
|
||||||
value: {
|
value: {
|
||||||
EXTENSIONS_ENABLED: false
|
EXTENSIONS_ENABLED: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -60,7 +62,6 @@ describe("cancelRunningRequest", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("sendNetworkRequest", () => {
|
describe("sendNetworkRequest", () => {
|
||||||
|
|
||||||
test("runs only axios request if extension not allowed in settings and extension is installed and clears the progress bar", async () => {
|
test("runs only axios request if extension not allowed in settings and extension is installed and clears the progress bar", async () => {
|
||||||
hasExtensionInstalled.mockReturnValue(true)
|
hasExtensionInstalled.mockReturnValue(true)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
import { cancelRunningRequest, sendNetworkRequest } from "../network"
|
import { cancelRunningRequest, sendNetworkRequest } from "../network"
|
||||||
|
|
||||||
import AxiosStrategy, { cancelRunningAxiosRequest } from "../strategies/AxiosStrategy"
|
import AxiosStrategy, {
|
||||||
|
cancelRunningAxiosRequest,
|
||||||
|
} from "../strategies/AxiosStrategy"
|
||||||
import ExtensionStrategy, {
|
import ExtensionStrategy, {
|
||||||
cancelRunningExtensionRequest,
|
cancelRunningExtensionRequest,
|
||||||
hasExtensionInstalled,
|
hasExtensionInstalled,
|
||||||
@@ -24,9 +25,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
return {
|
return {
|
||||||
settingsStore: {
|
settingsStore: {
|
||||||
value: {
|
value: {
|
||||||
EXTENSIONS_ENABLED: true
|
EXTENSIONS_ENABLED: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { PASS, FAIL } from "../postwomanTesting"
|
import runTestScriptWithVariables, { PASS, FAIL } from "../postwomanTesting"
|
||||||
import runTestScriptWithVariables from "../postwomanTesting"
|
|
||||||
|
|
||||||
function getTestResult(script, index) {
|
function getTestResult(script, index) {
|
||||||
return runTestScriptWithVariables(script).testResults[index].result
|
return runTestScriptWithVariables(script).testResults[index].result
|
||||||
@@ -41,8 +40,12 @@ describe("toBe", () => {
|
|||||||
test("test for negative assertion (.not.toBe)", () => {
|
test("test for negative assertion (.not.toBe)", () => {
|
||||||
expect(getTestResult("pw.expect(1).not.toBe(1)", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(1).not.toBe(1)", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect(1).not.toBe(2)", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect(1).not.toBe(2)", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('world').not.toBe('planet')", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('world').not.toBe('planet')", 0)).toEqual(
|
||||||
expect(getTestResult("pw.expect('world').not.toBe('world')", 0)).toEqual(FAIL)
|
PASS
|
||||||
|
)
|
||||||
|
expect(getTestResult("pw.expect('world').not.toBe('world')", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,16 +57,29 @@ describe("toHaveProperty", () => {
|
|||||||
|
|
||||||
test("test for positive assertion (.toHaveProperty)", () => {
|
test("test for positive assertion (.toHaveProperty)", () => {
|
||||||
expect(
|
expect(
|
||||||
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("id")`, 0)
|
getTestResult(
|
||||||
|
`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("id")`,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${dummyResponse.id}).toBe(843)`, 0)
|
||||||
).toEqual(PASS)
|
).toEqual(PASS)
|
||||||
expect(getTestResult(`pw.expect(${dummyResponse.id}).toBe(843)`, 0)).toEqual(PASS)
|
|
||||||
})
|
})
|
||||||
test("test for negative assertion (.not.toHaveProperty)", () => {
|
test("test for negative assertion (.not.toHaveProperty)", () => {
|
||||||
expect(
|
expect(
|
||||||
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).not.toHaveProperty("type")`, 0)
|
getTestResult(
|
||||||
|
`pw.expect(${JSON.stringify(
|
||||||
|
dummyResponse
|
||||||
|
)}).not.toHaveProperty("type")`,
|
||||||
|
0
|
||||||
|
)
|
||||||
).toEqual(PASS)
|
).toEqual(PASS)
|
||||||
expect(
|
expect(
|
||||||
getTestResult(`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("type")`, 0)
|
getTestResult(
|
||||||
|
`pw.expect(${JSON.stringify(dummyResponse)}).toHaveProperty("type")`,
|
||||||
|
0
|
||||||
|
)
|
||||||
).toEqual(FAIL)
|
).toEqual(FAIL)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -77,12 +93,18 @@ describe("toBeLevel2xx", () => {
|
|||||||
})
|
})
|
||||||
test("test for strings", () => {
|
test("test for strings", () => {
|
||||||
expect(getTestResult("pw.expect('200').toBeLevel2xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('200').toBeLevel2xx()", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('200').not.toBeLevel2xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('200').not.toBeLevel2xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect('300').toBeLevel2xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('300').toBeLevel2xx()", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect('300').not.toBeLevel2xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('300').not.toBeLevel2xx()", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
})
|
})
|
||||||
test("failed to parse to integer", () => {
|
test("failed to parse to integer", () => {
|
||||||
expect(getTestResult("pw.expect(undefined).toBeLevel2xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(undefined).toBeLevel2xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect(null).toBeLevel2xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(null).toBeLevel2xx()", 0)).toEqual(FAIL)
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel2xx()")
|
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel2xx()")
|
||||||
@@ -99,12 +121,18 @@ describe("toBeLevel3xx()", () => {
|
|||||||
})
|
})
|
||||||
test("test for strings", () => {
|
test("test for strings", () => {
|
||||||
expect(getTestResult("pw.expect('300').toBeLevel3xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('300').toBeLevel3xx()", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('300').not.toBeLevel3xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('300').not.toBeLevel3xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect('400').toBeLevel3xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('400').toBeLevel3xx()", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect('400').not.toBeLevel3xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('400').not.toBeLevel3xx()", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
})
|
})
|
||||||
test("failed to parse to integer", () => {
|
test("failed to parse to integer", () => {
|
||||||
expect(getTestResult("pw.expect(undefined).toBeLevel3xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(undefined).toBeLevel3xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect(null).toBeLevel3xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(null).toBeLevel3xx()", 0)).toEqual(FAIL)
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel3xx()")
|
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel3xx()")
|
||||||
@@ -121,12 +149,18 @@ describe("toBeLevel4xx()", () => {
|
|||||||
})
|
})
|
||||||
test("test for strings", () => {
|
test("test for strings", () => {
|
||||||
expect(getTestResult("pw.expect('400').toBeLevel4xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('400').toBeLevel4xx()", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('400').not.toBeLevel4xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('400').not.toBeLevel4xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect('500').toBeLevel4xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('500').toBeLevel4xx()", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect('500').not.toBeLevel4xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('500').not.toBeLevel4xx()", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
})
|
})
|
||||||
test("failed to parse to integer", () => {
|
test("failed to parse to integer", () => {
|
||||||
expect(getTestResult("pw.expect(undefined).toBeLevel4xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(undefined).toBeLevel4xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect(null).toBeLevel4xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(null).toBeLevel4xx()", 0)).toEqual(FAIL)
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel4xx()")
|
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel4xx()")
|
||||||
@@ -143,12 +177,18 @@ describe("toBeLevel5xx()", () => {
|
|||||||
})
|
})
|
||||||
test("test for strings", () => {
|
test("test for strings", () => {
|
||||||
expect(getTestResult("pw.expect('500').toBeLevel5xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('500').toBeLevel5xx()", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('500').not.toBeLevel5xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('500').not.toBeLevel5xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect('200').toBeLevel5xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('200').toBeLevel5xx()", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect('200').not.toBeLevel5xx()", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('200').not.toBeLevel5xx()", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
})
|
})
|
||||||
test("failed to parse to integer", () => {
|
test("failed to parse to integer", () => {
|
||||||
expect(getTestResult("pw.expect(undefined).toBeLevel5xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(undefined).toBeLevel5xx()", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect(null).toBeLevel5xx()", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(null).toBeLevel5xx()", 0)).toEqual(FAIL)
|
||||||
expect(() => {
|
expect(() => {
|
||||||
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel5xx()")
|
runTestScriptWithVariables("pw.expect(Symbol('test')).toBeLevel5xx()")
|
||||||
@@ -160,40 +200,85 @@ describe("toHaveLength()", () => {
|
|||||||
test("test for strings", () => {
|
test("test for strings", () => {
|
||||||
expect(getTestResult("pw.expect('word').toHaveLength(4)", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('word').toHaveLength(4)", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect('word').toHaveLength(5)", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('word').toHaveLength(5)", 0)).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect('word').not.toHaveLength(4)", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('word').not.toHaveLength(4)", 0)).toEqual(
|
||||||
expect(getTestResult("pw.expect('word').not.toHaveLength(5)", 0)).toEqual(PASS)
|
FAIL
|
||||||
|
)
|
||||||
|
expect(getTestResult("pw.expect('word').not.toHaveLength(5)", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
})
|
})
|
||||||
test("test for arrays", () => {
|
test("test for arrays", () => {
|
||||||
const fruits = "['apples', 'bananas', 'oranges', 'grapes', 'strawberries', 'cherries']"
|
const fruits =
|
||||||
expect(getTestResult(`pw.expect(${fruits}).toHaveLength(6)`, 0)).toEqual(PASS)
|
"['apples', 'bananas', 'oranges', 'grapes', 'strawberries', 'cherries']"
|
||||||
expect(getTestResult(`pw.expect(${fruits}).toHaveLength(7)`, 0)).toEqual(FAIL)
|
expect(getTestResult(`pw.expect(${fruits}).toHaveLength(6)`, 0)).toEqual(
|
||||||
expect(getTestResult(`pw.expect(${fruits}).not.toHaveLength(6)`, 0)).toEqual(FAIL)
|
PASS
|
||||||
expect(getTestResult(`pw.expect(${fruits}).not.toHaveLength(7)`, 0)).toEqual(PASS)
|
)
|
||||||
|
expect(getTestResult(`pw.expect(${fruits}).toHaveLength(7)`, 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${fruits}).not.toHaveLength(6)`, 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
expect(
|
||||||
|
getTestResult(`pw.expect(${fruits}).not.toHaveLength(7)`, 0)
|
||||||
|
).toEqual(PASS)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("toBeType()", () => {
|
describe("toBeType()", () => {
|
||||||
test("test for positive assertion", () => {
|
test("test for positive assertion", () => {
|
||||||
expect(getTestResult("pw.expect('random').toBeType('string')", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect('random').toBeType('string')", 0)).toEqual(
|
||||||
expect(getTestResult("pw.expect(true).toBeType('boolean')", 0)).toEqual(PASS)
|
PASS
|
||||||
|
)
|
||||||
|
expect(getTestResult("pw.expect(true).toBeType('boolean')", 0)).toEqual(
|
||||||
|
PASS
|
||||||
|
)
|
||||||
expect(getTestResult("pw.expect(5).toBeType('number')", 0)).toEqual(PASS)
|
expect(getTestResult("pw.expect(5).toBeType('number')", 0)).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect(new Date()).toBeType('object')", 0)).toEqual(PASS)
|
expect(
|
||||||
expect(getTestResult("pw.expect(undefined).toBeType('undefined')", 0)).toEqual(PASS)
|
getTestResult("pw.expect(new Date()).toBeType('object')", 0)
|
||||||
expect(getTestResult("pw.expect(BigInt(123)).toBeType('bigint')", 0)).toEqual(PASS)
|
).toEqual(PASS)
|
||||||
expect(getTestResult("pw.expect(Symbol('test')).toBeType('symbol')", 0)).toEqual(PASS)
|
expect(
|
||||||
expect(getTestResult("pw.expect(function() {}).toBeType('function')", 0)).toEqual(PASS)
|
getTestResult("pw.expect(undefined).toBeType('undefined')", 0)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(BigInt(123)).toBeType('bigint')", 0)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(Symbol('test')).toBeType('symbol')", 0)
|
||||||
|
).toEqual(PASS)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(function() {}).toBeType('function')", 0)
|
||||||
|
).toEqual(PASS)
|
||||||
})
|
})
|
||||||
test("test for negative assertion", () => {
|
test("test for negative assertion", () => {
|
||||||
expect(getTestResult("pw.expect('random').not.toBeType('string')", 0)).toEqual(FAIL)
|
expect(
|
||||||
expect(getTestResult("pw.expect(true).not.toBeType('boolean')", 0)).toEqual(FAIL)
|
getTestResult("pw.expect('random').not.toBeType('string')", 0)
|
||||||
expect(getTestResult("pw.expect(5).not.toBeType('number')", 0)).toEqual(FAIL)
|
).toEqual(FAIL)
|
||||||
expect(getTestResult("pw.expect(new Date()).not.toBeType('object')", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(true).not.toBeType('boolean')", 0)).toEqual(
|
||||||
expect(getTestResult("pw.expect(undefined).not.toBeType('undefined')", 0)).toEqual(FAIL)
|
FAIL
|
||||||
expect(getTestResult("pw.expect(BigInt(123)).not.toBeType('bigint')", 0)).toEqual(FAIL)
|
)
|
||||||
expect(getTestResult("pw.expect(Symbol('test')).not.toBeType('symbol')", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect(5).not.toBeType('number')", 0)).toEqual(
|
||||||
expect(getTestResult("pw.expect(function() {}).not.toBeType('function')", 0)).toEqual(FAIL)
|
FAIL
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(new Date()).not.toBeType('object')", 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(undefined).not.toBeType('undefined')", 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(BigInt(123)).not.toBeType('bigint')", 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(Symbol('test')).not.toBeType('symbol')", 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
|
expect(
|
||||||
|
getTestResult("pw.expect(function() {}).not.toBeType('function')", 0)
|
||||||
|
).toEqual(FAIL)
|
||||||
})
|
})
|
||||||
test("unexpected type", () => {
|
test("unexpected type", () => {
|
||||||
expect(getTestResult("pw.expect('random').toBeType('unknown')", 0)).toEqual(FAIL)
|
expect(getTestResult("pw.expect('random').toBeType('unknown')", 0)).toEqual(
|
||||||
|
FAIL
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { ApolloClient, HttpLink, InMemoryCache, split } from "@apollo/client/core"
|
import {
|
||||||
|
ApolloClient,
|
||||||
|
HttpLink,
|
||||||
|
InMemoryCache,
|
||||||
|
split,
|
||||||
|
} from "@apollo/client/core"
|
||||||
import { WebSocketLink } from "@apollo/client/link/ws"
|
import { WebSocketLink } from "@apollo/client/link/ws"
|
||||||
import { setContext } from "@apollo/client/link/context"
|
import { setContext } from "@apollo/client/link/context"
|
||||||
import { fb } from "./fb"
|
|
||||||
import { getMainDefinition } from "@apollo/client/utilities"
|
import { getMainDefinition } from "@apollo/client/utilities"
|
||||||
|
import { fb } from "./fb"
|
||||||
|
|
||||||
let authToken: String | null = null
|
let authToken: String | null = null
|
||||||
|
|
||||||
@@ -56,7 +61,10 @@ const wsLink = new WebSocketLink({
|
|||||||
const splitLink = split(
|
const splitLink = split(
|
||||||
({ query }) => {
|
({ query }) => {
|
||||||
const definition = getMainDefinition(query)
|
const definition = getMainDefinition(query)
|
||||||
return definition.kind === "OperationDefinition" && definition.operation === "subscription"
|
return (
|
||||||
|
definition.kind === "OperationDefinition" &&
|
||||||
|
definition.operation === "subscription"
|
||||||
|
)
|
||||||
},
|
},
|
||||||
wsLink,
|
wsLink,
|
||||||
httpLink
|
httpLink
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const TEST_HTTP_PASSWORD = "mockPassword"
|
|||||||
const TEST_BEARER_TOKEN = "abcdefghijklmn"
|
const TEST_BEARER_TOKEN = "abcdefghijklmn"
|
||||||
const TEST_RAW_REQUEST_BODY = "foo=bar&baz=qux"
|
const TEST_RAW_REQUEST_BODY = "foo=bar&baz=qux"
|
||||||
const TEST_RAW_PARAMS_JSON = '{"foo": "bar", "baz": "qux"}'
|
const TEST_RAW_PARAMS_JSON = '{"foo": "bar", "baz": "qux"}'
|
||||||
const TEST_RAW_PARAMS_XML = `<?xml version=\'1.0\' encoding=\'utf-8\'?>
|
const TEST_RAW_PARAMS_XML = `<?xml version='1.0' encoding='utf-8'?>
|
||||||
<xml>
|
<xml>
|
||||||
<element foo="bar"></element>
|
<element foo="bar"></element>
|
||||||
</xml>`
|
</xml>`
|
||||||
|
|||||||
@@ -20,13 +20,20 @@ export const CLibcurlCodegen = {
|
|||||||
const requestString = []
|
const requestString = []
|
||||||
|
|
||||||
requestString.push("CURL *hnd = curl_easy_init();")
|
requestString.push("CURL *hnd = curl_easy_init();")
|
||||||
requestString.push(`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${method}");`)
|
requestString.push(
|
||||||
requestString.push(`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}${queryString}");`)
|
`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${method}");`
|
||||||
|
)
|
||||||
|
requestString.push(
|
||||||
|
`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}${queryString}");`
|
||||||
|
)
|
||||||
requestString.push(`struct curl_slist *headers = NULL;`)
|
requestString.push(`struct curl_slist *headers = NULL;`)
|
||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
headers.forEach(({ key, value }) => {
|
headers.forEach(({ key, value }) => {
|
||||||
if (key) requestString.push(`headers = curl_slist_append(headers, "${key}: ${value}");`)
|
if (key)
|
||||||
|
requestString.push(
|
||||||
|
`headers = curl_slist_append(headers, "${key}: ${value}");`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +57,15 @@ export const CLibcurlCodegen = {
|
|||||||
requestBody = `"${requestBody}"`
|
requestBody = `"${requestBody}"`
|
||||||
} else requestBody = JSON.stringify(requestBody)
|
} else requestBody = JSON.stringify(requestBody)
|
||||||
|
|
||||||
requestString.push(`headers = curl_slist_append(headers, "Content-Type: ${contentType}");`)
|
requestString.push(
|
||||||
|
`headers = curl_slist_append(headers, "Content-Type: ${contentType}");`
|
||||||
|
)
|
||||||
|
requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
|
||||||
|
requestString.push(
|
||||||
|
`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${requestBody});`
|
||||||
|
)
|
||||||
|
} else
|
||||||
requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
|
requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
|
||||||
requestString.push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${requestBody});`)
|
|
||||||
} else requestString.push("curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);")
|
|
||||||
|
|
||||||
requestString.push(`CURLcode ret = curl_easy_perform(hnd);`)
|
requestString.push(`CURLcode ret = curl_easy_perform(hnd);`)
|
||||||
return requestString.join("\n")
|
return requestString.join("\n")
|
||||||
|
|||||||
@@ -57,12 +57,16 @@ export const CsRestsharpCodegen = {
|
|||||||
`client.Authenticator = new HttpBasicAuthenticator("${httpUser}", "${httpPassword}");\n`
|
`client.Authenticator = new HttpBasicAuthenticator("${httpUser}", "${httpPassword}");\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`request.AddHeader("Authorization", "Bearer ${bearerToken}");\n`)
|
requestString.push(
|
||||||
|
`request.AddHeader("Authorization", "Bearer ${bearerToken}");\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
requestString.push(`request.AddHeader("Content-Type", "${contentType}");\n`)
|
requestString.push(
|
||||||
|
`request.AddHeader("Content-Type", "${contentType}");\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom headers
|
// custom headers
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export const CurlCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
requestString.push(
|
requestString.push(
|
||||||
` -H 'Authorization: Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'`
|
` -H 'Authorization: Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}'`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(` -H 'Authorization: Bearer ${bearerToken}'`)
|
requestString.push(` -H 'Authorization: Bearer ${bearerToken}'`)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ export const GoNativeCodegen = {
|
|||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
let genHeaders = []
|
||||||
// initial request setup
|
// initial request setup
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
if (method == "GET") {
|
if (method === "GET") {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
`req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}")\n`
|
`req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}")\n`
|
||||||
)
|
)
|
||||||
@@ -52,7 +52,9 @@ export const GoNativeCodegen = {
|
|||||||
)}")\n`
|
)}")\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(`req.Header.Set("Authorization", "Bearer ${bearerToken}")\n`)
|
genHeaders.push(
|
||||||
|
`req.Header.Set("Authorization", "Bearer ${bearerToken}")\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// custom headers
|
// custom headers
|
||||||
if (headers) {
|
if (headers) {
|
||||||
@@ -62,7 +64,9 @@ export const GoNativeCodegen = {
|
|||||||
}
|
}
|
||||||
genHeaders = genHeaders.join("").slice(0, -1)
|
genHeaders = genHeaders.join("").slice(0, -1)
|
||||||
requestString.push(`${genHeaders}\n`)
|
requestString.push(`${genHeaders}\n`)
|
||||||
requestString.push(`if err != nil {\n log.Fatalf("An Error Occured %v", err)\n}\n\n`)
|
requestString.push(
|
||||||
|
`if err != nil {\n log.Fatalf("An Error Occured %v", err)\n}\n\n`
|
||||||
|
)
|
||||||
|
|
||||||
// request boilerplate
|
// request boilerplate
|
||||||
requestString.push(`client := &http.Client{}\n`)
|
requestString.push(`client := &http.Client{}\n`)
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ export const JavaOkhttpCodegen = {
|
|||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
|
|
||||||
requestString.push("OkHttpClient client = new OkHttpClient().newBuilder().build();")
|
requestString.push(
|
||||||
|
"OkHttpClient client = new OkHttpClient().newBuilder().build();"
|
||||||
|
)
|
||||||
|
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
@@ -28,17 +30,21 @@ export const JavaOkhttpCodegen = {
|
|||||||
requestBody = `"${requestBody}"`
|
requestBody = `"${requestBody}"`
|
||||||
} else requestBody = JSON.stringify(requestBody)
|
} else requestBody = JSON.stringify(requestBody)
|
||||||
|
|
||||||
requestString.push(`MediaType mediaType = MediaType.parse("${contentType}");`)
|
requestString.push(
|
||||||
requestString.push(`RequestBody body = RequestBody.create(mediaType,${requestBody});`)
|
`MediaType mediaType = MediaType.parse("${contentType}");`
|
||||||
|
)
|
||||||
|
requestString.push(
|
||||||
|
`RequestBody body = RequestBody.create(mediaType,${requestBody});`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestString.push("Request request = new Request.Builder()")
|
requestString.push("Request request = new Request.Builder()")
|
||||||
requestString.push(`.url(\"${url}${pathName}${queryString}\")`)
|
requestString.push(`.url("${url}${pathName}${queryString}")`)
|
||||||
|
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
requestString.push(`.method(\"${method}\", body)`)
|
requestString.push(`.method("${method}", body)`)
|
||||||
} else {
|
} else {
|
||||||
requestString.push(`.method(\"${method}\", null)`)
|
requestString.push(`.method("${method}", null)`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
@@ -49,12 +55,14 @@ export const JavaOkhttpCodegen = {
|
|||||||
)}") \n`
|
)}") \n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`.addHeader("authorization", "Bearer ${bearerToken}" ) \n`)
|
requestString.push(
|
||||||
|
`.addHeader("authorization", "Bearer ${bearerToken}" ) \n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
headers.forEach(({ key, value }) => {
|
headers.forEach(({ key, value }) => {
|
||||||
if (key) requestString.push(`.addHeader(\"${key}\", \"${value}\")`)
|
if (key) requestString.push(`.addHeader("${key}", "${value}")`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ export const JavaUnirestCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
requestString.push(
|
requestString.push(
|
||||||
`.header("authorization", "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}") \n`
|
`.header("authorization", "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}") \n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`.header("authorization", "Bearer ${bearerToken}") \n`)
|
requestString.push(`.header("authorization", "Bearer ${bearerToken}") \n`)
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ export const JavascriptFetchCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ export const JavascriptJqueryCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`jQuery.ajax({\n url: "${url}${pathName}${queryString}"`)
|
requestString.push(
|
||||||
|
`jQuery.ajax({\n url: "${url}${pathName}${queryString}"`
|
||||||
|
)
|
||||||
requestString.push(`,\n method: "${method.toUpperCase()}"`)
|
requestString.push(`,\n method: "${method.toUpperCase()}"`)
|
||||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
|
|
||||||
@@ -41,12 +43,16 @@ export const JavascriptJqueryCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
}
|
}
|
||||||
requestString.push(`,\n headers: {\n${genHeaders.join("").slice(0, -2)}\n }\n})`)
|
requestString.push(
|
||||||
|
`,\n headers: {\n${genHeaders.join("").slice(0, -2)}\n }\n})`
|
||||||
|
)
|
||||||
requestString.push(".then(response => {\n")
|
requestString.push(".then(response => {\n")
|
||||||
requestString.push(" console.log(response);\n")
|
requestString.push(" console.log(response);\n")
|
||||||
requestString.push("})")
|
requestString.push("})")
|
||||||
|
|||||||
@@ -28,11 +28,14 @@ export const JavascriptXhrCodegen = {
|
|||||||
`xhr.open('${method}', '${url}${pathName}${queryString}', true, ${user}, ${password})`
|
`xhr.open('${method}', '${url}${pathName}${queryString}', true, ${user}, ${password})`
|
||||||
)
|
)
|
||||||
if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`xhr.setRequestHeader('Authorization', 'Bearer ${bearerToken}')`)
|
requestString.push(
|
||||||
|
`xhr.setRequestHeader('Authorization', 'Bearer ${bearerToken}')`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (headers) {
|
if (headers) {
|
||||||
headers.forEach(({ key, value }) => {
|
headers.forEach(({ key, value }) => {
|
||||||
if (key) requestString.push(`xhr.setRequestHeader('${key}', '${value}')`)
|
if (key)
|
||||||
|
requestString.push(`xhr.setRequestHeader('${key}', '${value}')`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
@@ -42,7 +45,9 @@ export const JavascriptXhrCodegen = {
|
|||||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||||
requestBody = `"${requestBody}"`
|
requestBody = `"${requestBody}"`
|
||||||
}
|
}
|
||||||
requestString.push(`xhr.setRequestHeader('Content-Type', '${contentType}; charset=utf-8')`)
|
requestString.push(
|
||||||
|
`xhr.setRequestHeader('Content-Type', '${contentType}; charset=utf-8')`
|
||||||
|
)
|
||||||
requestString.push(`xhr.send(${requestBody})`)
|
requestString.push(`xhr.send(${requestBody})`)
|
||||||
} else {
|
} else {
|
||||||
requestString.push("xhr.send()")
|
requestString.push("xhr.send()")
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ export const NodejsAxiosCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
|
|
||||||
requestString.push(`axios.${method.toLowerCase()}('${url}${pathName}${queryString}'`)
|
requestString.push(
|
||||||
|
`axios.${method.toLowerCase()}('${url}${pathName}${queryString}'`
|
||||||
|
)
|
||||||
if (requestBody.length !== 0) {
|
if (requestBody.length !== 0) {
|
||||||
requestString.push(", ")
|
requestString.push(", ")
|
||||||
}
|
}
|
||||||
@@ -36,12 +38,16 @@ export const NodejsAxiosCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
}
|
}
|
||||||
requestString.push(`${requestBody},{ \n headers : {${genHeaders.join("").slice(0, -2)}}\n})`)
|
requestString.push(
|
||||||
|
`${requestBody},{ \n headers : {${genHeaders.join("").slice(0, -2)}}\n})`
|
||||||
|
)
|
||||||
requestString.push(".then(response => {\n")
|
requestString.push(".then(response => {\n")
|
||||||
requestString.push(" console.log(response);\n")
|
requestString.push(" console.log(response);\n")
|
||||||
requestString.push("})")
|
requestString.push("})")
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ export const NodejsNativeCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
@@ -47,7 +49,9 @@ export const NodejsNativeCodegen = {
|
|||||||
requestBody = `\`${requestBody}\``
|
requestBody = `\`${requestBody}\``
|
||||||
}
|
}
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
genHeaders.push(` "Content-Type": "${contentType}; charset=utf-8",\n`)
|
genHeaders.push(
|
||||||
|
` "Content-Type": "${contentType}; charset=utf-8",\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,11 +61,15 @@ export const NodejsNativeCodegen = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (genHeaders.length > 0 || headers.length > 0) {
|
if (genHeaders.length > 0 || headers.length > 0) {
|
||||||
requestString.push(` headers: {\n${genHeaders.join("").slice(0, -2)}\n }`)
|
requestString.push(
|
||||||
|
` headers: {\n${genHeaders.join("").slice(0, -2)}\n }`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
requestString.push(`};\n\n`)
|
requestString.push(`};\n\n`)
|
||||||
|
|
||||||
requestString.push(`const request = http.request(url, options, (response) => {\n`)
|
requestString.push(
|
||||||
|
`const request = http.request(url, options, (response) => {\n`
|
||||||
|
)
|
||||||
requestString.push(` console.log(response);\n`)
|
requestString.push(` console.log(response);\n`)
|
||||||
requestString.push(`});\n\n`)
|
requestString.push(`});\n\n`)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const NodejsRequestCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`const request = require('request');\n`)
|
requestString.push(`const request = require('request');\n`)
|
||||||
requestString.push(`const options = {\n`)
|
requestString.push(`const options = {\n`)
|
||||||
@@ -30,7 +30,9 @@ export const NodejsRequestCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
@@ -58,7 +60,9 @@ export const NodejsRequestCodegen = {
|
|||||||
reqBodyType = "body"
|
reqBodyType = "body"
|
||||||
}
|
}
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
genHeaders.push(` "Content-Type": "${contentType}; charset=utf-8",\n`)
|
genHeaders.push(
|
||||||
|
` "Content-Type": "${contentType}; charset=utf-8",\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
requestString.push(`,\n ${reqBodyType}: ${requestBody}`)
|
requestString.push(`,\n ${reqBodyType}: ${requestBody}`)
|
||||||
}
|
}
|
||||||
@@ -69,7 +73,9 @@ export const NodejsRequestCodegen = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (genHeaders.length > 0 || headers.length > 0) {
|
if (genHeaders.length > 0 || headers.length > 0) {
|
||||||
requestString.push(`,\n headers: {\n${genHeaders.join("").slice(0, -2)}\n }`)
|
requestString.push(
|
||||||
|
`,\n headers: {\n${genHeaders.join("").slice(0, -2)}\n }`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestString.push(`\n}`)
|
requestString.push(`\n}`)
|
||||||
|
|||||||
@@ -20,16 +20,20 @@ export const NodejsUnirestCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`const unirest = require('unirest');\n`)
|
requestString.push(`const unirest = require('unirest');\n`)
|
||||||
requestString.push(`const req = unirest(\n`)
|
requestString.push(`const req = unirest(\n`)
|
||||||
requestString.push(`'${method.toLowerCase()}', '${url}${pathName}${queryString}')\n`)
|
requestString.push(
|
||||||
|
`'${method.toLowerCase()}', '${url}${pathName}${queryString}')\n`
|
||||||
|
)
|
||||||
|
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization": "Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization": "Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization": "Bearer ${bearerToken}",\n`)
|
||||||
@@ -58,7 +62,9 @@ export const NodejsUnirestCodegen = {
|
|||||||
reqBodyType = "send"
|
reqBodyType = "send"
|
||||||
}
|
}
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
genHeaders.push(` "Content-Type": "${contentType}; charset=utf-8",\n`)
|
genHeaders.push(
|
||||||
|
` "Content-Type": "${contentType}; charset=utf-8",\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
requestString.push(`.\n ${reqBodyType}( ${requestBody})`)
|
requestString.push(`.\n ${reqBodyType}( ${requestBody})`)
|
||||||
}
|
}
|
||||||
@@ -69,7 +75,9 @@ export const NodejsUnirestCodegen = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (genHeaders.length > 0 || headers.length > 0) {
|
if (genHeaders.length > 0 || headers.length > 0) {
|
||||||
requestString.push(`.\n headers({\n${genHeaders.join("").slice(0, -2)}\n }`)
|
requestString.push(
|
||||||
|
`.\n headers({\n${genHeaders.join("").slice(0, -2)}\n }`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestString.push(`\n)`)
|
requestString.push(`\n)`)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const PhpCurlCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`<?php\n`)
|
requestString.push(`<?php\n`)
|
||||||
requestString.push(`$curl = curl_init();\n`)
|
requestString.push(`$curl = curl_init();\n`)
|
||||||
@@ -37,7 +37,9 @@ export const PhpCurlCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` "Authorization: Basic ${window.btoa(unescape(encodeURIComponent(basic)))}",\n`
|
` "Authorization: Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}",\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` "Authorization: Bearer ${bearerToken}",\n`)
|
genHeaders.push(` "Authorization: Bearer ${bearerToken}",\n`)
|
||||||
@@ -79,7 +81,9 @@ export const PhpCurlCodegen = {
|
|||||||
}
|
}
|
||||||
if (genHeaders.length > 0 || headers.length > 0) {
|
if (genHeaders.length > 0 || headers.length > 0) {
|
||||||
requestString.push(
|
requestString.push(
|
||||||
` CURLOPT_HTTPHEADER => array(\n${genHeaders.join("").slice(0, -2)}\n )\n`
|
` CURLOPT_HTTPHEADER => array(\n${genHeaders
|
||||||
|
.join("")
|
||||||
|
.slice(0, -2)}\n )\n`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ export const PowershellRestmethodCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const methodsWithBody = ["Put", "Post", "Delete"]
|
const methodsWithBody = ["Put", "Post", "Delete"]
|
||||||
const formattedMethod = method[0].toUpperCase() + method.substring(1).toLowerCase()
|
const formattedMethod =
|
||||||
|
method[0].toUpperCase() + method.substring(1).toLowerCase()
|
||||||
const includeBody = methodsWithBody.includes(formattedMethod)
|
const includeBody = methodsWithBody.includes(formattedMethod)
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
let genHeaders = []
|
||||||
@@ -46,7 +47,9 @@ export const PowershellRestmethodCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
` 'Authorization' = 'Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'\n`
|
` 'Authorization' = 'Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}'\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(` 'Authorization' = 'Bearer ${bearerToken}'\n`)
|
genHeaders.push(` 'Authorization' = 'Bearer ${bearerToken}'\n`)
|
||||||
|
|||||||
@@ -28,24 +28,28 @@ export const PythonHttpClientCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`import http.client\n`)
|
requestString.push(`import http.client\n`)
|
||||||
requestString.push(`import mimetypes\n`)
|
requestString.push(`import mimetypes\n`)
|
||||||
|
|
||||||
const currentUrl = new URL(url)
|
const currentUrl = new URL(url)
|
||||||
let hostname = currentUrl["hostname"]
|
const hostname = currentUrl.hostname
|
||||||
let port = currentUrl["port"]
|
const port = currentUrl.port
|
||||||
if (!port) {
|
if (!port) {
|
||||||
requestString.push(`conn = http.client.HTTPSConnection("${hostname}")\n`)
|
requestString.push(`conn = http.client.HTTPSConnection("${hostname}")\n`)
|
||||||
} else {
|
} else {
|
||||||
requestString.push(`conn = http.client.HTTPSConnection("${hostname}", ${port})\n`)
|
requestString.push(
|
||||||
|
`conn = http.client.HTTPSConnection("${hostname}", ${port})\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// auth headers
|
// auth headers
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
`'Authorization': 'Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'`
|
`'Authorization': 'Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}'`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(`'Authorization': 'Bearer ${bearerToken}'`)
|
genHeaders.push(`'Authorization': 'Bearer ${bearerToken}'`)
|
||||||
@@ -60,7 +64,7 @@ export const PythonHttpClientCodegen = {
|
|||||||
|
|
||||||
// initial request setup
|
// initial request setup
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
if (method == "GET") {
|
if (method === "GET") {
|
||||||
requestString.push(...printHeaders(genHeaders))
|
requestString.push(...printHeaders(genHeaders))
|
||||||
requestString.push(`payload = ''\n`)
|
requestString.push(`payload = ''\n`)
|
||||||
}
|
}
|
||||||
@@ -86,7 +90,9 @@ export const PythonHttpClientCodegen = {
|
|||||||
requestString.push(`paylod = '''${requestBody}'''\n`)
|
requestString.push(`paylod = '''${requestBody}'''\n`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requestString.push(`conn.request("${method}", "${pathName}${queryString}", payload, headers)\n`)
|
requestString.push(
|
||||||
|
`conn.request("${method}", "${pathName}${queryString}", payload, headers)\n`
|
||||||
|
)
|
||||||
requestString.push(`res = conn.getresponse()\n`)
|
requestString.push(`res = conn.getresponse()\n`)
|
||||||
requestString.push(`data = res.read()\n`)
|
requestString.push(`data = res.read()\n`)
|
||||||
requestString.push(`print(data.decode("utf-8"))`)
|
requestString.push(`print(data.decode("utf-8"))`)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const PythonRequestsCodegen = {
|
|||||||
headers,
|
headers,
|
||||||
}) => {
|
}) => {
|
||||||
const requestString = []
|
const requestString = []
|
||||||
let genHeaders = []
|
const genHeaders = []
|
||||||
|
|
||||||
requestString.push(`import requests\n\n`)
|
requestString.push(`import requests\n\n`)
|
||||||
requestString.push(`url = '${url}${pathName}${queryString}'\n`)
|
requestString.push(`url = '${url}${pathName}${queryString}'\n`)
|
||||||
@@ -37,7 +37,9 @@ export const PythonRequestsCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
genHeaders.push(
|
genHeaders.push(
|
||||||
`'Authorization': 'Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'`
|
`'Authorization': 'Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}'`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
genHeaders.push(`'Authorization': 'Bearer ${bearerToken}'`)
|
genHeaders.push(`'Authorization': 'Bearer ${bearerToken}'`)
|
||||||
@@ -52,7 +54,7 @@ export const PythonRequestsCodegen = {
|
|||||||
|
|
||||||
// initial request setup
|
// initial request setup
|
||||||
let requestBody = rawInput ? rawParams : rawRequestBody
|
let requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
if (method == "GET") {
|
if (method === "GET") {
|
||||||
requestString.push(...printHeaders(genHeaders))
|
requestString.push(...printHeaders(genHeaders))
|
||||||
requestString.push(`response = requests.request(\n`)
|
requestString.push(`response = requests.request(\n`)
|
||||||
requestString.push(` '${method}',\n`)
|
requestString.push(` '${method}',\n`)
|
||||||
|
|||||||
@@ -71,7 +71,9 @@ export const RubyNetHttpCodeGen = {
|
|||||||
|
|
||||||
// analyse result
|
// analyse result
|
||||||
requestString.push(`unless response.is_a?(Net::HTTPSuccess) then`)
|
requestString.push(`unless response.is_a?(Net::HTTPSuccess) then`)
|
||||||
requestString.push(` raise "An error occurred: #{response.code} #{response.message}"`)
|
requestString.push(
|
||||||
|
` raise "An error occurred: #{response.code} #{response.message}"`
|
||||||
|
)
|
||||||
requestString.push(`else`)
|
requestString.push(`else`)
|
||||||
requestString.push(` puts response.body`)
|
requestString.push(` puts response.body`)
|
||||||
requestString.push(`end`)
|
requestString.push(`end`)
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ export const SalesforceApexCodegen = {
|
|||||||
// create request
|
// create request
|
||||||
requestString.push(`HttpRequest request = new HttpRequest();\n`)
|
requestString.push(`HttpRequest request = new HttpRequest();\n`)
|
||||||
requestString.push(`request.setMethod('${method}');\n`)
|
requestString.push(`request.setMethod('${method}');\n`)
|
||||||
requestString.push(`request.setEndpoint('${url}${pathName}${queryString}');\n\n`)
|
requestString.push(
|
||||||
|
`request.setEndpoint('${url}${pathName}${queryString}');\n\n`
|
||||||
|
)
|
||||||
|
|
||||||
// authentification
|
// authentification
|
||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
@@ -40,12 +42,16 @@ export const SalesforceApexCodegen = {
|
|||||||
)}');\n`
|
)}');\n`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(`request.setHeader('Authorization', 'Bearer ${bearerToken}');\n`)
|
requestString.push(
|
||||||
|
`request.setHeader('Authorization', 'Bearer ${bearerToken}');\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// content type
|
// content type
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
requestString.push(`request.setHeader('Content-Type', '${contentType}');\n`)
|
requestString.push(
|
||||||
|
`request.setHeader('Content-Type', '${contentType}');\n`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom headers
|
// custom headers
|
||||||
@@ -70,7 +76,9 @@ export const SalesforceApexCodegen = {
|
|||||||
requestString.push(` HttpResponse response = client.send(request);\n`)
|
requestString.push(` HttpResponse response = client.send(request);\n`)
|
||||||
requestString.push(` System.debug(response.getBody());\n`)
|
requestString.push(` System.debug(response.getBody());\n`)
|
||||||
requestString.push(`} catch (CalloutException ex) {\n`)
|
requestString.push(`} catch (CalloutException ex) {\n`)
|
||||||
requestString.push(` System.debug('An error occured ' + ex.getMessage());\n`)
|
requestString.push(
|
||||||
|
` System.debug('An error occured ' + ex.getMessage());\n`
|
||||||
|
)
|
||||||
requestString.push(`}`)
|
requestString.push(`}`)
|
||||||
|
|
||||||
return requestString.join("")
|
return requestString.join("")
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ export const ShellHttpieCodegen = {
|
|||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
headers.forEach(({ key, value }) => {
|
headers.forEach(({ key, value }) => {
|
||||||
requestString.push(` $'${key.replace(/'/g, "\\'")}:${value.replace(/'/g, "\\'")}'`)
|
requestString.push(
|
||||||
|
` $'${key.replace(/'/g, "\\'")}:${value.replace(/'/g, "\\'")}'`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export const ShellWgetCodegen = {
|
|||||||
if (auth === "Basic Auth") {
|
if (auth === "Basic Auth") {
|
||||||
const basic = `${httpUser}:${httpPassword}`
|
const basic = `${httpUser}:${httpPassword}`
|
||||||
requestString.push(
|
requestString.push(
|
||||||
` --header='Authorization: Basic ${window.btoa(unescape(encodeURIComponent(basic)))}'`
|
` --header='Authorization: Basic ${window.btoa(
|
||||||
|
unescape(encodeURIComponent(basic))
|
||||||
|
)}'`
|
||||||
)
|
)
|
||||||
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
} else if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||||
requestString.push(` --header='Authorization: Bearer ${bearerToken}'`)
|
requestString.push(` --header='Authorization: Bearer ${bearerToken}'`)
|
||||||
@@ -35,7 +37,9 @@ export const ShellWgetCodegen = {
|
|||||||
}
|
}
|
||||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||||
requestString.push(` --header='Content-Type: ${contentType}; charset=utf-8'`)
|
requestString.push(
|
||||||
|
` --header='Content-Type: ${contentType}; charset=utf-8'`
|
||||||
|
)
|
||||||
requestString.push(` --body-data='${requestBody}'`)
|
requestString.push(` --body-data='${requestBody}'`)
|
||||||
}
|
}
|
||||||
return requestString.join(" \\\n")
|
return requestString.join(" \\\n")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as cookie from "cookie"
|
|
||||||
import * as URL from "url"
|
import * as URL from "url"
|
||||||
import * as querystring from "querystring"
|
import * as querystring from "querystring"
|
||||||
|
import * as cookie from "cookie"
|
||||||
import parser from "yargs-parser"
|
import parser from "yargs-parser"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +21,7 @@ const joinDataArguments = (dataArguments) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parseCurlCommand = (curlCommand) => {
|
const parseCurlCommand = (curlCommand) => {
|
||||||
let newlineFound = /\\/gi.test(curlCommand)
|
const newlineFound = /\\/gi.test(curlCommand)
|
||||||
if (newlineFound) {
|
if (newlineFound) {
|
||||||
// remove '\' and newlines
|
// remove '\' and newlines
|
||||||
curlCommand = curlCommand.replace(/\\/gi, "")
|
curlCommand = curlCommand.replace(/\\/gi, "")
|
||||||
@@ -34,12 +34,12 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
curlCommand = curlCommand.replace(/ -XPATCH/, " -X PATCH")
|
curlCommand = curlCommand.replace(/ -XPATCH/, " -X PATCH")
|
||||||
curlCommand = curlCommand.replace(/ -XDELETE/, " -X DELETE")
|
curlCommand = curlCommand.replace(/ -XDELETE/, " -X DELETE")
|
||||||
curlCommand = curlCommand.trim()
|
curlCommand = curlCommand.trim()
|
||||||
let parsedArguments = parser(curlCommand)
|
const parsedArguments = parser(curlCommand)
|
||||||
let cookieString
|
let cookieString
|
||||||
let cookies
|
let cookies
|
||||||
let url = parsedArguments._[1]
|
let url = parsedArguments._[1]
|
||||||
if (!url) {
|
if (!url) {
|
||||||
for (let argName in parsedArguments) {
|
for (const argName in parsedArguments) {
|
||||||
if (typeof parsedArguments[argName] === "string") {
|
if (typeof parsedArguments[argName] === "string") {
|
||||||
if (["http", "www."].includes(parsedArguments[argName])) {
|
if (["http", "www."].includes(parsedArguments[argName])) {
|
||||||
url = parsedArguments[argName]
|
url = parsedArguments[argName]
|
||||||
@@ -62,9 +62,9 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
// stupid javascript tricks: closure
|
// stupid javascript tricks: closure
|
||||||
cookieString = header
|
cookieString = header
|
||||||
} else {
|
} else {
|
||||||
let colonIndex = header.indexOf(":")
|
const colonIndex = header.indexOf(":")
|
||||||
let headerName = header.substring(0, colonIndex)
|
const headerName = header.substring(0, colonIndex)
|
||||||
let headerValue = header.substring(colonIndex + 1).trim()
|
const headerValue = header.substring(colonIndex + 1).trim()
|
||||||
headers[headerName] = headerValue
|
headers[headerName] = headerValue
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -109,12 +109,15 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
}
|
}
|
||||||
// separate out cookie headers into separate data structure
|
// separate out cookie headers into separate data structure
|
||||||
// note: cookie is case insensitive
|
// note: cookie is case insensitive
|
||||||
cookies = cookie.parse(cookieString.replace(/^Cookie: /gi, ""), cookieParseOptions)
|
cookies = cookie.parse(
|
||||||
|
cookieString.replace(/^Cookie: /gi, ""),
|
||||||
|
cookieParseOptions
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let method
|
let method
|
||||||
if (parsedArguments.X === "POST") {
|
if (parsedArguments.X === "POST") {
|
||||||
method = "post"
|
method = "post"
|
||||||
} else if (parsedArguments.X === "PUT" || parsedArguments["T"]) {
|
} else if (parsedArguments.X === "PUT" || parsedArguments.T) {
|
||||||
method = "put"
|
method = "put"
|
||||||
} else if (parsedArguments.X === "PATCH") {
|
} else if (parsedArguments.X === "PATCH") {
|
||||||
method = "patch"
|
method = "patch"
|
||||||
@@ -123,29 +126,30 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
} else if (parsedArguments.X === "OPTIONS") {
|
} else if (parsedArguments.X === "OPTIONS") {
|
||||||
method = "options"
|
method = "options"
|
||||||
} else if (
|
} else if (
|
||||||
(parsedArguments["d"] ||
|
(parsedArguments.d ||
|
||||||
parsedArguments["data"] ||
|
parsedArguments.data ||
|
||||||
parsedArguments["data-ascii"] ||
|
parsedArguments["data-ascii"] ||
|
||||||
parsedArguments["data-binary"] ||
|
parsedArguments["data-binary"] ||
|
||||||
parsedArguments["F"] ||
|
parsedArguments.F ||
|
||||||
parsedArguments["form"]) &&
|
parsedArguments.form) &&
|
||||||
!(parsedArguments["G"] || parsedArguments["get"])
|
!(parsedArguments.G || parsedArguments.get)
|
||||||
) {
|
) {
|
||||||
method = "post"
|
method = "post"
|
||||||
} else if (parsedArguments["I"] || parsedArguments["head"]) {
|
} else if (parsedArguments.I || parsedArguments.head) {
|
||||||
method = "head"
|
method = "head"
|
||||||
} else {
|
} else {
|
||||||
method = "get"
|
method = "get"
|
||||||
}
|
}
|
||||||
|
|
||||||
let compressed = !!parsedArguments.compressed
|
const compressed = !!parsedArguments.compressed
|
||||||
let urlObject = URL.parse(url) // eslint-disable-line
|
let urlObject = URL.parse(url) // eslint-disable-line
|
||||||
|
|
||||||
// if GET request with data, convert data to query string
|
// if GET request with data, convert data to query string
|
||||||
// NB: the -G flag does not change the http verb. It just moves the data into the url.
|
// NB: the -G flag does not change the http verb. It just moves the data into the url.
|
||||||
if (parsedArguments["G"] || parsedArguments["get"]) {
|
if (parsedArguments.G || parsedArguments.get) {
|
||||||
urlObject.query = urlObject.query ? urlObject.query : ""
|
urlObject.query = urlObject.query ? urlObject.query : ""
|
||||||
let option = "d" in parsedArguments ? "d" : "data" in parsedArguments ? "data" : null
|
const option =
|
||||||
|
"d" in parsedArguments ? "d" : "data" in parsedArguments ? "data" : null
|
||||||
if (option) {
|
if (option) {
|
||||||
let urlQueryString = ""
|
let urlQueryString = ""
|
||||||
|
|
||||||
@@ -165,7 +169,7 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
delete parsedArguments[option]
|
delete parsedArguments[option]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let query = querystring.parse(urlObject.query, null, null, {
|
const query = querystring.parse(urlObject.query, null, null, {
|
||||||
maxKeys: 10000,
|
maxKeys: 10000,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -175,7 +179,7 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
urlWithoutQuery: URL.format(urlObject),
|
urlWithoutQuery: URL.format(urlObject),
|
||||||
}
|
}
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
request["compressed"] = true
|
request.compressed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(query).length > 0) {
|
if (Object.keys(query).length > 0) {
|
||||||
@@ -184,7 +188,7 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
if (headers) {
|
if (headers) {
|
||||||
request.headers = headers
|
request.headers = headers
|
||||||
}
|
}
|
||||||
request["method"] = method
|
request.method = method
|
||||||
|
|
||||||
if (cookies) {
|
if (cookies) {
|
||||||
request.cookies = cookies
|
request.cookies = cookies
|
||||||
@@ -198,24 +202,24 @@ const parseCurlCommand = (curlCommand) => {
|
|||||||
} else if (parsedArguments["data-binary"]) {
|
} else if (parsedArguments["data-binary"]) {
|
||||||
request.data = parsedArguments["data-binary"]
|
request.data = parsedArguments["data-binary"]
|
||||||
request.isDataBinary = true
|
request.isDataBinary = true
|
||||||
} else if (parsedArguments["d"]) {
|
} else if (parsedArguments.d) {
|
||||||
request.data = parsedArguments["d"]
|
request.data = parsedArguments.d
|
||||||
} else if (parsedArguments["data-ascii"]) {
|
} else if (parsedArguments["data-ascii"]) {
|
||||||
request.data = parsedArguments["data-ascii"]
|
request.data = parsedArguments["data-ascii"]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedArguments["u"]) {
|
if (parsedArguments.u) {
|
||||||
request.auth = parsedArguments["u"]
|
request.auth = parsedArguments.u
|
||||||
}
|
}
|
||||||
if (parsedArguments["user"]) {
|
if (parsedArguments.user) {
|
||||||
request.auth = parsedArguments["user"]
|
request.auth = parsedArguments.user
|
||||||
}
|
}
|
||||||
if (Array.isArray(request.data)) {
|
if (Array.isArray(request.data)) {
|
||||||
request.dataArray = request.data
|
request.dataArray = request.data
|
||||||
request.data = joinDataArguments(request.data)
|
request.data = joinDataArguments(request.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedArguments["k"] || parsedArguments["insecure"]) {
|
if (parsedArguments.k || parsedArguments.insecure) {
|
||||||
request.insecure = true
|
request.insecure = true
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ describe("getSuitableLenses", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const contentTypes = {
|
const contentTypes = {
|
||||||
JSON: ["application/json", "application/ld+json", "application/hal+json; charset=utf8"],
|
JSON: [
|
||||||
|
"application/json",
|
||||||
|
"application/ld+json",
|
||||||
|
"application/hal+json; charset=utf8",
|
||||||
|
],
|
||||||
Image: [
|
Image: [
|
||||||
"image/gif",
|
"image/gif",
|
||||||
"image/jpeg; foo=bar",
|
"image/jpeg; foo=bar",
|
||||||
@@ -32,11 +36,15 @@ describe("getSuitableLenses", () => {
|
|||||||
"image/vnd.microsoft.icon",
|
"image/vnd.microsoft.icon",
|
||||||
],
|
],
|
||||||
HTML: ["text/html", "application/xhtml+xml", "text/html; charset=utf-8"],
|
HTML: ["text/html", "application/xhtml+xml", "text/html; charset=utf-8"],
|
||||||
XML: ["text/xml", "application/xml", "application/xhtml+xml; charset=utf-8"],
|
XML: [
|
||||||
|
"text/xml",
|
||||||
|
"application/xml",
|
||||||
|
"application/xhtml+xml; charset=utf-8",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
lenses
|
lenses
|
||||||
.filter(({ lensName }) => lensName != rawLens.lensName)
|
.filter(({ lensName }) => lensName !== rawLens.lensName)
|
||||||
.forEach((el) => {
|
.forEach((el) => {
|
||||||
test(`returns ${el.lensName} lens for its content-types`, () => {
|
test(`returns ${el.lensName} lens for its content-types`, () => {
|
||||||
contentTypes[el.lensName].forEach((contentType) => {
|
contentTypes[el.lensName].forEach((contentType) => {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ const htmlLens = {
|
|||||||
isSupportedContentType: (contentType) =>
|
isSupportedContentType: (contentType) =>
|
||||||
/\btext\/html|application\/xhtml\+xml\b/i.test(contentType),
|
/\btext\/html|application\/xhtml\+xml\b/i.test(contentType),
|
||||||
renderer: "htmlres",
|
renderer: "htmlres",
|
||||||
rendererImport: () => import("~/components/lenses/renderers/HTMLLensRenderer"),
|
rendererImport: () =>
|
||||||
|
import("~/components/lenses/renderers/HTMLLensRenderer"),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default htmlLens
|
export default htmlLens
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
const imageLens = {
|
const imageLens = {
|
||||||
lensName: "Image",
|
lensName: "Image",
|
||||||
isSupportedContentType: (contentType) =>
|
isSupportedContentType: (contentType) =>
|
||||||
/\bimage\/(?:gif|jpeg|png|bmp|svg\+xml|x-icon|vnd\.microsoft\.icon)\b/i.test(contentType),
|
/\bimage\/(?:gif|jpeg|png|bmp|svg\+xml|x-icon|vnd\.microsoft\.icon)\b/i.test(
|
||||||
|
contentType
|
||||||
|
),
|
||||||
renderer: "imageres",
|
renderer: "imageres",
|
||||||
rendererImport: () => import("~/components/lenses/renderers/ImageLensRenderer"),
|
rendererImport: () =>
|
||||||
|
import("~/components/lenses/renderers/ImageLensRenderer"),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default imageLens
|
export default imageLens
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { isJSONContentType } from "../utils/contenttypes";
|
import { isJSONContentType } from "../utils/contenttypes"
|
||||||
|
|
||||||
const jsonLens = {
|
const jsonLens = {
|
||||||
lensName: "JSON",
|
lensName: "JSON",
|
||||||
isSupportedContentType: isJSONContentType,
|
isSupportedContentType: isJSONContentType,
|
||||||
renderer: "json",
|
renderer: "json",
|
||||||
rendererImport: () => import("~/components/lenses/renderers/JSONLensRenderer"),
|
rendererImport: () =>
|
||||||
|
import("~/components/lenses/renderers/JSONLensRenderer"),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default jsonLens
|
export default jsonLens
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import { settingsStore, applySetting } from "~/newstore/settings"
|
|||||||
|
|
||||||
export function performMigrations(): void {
|
export function performMigrations(): void {
|
||||||
// Migrate old default proxy URL to the new proxy URL (if not set / overridden)
|
// Migrate old default proxy URL to the new proxy URL (if not set / overridden)
|
||||||
if (settingsStore.value.PROXY_URL === "https://hoppscotch.apollosoftware.xyz/") {
|
if (
|
||||||
|
settingsStore.value.PROXY_URL === "https://hoppscotch.apollosoftware.xyz/"
|
||||||
|
) {
|
||||||
applySetting("PROXY_URL", "https://proxy.hoppscotch.io/")
|
applySetting("PROXY_URL", "https://proxy.hoppscotch.io/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import AxiosStrategy, { cancelRunningAxiosRequest } from "./strategies/AxiosStrategy"
|
import AxiosStrategy, {
|
||||||
|
cancelRunningAxiosRequest,
|
||||||
|
} from "./strategies/AxiosStrategy"
|
||||||
import ExtensionStrategy, {
|
import ExtensionStrategy, {
|
||||||
cancelRunningExtensionRequest,
|
cancelRunningExtensionRequest,
|
||||||
hasExtensionInstalled,
|
hasExtensionInstalled,
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ const parseQueryString = (searchQuery) => {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
const segments = searchQuery.split("&").map((s) => s.split("="))
|
const segments = searchQuery.split("&").map((s) => s.split("="))
|
||||||
const queryString = segments.reduce((obj, el) => ({ ...obj, [el[0]]: el[1] }), {})
|
const queryString = segments.reduce(
|
||||||
|
(obj, el) => ({ ...obj, [el[0]]: el[1] }),
|
||||||
|
{}
|
||||||
|
)
|
||||||
return queryString
|
return queryString
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,25 +148,26 @@ const tokenRequest = async ({
|
|||||||
}) => {
|
}) => {
|
||||||
// Check oauth configuration
|
// Check oauth configuration
|
||||||
if (oidcDiscoveryUrl !== "") {
|
if (oidcDiscoveryUrl !== "") {
|
||||||
const { authorization_endpoint, token_endpoint } = await getTokenConfiguration(oidcDiscoveryUrl)
|
const { authorizationEndpoint, tokenEndpoint } =
|
||||||
authUrl = authorization_endpoint
|
await getTokenConfiguration(oidcDiscoveryUrl)
|
||||||
accessTokenUrl = token_endpoint
|
authUrl = authorizationEndpoint
|
||||||
|
accessTokenUrl = tokenEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store oauth information
|
// Store oauth information
|
||||||
localStorage.setItem("token_endpoint", accessTokenUrl)
|
localStorage.setItem("tokenEndpoint", accessTokenUrl)
|
||||||
localStorage.setItem("client_id", clientId)
|
localStorage.setItem("client_id", clientId)
|
||||||
|
|
||||||
// Create and store a random state value
|
// Create and store a random state value
|
||||||
const state = generateRandomString()
|
const state = generateRandomString()
|
||||||
localStorage.setItem("pkce_state", state)
|
localStorage.setItem("pkce_state", state)
|
||||||
|
|
||||||
// Create and store a new PKCE code_verifier (the plaintext random secret)
|
// Create and store a new PKCE codeVerifier (the plaintext random secret)
|
||||||
const code_verifier = generateRandomString()
|
const codeVerifier = generateRandomString()
|
||||||
localStorage.setItem("pkce_code_verifier", code_verifier)
|
localStorage.setItem("pkce_codeVerifier", codeVerifier)
|
||||||
|
|
||||||
// Hash and base64-urlencode the secret to use as the challenge
|
// Hash and base64-urlencode the secret to use as the challenge
|
||||||
const code_challenge = await pkceChallengeFromVerifier(code_verifier)
|
const codeChallenge = await pkceChallengeFromVerifier(codeVerifier)
|
||||||
|
|
||||||
// Build the authorization URL
|
// Build the authorization URL
|
||||||
const buildUrl = () =>
|
const buildUrl = () =>
|
||||||
@@ -171,9 +175,11 @@ const tokenRequest = async ({
|
|||||||
clientId
|
clientId
|
||||||
)}&state=${encodeURIComponent(state)}&scope=${encodeURIComponent(
|
)}&state=${encodeURIComponent(state)}&scope=${encodeURIComponent(
|
||||||
scope
|
scope
|
||||||
)}&redirect_uri=${encodeURIComponent(redirectUri)}&code_challenge=${encodeURIComponent(
|
)}&redirect_uri=${encodeURIComponent(
|
||||||
code_challenge
|
redirectUri
|
||||||
)}&code_challenge_method=S256`
|
)}&codeChallenge=${encodeURIComponent(
|
||||||
|
codeChallenge
|
||||||
|
)}&codeChallenge_method=S256`
|
||||||
|
|
||||||
// Redirect to the authorization server
|
// Redirect to the authorization server
|
||||||
window.location = buildUrl()
|
window.location = buildUrl()
|
||||||
@@ -190,7 +196,7 @@ const tokenRequest = async ({
|
|||||||
|
|
||||||
const oauthRedirect = async () => {
|
const oauthRedirect = async () => {
|
||||||
let tokenResponse = ""
|
let tokenResponse = ""
|
||||||
let q = parseQueryString(window.location.search.substring(1))
|
const q = parseQueryString(window.location.search.substring(1))
|
||||||
// Check if the server returned an error string
|
// Check if the server returned an error string
|
||||||
if (q.error) {
|
if (q.error) {
|
||||||
alert(`Error returned from authorization server: ${q.error}`)
|
alert(`Error returned from authorization server: ${q.error}`)
|
||||||
@@ -198,26 +204,29 @@ const oauthRedirect = async () => {
|
|||||||
// If the server returned an authorization code, attempt to exchange it for an access token
|
// If the server returned an authorization code, attempt to exchange it for an access token
|
||||||
if (q.code) {
|
if (q.code) {
|
||||||
// Verify state matches what we set at the beginning
|
// Verify state matches what we set at the beginning
|
||||||
if (localStorage.getItem("pkce_state") != q.state) {
|
if (localStorage.getItem("pkce_state") !== q.state) {
|
||||||
alert("Invalid state")
|
alert("Invalid state")
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// Exchange the authorization code for an access token
|
// Exchange the authorization code for an access token
|
||||||
tokenResponse = await sendPostRequest(localStorage.getItem("token_endpoint"), {
|
tokenResponse = await sendPostRequest(
|
||||||
grant_type: "authorization_code",
|
localStorage.getItem("tokenEndpoint"),
|
||||||
code: q.code,
|
{
|
||||||
client_id: localStorage.getItem("client_id"),
|
grant_type: "authorization_code",
|
||||||
redirect_uri: redirectUri,
|
code: q.code,
|
||||||
code_verifier: localStorage.getItem("pkce_code_verifier"),
|
client_id: localStorage.getItem("client_id"),
|
||||||
})
|
redirect_uri: redirectUri,
|
||||||
|
codeVerifier: localStorage.getItem("pkce_codeVerifier"),
|
||||||
|
}
|
||||||
|
)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(`${error.error}\n\n${error.error_description}`)
|
console.log(`${error.error}\n\n${error.error_description}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clean these up since we don't need them anymore
|
// Clean these up since we don't need them anymore
|
||||||
localStorage.removeItem("pkce_state")
|
localStorage.removeItem("pkce_state")
|
||||||
localStorage.removeItem("pkce_code_verifier")
|
localStorage.removeItem("pkce_codeVerifier")
|
||||||
localStorage.removeItem("token_endpoint")
|
localStorage.removeItem("tokenEndpoint")
|
||||||
localStorage.removeItem("client_id")
|
localStorage.removeItem("client_id")
|
||||||
return tokenResponse
|
return tokenResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,21 +15,21 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const linkParents = (node) => {
|
const linkParents = (node) => {
|
||||||
if (node.kind == "Object") {
|
if (node.kind === "Object") {
|
||||||
if (node.members) {
|
if (node.members) {
|
||||||
node.members.forEach((m) => {
|
node.members.forEach((m) => {
|
||||||
m.parent = node
|
m.parent = node
|
||||||
linkParents(m)
|
linkParents(m)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (node.kind == "Array") {
|
} else if (node.kind === "Array") {
|
||||||
if (node.values) {
|
if (node.values) {
|
||||||
node.values.forEach((v) => {
|
node.values.forEach((v) => {
|
||||||
v.parent = node
|
v.parent = node
|
||||||
linkParents(v)
|
linkParents(v)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (node.kind == "Member") {
|
} else if (node.kind === "Member") {
|
||||||
if (node.value) {
|
if (node.value) {
|
||||||
node.value.parent = node
|
node.value.parent = node
|
||||||
linkParents(node.value)
|
linkParents(node.value)
|
||||||
@@ -41,20 +41,20 @@ export default () => {
|
|||||||
let output = {}
|
let output = {}
|
||||||
path = []
|
path = []
|
||||||
let current = jsonAST
|
let current = jsonAST
|
||||||
if (current.kind == "Object") {
|
if (current.kind === "Object") {
|
||||||
path.push({ label: "{}", obj: "root" })
|
path.push({ label: "{}", obj: "root" })
|
||||||
} else if (current.kind == "Array") {
|
} else if (current.kind === "Array") {
|
||||||
path.push({ label: "[]", obj: "root" })
|
path.push({ label: "[]", obj: "root" })
|
||||||
}
|
}
|
||||||
let over = false
|
let over = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (!over) {
|
while (!over) {
|
||||||
if (current.kind == "Object") {
|
if (current.kind === "Object") {
|
||||||
let i = 0
|
let i = 0
|
||||||
let found = false
|
let found = false
|
||||||
while (i < current.members.length) {
|
while (i < current.members.length) {
|
||||||
let m = current.members[i]
|
const m = current.members[i]
|
||||||
if (m.start <= index && m.end >= index) {
|
if (m.start <= index && m.end >= index) {
|
||||||
path.push({ label: m.key.value, obj: m })
|
path.push({ label: m.key.value, obj: m })
|
||||||
current = current.members[i]
|
current = current.members[i]
|
||||||
@@ -64,12 +64,12 @@ export default () => {
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
if (!found) over = true
|
if (!found) over = true
|
||||||
} else if (current.kind == "Array") {
|
} else if (current.kind === "Array") {
|
||||||
if (current.values) {
|
if (current.values) {
|
||||||
let i = 0
|
let i = 0
|
||||||
let found = false
|
let found = false
|
||||||
while (i < current.values.length) {
|
while (i < current.values.length) {
|
||||||
let m = current.values[i]
|
const m = current.values[i]
|
||||||
if (m.start <= index && m.end >= index) {
|
if (m.start <= index && m.end >= index) {
|
||||||
path.push({ label: `[${i.toString()}]`, obj: m })
|
path.push({ label: `[${i.toString()}]`, obj: m })
|
||||||
current = current.values[i]
|
current = current.values[i]
|
||||||
@@ -80,17 +80,17 @@ export default () => {
|
|||||||
}
|
}
|
||||||
if (!found) over = true
|
if (!found) over = true
|
||||||
} else over = true
|
} else over = true
|
||||||
} else if (current.kind == "Member") {
|
} else if (current.kind === "Member") {
|
||||||
if (current.value) {
|
if (current.value) {
|
||||||
if (current.value.start <= index && current.value.end >= index) {
|
if (current.value.start <= index && current.value.end >= index) {
|
||||||
current = current.value
|
current = current.value
|
||||||
} else over = true
|
} else over = true
|
||||||
} else over = true
|
} else over = true
|
||||||
} else if (
|
} else if (
|
||||||
current.kind == "String" ||
|
current.kind === "String" ||
|
||||||
current.kind == "Number" ||
|
current.kind === "Number" ||
|
||||||
current.kind == "Boolean" ||
|
current.kind === "Boolean" ||
|
||||||
current.kind == "Null"
|
current.kind === "Null"
|
||||||
) {
|
) {
|
||||||
if (current.start <= index && current.end >= index) {
|
if (current.start <= index && current.end >= index) {
|
||||||
path.push({ label: `${current.value}`, obj: current })
|
path.push({ label: `${current.value}`, obj: current })
|
||||||
@@ -106,15 +106,13 @@ export default () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getSiblings = (index) => {
|
const getSiblings = (index) => {
|
||||||
let parent = path[index].obj.parent
|
const parent = path[index].obj.parent
|
||||||
if (!parent) return []
|
if (!parent) return []
|
||||||
else {
|
else if (parent.kind === "Object") {
|
||||||
if (parent.kind == "Object") {
|
return parent.members
|
||||||
return parent.members
|
} else if (parent.kind === "Array") {
|
||||||
} else if (parent.kind == "Array") {
|
return parent.values
|
||||||
return parent.values
|
} else return []
|
||||||
} else return []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
export default () => {
|
export default () => {
|
||||||
//*** Determine whether or not the PWA has been installed. ***//
|
//* ** Determine whether or not the PWA has been installed. ***//
|
||||||
|
|
||||||
// Step 1: Check local storage
|
// Step 1: Check local storage
|
||||||
let pwaInstalled = localStorage.getItem("pwaInstalled") === "yes"
|
let pwaInstalled = localStorage.getItem("pwaInstalled") === "yes"
|
||||||
|
|
||||||
// Step 2: Check if the display-mode is standalone. (Only permitted for PWAs.)
|
// Step 2: Check if the display-mode is standalone. (Only permitted for PWAs.)
|
||||||
if (!pwaInstalled && window.matchMedia("(display-mode: standalone)").matches) {
|
if (
|
||||||
|
!pwaInstalled &&
|
||||||
|
window.matchMedia("(display-mode: standalone)").matches
|
||||||
|
) {
|
||||||
localStorage.setItem("pwaInstalled", "yes")
|
localStorage.setItem("pwaInstalled", "yes")
|
||||||
pwaInstalled = true
|
pwaInstalled = true
|
||||||
}
|
}
|
||||||
@@ -16,7 +19,7 @@ export default () => {
|
|||||||
pwaInstalled = true
|
pwaInstalled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//*** If the PWA has not been installed, show the install PWA prompt.. ***//
|
//* ** If the PWA has not been installed, show the install PWA prompt.. ***//
|
||||||
let deferredPrompt = null
|
let deferredPrompt = null
|
||||||
window.addEventListener("beforeinstallprompt", (event) => {
|
window.addEventListener("beforeinstallprompt", (event) => {
|
||||||
deferredPrompt = event
|
deferredPrompt = event
|
||||||
@@ -28,7 +31,7 @@ export default () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// When the app is installed, remove install prompts.
|
// When the app is installed, remove install prompts.
|
||||||
window.addEventListener("appinstalled", (event) => {
|
window.addEventListener("appinstalled", () => {
|
||||||
localStorage.setItem("pwaInstalled", "yes")
|
localStorage.setItem("pwaInstalled", "yes")
|
||||||
pwaInstalled = true
|
pwaInstalled = true
|
||||||
document.getElementById("installPWA").style.display = "none"
|
document.getElementById("installPWA").style.display = "none"
|
||||||
@@ -38,12 +41,14 @@ export default () => {
|
|||||||
return async () => {
|
return async () => {
|
||||||
if (deferredPrompt) {
|
if (deferredPrompt) {
|
||||||
deferredPrompt.prompt()
|
deferredPrompt.prompt()
|
||||||
let outcome = await deferredPrompt.userChoice
|
const outcome = await deferredPrompt.userChoice
|
||||||
|
|
||||||
if (outcome === "accepted") {
|
if (outcome === "accepted") {
|
||||||
console.log("Hoppscotch was installed successfully.")
|
console.log("Hoppscotch was installed successfully.")
|
||||||
} else {
|
} else {
|
||||||
console.log("Hoppscotch could not be installed. (Installation rejected by user.)")
|
console.log(
|
||||||
|
"Hoppscotch could not be installed. (Installation rejected by user.)"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
deferredPrompt = null
|
deferredPrompt = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
export function hasPathParams(params) {
|
export function hasPathParams(params) {
|
||||||
return params
|
return params
|
||||||
.filter((item) => (item.hasOwnProperty("active") ? item.active == true : true))
|
.filter((item) =>
|
||||||
|
Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true
|
||||||
|
)
|
||||||
.some(({ type }) => type === "path")
|
.some(({ type }) => type === "path")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addPathParamsToVariables(params, variables) {
|
export function addPathParamsToVariables(params, variables) {
|
||||||
params
|
params
|
||||||
.filter((item) => (item.hasOwnProperty("active") ? item.active == true : true))
|
.filter((item) =>
|
||||||
|
Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true
|
||||||
|
)
|
||||||
.filter(({ key }) => !!key)
|
.filter(({ key }) => !!key)
|
||||||
.filter(({ type }) => type === "path")
|
.filter(({ type }) => type === "path")
|
||||||
.forEach(({ key, value }) => (variables[key] = value))
|
.forEach(({ key, value }) => (variables[key] = value))
|
||||||
@@ -15,7 +23,11 @@ export function addPathParamsToVariables(params, variables) {
|
|||||||
|
|
||||||
export function getQueryParams(params) {
|
export function getQueryParams(params) {
|
||||||
return params
|
return params
|
||||||
.filter((item) => (item.hasOwnProperty("active") ? item.active == true : true))
|
.filter((item) =>
|
||||||
|
Object.prototype.hasOwnProperty.call(item, "active")
|
||||||
|
? item.active === true
|
||||||
|
: true
|
||||||
|
)
|
||||||
.filter(({ key }) => !!key)
|
.filter(({ key }) => !!key)
|
||||||
.filter(({ type }) => type != "path")
|
.filter(({ type }) => type !== "path")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,18 @@ export const hasExtensionInstalled = () =>
|
|||||||
typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"
|
typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined"
|
||||||
|
|
||||||
export const hasChromeExtensionInstalled = () =>
|
export const hasChromeExtensionInstalled = () =>
|
||||||
hasExtensionInstalled() && /Chrome/i.test(navigator.userAgent) && /Google/i.test(navigator.vendor)
|
hasExtensionInstalled() &&
|
||||||
|
/Chrome/i.test(navigator.userAgent) &&
|
||||||
|
/Google/i.test(navigator.vendor)
|
||||||
|
|
||||||
export const hasFirefoxExtensionInstalled = () =>
|
export const hasFirefoxExtensionInstalled = () =>
|
||||||
hasExtensionInstalled() && /Firefox/i.test(navigator.userAgent)
|
hasExtensionInstalled() && /Firefox/i.test(navigator.userAgent)
|
||||||
|
|
||||||
export const cancelRunningExtensionRequest = () => {
|
export const cancelRunningExtensionRequest = () => {
|
||||||
if (hasExtensionInstalled() && window.__POSTWOMAN_EXTENSION_HOOK__.cancelRunningRequest) {
|
if (
|
||||||
|
hasExtensionInstalled() &&
|
||||||
|
window.__POSTWOMAN_EXTENSION_HOOK__.cancelRunningRequest
|
||||||
|
) {
|
||||||
window.__POSTWOMAN_EXTENSION_HOOK__.cancelRunningRequest()
|
window.__POSTWOMAN_EXTENSION_HOOK__.cancelRunningRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
__esModule: true,
|
__esModule: true,
|
||||||
settingsStore: {
|
settingsStore: {
|
||||||
value: {
|
value: {
|
||||||
PROXY_ENABLED: false
|
PROXY_ENABLED: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -18,7 +18,6 @@ axios.mockResolvedValue({})
|
|||||||
|
|
||||||
describe("axiosStrategy", () => {
|
describe("axiosStrategy", () => {
|
||||||
describe("No-Proxy Requests", () => {
|
describe("No-Proxy Requests", () => {
|
||||||
|
|
||||||
test("sends request to the actual sender if proxy disabled", async () => {
|
test("sends request to the actual sender if proxy disabled", async () => {
|
||||||
await axiosStrategy({ url: "test" })
|
await axiosStrategy({ url: "test" })
|
||||||
|
|
||||||
@@ -43,14 +42,14 @@ describe("axiosStrategy", () => {
|
|||||||
await expect(axiosStrategy({})).resolves.toBeDefined()
|
await expect(axiosStrategy({})).resolves.toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
test("rejects cancel errors with text 'cancellation'", async () => {
|
test("rejects cancel errors with text 'cancellation'", () => {
|
||||||
axios.isCancel.mockReturnValueOnce(true)
|
axios.isCancel.mockReturnValueOnce(true)
|
||||||
axios.mockRejectedValue("err")
|
axios.mockRejectedValue("err")
|
||||||
|
|
||||||
expect(axiosStrategy({})).rejects.toBe("cancellation")
|
expect(axiosStrategy({})).rejects.toBe("cancellation")
|
||||||
})
|
})
|
||||||
|
|
||||||
test("rejects non-cancellation errors as-is", async () => {
|
test("rejects non-cancellation errors as-is", () => {
|
||||||
axios.isCancel.mockReturnValueOnce(false)
|
axios.isCancel.mockReturnValueOnce(false)
|
||||||
axios.mockRejectedValue("err")
|
axios.mockRejectedValue("err")
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import axiosStrategy, { testables, cancelRunningAxiosRequest } from "../AxiosStrategy"
|
import axiosStrategy, {
|
||||||
|
testables,
|
||||||
|
cancelRunningAxiosRequest,
|
||||||
|
} from "../AxiosStrategy"
|
||||||
|
|
||||||
jest.mock("../../utils/b64", () => ({
|
jest.mock("../../utils/b64", () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
@@ -11,9 +14,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
settingsStore: {
|
settingsStore: {
|
||||||
value: {
|
value: {
|
||||||
PROXY_ENABLED: true,
|
PROXY_ENABLED: true,
|
||||||
PROXY_URL: "test"
|
PROXY_URL: "test",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -28,7 +31,6 @@ describe("cancelRunningAxiosRequest", () => {
|
|||||||
|
|
||||||
describe("axiosStrategy", () => {
|
describe("axiosStrategy", () => {
|
||||||
describe("Proxy Requests", () => {
|
describe("Proxy Requests", () => {
|
||||||
|
|
||||||
test("sends POST request to proxy if proxy is enabled", async () => {
|
test("sends POST request to proxy if proxy is enabled", async () => {
|
||||||
let passedURL
|
let passedURL
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import extensionStrategy, {
|
import extensionStrategy, {
|
||||||
hasExtensionInstalled,
|
hasExtensionInstalled,
|
||||||
hasChromeExtensionInstalled,
|
hasChromeExtensionInstalled,
|
||||||
@@ -17,9 +16,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
settingsStore: {
|
settingsStore: {
|
||||||
value: {
|
value: {
|
||||||
EXTENSIONS_ENABLED: true,
|
EXTENSIONS_ENABLED: true,
|
||||||
PROXY_ENABLED: false
|
PROXY_ENABLED: false,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -140,7 +139,6 @@ describe("extensionStrategy", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("Non-Proxy Requests", () => {
|
describe("Non-Proxy Requests", () => {
|
||||||
|
|
||||||
test("ask extension to send request", async () => {
|
test("ask extension to send request", async () => {
|
||||||
global.__POSTWOMAN_EXTENSION_HOOK__ = {
|
global.__POSTWOMAN_EXTENSION_HOOK__ = {
|
||||||
sendRequest: sendReqFunc,
|
sendRequest: sendReqFunc,
|
||||||
@@ -162,7 +160,7 @@ describe("extensionStrategy", () => {
|
|||||||
sendRequest: sendReqFunc,
|
sendRequest: sendReqFunc,
|
||||||
}
|
}
|
||||||
|
|
||||||
sendReqFunc.mockImplementation(({ method, url }) => {
|
sendReqFunc.mockImplementation(({ url }) => {
|
||||||
passedUrl = url
|
passedUrl = url
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ jest.mock("~/newstore/settings", () => {
|
|||||||
value: {
|
value: {
|
||||||
EXTENSIONS_ENABLED: true,
|
EXTENSIONS_ENABLED: true,
|
||||||
PROXY_ENABLED: true,
|
PROXY_ENABLED: true,
|
||||||
PROXY_URL: "test"
|
PROXY_URL: "test",
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -140,7 +140,6 @@ describe("extensionStrategy", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("Proxy Requests", () => {
|
describe("Proxy Requests", () => {
|
||||||
|
|
||||||
test("asks extension to send request", async () => {
|
test("asks extension to send request", async () => {
|
||||||
global.__POSTWOMAN_EXTENSION_HOOK__ = {
|
global.__POSTWOMAN_EXTENSION_HOOK__ = {
|
||||||
sendRequest: sendReqFunc,
|
sendRequest: sendReqFunc,
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ export function defineGQLLanguageMode(ace) {
|
|||||||
(aceRequire, exports) => {
|
(aceRequire, exports) => {
|
||||||
const oop = aceRequire("ace/lib/oop")
|
const oop = aceRequire("ace/lib/oop")
|
||||||
|
|
||||||
const TextHighlightRules = aceRequire("ace/mode/text_highlight_rules").TextHighlightRules
|
const TextHighlightRules = aceRequire(
|
||||||
|
"ace/mode/text_highlight_rules"
|
||||||
|
).TextHighlightRules
|
||||||
|
|
||||||
const GQLQueryTextHighlightRules = function () {
|
const GQLQueryTextHighlightRules = function () {
|
||||||
const keywords =
|
const keywords =
|
||||||
@@ -35,7 +37,7 @@ export function defineGQLLanguageMode(ace) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
token: "paren.lparen",
|
token: "paren.lparen",
|
||||||
regex: /[\[({]/,
|
regex: /[[({]/,
|
||||||
next: "start",
|
next: "start",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,7 +76,7 @@ export function defineGQLLanguageMode(ace) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
token: "constant.numeric",
|
token: "constant.numeric",
|
||||||
regex: /\d+\.?\d*[eE]?[\+\-]?\d*/,
|
regex: /\d+\.?\d*[eE]?[+-]?\d*/,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
token: "variable",
|
token: "variable",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { fb } from "../fb"
|
|
||||||
import { BehaviorSubject } from "rxjs"
|
import { BehaviorSubject } from "rxjs"
|
||||||
import { apolloClient } from "../apollo"
|
|
||||||
import gql from "graphql-tag"
|
import gql from "graphql-tag"
|
||||||
|
import { fb } from "../fb"
|
||||||
|
import { apolloClient } from "../apollo"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file deals with interfacing data provided by the
|
* This file deals with interfacing data provided by the
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { BehaviorSubject } from "rxjs"
|
import { BehaviorSubject } from "rxjs"
|
||||||
import { TeamCollection } from "./TeamCollection"
|
|
||||||
import { TeamRequest } from "./TeamRequest"
|
|
||||||
import { apolloClient } from "~/helpers/apollo"
|
|
||||||
import { rootCollectionsOfTeam, getCollectionChildren, getCollectionRequests } from "./utils"
|
|
||||||
import { gql } from "graphql-tag"
|
import { gql } from "graphql-tag"
|
||||||
import pull from "lodash/pull"
|
import pull from "lodash/pull"
|
||||||
import remove from "lodash/remove"
|
import remove from "lodash/remove"
|
||||||
|
import { TeamCollection } from "./TeamCollection"
|
||||||
|
import { TeamRequest } from "./TeamRequest"
|
||||||
|
import {
|
||||||
|
rootCollectionsOfTeam,
|
||||||
|
getCollectionChildren,
|
||||||
|
getCollectionRequests,
|
||||||
|
} from "./utils"
|
||||||
|
import { apolloClient } from "~/helpers/apollo"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: These functions deal with REFERENCES to objects and mutates them, for a simpler implementation.
|
* NOTE: These functions deal with REFERENCES to objects and mutates them, for a simpler implementation.
|
||||||
@@ -31,7 +35,7 @@ function findParentOfColl(
|
|||||||
): TeamCollection | null {
|
): TeamCollection | null {
|
||||||
for (const coll of tree) {
|
for (const coll of tree) {
|
||||||
// If the root is parent, return null
|
// If the root is parent, return null
|
||||||
if (coll.id === collID) return currentParent ? currentParent : null
|
if (coll.id === collID) return currentParent || null
|
||||||
|
|
||||||
// Else run it in children
|
// Else run it in children
|
||||||
if (coll.children) {
|
if (coll.children) {
|
||||||
@@ -51,7 +55,10 @@ function findParentOfColl(
|
|||||||
*
|
*
|
||||||
* @returns REFERENCE to the collection or null if not found
|
* @returns REFERENCE to the collection or null if not found
|
||||||
*/
|
*/
|
||||||
function findCollInTree(tree: TeamCollection[], targetID: string): TeamCollection | null {
|
function findCollInTree(
|
||||||
|
tree: TeamCollection[],
|
||||||
|
targetID: string
|
||||||
|
): TeamCollection | null {
|
||||||
for (const coll of tree) {
|
for (const coll of tree) {
|
||||||
// If the direct child matched, then return that
|
// If the direct child matched, then return that
|
||||||
if (coll.id === targetID) return coll
|
if (coll.id === targetID) return coll
|
||||||
@@ -75,7 +82,10 @@ function findCollInTree(tree: TeamCollection[], targetID: string): TeamCollectio
|
|||||||
*
|
*
|
||||||
* @returns REFERENCE to the collection or null if request not found
|
* @returns REFERENCE to the collection or null if request not found
|
||||||
*/
|
*/
|
||||||
function findCollWithReqIDInTree(tree: TeamCollection[], reqID: string): TeamCollection | null {
|
function findCollWithReqIDInTree(
|
||||||
|
tree: TeamCollection[],
|
||||||
|
reqID: string
|
||||||
|
): TeamCollection | null {
|
||||||
for (const coll of tree) {
|
for (const coll of tree) {
|
||||||
// Check in root collections (if expanded)
|
// Check in root collections (if expanded)
|
||||||
if (coll.requests) {
|
if (coll.requests) {
|
||||||
@@ -101,7 +111,10 @@ function findCollWithReqIDInTree(tree: TeamCollection[], reqID: string): TeamCol
|
|||||||
*
|
*
|
||||||
* @returns REFERENCE to the request or null if request not found
|
* @returns REFERENCE to the request or null if request not found
|
||||||
*/
|
*/
|
||||||
function findReqInTree(tree: TeamCollection[], reqID: string): TeamRequest | null {
|
function findReqInTree(
|
||||||
|
tree: TeamCollection[],
|
||||||
|
reqID: string
|
||||||
|
): TeamRequest | null {
|
||||||
for (const coll of tree) {
|
for (const coll of tree) {
|
||||||
// Check in root collections (if expanded)
|
// Check in root collections (if expanded)
|
||||||
if (coll.requests) {
|
if (coll.requests) {
|
||||||
@@ -251,7 +264,10 @@ export default class TeamCollectionAdapter {
|
|||||||
* @param {TeamCollection} collection - The collection to add to the tree
|
* @param {TeamCollection} collection - The collection to add to the tree
|
||||||
* @param {string | null} parentCollectionID - The parent of the new collection, pass null if this collection is in root
|
* @param {string | null} parentCollectionID - The parent of the new collection, pass null if this collection is in root
|
||||||
*/
|
*/
|
||||||
private addCollection(collection: TeamCollection, parentCollectionID: string | null) {
|
private addCollection(
|
||||||
|
collection: TeamCollection,
|
||||||
|
parentCollectionID: string | null
|
||||||
|
) {
|
||||||
const tree = this.collections$.value
|
const tree = this.collections$.value
|
||||||
|
|
||||||
if (!parentCollectionID) {
|
if (!parentCollectionID) {
|
||||||
@@ -276,7 +292,9 @@ export default class TeamCollectionAdapter {
|
|||||||
*
|
*
|
||||||
* @param {Partial<TeamCollection> & Pick<TeamCollection, "id">} collectionUpdate - Object defining the fields that need to be updated (ID is required to find the target)
|
* @param {Partial<TeamCollection> & Pick<TeamCollection, "id">} collectionUpdate - Object defining the fields that need to be updated (ID is required to find the target)
|
||||||
*/
|
*/
|
||||||
private updateCollection(collectionUpdate: Partial<TeamCollection> & Pick<TeamCollection, "id">) {
|
private updateCollection(
|
||||||
|
collectionUpdate: Partial<TeamCollection> & Pick<TeamCollection, "id">
|
||||||
|
) {
|
||||||
const tree = this.collections$.value
|
const tree = this.collections$.value
|
||||||
|
|
||||||
updateCollInTree(tree, collectionUpdate)
|
updateCollInTree(tree, collectionUpdate)
|
||||||
@@ -342,7 +360,9 @@ export default class TeamCollectionAdapter {
|
|||||||
*
|
*
|
||||||
* @param {Partial<TeamRequest> & Pick<TeamRequest, 'id'>} requestUpdate - Object defining all the fields to update in request (ID of the request is required)
|
* @param {Partial<TeamRequest> & Pick<TeamRequest, 'id'>} requestUpdate - Object defining all the fields to update in request (ID of the request is required)
|
||||||
*/
|
*/
|
||||||
private updateRequest(requestUpdate: Partial<TeamRequest> & Pick<TeamRequest, "id">) {
|
private updateRequest(
|
||||||
|
requestUpdate: Partial<TeamRequest> & Pick<TeamRequest, "id">
|
||||||
|
) {
|
||||||
const tree = this.collections$.value
|
const tree = this.collections$.value
|
||||||
|
|
||||||
// Find request, if not present, don't update
|
// Find request, if not present, don't update
|
||||||
@@ -526,7 +546,7 @@ export default class TeamCollectionAdapter {
|
|||||||
).map<TeamRequest>((el) => {
|
).map<TeamRequest>((el) => {
|
||||||
return {
|
return {
|
||||||
id: el.id,
|
id: el.id,
|
||||||
collectionID: collectionID,
|
collectionID,
|
||||||
title: el.title,
|
title: el.title,
|
||||||
request: JSON.parse(el.request),
|
request: JSON.parse(el.request),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export default class TeamMemberAdapter {
|
|||||||
cursor,
|
cursor,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
debugger
|
debugger
|
||||||
|
|
||||||
result.push(...response.data.team.members)
|
result.push(...response.data.team.members)
|
||||||
|
|||||||
@@ -3,5 +3,8 @@ export default function parseTemplateString(string, variables) {
|
|||||||
return string
|
return string
|
||||||
}
|
}
|
||||||
const searchTerm = /<<([^>]*)>>/g // "<<myVariable>>"
|
const searchTerm = /<<([^>]*)>>/g // "<<myVariable>>"
|
||||||
return decodeURI(encodeURI(string)).replace(searchTerm, (match, p1) => variables[p1] || "")
|
return decodeURI(encodeURI(string)).replace(
|
||||||
|
searchTerm,
|
||||||
|
(_, p1) => variables[p1] || ""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import tern from "tern"
|
import tern from "tern"
|
||||||
|
|
||||||
|
import { registerTernLinter } from "./ternlint"
|
||||||
import ECMA_DEF from "~/helpers/terndoc/ecma.json"
|
import ECMA_DEF from "~/helpers/terndoc/ecma.json"
|
||||||
import PW_PRE_DEF from "~/helpers/terndoc/pw-pre.json"
|
import PW_PRE_DEF from "~/helpers/terndoc/pw-pre.json"
|
||||||
import PW_TEST_DEF from "~/helpers/terndoc/pw-test.json"
|
import PW_TEST_DEF from "~/helpers/terndoc/pw-test.json"
|
||||||
import PW_EXTRAS_DEF from "~/helpers/terndoc/pw-extras.json"
|
import PW_EXTRAS_DEF from "~/helpers/terndoc/pw-extras.json"
|
||||||
|
|
||||||
import { registerTernLinter } from "./ternlint"
|
|
||||||
|
|
||||||
const server = new tern.Server({
|
const server = new tern.Server({
|
||||||
defs: [ECMA_DEF, PW_EXTRAS_DEF],
|
defs: [ECMA_DEF, PW_EXTRAS_DEF],
|
||||||
plugins: {
|
plugins: {
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ describe("decodeB64StringToArrayBuffer", () => {
|
|||||||
test("decodes content correctly", () => {
|
test("decodes content correctly", () => {
|
||||||
const decoder = new TextDecoder("utf-8")
|
const decoder = new TextDecoder("utf-8")
|
||||||
expect(
|
expect(
|
||||||
decoder.decode(decodeB64StringToArrayBuffer("aG9wcHNjb3RjaCBpcyBhd2Vzb21lIQ=="))
|
decoder.decode(
|
||||||
|
decodeB64StringToArrayBuffer("aG9wcHNjb3RjaCBpcyBhd2Vzb21lIQ==")
|
||||||
|
)
|
||||||
).toMatch("hoppscotch is awesome!")
|
).toMatch("hoppscotch is awesome!")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ describe("isJSONContentType", () => {
|
|||||||
|
|
||||||
test("returns true for JSON types with charset specified", () => {
|
test("returns true for JSON types with charset specified", () => {
|
||||||
expect(isJSONContentType("application/json; charset=utf-8")).toBe(true)
|
expect(isJSONContentType("application/json; charset=utf-8")).toBe(true)
|
||||||
expect(isJSONContentType("application/vnd.api+json; charset=utf-8")).toBe(true)
|
expect(isJSONContentType("application/vnd.api+json; charset=utf-8")).toBe(
|
||||||
|
true
|
||||||
|
)
|
||||||
expect(isJSONContentType("application/hal+json; charset=utf-8")).toBe(true)
|
expect(isJSONContentType("application/hal+json; charset=utf-8")).toBe(true)
|
||||||
expect(isJSONContentType("application/ld+json; charset=utf-8")).toBe(true)
|
expect(isJSONContentType("application/ld+json; charset=utf-8")).toBe(true)
|
||||||
})
|
})
|
||||||
@@ -25,7 +27,9 @@ describe("isJSONContentType", () => {
|
|||||||
test("returns false for non-JSON content types with charset", () => {
|
test("returns false for non-JSON content types with charset", () => {
|
||||||
expect(isJSONContentType("application/xml; charset=utf-8")).toBe(false)
|
expect(isJSONContentType("application/xml; charset=utf-8")).toBe(false)
|
||||||
expect(isJSONContentType("text/html; charset=utf-8")).toBe(false)
|
expect(isJSONContentType("text/html; charset=utf-8")).toBe(false)
|
||||||
expect(isJSONContentType("application/x-www-form-urlencoded; charset=utf-8")).toBe(false)
|
expect(
|
||||||
|
isJSONContentType("application/x-www-form-urlencoded; charset=utf-8")
|
||||||
|
).toBe(false)
|
||||||
expect(isJSONContentType("foo/jsoninword; charset=utf-8")).toBe(false)
|
expect(isJSONContentType("foo/jsoninword; charset=utf-8")).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ export const decodeB64StringToArrayBuffer = (input) => {
|
|||||||
const ab = new ArrayBuffer(bytes)
|
const ab = new ArrayBuffer(bytes)
|
||||||
const uarray = new Uint8Array(ab)
|
const uarray = new Uint8Array(ab)
|
||||||
|
|
||||||
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
const keyStr =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||||
|
|
||||||
let chr1, chr2, chr3
|
let chr1, chr2, chr3
|
||||||
let enc1, enc2, enc3, enc4
|
let enc1, enc2, enc3, enc4
|
||||||
let j = 0
|
let j = 0
|
||||||
|
|
||||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "")
|
input = input.replace(/[^A-Za-z0-9+/=]/g, "")
|
||||||
|
|
||||||
for (let i = 0; i < bytes; i += 3) {
|
for (let i = 0; i < bytes; i += 3) {
|
||||||
//get the 3 octets in 4 ASCII chars
|
// get the 3 octets in 4 ASCII chars
|
||||||
enc1 = keyStr.indexOf(input.charAt(j++))
|
enc1 = keyStr.indexOf(input.charAt(j++))
|
||||||
enc2 = keyStr.indexOf(input.charAt(j++))
|
enc2 = keyStr.indexOf(input.charAt(j++))
|
||||||
enc3 = keyStr.indexOf(input.charAt(j++))
|
enc3 = keyStr.indexOf(input.charAt(j++))
|
||||||
@@ -23,8 +24,8 @@ export const decodeB64StringToArrayBuffer = (input) => {
|
|||||||
chr3 = ((enc3 & 3) << 6) | enc4
|
chr3 = ((enc3 & 3) << 6) | enc4
|
||||||
|
|
||||||
uarray[i] = chr1
|
uarray[i] = chr1
|
||||||
if (enc3 != 64) uarray[i + 1] = chr2
|
if (enc3 !== 64) uarray[i + 1] = chr2
|
||||||
if (enc4 != 64) uarray[i + 2] = chr3
|
if (enc4 !== 64) uarray[i + 2] = chr3
|
||||||
}
|
}
|
||||||
|
|
||||||
return ab
|
return ab
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
export function parseUrlAndPath(value) {
|
export function parseUrlAndPath(value) {
|
||||||
let result = {}
|
const result = {}
|
||||||
try {
|
try {
|
||||||
let url = new URL(value)
|
const url = new URL(value)
|
||||||
result.url = url.origin
|
result.url = url.origin
|
||||||
result.path = url.pathname
|
result.path = url.pathname
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let uriRegex = value.match(/^((http[s]?:\/\/)?(<<[^\/]+>>)?[^\/]*|)(\/?.*)$/)
|
const uriRegex = value.match(
|
||||||
|
/^((http[s]?:\/\/)?(<<[^/]+>>)?[^/]*|)(\/?.*)$/
|
||||||
|
)
|
||||||
result.url = uriRegex[1]
|
result.url = uriRegex[1]
|
||||||
result.path = uriRegex[4]
|
result.path = uriRegex[4]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const [wsRegexIP, wsRegexHostname] = generateREForProtocol("^(wss?:\\/\\/)?")
|
const [wsRegexIP, wsRegexHostname] = generateREForProtocol("^(wss?:\\/\\/)?")
|
||||||
const [sseRegexIP, sseRegexHostname] = generateREForProtocol("^(https?:\\/\\/)?")
|
const [sseRegexIP, sseRegexHostname] =
|
||||||
|
generateREForProtocol("^(https?:\\/\\/)?")
|
||||||
const [socketioRegexIP, socketioRegexHostname] = generateREForProtocol(
|
const [socketioRegexIP, socketioRegexHostname] = generateREForProtocol(
|
||||||
"^((wss?:\\/\\/)|(https?:\\/\\/))?"
|
"^((wss?:\\/\\/)|(https?:\\/\\/))?"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user