fix: remove confirm change popup and add ability to overwrite request in saveas popup (#2433)

This commit is contained in:
Nivedin
2022-06-22 15:21:35 +05:30
committed by GitHub
parent 8fefd37862
commit c8dec56b96
2 changed files with 28 additions and 60 deletions

View File

@@ -324,19 +324,22 @@ const setRestReq = (request: any) => {
/** Loads request from the save once, checks for unsaved changes, but ignores default values */
const selectRequest = () => {
if (!active.value) {
// Check if this is a save as request popup, if so we don't need to prompt the confirm change popup.
if (props.saveRequest) {
emit("select", {
picked: {
pickedType: "my-request",
collectionIndex: props.collectionIndex,
folderPath: props.folderPath,
folderName: props.folderName,
requestIndex: props.requestIndex,
},
})
} else if (isEqualHoppRESTRequest(props.request, getDefaultRESTRequest())) {
confirmChange.value = false
setRestReq(props.request)
} else if (!active.value) {
confirmChange.value = true
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "my-request",
collectionIndex: props.collectionIndex,
folderPath: props.folderPath,
folderName: props.folderName,
requestIndex: props.requestIndex,
},
})
} else {
const currentReqWithNoChange = active.value.req
const currentFullReq = getRESTRequest()
@@ -346,16 +349,6 @@ const selectRequest = () => {
// Check if there is any changes done on the current request
if (isEqualHoppRESTRequest(currentReqWithNoChange, currentFullReq)) {
setRestReq(props.request)
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "my-request",
collectionIndex: props.collectionIndex,
folderPath: props.folderPath,
folderName: props.folderName,
requestIndex: props.requestIndex,
},
})
} else {
confirmChange.value = true
}
@@ -363,9 +356,6 @@ const selectRequest = () => {
setRESTSaveContext(null)
}
}
if (isEqualHoppRESTRequest(getRESTRequest(), getDefaultRESTRequest())) {
confirmChange.value = false
}
}
/** Save current request to the collection */
@@ -378,16 +368,6 @@ const saveRequestChange = () => {
/** Discard changes and change the current request and context */
const discardRequestChange = () => {
setRestReq(props.request)
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "my-request",
collectionIndex: props.collectionIndex,
folderPath: props.folderPath,
folderName: props.folderName,
requestIndex: props.requestIndex,
},
})
if (!isActive.value) {
setRESTSaveContext({
originLocation: "user-collection",

View File

@@ -261,7 +261,7 @@ const active = useReadonlyStream(restSaveContext$, null)
const isSelected = computed(
() =>
props.picked &&
props.picked.pickedType === "team-collection" &&
props.picked.pickedType === "teams-collection" &&
props.picked.requestID === props.requestIndex
)
@@ -308,16 +308,19 @@ const setRestReq = (request: HoppRESTRequest) => {
}
const selectRequest = () => {
if (!active.value) {
// Check if this is a save as request popup, if so we don't need to prompt the confirm change popup.
if (props.saveRequest) {
emit("select", {
picked: {
pickedType: "teams-collection",
requestID: props.requestIndex,
},
})
} else if (isEqualHoppRESTRequest(props.request, getDefaultRESTRequest())) {
confirmChange.value = false
setRestReq(props.request)
} else if (!active.value) {
confirmChange.value = true
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "team-collection",
requestID: props.requestIndex,
},
})
} else {
const currentReqWithNoChange = active.value.req
const currentFullReq = getRESTRequest()
@@ -327,13 +330,6 @@ const selectRequest = () => {
// Check if there is any changes done on the current request
if (isEqualHoppRESTRequest(currentReqWithNoChange, currentFullReq)) {
setRestReq(props.request)
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "team-collection",
requestID: props.requestIndex,
},
})
} else {
confirmChange.value = true
}
@@ -353,13 +349,6 @@ const saveRequestChange = () => {
/** Discard changes and change the current request and context */
const discardRequestChange = () => {
setRestReq(props.request)
if (props.saveRequest)
emit("select", {
picked: {
pickedType: "team-collection",
requestID: props.requestIndex,
},
})
if (!isActive.value) {
setRESTSaveContext({
originLocation: "team-collection",
@@ -367,7 +356,6 @@ const discardRequestChange = () => {
req: props.request,
})
}
confirmChange.value = false
}