Compare commits
8 Commits
feat/pat-u
...
feat/app-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7411e36880 | ||
|
|
05ad84f372 | ||
|
|
0c993d0e90 | ||
|
|
10cb900bd7 | ||
|
|
8fd6b2ffb0 | ||
|
|
e6e300ca86 | ||
|
|
5bac6222a0 | ||
|
|
cf37fbd610 |
@@ -568,7 +568,9 @@
|
|||||||
"generated_code": "Generated code",
|
"generated_code": "Generated code",
|
||||||
"go_to_authorization_tab": "Go to Authorization tab",
|
"go_to_authorization_tab": "Go to Authorization tab",
|
||||||
"go_to_body_tab": "Go to Body tab",
|
"go_to_body_tab": "Go to Body tab",
|
||||||
|
"graphql_placeholder": "Enter a URL",
|
||||||
"header_list": "Header List",
|
"header_list": "Header List",
|
||||||
|
"http_placeholder":"Enter a URL or cURL command",
|
||||||
"invalid_name": "Please provide a name for the request",
|
"invalid_name": "Please provide a name for the request",
|
||||||
"method": "Method",
|
"method": "Method",
|
||||||
"moved": "Request moved",
|
"moved": "Request moved",
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ import { platform } from "~/platform"
|
|||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
|
import { getDefaultRESTRequest } from "~/helpers/rest/default"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -221,6 +223,15 @@ const saveRequestAs = async () => {
|
|||||||
|
|
||||||
requestUpdated.name = requestName.value
|
requestUpdated.name = requestName.value
|
||||||
|
|
||||||
|
if (props.mode === "rest") {
|
||||||
|
;(requestUpdated as HoppRESTRequest).endpoint =
|
||||||
|
(requestUpdated as HoppRESTRequest).endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint
|
||||||
|
} else {
|
||||||
|
;(requestUpdated as HoppGQLRequest).url =
|
||||||
|
(requestUpdated as HoppGQLRequest).url || getDefaultGQLRequest().url
|
||||||
|
}
|
||||||
|
|
||||||
if (picked.value.pickedType === "my-collection") {
|
if (picked.value.pickedType === "my-collection") {
|
||||||
if (!isHoppRESTRequest(requestUpdated))
|
if (!isHoppRESTRequest(requestUpdated))
|
||||||
throw new Error("requestUpdated is not a REST Request")
|
throw new Error("requestUpdated is not a REST Request")
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ import { PersistedOAuthConfig } from "~/services/oauth/oauth.service"
|
|||||||
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
|
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
|
||||||
import { EditingProperties } from "../Properties.vue"
|
import { EditingProperties } from "../Properties.vue"
|
||||||
import { defineActionHandler } from "~/helpers/actions"
|
import { defineActionHandler } from "~/helpers/actions"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -380,32 +381,26 @@ const editCollection = (
|
|||||||
displayModalEdit(true)
|
displayModalEdit(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onAddRequest = ({
|
const onAddRequest = ({ name, path }: { name: string; path: string }) => {
|
||||||
name,
|
|
||||||
path,
|
|
||||||
index,
|
|
||||||
}: {
|
|
||||||
name: string
|
|
||||||
path: string
|
|
||||||
index: number
|
|
||||||
}) => {
|
|
||||||
const newRequest = {
|
const newRequest = {
|
||||||
...tabs.currentActiveTab.value.document.request,
|
...tabs.currentActiveTab.value.document.request,
|
||||||
name,
|
name,
|
||||||
|
url:
|
||||||
|
tabs.currentActiveTab.value.document.request.url ||
|
||||||
|
getDefaultGQLRequest().url,
|
||||||
}
|
}
|
||||||
|
|
||||||
saveGraphqlRequestAs(path, newRequest)
|
const insertionIndex = saveGraphqlRequestAs(path, newRequest)
|
||||||
|
|
||||||
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
||||||
path,
|
path,
|
||||||
"graphql"
|
"graphql"
|
||||||
)
|
)
|
||||||
|
|
||||||
tabs.createNewTab({
|
tabs.createNewTab({
|
||||||
saveContext: {
|
saveContext: {
|
||||||
originLocation: "user-collection",
|
originLocation: "user-collection",
|
||||||
folderPath: path,
|
folderPath: path,
|
||||||
requestIndex: index,
|
requestIndex: insertionIndex,
|
||||||
},
|
},
|
||||||
request: newRequest,
|
request: newRequest,
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ import { PersistenceService } from "~/services/persistence"
|
|||||||
import { PersistedOAuthConfig } from "~/services/oauth/oauth.service"
|
import { PersistedOAuthConfig } from "~/services/oauth/oauth.service"
|
||||||
import { RESTOptionTabs } from "../http/RequestOptions.vue"
|
import { RESTOptionTabs } from "../http/RequestOptions.vue"
|
||||||
import { EditingProperties } from "./Properties.vue"
|
import { EditingProperties } from "./Properties.vue"
|
||||||
|
import { getDefaultRESTRequest } from "~/helpers/rest/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
@@ -790,6 +791,9 @@ const onAddRequest = (requestName: string) => {
|
|||||||
const newRequest = {
|
const newRequest = {
|
||||||
...cloneDeep(tabs.currentActiveTab.value.document.request),
|
...cloneDeep(tabs.currentActiveTab.value.document.request),
|
||||||
name: requestName,
|
name: requestName,
|
||||||
|
endpoint:
|
||||||
|
tabs.currentActiveTab.value.document.request.endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
const path = editingFolderPath.value
|
const path = editingFolderPath.value
|
||||||
|
|||||||
@@ -3,16 +3,13 @@
|
|||||||
class="sticky top-0 z-10 flex flex-shrink-0 space-x-2 overflow-x-auto bg-primary p-4"
|
class="sticky top-0 z-10 flex flex-shrink-0 space-x-2 overflow-x-auto bg-primary p-4"
|
||||||
>
|
>
|
||||||
<div class="inline-flex flex-1 space-x-2">
|
<div class="inline-flex flex-1 space-x-2">
|
||||||
<input
|
<SmartEnvInput
|
||||||
id="url"
|
|
||||||
v-model="url"
|
v-model="url"
|
||||||
type="url"
|
:placeholder="getDefaultGQLRequest().url"
|
||||||
autocomplete="off"
|
:placeholder-hover-string="t('request.graphql_placeholder')"
|
||||||
spellcheck="false"
|
:readonly="connected"
|
||||||
class="w-full rounded border border-divider bg-primaryLight px-4 py-2 text-secondaryDark"
|
class="rounded border border-divider bg-primaryLight"
|
||||||
:placeholder="`${t('request.url')}`"
|
@enter="onConnectClick"
|
||||||
:disabled="connected"
|
|
||||||
@keyup.enter="onConnectClick"
|
|
||||||
/>
|
/>
|
||||||
<HoppButtonPrimary
|
<HoppButtonPrimary
|
||||||
id="get"
|
id="get"
|
||||||
@@ -72,6 +69,7 @@ import { InterceptorService } from "~/services/interceptor.service"
|
|||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { defineActionHandler } from "~/helpers/actions"
|
import { defineActionHandler } from "~/helpers/actions"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const tabs = useService(GQLTabService)
|
const tabs = useService(GQLTabService)
|
||||||
@@ -98,7 +96,10 @@ const onConnectClick = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gqlConnect = () => {
|
const gqlConnect = () => {
|
||||||
connect(url.value, tabs.currentActiveTab.value?.document.request.headers)
|
connect(
|
||||||
|
url.value || getDefaultGQLRequest().url,
|
||||||
|
tabs.currentActiveTab.value?.document.request.headers
|
||||||
|
)
|
||||||
|
|
||||||
platform.analytics?.logEvent({
|
platform.analytics?.logEvent({
|
||||||
type: "HOPP_REQUEST_RUN",
|
type: "HOPP_REQUEST_RUN",
|
||||||
@@ -118,7 +119,9 @@ watch(
|
|||||||
tabs.currentActiveTab,
|
tabs.currentActiveTab,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
lastTwoUrls.value.push(newVal.document.request.url)
|
lastTwoUrls.value.push(
|
||||||
|
newVal.document.request.url ?? getDefaultGQLRequest().url
|
||||||
|
)
|
||||||
if (lastTwoUrls.value.length > 2) {
|
if (lastTwoUrls.value.length > 2) {
|
||||||
lastTwoUrls.value.shift()
|
lastTwoUrls.value.shift()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import { InterceptorService } from "~/services/interceptor.service"
|
|||||||
import { editGraphqlRequest } from "~/newstore/collections"
|
import { editGraphqlRequest } from "~/newstore/collections"
|
||||||
import { GQLTabService } from "~/services/tab/graphql"
|
import { GQLTabService } from "~/services/tab/graphql"
|
||||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||||
|
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||||
|
|
||||||
const VALID_GQL_OPERATIONS = [
|
const VALID_GQL_OPERATIONS = [
|
||||||
"query",
|
"query",
|
||||||
@@ -119,7 +120,9 @@ const request = useVModel(props, "modelValue", emit)
|
|||||||
|
|
||||||
const url = computedWithControl(
|
const url = computedWithControl(
|
||||||
() => tabs.currentActiveTab.value,
|
() => tabs.currentActiveTab.value,
|
||||||
() => tabs.currentActiveTab.value.document.request.url
|
() =>
|
||||||
|
tabs.currentActiveTab.value.document.request.url ||
|
||||||
|
getDefaultGQLRequest().url
|
||||||
)
|
)
|
||||||
|
|
||||||
const activeGQLHeadersCount = computed(
|
const activeGQLHeadersCount = computed(
|
||||||
@@ -247,10 +250,16 @@ const saveRequest = () => {
|
|||||||
tabs.currentActiveTab.value.document.saveContext.originLocation ===
|
tabs.currentActiveTab.value.document.saveContext.originLocation ===
|
||||||
"user-collection"
|
"user-collection"
|
||||||
) {
|
) {
|
||||||
|
const finalRequest = {
|
||||||
|
...tabs.currentActiveTab.value.document.request,
|
||||||
|
url:
|
||||||
|
tabs.currentActiveTab.value.document.request.url ||
|
||||||
|
getDefaultGQLRequest().url,
|
||||||
|
}
|
||||||
editGraphqlRequest(
|
editGraphqlRequest(
|
||||||
tabs.currentActiveTab.value.document.saveContext.folderPath,
|
tabs.currentActiveTab.value.document.saveContext.folderPath,
|
||||||
tabs.currentActiveTab.value.document.saveContext.requestIndex,
|
tabs.currentActiveTab.value.document.saveContext.requestIndex,
|
||||||
tabs.currentActiveTab.value.document.request
|
finalRequest
|
||||||
)
|
)
|
||||||
|
|
||||||
tabs.currentActiveTab.value.document.isDirty = false
|
tabs.currentActiveTab.value.document.isDirty = false
|
||||||
|
|||||||
@@ -54,9 +54,10 @@
|
|||||||
>
|
>
|
||||||
<SmartEnvInput
|
<SmartEnvInput
|
||||||
v-model="tab.document.request.endpoint"
|
v-model="tab.document.request.endpoint"
|
||||||
:placeholder="`${t('request.url')}`"
|
:placeholder="getDefaultRESTRequest().endpoint"
|
||||||
:auto-complete-source="userHistories"
|
:auto-complete-source="userHistories"
|
||||||
:auto-complete-env="true"
|
:auto-complete-env="true"
|
||||||
|
:placeholder-hover-string="t('request.http_placeholder')"
|
||||||
:inspection-results="tabResults"
|
:inspection-results="tabResults"
|
||||||
@paste="onPasteUrl($event)"
|
@paste="onPasteUrl($event)"
|
||||||
@enter="newSendRequest"
|
@enter="newSendRequest"
|
||||||
@@ -331,12 +332,12 @@ const tabs = useService(RESTTabService)
|
|||||||
const workspaceService = useService(WorkspaceService)
|
const workspaceService = useService(WorkspaceService)
|
||||||
|
|
||||||
const newSendRequest = async () => {
|
const newSendRequest = async () => {
|
||||||
if (newEndpoint.value === "" || /^\s+$/.test(newEndpoint.value)) {
|
if (/^\s+$/.test(newEndpoint.value)) {
|
||||||
toast.error(`${t("empty.endpoint")}`)
|
toast.error(`${t("empty.endpoint")}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureMethodInEndpoint()
|
if (newEndpoint.value) ensureMethodInEndpoint()
|
||||||
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
||||||
@@ -348,7 +349,20 @@ const newSendRequest = async () => {
|
|||||||
workspaceType: workspaceService.currentWorkspace.value.type,
|
workspaceType: workspaceService.currentWorkspace.value.type,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [cancel, streamPromise] = runRESTRequest$(tab)
|
const finalTab = ref({
|
||||||
|
...tab.value,
|
||||||
|
document: {
|
||||||
|
...tab.value.document,
|
||||||
|
request: {
|
||||||
|
...tab.value.document.request,
|
||||||
|
endpoint:
|
||||||
|
tab.value.document.request.endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const [cancel, streamPromise] = runRESTRequest$(finalTab)
|
||||||
const streamResult = await streamPromise
|
const streamResult = await streamPromise
|
||||||
|
|
||||||
requestCancelFunc.value = cancel
|
requestCancelFunc.value = cancel
|
||||||
@@ -472,8 +486,13 @@ const fetchingShareLink = ref(false)
|
|||||||
|
|
||||||
const shareRequest = () => {
|
const shareRequest = () => {
|
||||||
if (currentUser.value) {
|
if (currentUser.value) {
|
||||||
|
const finalRequest = {
|
||||||
|
...tab.value.document.request,
|
||||||
|
endpoint:
|
||||||
|
tab.value.document.request.endpoint || getDefaultRESTRequest().endpoint,
|
||||||
|
}
|
||||||
invokeAction("share.request", {
|
invokeAction("share.request", {
|
||||||
request: tab.value.document.request,
|
request: finalRequest,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
invokeAction("modals.login.toggle")
|
invokeAction("modals.login.toggle")
|
||||||
@@ -513,11 +532,17 @@ const saveRequest = () => {
|
|||||||
showSaveRequestModal.value = true
|
showSaveRequestModal.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (saveCtx.originLocation === "user-collection") {
|
|
||||||
const req = tab.value.document.request
|
const req = tab.value.document.request
|
||||||
|
|
||||||
|
const finalRequest = {
|
||||||
|
...req,
|
||||||
|
endpoint: req.endpoint.trim() || getDefaultRESTRequest().endpoint,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveCtx.originLocation === "user-collection") {
|
||||||
try {
|
try {
|
||||||
editRESTRequest(saveCtx.folderPath, saveCtx.requestIndex, req)
|
editRESTRequest(saveCtx.folderPath, saveCtx.requestIndex, finalRequest)
|
||||||
|
|
||||||
tab.value.document.isDirty = false
|
tab.value.document.isDirty = false
|
||||||
|
|
||||||
@@ -534,8 +559,6 @@ const saveRequest = () => {
|
|||||||
saveRequest()
|
saveRequest()
|
||||||
}
|
}
|
||||||
} else if (saveCtx.originLocation === "team-collection") {
|
} else if (saveCtx.originLocation === "team-collection") {
|
||||||
const req = tab.value.document.request
|
|
||||||
|
|
||||||
// TODO: handle error case (NOTE: overwriteRequestTeams is async)
|
// TODO: handle error case (NOTE: overwriteRequestTeams is async)
|
||||||
try {
|
try {
|
||||||
platform.analytics?.logEvent({
|
platform.analytics?.logEvent({
|
||||||
@@ -549,7 +572,7 @@ const saveRequest = () => {
|
|||||||
requestID: saveCtx.requestID,
|
requestID: saveCtx.requestID,
|
||||||
data: {
|
data: {
|
||||||
title: req.name,
|
title: req.name,
|
||||||
request: JSON.stringify(req),
|
request: JSON.stringify(finalRequest),
|
||||||
},
|
},
|
||||||
})().then((result) => {
|
})().then((result) => {
|
||||||
if (E.isLeft(result)) {
|
if (E.isLeft(result)) {
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ import * as E from "fp-ts/Either"
|
|||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { watch } from "vue"
|
import { watch } from "vue"
|
||||||
|
import { getDefaultRESTRequest } from "~/helpers/rest/default"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
@@ -511,7 +512,10 @@ const openRequestInNewTab = (request: HoppRESTRequest) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defineActionHandler("share.request", ({ request }) => {
|
defineActionHandler("share.request", ({ request }) => {
|
||||||
requestToShare.value = request
|
requestToShare.value = {
|
||||||
|
...request,
|
||||||
|
endpoint: request.endpoint || getDefaultRESTRequest().endpoint,
|
||||||
|
}
|
||||||
displayShareRequestModal(true)
|
displayShareRequestModal(true)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ import {
|
|||||||
keymap,
|
keymap,
|
||||||
tooltips,
|
tooltips,
|
||||||
} from "@codemirror/view"
|
} from "@codemirror/view"
|
||||||
import { EditorSelection, EditorState, Extension } from "@codemirror/state"
|
import {
|
||||||
|
Compartment,
|
||||||
|
EditorSelection,
|
||||||
|
EditorState,
|
||||||
|
Extension,
|
||||||
|
} from "@codemirror/state"
|
||||||
import { clone } from "lodash-es"
|
import { clone } from "lodash-es"
|
||||||
import { history, historyKeymap } from "@codemirror/commands"
|
import { history, historyKeymap } from "@codemirror/commands"
|
||||||
import { inputTheme } from "~/helpers/editor/themes/baseTheme"
|
import { inputTheme } from "~/helpers/editor/themes/baseTheme"
|
||||||
@@ -109,6 +114,7 @@ const props = withDefaults(
|
|||||||
contextMenuEnabled?: boolean
|
contextMenuEnabled?: boolean
|
||||||
secret?: boolean
|
secret?: boolean
|
||||||
autoCompleteEnv?: boolean
|
autoCompleteEnv?: boolean
|
||||||
|
placeholderHoverString: string
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
modelValue: "",
|
modelValue: "",
|
||||||
@@ -124,6 +130,7 @@ const props = withDefaults(
|
|||||||
contextMenuEnabled: true,
|
contextMenuEnabled: true,
|
||||||
secret: false,
|
secret: false,
|
||||||
autoCompleteEnvSource: false,
|
autoCompleteEnvSource: false,
|
||||||
|
placeholderHoverString: "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -137,6 +144,8 @@ const emit = defineEmits<{
|
|||||||
(e: "click", ev: any): void
|
(e: "click", ev: any): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const placeholderString = ref(props.placeholder)
|
||||||
|
|
||||||
const cachedValue = ref(props.modelValue)
|
const cachedValue = ref(props.modelValue)
|
||||||
|
|
||||||
const view = ref<EditorView>()
|
const view = ref<EditorView>()
|
||||||
@@ -441,6 +450,9 @@ function handleTextSelection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const placeholderCompt = new Compartment()
|
||||||
|
const readOnlyCompt = new Compartment()
|
||||||
|
|
||||||
// Debounce to prevent double click from selecting the word
|
// Debounce to prevent double click from selecting the word
|
||||||
const debouncedTextSelection = (time: number) =>
|
const debouncedTextSelection = (time: number) =>
|
||||||
useDebounceFn(() => {
|
useDebounceFn(() => {
|
||||||
@@ -475,6 +487,7 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
}),
|
}),
|
||||||
EditorState.changeFilter.of(() => !readonly),
|
EditorState.changeFilter.of(() => !readonly),
|
||||||
inputTheme,
|
inputTheme,
|
||||||
|
readOnlyCompt.of(EditorState.readOnly.of(readonly)),
|
||||||
readonly
|
readonly
|
||||||
? EditorView.theme({
|
? EditorView.theme({
|
||||||
".cm-content": {
|
".cm-content": {
|
||||||
@@ -490,7 +503,8 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
position: "absolute",
|
position: "absolute",
|
||||||
}),
|
}),
|
||||||
props.environmentHighlights ? envTooltipPlugin : [],
|
props.environmentHighlights ? envTooltipPlugin : [],
|
||||||
placeholderExt(props.placeholder),
|
placeholderCompt.of(placeholderExt(props.placeholder)),
|
||||||
|
|
||||||
EditorView.domEventHandlers({
|
EditorView.domEventHandlers({
|
||||||
paste(ev) {
|
paste(ev) {
|
||||||
clipboardEv = ev
|
clipboardEv = ev
|
||||||
@@ -505,6 +519,27 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
debouncedTextSelection(30)()
|
debouncedTextSelection(30)()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mouseenter() {
|
||||||
|
//change placeholder to hover string if provided
|
||||||
|
if (props.placeholderHoverString && !props.readonly) {
|
||||||
|
placeholderString.value = props.placeholderHoverString
|
||||||
|
view.value?.dispatch({
|
||||||
|
effects: placeholderCompt.reconfigure(
|
||||||
|
placeholderExt(props.placeholderHoverString)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mouseleave() {
|
||||||
|
//change placeholder back to original string
|
||||||
|
if (props.placeholderHoverString && !props.readonly) {
|
||||||
|
view.value?.dispatch({
|
||||||
|
effects: placeholderCompt.reconfigure(
|
||||||
|
placeholderExt(props.placeholder)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
props.autoCompleteEnv
|
props.autoCompleteEnv
|
||||||
? autocompletion({
|
? autocompletion({
|
||||||
@@ -568,6 +603,38 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
return extensions
|
return extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.readonly,
|
||||||
|
(readonly) => {
|
||||||
|
if (readonly) {
|
||||||
|
view.value!.dispatch({
|
||||||
|
effects: [
|
||||||
|
readOnlyCompt.reconfigure([
|
||||||
|
EditorState.readOnly.of(readonly),
|
||||||
|
EditorView.theme({
|
||||||
|
".cm-content": {
|
||||||
|
caretColor: "var(--secondary-dark-color)",
|
||||||
|
color: "var(--secondary-dark-color)",
|
||||||
|
backgroundColor: "var(--divider-color)",
|
||||||
|
opacity: 0.25,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
view.value!.dispatch({
|
||||||
|
effects: [
|
||||||
|
readOnlyCompt.reconfigure([
|
||||||
|
EditorState.readOnly.of(readonly),
|
||||||
|
EditorView.theme({}),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const triggerTextSelection = () => {
|
const triggerTextSelection = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
view.value?.focus()
|
view.value?.focus()
|
||||||
|
|||||||
@@ -1393,6 +1393,14 @@ export function editGraphqlRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function saveGraphqlRequestAs(path: string, request: HoppGQLRequest) {
|
export function saveGraphqlRequestAs(path: string, request: HoppGQLRequest) {
|
||||||
|
// For calculating the insertion request index
|
||||||
|
const targetLocation = navigateToFolderWithIndexPath(
|
||||||
|
graphqlCollectionStore.value.state,
|
||||||
|
path.split("/").map((x) => parseInt(x))
|
||||||
|
)
|
||||||
|
|
||||||
|
const insertionIndex = targetLocation!.requests.length
|
||||||
|
|
||||||
graphqlCollectionStore.dispatch({
|
graphqlCollectionStore.dispatch({
|
||||||
dispatcher: "saveRequestAs",
|
dispatcher: "saveRequestAs",
|
||||||
payload: {
|
payload: {
|
||||||
@@ -1400,6 +1408,8 @@ export function saveGraphqlRequestAs(path: string, request: HoppGQLRequest) {
|
|||||||
request,
|
request,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return insertionIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeGraphqlRequest(
|
export function removeGraphqlRequest(
|
||||||
|
|||||||
@@ -112,7 +112,10 @@ const activeTabs = tabs.getActiveTabs()
|
|||||||
|
|
||||||
const addNewTab = () => {
|
const addNewTab = () => {
|
||||||
const tab = tabs.createNewTab({
|
const tab = tabs.createNewTab({
|
||||||
request: getDefaultGQLRequest(),
|
request: {
|
||||||
|
...getDefaultGQLRequest(),
|
||||||
|
url: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,10 @@ const onTabUpdate = (tab: HoppTab<HoppRESTDocument>) => {
|
|||||||
|
|
||||||
const addNewTab = () => {
|
const addNewTab = () => {
|
||||||
const tab = tabs.createNewTab({
|
const tab = tabs.createNewTab({
|
||||||
request: getDefaultRESTRequest(),
|
request: {
|
||||||
|
...getDefaultRESTRequest(),
|
||||||
|
endpoint: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -295,8 +298,14 @@ const shareTabRequest = (tabID: string) => {
|
|||||||
const tab = tabs.getTabRef(tabID)
|
const tab = tabs.getTabRef(tabID)
|
||||||
if (tab.value) {
|
if (tab.value) {
|
||||||
if (currentUser.value) {
|
if (currentUser.value) {
|
||||||
|
const finalRequest = {
|
||||||
|
...tab.value.document.request,
|
||||||
|
endpoint:
|
||||||
|
tab.value.document.request.endpoint ||
|
||||||
|
getDefaultRESTRequest().endpoint,
|
||||||
|
}
|
||||||
invokeAction("share.request", {
|
invokeAction("share.request", {
|
||||||
request: tab.value.document.request,
|
request: finalRequest,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
invokeAction("modals.login.toggle")
|
invokeAction("modals.login.toggle")
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ export class GQLTabService extends TabService<HoppGQLDocument> {
|
|||||||
this.tabMap.set("test", {
|
this.tabMap.set("test", {
|
||||||
id: "test",
|
id: "test",
|
||||||
document: {
|
document: {
|
||||||
request: getDefaultGQLRequest(),
|
request: {
|
||||||
|
...getDefaultGQLRequest(),
|
||||||
|
url: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
optionTabPreference: "query",
|
optionTabPreference: "query",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ export class RESTTabService extends TabService<HoppRESTDocument> {
|
|||||||
this.tabMap.set("test", {
|
this.tabMap.set("test", {
|
||||||
id: "test",
|
id: "test",
|
||||||
document: {
|
document: {
|
||||||
request: getDefaultRESTRequest(),
|
request: {
|
||||||
|
...getDefaultRESTRequest(),
|
||||||
|
endpoint: "",
|
||||||
|
},
|
||||||
isDirty: false,
|
isDirty: false,
|
||||||
optionTabPreference: "params",
|
optionTabPreference: "params",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user