Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Merge remote-tracking branch 'origin/main' into refactor/ui

liyasthomas68ff422a5f6c
diff --cc pages/index.vue
index 54d3a0b3c,4512ab560..c7d810661
--- a/pages/index.vue
+++ b/pages/index.vue
@@@ -1,732 -1,650 +1,734 @@@
<template>
<!-- eslint-disable -->
- <div class="page">
- <div class="content">
- <div class="page-columns inner-left">
- <AppSection ref="request" label="request">
- <ul>
- <li class="shrink">
- <label for="method">{{ $t("method") }}</label>
- <span class="select-wrapper">
- <v-popover>
- <input
- id="method"
- class="input drop-down-input"
- v-model="method"
- :readonly="!customMethod"
- autofocus
- />
- <template #popover>
- <div
+ <div>
+ <Splitpanes vertical :dbl-click-splitter="false">
+ <Pane class="overflow-auto hide-scrollbar">
+ <Splitpanes horizontal :dbl-click-splitter="false">
+ <Pane class="overflow-auto hide-scrollbar">
+ <div class="sticky top-0 z-10 bg-primary flex p-4">
+ <div class="relative inline-flex">
+ <span class="select-wrapper">
+ <tippy
+ interactive
+ ref="options"
+ tabindex="-1"
+ trigger="click"
+ theme="popover"
+ arrow
+ >
+ <template #trigger>
+ <input
+ id="method"
+ class="
+ flex
+ rounded-l-lg
+ bg-primaryLight
+ font-mono
+ w-32
+ px-4
+ py-2
+ truncate
+ text-secondaryDark
+ font-semibold
+ border border-divider
+ transition
+ focus:outline-none focus:border-accent
+ "
+ v-model="method"
+ :readonly="!customMethod"
+ autofocus
+ />
+ </template>
+ <SmartItem
v-for="(methodMenuItem, index) in methodMenuItems"
:key="`method-${index}`"
+ @click.native="
+ customMethod = methodMenuItem == 'CUSTOM' ? true : false
+ method = methodMenuItem
+ $refs.options.tippy().hide()
+ "
+ :label="methodMenuItem"
+ />
+ </tippy>
+ </span>
+ </div>
+ <div class="flex-1 inline-flex">
+ <input
+ v-if="!EXPERIMENTAL_URL_BAR_ENABLED"
+ :class="{ error: !isValidURL }"
+ class="
+ w-full
+ font-mono font-semibold
+ truncate
+ text-secondaryDark
+ px-4
+ py-2
+ border border-divider
+ bg-primaryLight
+ transition
+ focus:outline-none focus:border-accent
+ "
+ @keyup.enter="isValidURL ? sendRequest() : null"
+ id="url"
+ name="url"
+ type="text"
+ v-model="newEndpoint$"
+ spellcheck="false"
+ @input="pathInputHandler"
+ :placeholder="$t('url')"
+ />
+ <SmartUrlField v-model="uri" v-else />
+ </div>
+ <div class="flex">
+ <span
+ id="send"
+ :disabled="!isValidURL"
+ @click="sendRequest"
+ v-if="!runningRequest"
+ class="
+ px-4
+ py-2
+ border border-accent
+ font-mono
+ flex
+ items-center
+ truncate
+ font-semibold
+ bg-accent
+ text-white
+ "
+ >
+ {{ $t("send") }}
+ </span>
+ <span
+ id="cancel"
+ @click="cancelRequest"
+ v-else
+ class="
+ px-4
+ py-2
+ border border-accent
+ font-mono
+ flex
+ items-center
+ truncate
+ font-semibold
+ bg-accent
+ text-white
+ "
+ >
+ {{ $t("cancel") }}
+ </span>
+ <tippy
+ ref="sendOptions"
+ interactive
+ tabindex="-1"
+ trigger="click"
+ theme="popover"
+ arrow
+ >
+ <template #trigger>
+ <span
+ class="
+ px-1
+ py-2
+ border border-accent
+ font-mono
+ flex
+ items-center
+ justify-center
+ truncate
+ font-semibold
+ bg-accent
+ text-white
+ rounded-r-lg
+ "
>
- <button
- class="icon button"
- @click="
- customMethod =
- methodMenuItem == 'CUSTOM' ? true : false
- method = methodMenuItem
- "
- v-close-popover
- >
- {{ methodMenuItem }}
- </button>
- </div>
+ <i class="material-icons">keyboard_arrow_down</i>
+ </span>
</template>
- </v-popover>
- </span>
- </li>
- <li>
- <label for="url">{{ $t("url") }}</label>
- <input
- v-if="!EXPERIMENTAL_URL_BAR_ENABLED"
- :class="{ error: !isValidURL }"
- class="input border-dashed md:border-l border-divider"
- @keyup.enter="isValidURL ? sendRequest() : null"
- id="url"
- name="url"
- type="text"
- v-model="uri"
- spellcheck="false"
- @input="pathInputHandler"
- :placeholder="$t('url')"
- />
- <SmartUrlField v-model="uri" v-else />
- </li>
- <li class="shrink">
- <label class="hide-on-small-screen" for="send">&nbsp;</label>
- <button
- v-if="!runningRequest"
- :disabled="!isValidURL"
- @click="sendRequest"
- id="send"
- class="button"
- ref="sendButton"
- >
- {{ $t("send") }}
- <span>
- <i class="material-icons">send</i>
+ <SmartItem
+ :label="$t('import_curl')"
+ icon="import_export"
+ @click.native="
+ showCurlImportModal = !showCurlImportModal
+ $refs.sendOptions.tippy().hide()
+ "
+ />
+ <SmartItem
+ @click.native="
+ showCodegenModal = !showCodegenModal
+ $refs.sendOptions.tippy().hide()
+ "
+ :disabled="!isValidURL"
+ :label="$t('show_code')"
+ icon="code"
+ />
+ <SmartItem
+ @click.native="
+ clearContent('', $event)
+ $refs.sendOptions.tippy().hide()
+ "
+ :label="$t('clear_all')"
+ ref="clearAll"
+ icon="clear_all"
+ />
+ </tippy>
+ <span
+ class="
+ ml-4
+ px-4
+ py-2
+ border border-divider
+ font-mono
+ flex
+ items-center
+ justify-center
+ truncate
+ font-semibold
+ rounded-l-lg
+ "
+ >
+ Save
</span>
- </button>
- <button
- v-else
- @click="cancelRequest"
- id="send"
- class="button"
- ref="sendButton"
+ <tippy
+ ref="saveOptions"
+ interactive
+ tabindex="-1"
+ trigger="click"
+ theme="popover"
+ arrow
+ >
+ <template #trigger>
+ <span
+ class="
+ px-1
+ py-2
+ border border-divider
+ font-mono
+ flex
+ items-center
+ justify-center
+ truncate
+ font-semibold
+ rounded-r-lg
+ "
+ >
+ <i class="material-icons">keyboard_arrow_down</i>
+ </span>
+ </template>
+ <SmartItem :description="$t('token_req_name')" />
+ <input
+ id="request-name"
+ name="request-name"
+ type="text"
+ v-model="name"
+ class="input text-sm"
+ />
+ <SmartItem
+ @click.native="
+ copyRequest
+ $refs.saveOptions.tippy().hide()
+ "
+ ref="copyRequest"
+ :disabled="!isValidURL"
+ :label="$t('copy_request_link')"
+ :icon="navigatorShare ? 'share' : 'content_copy'"
+ />
+ <SmartItem
+ @click.native="
+ saveRequest
+ $refs.saveOptions.tippy().hide()
+ "
+ ref="saveRequest"
+ :disabled="!isValidURL"
+ :label="$t('save_to_collections')"
+ icon="create_new_folder"
+ />
+ </tippy>
+ </div>
+ </div>
+ <SmartTabs styles="sticky top-70px z-10">
+ <SmartTab
+ :id="'params'"
+ :label="
+ $t('parameters') +
+ `${
- newParams$.length !== 0 ? ' \xA0 • \xA0 ' + newParams$.length : ''
++ newParams$.length !== 0
++ ? ' \xA0 • \xA0 ' + newParams$.length
++ : ''
+ }`
+ "
+ :selected="true"
>
- {{ $t("cancel") }}
- <span>
- <i class="material-icons">clear</i>
- </span>
- </button>
- </li>
- </ul>
- <ul>
- <li>
- <label for="request-name" class="text-sm">
- {{ $t("token_req_name") }}
- </label>
- <input
- id="request-name"
- name="request-name"
- type="text"
- v-model="name"
- class="input text-sm"
- />
- </li>
- </ul>
- <div
- label="Request Body"
- v-if="['POST', 'PUT', 'PATCH', 'DELETE'].includes(method)"
- >
- <ul>
- <li>
- <label for="contentType" class="text-sm">{{
- $t("content_type")
- }}</label>
- <span class="select-wrapper">
- <v-popover>
- <input
- id="contentType"
- class="input drop-down-input"
- v-model="contentType"
- readonly
- />
- <template #popover>
- <div
- v-for="(
- contentTypeMenuItem, index
- ) in validContentTypes"
- :key="`content-type-${index}`"
- >
- <button
- class="icon button"
- @click="contentType = contentTypeMenuItem"
- v-close-popover
- >
- {{ contentTypeMenuItem }}
- </button>
+ <HttpParameters
+ :params="newParams$"
+ @clear-content="clearContent"
+ @remove-request-param="removeRequestParam"
+ @add-request-param="addRequestParam"
+ />
+ </SmartTab>
+
+ <SmartTab
+ :id="'bodyParams'"
+ :label="
+ $t('body') +
+ `${
+ bodyParams.length !== 0
+ ? ' \xA0 • \xA0 ' + bodyParams.length
+ : ''
+ }`
+ "
+ >
+ <div class="flex flex-1 items-center justify-between py-2">
+ <tippy
+ interactive
+ ref="contentTypeOptions"
+ tabindex="-1"
+ trigger="click"
+ theme="popover"
+ arrow
+ >
+ <template #trigger>
+ <div class="flex">
+ <span class="select-wrapper">
+ <input
+ id="contentType"
+ class="
+ flex
+ w-full
+ px-4
+ py-2
+ bg-primary
+ truncate
+ rounded-lg
+ font-semibold font-mono
+ text-xs
+ transition
+ focus:outline-none
+ "
+ v-model="contentType"
+ readonly
+ />
+ </span>
</div>
</template>
- </v-popover>
- </span>
- <!-- <SmartAutoComplete
- :source="validContentTypes"
- :spellcheck="false"
- v-model="contentType"
- styles="text-sm"
- /> -->
- </li>
- </ul>
- <ul>
- <li>
- <div class="row-wrapper">
- <span>
- <SmartToggle
- v-if="canListParameters"
- :on="rawInput"
- @change="rawInput = !rawInput"
- >
- {{ $t("raw_input") }}
- </SmartToggle>
- </span>
+ <SmartItem
+ v-for="(contentTypeMenuItem, index) in validContentTypes"
+ :key="`content-type-${index}`"
+ @click.native="
+ contentType = contentTypeMenuItem
+ $refs.contentTypeOptions.tippy().hide()
+ "
+ :label="contentTypeMenuItem"
+ />
+ </tippy>
+ <SmartToggle
+ v-if="canListParameters"
+ :on="rawInput"
+ @change="rawInput = !rawInput"
+ class="px-4"
+ >
+ {{ $t("raw_input") }}
+ </SmartToggle>
</div>
- </li>
- </ul>
- <HttpBodyParameters
- v-if="!rawInput"
- :bodyParams="bodyParams"
- @clear-content="clearContent"
- @set-route-query-state="setRouteQueryState"
- @remove-request-body-param="removeRequestBodyParam"
- @add-request-body-param="addRequestBodyParam"
- />
- <HttpRawBody
- v-else
- :rawParams="rawParams"
- :contentType="contentType"
- :rawInput="rawInput"
- @clear-content="clearContent"
- @update-raw-body="updateRawBody"
- @update-raw-input="updateRawInput = (value) => (rawInput = value)"
- />
- </div>
- <div class="row-wrapper">
- <span>
- <button
- class="icon button"
- @click="showCurlImportModal = !showCurlImportModal"
- v-tooltip.bottom="$t('import_curl')"
- >
- <i class="material-icons">import_export</i>
- </button>
- <button
- class="icon button"
- @click="showCodegenModal = !showCodegenModal"
- :disabled="!isValidURL"
- v-tooltip.bottom="$t('show_code')"
- >
- <i class="material-icons">code</i>
- </button>
- </span>
- <span>
- <button
- class="icon button"
- @click="copyRequest"
- ref="copyRequest"
- :disabled="!isValidURL"
- v-tooltip.bottom="$t('copy_request_link')"
- >
- <i v-if="navigatorShare" class="material-icons">share</i>
- <i v-else class="material-icons">content_copy</i>
- </button>
- <button
- class="icon button"
- @click="saveRequest"
- ref="saveRequest"
- :disabled="!isValidURL"
- v-tooltip.bottom="$t('save_to_collections')"
- >
- <i class="material-icons">create_new_folder</i>
- </button>
- <button
- class="icon button"
- @click="clearContent('', $event)"
- v-tooltip.bottom="$t('clear_all')"
- ref="clearAll"
- >
- <i class="material-icons">clear_all</i>
- </button>
- </span>
- </div>
- </AppSection>
-
- <section id="options">
- <SmartTabs>
- <SmartTab
- :id="'params'"
- :label="
- $t('parameters') +
- `${params.length !== 0 ? ' \xA0 • \xA0 ' + params.length : ''}`
- "
- :selected="true"
- >
- <HttpParameters
- :params="params"
- @clear-content="clearContent"
- @remove-request-param="removeRequestParam"
- @add-request-param="addRequestParam"
- />
- </SmartTab>
+ <HttpBodyParameters
+ v-if="!rawInput"
+ :bodyParams="bodyParams"
+ @clear-content="clearContent"
+ @set-route-query-state="setRouteQueryState"
+ @remove-request-body-param="removeRequestBodyParam"
+ @add-request-body-param="addRequestBodyParam"
+ />
+ <HttpRawBody
+ v-else
+ :rawParams="rawParams"
+ :contentType="contentType"
+ :rawInput="rawInput"
+ @clear-content="clearContent"
+ @update-raw-body="updateRawBody"
+ @update-raw-input="
+ updateRawInput = (value) => (rawInput = value)
+ "
+ />
+ </SmartTab>
- <SmartTab
- :id="'headers'"
- :label="
- $t('headers') +
- `${
- headers.length !== 0 ? ' \xA0 • \xA0 ' + headers.length : ''
- }`
- "
- >
- <HttpHeaders
- :headers="headers"
- @clear-content="clearContent"
- @set-route-query-state="setRouteQueryState"
- @remove-request-header="removeRequestHeader"
- @add-request-header="addRequestHeader"
- />
- </SmartTab>
+ <SmartTab
+ :id="'headers'"
+ :label="
+ $t('headers') +
+ `${
+ headers.length !== 0 ? ' \xA0 • \xA0 ' + headers.length : ''
+ }`
+ "
+ >
+ <HttpHeaders
+ :headers="headers"
+ @clear-content="clearContent"
+ @set-route-query-state="setRouteQueryState"
+ @remove-request-header="removeRequestHeader"
+ @add-request-header="addRequestHeader"
+ />
+ </SmartTab>
- <SmartTab :id="'authentication'" :label="$t('authentication')">
- <AppSection label="authentication">
- <ul>
- <li>
- <div class="row-wrapper">
- <label for="auth">{{ $t("authentication") }}</label>
- <div>
- <button
- class="icon button"
- @click="clearContent('auth', $event)"
- v-tooltip.bottom="$t('clear')"
- >
- <i class="material-icons">clear_all</i>
- </button>
+ <SmartTab :id="'authentication'" :label="$t('authentication')">
+ <AppSection label="authentication">
+ <ul>
+ <li>
+ <div class="flex flex-1">
+ <label for="auth">{{ $t("authentication") }}</label>
+ <div>
+ <ButtonSecondary
+ @click.native="clearContent('auth', $event)"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('clear')"
+ icon="clear_all"
+ />
+ </div>
</div>
- </div>
- <span class="select-wrapper">
- <select class="select" id="auth" v-model="auth">
- <option>None</option>
- <option>Basic Auth</option>
- <option>Bearer Token</option>
- <option>OAuth 2.0</option>
- </select>
- </span>
- </li>
- </ul>
- <ul v-if="auth === 'Basic Auth'">
- <li>
- <input
- class="input"
- placeholder="User"
- name="http_basic_user"
- v-model="httpUser"
- />
- </li>
- <li>
- <input
- class="input"
- placeholder="Password"
- name="http_basic_passwd"
- :type="passwordFieldType"
- v-model="httpPassword"
- />
- </li>
- <div>
+ <span class="select-wrapper">
+ <select class="select" id="auth" v-model="auth">
+ <option>None</option>
+ <option>Basic Auth</option>
+ <option>Bearer Token</option>
+ <option>OAuth 2.0</option>
+ </select>
+ </span>
+ </li>
+ </ul>
+ <ul v-if="auth === 'Basic Auth'">
<li>
- <button
- class="icon button"
- ref="switchVisibility"
- @click="switchVisibility"
- >
- <i
- class="material-icons"
- v-if="passwordFieldType === 'text'"
- >visibility</i
- >
- <i
- class="material-icons"
- v-if="passwordFieldType !== 'text'"
- >visibility_off</i
- >
- </button>
+ <input
+ class="input"
+ placeholder="User"
+ name="http_basic_user"
+ v-model="httpUser"
+ />
</li>
- </div>
- </ul>
- <ul v-if="auth === 'Bearer Token' || auth === 'OAuth 2.0'">
- <li>
- <div class="row-wrapper">
+ <li>
<input
class="input"
- placeholder="Token"
- name="bearer_token"
- v-model="bearerToken"
+ placeholder="Password"
+ name="http_basic_passwd"
+ :type="passwordFieldType"
+ v-model="httpPassword"
/>
- <button
- v-if="auth === 'OAuth 2.0'"
- class="icon button"
- @click="showTokenListModal = !showTokenListModal"
- v-tooltip.bottom="$t('use_token')"
- >
- <i class="material-icons">open_in_new</i>
- </button>
- <button
- v-if="auth === 'OAuth 2.0'"
- class="icon button"
- @click="showTokenRequest = !showTokenRequest"
- v-tooltip.bottom="$t('get_token')"
- >
- <i class="material-icons">vpn_key</i>
- </button>
+ </li>
+ <div>
+ <li>
+ <ButtonSecondary
+ ref="switchVisibility"
+ @click.native="switchVisibility"
+ :icon="
+ passwordFieldType === 'text'
+ ? 'visibility'
+ : 'visibility_off'
+ "
+ />
+ </li>
</div>
- </li>
- </ul>
- <div class="row-wrapper">
- <SmartToggle
- :on="!URL_EXCLUDES.auth"
- @change="setExclude('auth', !$event)"
- >
- {{ $t("include_in_url") }}
- </SmartToggle>
- </div>
- </AppSection>
-
- <AppSection v-if="showTokenRequest" label="accessTokenRequest">
- <ul>
- <li>
- <div class="row-wrapper">
- <label for="token-name">{{ $t("token_name") }}</label>
- <div>
- <button
- class="icon button"
- @click="showTokenRequestList = true"
- v-tooltip.bottom="$t('manage_token_req')"
- >
- <i class="material-icons">library_add</i>
- </button>
- <button
- class="icon button"
- @click="clearContent('access_token', $event)"
- v-tooltip.bottom="$t('clear')"
- >
- <i class="material-icons">clear_all</i>
- </button>
- <button
- class="icon button"
- @click="showTokenRequest = false"
- v-tooltip.bottom="$t('close')"
- >
- <i class="material-icons">close</i>
- </button>
+ </ul>
+ <ul v-if="auth === 'Bearer Token' || auth === 'OAuth 2.0'">
+ <li>
+ <div class="flex flex-1">
+ <input
+ class="input"
+ placeholder="Token"
+ name="bearer_token"
+ v-model="bearerToken"
+ />
+ <ButtonSecondary
+ v-if="auth === 'OAuth 2.0'"
+ @click.native="
+ showTokenListModal = !showTokenListModal
+ "
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('use_token')"
+ icon="open_in_new"
+ />
+ <ButtonSecondary
+ v-if="auth === 'OAuth 2.0'"
+ @click.native="showTokenRequest = !showTokenRequest"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('get_token')"
+ icon="vpn_key"
+ />
</div>
- </div>
- <input
- class="input"
- id="token-name"
- :placeholder="$t('optional')"
- name="token_name"
- v-model="accessTokenName"
- type="text"
- />
- </li>
- </ul>
- <ul>
- <li>
- <label for="oidc-discovery-url">
- {{ $t("oidc_discovery_url") }}
- </label>
- <input
- class="input"
- :disabled="
- this.authUrl !== '' || this.accessTokenUrl !== ''
- "
- id="oidc-discovery-url"
- name="oidc_discovery_url"
- type="url"
- v-model="oidcDiscoveryUrl"
- placeholder="https://example.com/.well-known/openid-configuration"
- />
- </li>
- </ul>
- <ul>
- <li>
- <label for="auth-url">{{ $t("auth_url") }}</label>
- <input
- class="input"
- :disabled="this.oidcDiscoveryUrl !== ''"
- id="auth-url"
- name="auth_url"
- type="url"
- v-model="authUrl"
- placeholder="https://example.com/login/oauth/authorize"
- />
- </li>
- </ul>
- <ul>
- <li>
- <label for="access-token-url">
- {{ $t("access_token_url") }}
- </label>
- <input
- class="input"
- :disabled="this.oidcDiscoveryUrl !== ''"
- id="access-token-url"
- name="access_token_url"
- type="url"
- v-model="accessTokenUrl"
- placeholder="https://example.com/login/oauth/access_token"
- />
- </li>
- </ul>
- <ul>
- <li>
- <label for="client-id">{{ $t("client_id") }}</label>
- <input
- class="input"
- id="client-id"
- name="client_id"
- type="text"
- v-model="clientId"
- placeholder="Client ID"
- />
- </li>
- </ul>
- <ul>
- <li>
- <label for="scope">{{ $t("scope") }}</label>
- <input
- class="input"
- id="scope"
- name="scope"
- type="text"
- v-model="scope"
- placeholder="e.g. read:org"
- />
- </li>
- </ul>
- <ul>
- <li>
- <button
- class="icon button"
- @click="handleAccessTokenRequest"
+ </li>
+ </ul>
+ <div class="flex flex-1">
+ <SmartToggle
+ :on="!URL_EXCLUDES.auth"
+ @change="setExclude('auth', !$event)"
>
- <i class="material-icons">vpn_key</i>
- <span>{{ $t("request_token") }}</span>
- </button>
- </li>
- </ul>
- </AppSection>
- </SmartTab>
+ {{ $t("include_in_url") }}
+ </SmartToggle>
+ </div>
+ </AppSection>
- <SmartTab
- :id="'pre_request_script'"
- :label="$t('pre_request_script')"
- >
- <AppSection v-if="showPreRequestScript" label="preRequest">
- <ul>
- <li>
- <div class="row-wrapper">
- <label>{{ $t("javascript_code") }}</label>
- <div>
- <a
- href="https://github.com/hoppscotch/hoppscotch/wiki/Pre-Request-Scripts"
- target="_blank"
- rel="noopener"
- >
- <button class="icon button" v-tooltip="$t('wiki')">
- <i class="material-icons">help_outline</i>
- </button>
- </a>
+ <AppSection v-if="showTokenRequest" label="accessTokenRequest">
+ <ul>
+ <li>
+ <div class="flex flex-1">
+ <label for="token-name">{{ $t("token_name") }}</label>
+ <div>
+ <ButtonSecondary
+ @click.native="showTokenRequestList = true"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('manage_token_req')"
+ icon="library_add"
+ />
+ <ButtonSecondary
+ @click.native="clearContent('access_token', $event)"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('clear')"
+ icon="clear_all"
+ />
+ <ButtonSecondary
+ @click.native="showTokenRequest = false"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('close')"
+ icon="close"
+ />
+ </div>
</div>
- </div>
- <SmartJsEditor
- v-model="preRequestScript"
- :options="{
- maxLines: '16',
- minLines: '8',
- fontSize: '15px',
- autoScrollEditorIntoView: true,
- showPrintMargin: false,
- useWorker: false,
- }"
- styles="rounded-b-lg"
- completeMode="pre"
+ <input
+ class="input"
+ id="token-name"
+ :placeholder="$t('optional')"
+ name="token_name"
+ v-model="accessTokenName"
+ type="text"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <label for="oidc-discovery-url">
+ {{ $t("oidc_discovery_url") }}
+ </label>
+ <input
+ class="input"
+ :disabled="
+ this.authUrl !== '' || this.accessTokenUrl !== ''
+ "
+ id="oidc-discovery-url"
+ name="oidc_discovery_url"
+ type="url"
+ v-model="oidcDiscoveryUrl"
+ placeholder="https://example.com/.well-known/openid-configuration"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <label for="auth-url">{{ $t("auth_url") }}</label>
+ <input
+ class="input"
+ :disabled="this.oidcDiscoveryUrl !== ''"
+ id="auth-url"
+ name="auth_url"
+ type="url"
+ v-model="authUrl"
+ placeholder="https://example.com/login/oauth/authorize"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <label for="access-token-url">
+ {{ $t("access_token_url") }}
+ </label>
+ <input
+ class="input"
+ :disabled="this.oidcDiscoveryUrl !== ''"
+ id="access-token-url"
+ name="access_token_url"
+ type="url"
+ v-model="accessTokenUrl"
+ placeholder="https://example.com/login/oauth/access_token"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <label for="client-id">{{ $t("client_id") }}</label>
+ <input
+ class="input"
+ id="client-id"
+ name="client_id"
+ type="text"
+ v-model="clientId"
+ placeholder="Client ID"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <label for="scope">{{ $t("scope") }}</label>
+ <input
+ class="input"
+ id="scope"
+ name="scope"
+ type="text"
+ v-model="scope"
+ placeholder="e.g. read:org"
+ />
+ </li>
+ </ul>
+ <ul>
+ <li>
+ <ButtonSecondary
+ @click.native="handleAccessTokenRequest"
+ icon="vpn_key"
+ :label="$t('request_token')"
+ />
+ </li>
+ </ul>
+ </AppSection>
+ </SmartTab>
+
+ <SmartTab
+ :id="'pre_request_script'"
+ :label="$t('pre_request_script')"
+ >
+ <AppSection v-if="showPreRequestScript" label="preRequest">
+ <div class="flex flex-1 items-center justify-between pl-4">
+ <label class="font-semibold text-xs">
+ {{ $t("javascript_code") }}
+ </label>
+ <ButtonSecondary
+ to="https://github.com/hoppscotch/hoppscotch/wiki/Pre-Request-Scripts"
+ blank
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('wiki')"
+ icon="help_outline"
/>
- </li>
- </ul>
- </AppSection>
- </SmartTab>
+ </div>
+ <SmartJsEditor
+ v-model="preRequestScript"
+ :options="{
+ maxLines: '16',
+ minLines: '8',
+ fontSize: '14px',
+ autoScrollEditorIntoView: true,
+ showPrintMargin: false,
+ useWorker: false,
+ }"
+ completeMode="pre"
+ />
+ </AppSection>
+ </SmartTab>
- <SmartTab :id="'tests'" :label="$t('tests')">
- <AppSection v-if="testsEnabled" label="postRequestTests">
- <ul>
- <li>
- <div class="row-wrapper">
- <label>{{ $t("javascript_code") }}</label>
- <div>
- <a
- href="https://github.com/hoppscotch/hoppscotch/wiki/Post-Request-Tests"
- target="_blank"
- rel="noopener"
- >
- <button class="icon button" v-tooltip="$t('wiki')">
- <i class="material-icons">help_outline</i>
- </button>
- </a>
- </div>
- </div>
- <SmartJsEditor
- v-model="testScript"
- :options="{
- maxLines: '16',
- minLines: '8',
- fontSize: '15px',
- autoScrollEditorIntoView: true,
- showPrintMargin: false,
- useWorker: false,
- }"
- styles="rounded-b-lg"
- completeMode="test"
+ <SmartTab :id="'tests'" :label="$t('tests')">
+ <AppSection v-if="testsEnabled" label="postRequestTests">
+ <div class="flex flex-1 items-center justify-between pl-4">
+ <label class="font-semibold text-xs">
+ {{ $t("javascript_code") }}
+ </label>
+ <ButtonSecondary
+ to="https://github.com/hoppscotch/hoppscotch/wiki/Post-Request-Tests"
+ blank
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('wiki')"
+ icon="help_outline"
/>
- <div v-if="testReports.length !== 0">
- <div class="row-wrapper">
- <label>Test Reports</label>
- <div>
- <button
- class="icon button"
- @click="clearContent('tests', $event)"
- v-tooltip.bottom="$t('clear')"
- >
- <i class="material-icons">clear_all</i>
- </button>
- </div>
+ </div>
+ <SmartJsEditor
+ v-model="testScript"
+ :options="{
+ maxLines: '16',
+ minLines: '8',
+ fontSize: '14px',
+ autoScrollEditorIntoView: true,
+ showPrintMargin: false,
+ useWorker: false,
+ }"
+ completeMode="test"
+ />
+ <div v-if="testReports.length !== 0">
+ <div class="flex flex-1 items-center justify-between pl-4">
+ <label class="font-semibold text-xs">
+ Test Reports
+ </label>
+ <ButtonSecondary
+ @click.native="clearContent('tests', $event)"
+ v-tippy="{ theme: 'tooltip' }"
+ :title="$t('clear')"
+ icon="clear_all"
+ />
+ </div>
+ <div
+ v-for="(testReport, index) in testReports"
+ :key="index"
+ class="px-4"
+ >
+ <div v-if="testReport.startBlock">
+ <hr />
+ <h4 class="heading">
+ {{ testReport.startBlock }}
+ </h4>
</div>
- <div
- v-for="(testReport, index) in testReports"
- :key="index"
+ <p
+ v-else-if="testReport.result"
+ class="flex flex-1 font-mono text-xs info"
>
- <div v-if="testReport.startBlock" class="info">
- <hr />
- <h4 class="heading">{{ testReport.startBlock }}</h4>
- </div>
- <p
- v-else-if="testReport.result"
- class="row-wrapper info"
+ <span
+ :class="testReport.styles.class"
+ class="flex items-center"
>
- <span :class="testReport.styles.class">
- <i class="material-icons">
- {{ testReport.styles.icon }}
- </i>
- <span>&nbsp; {{ testReport.result }}</span>
- <span v-if="testReport.message">
- <label
- >&nbsp; • &nbsp; {{ testReport.message }}</label
- >
- </span>
+ <i class="material-icons text-sm">
+ {{ testReport.styles.icon }}
+ </i>
+ <span>&nbsp;{{ testReport.result }}</span>
+ <span v-if="testReport.message">
+ <label>: {{ testReport.message }}</label>
</span>
- </p>
- <div v-else-if="testReport.endBlock"><hr /></div>
- </div>
+ </span>
+ </p>
+ <div v-else-if="testReport.endBlock"><hr /></div>
</div>
- </li>
- </ul>
- </AppSection>
- </SmartTab>
- </SmartTabs>
- </section>
-
- <HttpResponse
- :response="response"
- :active="runningRequest"
- ref="response"
- />
- </div>
-
- <TranslateSlideLeft>
- <aside
- v-if="activeSidebar"
- class="sticky-inner inner-right lg:max-w-md"
- >
- <section>
- <SmartTabs>
- <SmartTab :id="'history'" :label="$t('history')" :selected="true">
- <History
- :page="'rest'"
- @useHistory="handleUseHistory"
- ref="historyComponent"
- />
+ </div>
+ </AppSection>
</SmartTab>
+ </SmartTabs>
+ </Pane>
+ <Pane class="overflow-auto hide-scrollbar">
+ <HttpResponse
+ :response="response"
+ :active="runningRequest"
+ ref="response"
+ />
+ </Pane>
+ </Splitpanes>
+ </Pane>
+ <Pane
+ max-size="30"
+ size="25"
+ min-size="20"
+ class="overflow-auto hide-scrollbar"
+ >
+ <aside class="h-full">
+ <SmartTabs styles="sticky z-10 top-0">
+ <SmartTab :id="'history'" :label="$t('history')" :selected="true">
+ <History
+ :page="'rest'"
+ @useHistory="handleUseHistory"
+ ref="historyComponent"
+ />
+ </SmartTab>
- <SmartTab :id="'collections'" :label="$t('collections')">
- <Collections />
- </SmartTab>
+ <SmartTab :id="'collections'" :label="$t('collections')">
+ <Collections />
+ </SmartTab>
- <SmartTab :id="'env'" :label="$t('environments')">
- <Environments />
- </SmartTab>
- </SmartTabs>
- </section>
+ <SmartTab :id="'env'" :label="$t('environments')">
+ <Environments />
+ </SmartTab>
+ </SmartTabs>
</aside>
- </TranslateSlideLeft>
-
- <SmartHideMenu
- :active="activeSidebar"
- @toggle="activeSidebar = !activeSidebar"
- />
- </div>
+ </Pane>
+ </Splitpanes>
<CollectionsSaveRequest
mode="rest"
@@@ -864,11 -786,9 +866,16 @@@ import { generateCodeWithGenerator } fr
import { getSettingSubject, applySetting } from "~/newstore/settings"
import { addRESTHistoryEntry } from "~/newstore/history"
import clone from "lodash/clone"
- import { restEndpoint$, restParams$, restRequest$, setRESTEndpoint } from "~/newstore/RESTSession"
-import { logHoppRequestRunToAnalytics } from "~/helpers/fb/analytics"
++import {
++ restEndpoint$,
++ restParams$,
++ restRequest$,
++ setRESTEndpoint,
++} from "~/newstore/RESTSession"
export default {
+ components: { Splitpanes, Pane },
+
data() {
return {
showCurlImportModal: false,
@@@ -913,9 -834,6 +920,9 @@@
"PATCH",
"CUSTOM",
],
+
+ newEndpoint$: "",
- newParams$: []
++ newParams$: [],
}
},
subscriptions() {
@@@ -926,8 -844,6 +933,8 @@@
EXPERIMENTAL_URL_BAR_ENABLED: getSettingSubject(
"EXPERIMENTAL_URL_BAR_ENABLED"
),
+ newEndpoint$: restEndpoint$,
- newParams$: restParams$
++ newParams$: restParams$,
}
},
watch: {
@@@ -2181,7 -2133,7 +2188,7 @@@
},
},
async mounted() {
- restRequest$.subscribe(x => console.log(x))
- // this.observeRequestButton()
++ restRequest$.subscribe((x) => console.log(x))
this._keyListener = function (e) {
if (e.key === "g" && (e.ctrlKey || e.metaKey)) {
e.preventDefault()