fix: save request context set on teams

This commit is contained in:
Andrew Bastin
2021-08-20 18:25:34 +05:30
parent 7082eb27db
commit b08b06c4d4
4 changed files with 33 additions and 21 deletions

View File

@@ -116,7 +116,7 @@ export default defineComponent({
onSelect({ picked }) {
this.picked = picked
},
saveRequestAs() {
async saveRequestAs() {
if (!this.requestName) {
this.$toast.error(this.$t("error.empty_req_name"), {
icon: "error_outline",
@@ -180,33 +180,43 @@ export default defineComponent({
this.picked.requestID
)
setRESTSaveContext({
originLocation: "teams-collection",
originLocation: "team-collection",
requestID: this.picked.requestID,
})
} else if (this.picked.pickedType === "teams-folder") {
teamUtils.saveRequestAsTeams(
const req = await teamUtils.saveRequestAsTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.collectionsType.selectedTeam.id,
this.picked.folderID
)
setRESTSaveContext({
originLocation: "teams-collection",
requestID: this.picked.requestID,
})
if (req && req.id) {
setRESTSaveContext({
originLocation: "team-collection",
requestID: req.id,
teamID: this.collectionsType.selectedTeam.id,
collectionID: this.picked.folderID,
})
}
} else if (this.picked.pickedType === "teams-collection") {
teamUtils.saveRequestAsTeams(
const req = await teamUtils.saveRequestAsTeams(
this.$apollo,
JSON.stringify(requestUpdated),
requestUpdated.name,
this.collectionsType.selectedTeam.id,
this.picked.collectionID
)
setRESTSaveContext({
originLocation: "teams-collection",
requestID: this.picked.requestID,
})
if (req && req.id) {
setRESTSaveContext({
originLocation: "team-collection",
requestID: req.id,
teamID: this.collectionsType.selectedTeam.id,
collectionID: this.picked.collectionID,
})
}
} else if (this.picked.pickedType === "gql-my-request") {
editGraphqlRequest(
this.picked.folderPath,

View File

@@ -105,7 +105,7 @@
</div>
</template>
<script>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api"
import { translateToNewRequest } from "~/helpers/types/HoppRESTRequest"
import { useReadonlyStream } from "~/helpers/utils/composables"
@@ -143,7 +143,7 @@ export default defineComponent({
}
},
computed: {
isSelected() {
isSelected(): boolean {
return (
this.picked &&
this.picked.pickedType === "teams-request" &&
@@ -163,7 +163,7 @@ export default defineComponent({
else
setRESTRequest(translateToNewRequest(this.request), {
originLocation: "team-collection",
requestIndex: this.requestIndex,
requestID: this.requestIndex as string,
})
},
removeRequest() {
@@ -173,9 +173,9 @@ export default defineComponent({
requestIndex: this.$props.requestIndex,
})
},
getRequestLabelColor(method) {
getRequestLabelColor(method: any) {
return (
this.requestMethodLabels[method.toLowerCase()] ||
(this.requestMethodLabels as any)[method.toLowerCase()] ||
this.requestMethodLabels.default
)
},

View File

@@ -232,7 +232,7 @@ import {
import { defineActionHandler } from "~/helpers/actions"
import { copyToClipboard } from "~/helpers/utils/clipboard"
import { useSetting } from "~/newstore/settings"
import { saveRequestAsTeams } from "~/helpers/teams/utils"
import { overwriteRequestTeams } from "~/helpers/teams/utils"
import { apolloClient } from "~/helpers/apollo"
const methods = [
@@ -386,9 +386,9 @@ export default defineComponent({
} else if (saveCtx.originLocation === "team-collection") {
const req = getRESTRequest()
// TODO: handle error case (NOTE: saveRequestAsTeams is async)
// TODO: handle error case (NOTE: overwriteRequestTeams is async)
try {
saveRequestAsTeams(
overwriteRequestTeams(
apolloClient,
JSON.stringify(req),
req.name,