duplicate identifier for requests fixed (#1346)

Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
Hari Narayanan
2020-11-27 17:12:33 +05:30
committed by GitHub
parent a5a812d3f4
commit 57627367f5
5 changed files with 30 additions and 30 deletions

View File

@@ -17,12 +17,11 @@
<div slot="body"> <div slot="body">
<ul> <ul>
<li> <li>
<label for="selectLabel">{{ $t("label") }}</label> <label for="selectLabel">{{ $t("token_req_name") }}</label>
<input <input
type="text" type="text"
id="selectLabel" id="selectLabel"
v-model="requestData.name" v-model="requestData.name"
:placeholder="defaultRequestName"
@keyup.enter="saveRequestAs" @keyup.enter="saveRequestAs"
/> />
<label for="selectCollection">{{ $t("collection") }}</label> <label for="selectCollection">{{ $t("collection") }}</label>
@@ -89,7 +88,7 @@ export default {
}, },
data() { data() {
return { return {
defaultRequestName: "My Request", defaultRequestName: "Untitled Request",
requestData: { requestData: {
name: undefined, name: undefined,
collectionIndex: undefined, collectionIndex: undefined,
@@ -108,8 +107,8 @@ export default {
"requestData.folderName": function resetRequestIndex() { "requestData.folderName": function resetRequestIndex() {
this.$data.requestData.requestIndex = undefined this.$data.requestData.requestIndex = undefined
}, },
editingRequest({ label }) { editingRequest({ name }) {
this.defaultRequestName = label || "My Request" this.$data.requestData.name = name || this.$data.defaultRequestName
}, },
}, },
computed: { computed: {
@@ -168,10 +167,16 @@ export default {
}) })
return return
} }
if (this.$data.requestData.name.length === 0) {
this.$toast.error(this.$t("empty_req_name"), {
icon: "error",
})
return
}
const requestUpdated = { const requestUpdated = {
...this.$props.editingRequest, ...this.$props.editingRequest,
name: this.$data.requestData.name || this.$data.defaultRequestName, name: this.$data.requestData.name,
collection: this.$data.requestData.collectionIndex, collection: this.$data.requestData.collectionIndex,
} }

View File

@@ -23,11 +23,11 @@
</button> </button>
<li> <li>
<input <input
:aria-label="$t('label')" :aria-label="$t('token_req_name')"
type="text" type="text"
readonly readonly
:value="entry.label" :value="entry.name"
:placeholder="$t('no_label')" :placeholder="$t('empty_req_name')"
class="bg-color" class="bg-color"
/> />
</li> </li>

View File

@@ -103,6 +103,7 @@
"manage_token_req": "Manage Token Request", "manage_token_req": "Manage Token Request",
"use_token_req": "Use Token Request", "use_token_req": "Use Token Request",
"token_req_name": "Request Name", "token_req_name": "Request Name",
"empty_req_name": "Empty Request Name",
"token_req_details": "Request Details", "token_req_details": "Request Details",
"token_name": "Token Name", "token_name": "Token Name",
"oidc_discovery_url": "OIDC Discovery URL", "oidc_discovery_url": "OIDC Discovery URL",
@@ -294,4 +295,4 @@
"experiments": "Experiments", "experiments": "Experiments",
"experiments_notice": "This is a collection of experiments we're working on that might turn out to be useful, fun, both, or neither. They're not final and may not be stable, so if something overly weird happens, don't panic. Just turn the dang thing off. Jokes aside, ", "experiments_notice": "This is a collection of experiments we're working on that might turn out to be useful, fun, both, or neither. They're not final and may not be stable, so if something overly weird happens, don't panic. Just turn the dang thing off. Jokes aside, ",
"use_experimental_url_bar": "Use experimental URL bar with environment highlighting" "use_experimental_url_bar": "Use experimental URL bar with environment highlighting"
} }

View File

@@ -178,14 +178,8 @@
</li> </li>
</ul> </ul>
<div class="blue"> <div class="blue">
<label for="label">{{ $t("label") }}</label> <label for="name">{{ $t("token_req_name") }}</label>
<input <input id="name" name="name" type="text" v-model="name" />
id="label"
name="label"
type="text"
v-model="label"
:placeholder="$t('optional')"
/>
</div> </div>
<div <div
class="blue" class="blue"
@@ -1461,7 +1455,7 @@ export default {
this.testsEnabled = true this.testsEnabled = true
this.testScript = newValue.testScript this.testScript = newValue.testScript
} }
this.label = newValue.label this.name = newValue.name
}, },
editingRequest(newValue) { editingRequest(newValue) {
this.editRequest = newValue this.editRequest = newValue
@@ -1528,12 +1522,12 @@ export default {
this.$store.commit("setState", { value, attribute: "path" }) this.$store.commit("setState", { value, attribute: "path" })
}, },
}, },
label: { name: {
get() { get() {
return this.$store.state.request.label return this.$store.state.request.name
}, },
set(value) { set(value) {
this.$store.commit("setState", { value, attribute: "label" }) this.$store.commit("setState", { value, attribute: "name" })
}, },
}, },
auth: { auth: {
@@ -1739,7 +1733,7 @@ export default {
return this.$store.state.postwoman.editingRequest return this.$store.state.postwoman.editingRequest
}, },
requestName() { requestName() {
return this.label return this.name
}, },
statusCategory() { statusCategory() {
return findStatusGroup(this.response.status) return findStatusGroup(this.response.status)
@@ -1878,7 +1872,7 @@ export default {
}) })
}, },
handleUseHistory(entry) { handleUseHistory(entry) {
this.label = entry.label this.name = entry.name
this.method = entry.method this.method = entry.method
this.uri = entry.url + entry.path this.uri = entry.url + entry.path
this.url = entry.url this.url = entry.url
@@ -2021,7 +2015,7 @@ export default {
this.response.body = payload.data this.response.body = payload.data
// Addition of an entry to the history component. // Addition of an entry to the history component.
const entry = { const entry = {
label: this.requestName, name: this.requestName,
status: this.response.status, status: this.response.status,
date: new Date().toLocaleDateString(), date: new Date().toLocaleDateString(),
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
@@ -2076,7 +2070,7 @@ export default {
this.response.body = error.response.data this.response.body = error.response.data
// Addition of an entry to the history component. // Addition of an entry to the history component.
const entry = { const entry = {
label: this.requestName, name: this.requestName,
status: this.response.status, status: this.response.status,
date: new Date().toLocaleDateString(), date: new Date().toLocaleDateString(),
time: new Date().toLocaleTimeString(), time: new Date().toLocaleTimeString(),
@@ -2427,7 +2421,7 @@ export default {
this.url = "https://httpbin.org" this.url = "https://httpbin.org"
this.path = "/get" this.path = "/get"
this.uri = this.url + this.path this.uri = this.url + this.path
this.label = "" this.name = "Untitled request"
this.bodyParams = [] this.bodyParams = []
this.rawParams = "{}" this.rawParams = "{}"
this.files = [] this.files = []
@@ -2480,7 +2474,7 @@ export default {
requestType: this.requestType, requestType: this.requestType,
preRequestScript: this.showPreRequestScript == true ? this.preRequestScript : null, preRequestScript: this.showPreRequestScript == true ? this.preRequestScript : null,
testScript: this.testsEnabled == true ? this.testScript : null, testScript: this.testsEnabled == true ? this.testScript : null,
label: this.requestName, name: this.requestName,
} }
if (this.selectedRequest.url) { if (this.selectedRequest.url) {
this.editRequest = Object.assign({}, this.selectedRequest, this.editRequest) this.editRequest = Object.assign({}, this.selectedRequest, this.editRequest)
@@ -2701,7 +2695,7 @@ export default {
if (Object.keys(this.$route.query).length) this.setRouteQueries(this.$route.query) if (Object.keys(this.$route.query).length) this.setRouteQueries(this.$route.query)
this.$watch( this.$watch(
(vm) => [ (vm) => [
vm.label, vm.name,
vm.method, vm.method,
vm.url, vm.url,
vm.auth, vm.auth,

View File

@@ -1,10 +1,10 @@
export default () => ({ export default () => ({
request: { request: {
name: "Untitled request",
method: "GET", method: "GET",
uri: "", uri: "",
url: "https://httpbin.org", url: "https://httpbin.org",
path: "/get", path: "/get",
label: "",
auth: "None", auth: "None",
httpUser: "", httpUser: "",
httpPassword: "", httpPassword: "",