fix: kernel-io calls via openExternalLink (#4807)
This commit is contained in:
parent
ae0303415a
commit
5f0acab055
9 changed files with 52 additions and 18 deletions
|
|
@ -48,7 +48,8 @@ defineEmits<{
|
|||
}>()
|
||||
|
||||
const openWhatsNew = () => {
|
||||
if (props.notesUrl) platform.kernelIO.openExternalLink(props.notesUrl)
|
||||
if (props.notesUrl)
|
||||
platform.kernelIO.openExternalLink({ url: props.notesUrl })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ const HoppGistCollectionsExporter: ImporterOrExporter = {
|
|||
platform: "rest",
|
||||
})
|
||||
|
||||
platform.kernelIO.openExternalLink(res.right)
|
||||
platform.kernelIO.openExternalLink({ url: res.right })
|
||||
} else {
|
||||
toast.error(collectionJSON.left)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ const GqlCollectionsGistExporter: ImporterOrExporter = {
|
|||
exporter: "gist",
|
||||
})
|
||||
|
||||
platform.kernelIO.openExternalLink(res.right)
|
||||
platform.kernelIO.openExternalLink({ url: res.right })
|
||||
}
|
||||
|
||||
isGqlCollectionGistExportInProgress.value = false
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ const HoppEnvironmentsGistExporter: ImporterOrExporter = {
|
|||
platform: "rest",
|
||||
})
|
||||
|
||||
platform.kernelIO.openExternalLink(res.right)
|
||||
platform.kernelIO.openExternalLink({ url: res.right })
|
||||
}
|
||||
|
||||
isEnvironmentGistExportInProgress.value = false
|
||||
|
|
|
|||
|
|
@ -42,11 +42,24 @@ export type SaveFileWithDialogOptions = {
|
|||
}>
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for opening an external link.
|
||||
*/
|
||||
export type OpenExternalLinkOptions = {
|
||||
/**
|
||||
* The URL to open.
|
||||
*/
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Response from a file save operation.
|
||||
*/
|
||||
export type SaveFileResponse =
|
||||
| {
|
||||
/**
|
||||
* The implementation was unable to determine the status of the save operation.
|
||||
* This cannot be considered a success or a failure and should be handled as an uncertainity.
|
||||
* This cannot be considered a success or a failure and should be handled as an uncertainty.
|
||||
* The browser standard implementation (std) returns this value as there is no way to
|
||||
* check if the user downloaded the file or not.
|
||||
*/
|
||||
|
|
@ -70,6 +83,29 @@ export type SaveFileResponse =
|
|||
path: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Response from an external link operation.
|
||||
*/
|
||||
export type OpenExternalLinkResponse =
|
||||
| {
|
||||
/**
|
||||
* The implementation was unable to determine the status of the open operation.
|
||||
*/
|
||||
type: "unknown"
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* The result is known and the user cancelled the open action.
|
||||
*/
|
||||
type: "cancelled"
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* The result is known and the link was opened successfully.
|
||||
*/
|
||||
type: "opened"
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform definitions for how to handle IO operations.
|
||||
*/
|
||||
|
|
@ -85,7 +121,8 @@ export type KernelIO = {
|
|||
/**
|
||||
* Opens a link in the user's browser.
|
||||
* The expected behaviour is for the browser to open a new tab/window (for example in desktop app) with the given URL.
|
||||
* @param url The URL to open
|
||||
*/
|
||||
openExternalLink: (url: string) => Promise<void>
|
||||
openExternalLink: (
|
||||
opts: OpenExternalLinkOptions
|
||||
) => Promise<OpenExternalLinkResponse>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { computed, markRaw, ref } from "vue"
|
||||
import { computed, markRaw } from "vue"
|
||||
import { Service } from "dioc"
|
||||
import type { RelayRequest, RelayResponse } from "@hoppscotch/kernel"
|
||||
import { body } from "@hoppscotch/kernel"
|
||||
|
|
@ -147,10 +147,7 @@ export class ExtensionKernelInterceptorService
|
|||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers: response.headers,
|
||||
body: body.body(
|
||||
response.data,
|
||||
response.headers["content-type"]
|
||||
),
|
||||
body: body.body(response.data, response.headers["content-type"]),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,9 +119,8 @@ export class KernelInterceptorExtensionStore extends Service {
|
|||
})
|
||||
|
||||
window.__HOPP_EXTENSION_STATUS_PROXY__ = statusProxy
|
||||
statusProxy.subscribe(
|
||||
"status",
|
||||
(status: ExtensionStatus) => this.updateSettings({ status })
|
||||
statusProxy.subscribe("status", (status: ExtensionStatus) =>
|
||||
this.updateSettings({ status })
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export const kernelIO: KernelIO = {
|
|||
saveFileWithDialog(opts) {
|
||||
return Io.saveFileWithDialog(opts)
|
||||
},
|
||||
openExternalLink(url) {
|
||||
return Io.openExternalLink(url)
|
||||
openExternalLink(opts) {
|
||||
return Io.openExternalLink(opts)
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export class GeneralSpotlightSearcherService extends StaticSpotlightSearcherServ
|
|||
}
|
||||
|
||||
private openURL(url: string) {
|
||||
platform.kernelIO.openExternalLink(url)
|
||||
platform.kernelIO.openExternalLink({ url })
|
||||
}
|
||||
|
||||
public onDocSelected(id: string): void {
|
||||
|
|
|
|||
Loading…
Reference in a new issue