chore: add i18n and readonly to envinput
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<SmartEnvInput
|
<SmartEnvInput
|
||||||
v-model="url"
|
v-model="url"
|
||||||
:placeholder="getDefaultGQLRequest().url"
|
:placeholder="getDefaultGQLRequest().url"
|
||||||
placeholder-hover-string="Enter a URL or paste a GraphQL endpoint"
|
:placeholder-hover-string="t('request.graphql_placeholder')"
|
||||||
:readonly="connected"
|
:readonly="connected"
|
||||||
class="rounded border border-divider bg-primaryLight"
|
class="rounded border border-divider bg-primaryLight"
|
||||||
@enter="onConnectClick"
|
@enter="onConnectClick"
|
||||||
@@ -81,9 +81,7 @@ const connectionSwitchModal = ref(false)
|
|||||||
const connected = computed(() => connection.state === "CONNECTED")
|
const connected = computed(() => connection.state === "CONNECTED")
|
||||||
|
|
||||||
const url = computed({
|
const url = computed({
|
||||||
get: () =>
|
get: () => tabs.currentActiveTab.value?.document.request.url ?? "",
|
||||||
tabs.currentActiveTab.value?.document.request.url ||
|
|
||||||
getDefaultGQLRequest().url,
|
|
||||||
set: (value) => {
|
set: (value) => {
|
||||||
tabs.currentActiveTab.value!.document.request.url = value
|
tabs.currentActiveTab.value!.document.request.url = value
|
||||||
},
|
},
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
:placeholder="getDefaultRESTRequest().endpoint"
|
:placeholder="getDefaultRESTRequest().endpoint"
|
||||||
:auto-complete-source="userHistories"
|
:auto-complete-source="userHistories"
|
||||||
:auto-complete-env="true"
|
:auto-complete-env="true"
|
||||||
placeholder-hover-string="Enter a URL or cURL command"
|
:placeholder-hover-string="t('request.http_placeholder')"
|
||||||
:inspection-results="tabResults"
|
:inspection-results="tabResults"
|
||||||
@paste="onPasteUrl($event)"
|
@paste="onPasteUrl($event)"
|
||||||
@enter="newSendRequest"
|
@enter="newSendRequest"
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -451,6 +451,7 @@ function handleTextSelection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const placeholderCompt = new Compartment()
|
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) =>
|
||||||
@@ -486,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": {
|
||||||
@@ -519,7 +521,7 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
},
|
},
|
||||||
mouseenter() {
|
mouseenter() {
|
||||||
//change placeholder to hover string if provided
|
//change placeholder to hover string if provided
|
||||||
if (props.placeholderHoverString) {
|
if (props.placeholderHoverString && !props.readonly) {
|
||||||
placeholderString.value = props.placeholderHoverString
|
placeholderString.value = props.placeholderHoverString
|
||||||
view.value?.dispatch({
|
view.value?.dispatch({
|
||||||
effects: placeholderCompt.reconfigure(
|
effects: placeholderCompt.reconfigure(
|
||||||
@@ -530,7 +532,7 @@ const getExtensions = (readonly: boolean): Extension => {
|
|||||||
},
|
},
|
||||||
mouseleave() {
|
mouseleave() {
|
||||||
//change placeholder back to original string
|
//change placeholder back to original string
|
||||||
if (props.placeholderHoverString) {
|
if (props.placeholderHoverString && !props.readonly) {
|
||||||
view.value?.dispatch({
|
view.value?.dispatch({
|
||||||
effects: placeholderCompt.reconfigure(
|
effects: placeholderCompt.reconfigure(
|
||||||
placeholderExt(props.placeholder)
|
placeholderExt(props.placeholder)
|
||||||
@@ -601,6 +603,29 @@ 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,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const triggerTextSelection = () => {
|
const triggerTextSelection = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
view.value?.focus()
|
view.value?.focus()
|
||||||
|
|||||||
Reference in New Issue
Block a user