refactor: request actions + fix: timeout bug
This commit is contained in:
@@ -124,6 +124,7 @@
|
||||
@unselect-collection="$emit('remove-collection', collection)"
|
||||
@expand-collection="expandCollection"
|
||||
@remove-collection="removeCollection"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -595,6 +596,36 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
||||
if (this.collectionsType.type == "my-collections") {
|
||||
this.$store.commit("postwoman/removeRequest", {
|
||||
collectionIndex: collectionIndex,
|
||||
folderName: folderName,
|
||||
requestIndex: requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.syncCollections()
|
||||
} else if (this.collectionsType.type == "team-collections") {
|
||||
team_utils
|
||||
.deleteRequest(this.$apollo, requestIndex)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener)
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
reqIdx: $event.reqIdx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -115,6 +116,7 @@
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -224,6 +226,13 @@ export default {
|
||||
})
|
||||
this.syncCollections()
|
||||
},
|
||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex,
|
||||
folderName,
|
||||
requestIndex,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
reqIdx: $event.reqIdx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -103,6 +104,7 @@
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -206,6 +208,13 @@ export default {
|
||||
})
|
||||
this.syncCollections()
|
||||
},
|
||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex,
|
||||
folderName,
|
||||
requestIndex,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -88,20 +88,7 @@ export default {
|
||||
confirmRemove: false,
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
return {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncCollections() {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
fb.writeCollections(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
||||
"collections"
|
||||
)
|
||||
}
|
||||
},
|
||||
selectRequest() {
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-request", {
|
||||
@@ -118,16 +105,11 @@ export default {
|
||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
||||
},
|
||||
removeRequest() {
|
||||
this.$store.commit("postwoman/removeRequest", {
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folderName,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
flag: "rest",
|
||||
})
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
this.syncCollections()
|
||||
},
|
||||
getRequestLabelColor(method) {
|
||||
return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
})
|
||||
"
|
||||
@expand-collection="expandCollection"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -123,6 +124,7 @@
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -203,6 +205,13 @@ export default {
|
||||
expandCollection(collectionID) {
|
||||
this.$emit("expand-collection", collectionID)
|
||||
},
|
||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex,
|
||||
folderName,
|
||||
requestIndex,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
})
|
||||
"
|
||||
@expand-collection="expandCollection"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -107,6 +108,7 @@
|
||||
reqIdx: $event.idx,
|
||||
})
|
||||
"
|
||||
@remove-request="removeRequest"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -203,6 +205,13 @@ export default {
|
||||
expandCollection(collectionID) {
|
||||
this.$emit("expand-collection", collectionID)
|
||||
},
|
||||
removeRequest({ collectionIndex, folderName, requestIndex }) {
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex,
|
||||
folderName,
|
||||
requestIndex,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -85,20 +85,7 @@ export default {
|
||||
confirmRemove: false,
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
return {
|
||||
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncCollections() {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
fb.writeCollections(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
||||
"collections"
|
||||
)
|
||||
}
|
||||
},
|
||||
selectRequest() {
|
||||
if (this.$props.saveRequest)
|
||||
this.$emit("select-request", {
|
||||
@@ -107,30 +94,12 @@ export default {
|
||||
})
|
||||
else this.$store.commit("postwoman/selectRequest", { request: this.request })
|
||||
},
|
||||
dragStart({ dataTransfer }) {
|
||||
this.dragging = !this.dragging
|
||||
dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex)
|
||||
dataTransfer.setData("oldFolderIndex", this.$props.folderIndex)
|
||||
dataTransfer.setData("oldFolderName", this.$props.folderName)
|
||||
dataTransfer.setData("requestIndex", this.$props.requestIndex)
|
||||
},
|
||||
removeRequest() {
|
||||
team_utils
|
||||
.deleteRequest(this.$apollo, this.$props.requestIndex)
|
||||
.then((data) => {
|
||||
// Result
|
||||
this.$toast.success(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
// Error
|
||||
this.$toast.error(this.$t("error_occurred"), {
|
||||
icon: "done",
|
||||
})
|
||||
console.error(error)
|
||||
})
|
||||
this.$data.confirmRemove = false
|
||||
this.$emit("remove-request", {
|
||||
collectionIndex: this.$props.collectionIndex,
|
||||
folderName: this.$props.folderName,
|
||||
requestIndex: this.$props.requestIndex,
|
||||
})
|
||||
},
|
||||
getRequestLabelColor(method) {
|
||||
return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="row-wrapper">
|
||||
<h3 class="title">{{ $t("edit_team") }}</h3>
|
||||
<div>
|
||||
<button class="icon" @click="hideModal">
|
||||
<button class="icon" @click="ideModal">
|
||||
<i class="material-icons">close</i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -53,15 +53,17 @@
|
||||
/>
|
||||
<template slot="popover">
|
||||
<div>
|
||||
<button class="icon" v-close-popover @click="member.role = 'OWNER'">OWNER</button>
|
||||
<button class="icon" v-close-popover @click="updateRole(index, 'OWNER')">
|
||||
OWNER
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" v-close-popover @click="member.role = 'EDITOR'">
|
||||
<button class="icon" v-close-popover @click="updateRole(index, 'EDITOR')">
|
||||
EDITOR
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="icon" v-close-popover @click="member.role = 'VIEWER'">
|
||||
<button class="icon" v-close-popover @click="updateRole(index, 'VIEWER')">
|
||||
VIEWER
|
||||
</button>
|
||||
</div>
|
||||
@@ -304,6 +306,9 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateRole(id, role) {
|
||||
this.teamMembers[id].role = role
|
||||
},
|
||||
addTeamMember() {
|
||||
let value = { key: "", value: "" }
|
||||
this.members.push(value)
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<div class="row-wrapper">
|
||||
<div>
|
||||
<button class="icon" v-tooltip.right="$t('use_team')">
|
||||
<button
|
||||
class="icon"
|
||||
@click="team.myRole === 'OWNER' ? $emit('edit-team') : ''"
|
||||
v-tooltip.right="$t('edit')"
|
||||
>
|
||||
<i class="material-icons">group</i>
|
||||
<span>{{ team.name }}</span>
|
||||
</button>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ApolloClient, HttpLink, InMemoryCache, split } from "@apollo/client/core";
|
||||
import { WebSocketLink } from "@apollo/client/link/ws";
|
||||
import { setContext } from '@apollo/client/link/context';
|
||||
import { fb } from "./fb";
|
||||
import { getMainDefinition } from "@apollo/client/utilities";
|
||||
import { ApolloClient, HttpLink, InMemoryCache, split } from "@apollo/client/core"
|
||||
import { WebSocketLink } from "@apollo/client/link/ws"
|
||||
import { setContext } from "@apollo/client/link/context"
|
||||
import { fb } from "./fb"
|
||||
import { getMainDefinition } from "@apollo/client/utilities"
|
||||
|
||||
/**
|
||||
* Stores the current authentication token
|
||||
@@ -10,14 +10,14 @@ import { getMainDefinition } from "@apollo/client/utilities";
|
||||
* The token stored here is the Firebase Auth token.
|
||||
* If null, no token is passed (no user signed in)
|
||||
*/
|
||||
let authToken: string | null = null;
|
||||
let authToken: string | null = null
|
||||
|
||||
/*
|
||||
* Updates the token value on Firebase ID Token changes
|
||||
*/
|
||||
fb.idToken$.subscribe(newToken => {
|
||||
authToken = newToken;
|
||||
});
|
||||
fb.idToken$.subscribe((newToken) => {
|
||||
authToken = newToken
|
||||
})
|
||||
|
||||
/**
|
||||
* Injects auth token if available
|
||||
@@ -27,63 +27,62 @@ const authLink = setContext((_, { headers }) => {
|
||||
return {
|
||||
headers: {
|
||||
...headers,
|
||||
authorization: `Bearer ${authToken}`
|
||||
}
|
||||
authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
headers
|
||||
headers,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const httpLink = new HttpLink({
|
||||
uri: process.env.CONTEXT === "production"
|
||||
? "https://api.hoppscotch.io/graphql"
|
||||
: "https://api.hoppscotch.io/graphql",
|
||||
uri:
|
||||
process.env.CONTEXT === "production"
|
||||
? "https://api.hoppscotch.io/graphql"
|
||||
: "https://api.hoppscotch.io/graphql",
|
||||
})
|
||||
|
||||
|
||||
const wsLink = new WebSocketLink({
|
||||
uri: process.env.CONTEXT === "production"
|
||||
? "wss://api.hoppscotch.io/graphql"
|
||||
: "wss://api.hoppscotch.io/graphql",
|
||||
uri:
|
||||
process.env.CONTEXT === "production"
|
||||
? "wss://api.hoppscotch.io/graphql"
|
||||
: "wss://api.hoppscotch.io/graphql",
|
||||
options: {
|
||||
lazy: true,
|
||||
reconnect: true,
|
||||
timeout: 300,
|
||||
lazy: true,
|
||||
connectionParams: () => {
|
||||
console.log("WS Authorization")
|
||||
console.log(authToken)
|
||||
|
||||
return {
|
||||
authorization: `Bearer ${authToken}`
|
||||
authorization: `Bearer ${authToken}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const splitLink = split(
|
||||
({ query }) => {
|
||||
const definition = getMainDefinition(query);
|
||||
return (
|
||||
definition.kind === 'OperationDefinition' &&
|
||||
definition.operation === 'subscription'
|
||||
)
|
||||
},
|
||||
wsLink,
|
||||
httpLink
|
||||
);
|
||||
const definition = getMainDefinition(query)
|
||||
return definition.kind === "OperationDefinition" && definition.operation === "subscription"
|
||||
},
|
||||
wsLink,
|
||||
httpLink
|
||||
)
|
||||
|
||||
export const apolloClient = new ApolloClient({
|
||||
link: authLink.concat(splitLink),
|
||||
cache: new InMemoryCache(),
|
||||
defaultOptions: {
|
||||
query: {
|
||||
fetchPolicy: 'network-only',
|
||||
errorPolicy: 'ignore'
|
||||
fetchPolicy: "network-only",
|
||||
errorPolicy: "ignore",
|
||||
},
|
||||
watchQuery: {
|
||||
fetchPolicy: 'network-only',
|
||||
errorPolicy: 'ignore'
|
||||
}
|
||||
}
|
||||
});
|
||||
fetchPolicy: "network-only",
|
||||
errorPolicy: "ignore",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user