refactor: move actions from app header to app footer

This commit is contained in:
Liyas Thomas
2021-07-23 18:28:07 +00:00
committed by GitHub
parent f694f1ad36
commit 233214cb30
35 changed files with 222 additions and 278 deletions

View File

@@ -89,7 +89,6 @@ a {
@apply text-current; @apply text-current;
@apply no-underline; @apply no-underline;
@apply outline-none; @apply outline-none;
@apply rounded-lg;
@apply focus-visible:(ring ring-inset ring-accent); @apply focus-visible:(ring ring-inset ring-accent);
@apply transition; @apply transition;
@@ -149,7 +148,7 @@ a {
.tippy-content > div { .tippy-content > div {
@apply flex flex-col; @apply flex flex-col;
@apply max-h-64; @apply max-h-48;
@apply items-stretch; @apply items-stretch;
@apply overflow-y-auto; @apply overflow-y-auto;
} }
@@ -170,7 +169,7 @@ hr {
@apply px-4 py-2; @apply px-4 py-2;
@apply bg-primary; @apply bg-primary;
@apply truncate; @apply truncate;
@apply rounded-lg; @apply rounded;
@apply font-semibold font-mono; @apply font-semibold font-mono;
@apply text-xs; @apply text-xs;
@apply border border-divider; @apply border border-divider;
@@ -226,7 +225,7 @@ input[type="checkbox"] {
&::before { &::before {
@apply border border-secondary; @apply border border-secondary;
@apply rounded-lg; @apply rounded;
@apply inline-flex; @apply inline-flex;
@apply items-center; @apply items-center;
@apply justify-center; @apply justify-center;

View File

@@ -1,63 +0,0 @@
<template>
<SmartModal v-if="show" @close="hideModal">
<template #header>
<h3 class="heading">{{ $t("extensions") }}</h3>
<div>
<ButtonSecondary icon="close" @click.native="hideModal" />
</div>
</template>
<template #body>
<div class="flex flex-col space-y-2 px-2">
<SmartItem
to="https://addons.mozilla.org/en-US/firefox/addon/hoppscotch"
blank
svg="firefox"
label="Firefox"
:info-icon="hasFirefoxExtInstalled ? 'check_circle' : ''"
/>
<SmartItem
to="https://chrome.google.com/webstore/detail/hoppscotch-browser-extens/amknoiejhlmhancpahfcfcfhllgkpbld"
blank
svg="chrome"
label="Chrome"
:info-icon="hasChromeExtInstalled ? 'check_circle' : ''"
/>
</div>
</template>
<template #footer>
<div class="text-secondaryLight text-xs px-2">
{{ $t("extensions_info1") }}
</div>
</template>
</SmartModal>
</template>
<script>
import {
hasChromeExtensionInstalled,
hasFirefoxExtensionInstalled,
} from "~/helpers/strategies/ExtensionStrategy"
export default {
props: {
show: Boolean,
},
data() {
return {
hasChromeExtInstalled: hasChromeExtensionInstalled(),
hasFirefoxExtInstalled: hasFirefoxExtensionInstalled(),
}
},
watch: {
show() {
this.hasChromeExtInstalled = hasChromeExtensionInstalled()
this.hasFirefoxExtInstalled = hasFirefoxExtensionInstalled()
},
},
methods: {
hideModal() {
this.$emit("hide-modal")
},
},
}
</script>

110
components/app/Footer.vue Normal file
View File

@@ -0,0 +1,110 @@
<template>
<div class="flex justify-between">
<div>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="LEFT_SIDEBAR ? $t('hide_sidebar') : $t('show_sidebar')"
icon="menu_open"
:class="{ 'transform rotate-180': !LEFT_SIDEBAR }"
@click.native="toggleSetting('LEFT_SIDEBAR')"
/>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="`${ZEN_MODE ? $t('turn_off') : $t('turn_on')} ${$t(
'zen_mode'
)}`"
:icon="ZEN_MODE ? 'fullscreen_exit' : 'fullscreen'"
:class="{
'text-accent focus:text-accent hover:text-accent': ZEN_MODE,
}"
@click.native="toggleSetting('ZEN_MODE')"
/>
</div>
<div>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
icon="keyboard"
:title="$t('shortcuts')"
:shortcut="[getSpecialKey(), '/']"
@click.native="showShortcuts = true"
/>
<ButtonSecondary
v-if="navigatorShare"
v-tippy="{ theme: 'tooltip' }"
icon="share"
:title="$t('share')"
@click.native="nativeShare()"
/>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="RIGHT_SIDEBAR ? $t('hide_sidebar') : $t('show_sidebar')"
icon="menu_open"
:class="['transform rotate-180', { 'rotate-0': !RIGHT_SIDEBAR }]"
@click.native="toggleSetting('RIGHT_SIDEBAR')"
/>
</div>
<AppShortcuts :show="showShortcuts" @hide-modal="showShortcuts = false" />
</div>
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api"
import {
defaultSettings,
getSettingSubject,
applySetting,
toggleSetting,
} from "~/newstore/settings"
import type { KeysMatching } from "~/types/ts-utils"
import { getPlatformSpecialKey } from "~/helpers/platformutils"
type SettingsType = typeof defaultSettings
export default defineComponent({
data() {
return {
LEFT_SIDEBAR: null,
RIGHT_SIDEBAR: null,
ZEN_MODE: null,
showShortcuts: false,
navigatorShare: navigator.share,
}
},
subscriptions() {
return {
LEFT_SIDEBAR: getSettingSubject("LEFT_SIDEBAR"),
RIGHT_SIDEBAR: getSettingSubject("RIGHT_SIDEBAR"),
ZEN_MODE: getSettingSubject("ZEN_MODE"),
}
},
watch: {
ZEN_MODE(ZEN_MODE) {
this.applySetting("LEFT_SIDEBAR", !ZEN_MODE)
this.applySetting("RIGHT_SIDEBAR", !ZEN_MODE)
},
},
methods: {
toggleSetting<K extends KeysMatching<SettingsType, boolean>>(key: K) {
toggleSetting(key)
},
applySetting<K extends keyof SettingsType>(key: K, value: SettingsType[K]) {
applySetting(key, value)
},
nativeShare() {
if (navigator.share) {
navigator
.share({
title: "Hoppscotch",
text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
url: "https://hoppscotch.io",
})
.then(() => {})
.catch(console.error)
} else {
// fallback
}
},
getSpecialKey: getPlatformSpecialKey,
},
})
</script>

View File

@@ -1,7 +1,7 @@
<template> <template>
<header class="flex flex-1 p-2 items-center justify-between"> <header class="flex flex-1 py-2 px-4 items-center justify-between">
<div class="font-bold space-x-2 flex-shrink-0 inline-flex items-center"> <div class="font-bold space-x-2 flex-shrink-0 inline-flex items-center">
<AppLogo class="h-6 mx-4" /> Hoppscotch <AppLogo class="h-6 mr-4" /> Hoppscotch
</div> </div>
<div class="space-x-2 flex-shrink-0 inline-flex items-center"> <div class="space-x-2 flex-shrink-0 inline-flex items-center">
<AppGitHubStarButton class="mt-1 mr-2" /> <AppGitHubStarButton class="mt-1 mr-2" />
@@ -62,56 +62,8 @@
<FirebaseLogout @confirm-logout="$refs.user.tippy().hide()" /> <FirebaseLogout @confirm-logout="$refs.user.tippy().hide()" />
</tippy> </tippy>
</span> </span>
<span tabindex="-1">
<tippy
ref="options"
interactive
tabindex="-1"
trigger="click"
theme="popover"
arrow
>
<template #trigger>
<TabPrimary
v-tippy="{ theme: 'tooltip' }"
:title="$t('more')"
icon="drag_indicator"
/>
</template>
<SmartItem
icon="extension"
:label="$t('extensions')"
@click.native="
showExtensions = true
$refs.options.tippy().hide()
"
/>
<SmartItem
icon="keyboard"
:label="$t('shortcuts')"
@click.native="
showShortcuts = true
$refs.options.tippy().hide()
"
/>
<SmartItem
v-if="navigatorShare"
icon="share"
:label="$t('share')"
@click.native="
nativeShare()
$refs.options.tippy().hide()
"
/>
</tippy>
</span>
</div> </div>
<FirebaseLogin :show="showLogin" @hide-modal="showLogin = false" /> <FirebaseLogin :show="showLogin" @hide-modal="showLogin = false" />
<AppExtensions
:show="showExtensions"
@hide-modal="showExtensions = false"
/>
<AppShortcuts :show="showShortcuts" @hide-modal="showShortcuts = false" />
</header> </header>
</template> </template>
@@ -119,7 +71,6 @@
import intializePwa from "~/helpers/pwa" import intializePwa from "~/helpers/pwa"
import { currentUser$ } from "~/helpers/fb/auth" import { currentUser$ } from "~/helpers/fb/auth"
import { getLocalConfig, setLocalConfig } from "~/newstore/localpersistence" import { getLocalConfig, setLocalConfig } from "~/newstore/localpersistence"
import { getPlatformSpecialKey } from "~/helpers/platformutils"
export default { export default {
data() { data() {
@@ -129,9 +80,6 @@ export default {
// prompt. // prompt.
showInstallPrompt: null, showInstallPrompt: null,
showLogin: false, showLogin: false,
showExtensions: false,
showShortcuts: false,
navigatorShare: navigator.share,
} }
}, },
subscriptions() { subscriptions() {
@@ -161,22 +109,5 @@ export default {
}) })
} }
}, },
methods: {
nativeShare() {
if (navigator.share) {
navigator
.share({
title: "Hoppscotch",
text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
url: "https://hoppscotch.io",
})
.then(() => {})
.catch(console.error)
} else {
// fallback
}
},
getSpecialKey: getPlatformSpecialKey,
},
} }
</script> </script>

View File

@@ -18,7 +18,7 @@
:key="`shortcut-${index}-key-${keyIndex}`" :key="`shortcut-${index}-key-${keyIndex}`"
class=" class="
border border-divider border border-divider
rounded-lg rounded
font-bold font-bold
m-1 m-1
text-xs text-xs

View File

@@ -17,7 +17,7 @@
? `text-${color}-800 bg-${color}-200 hover:text-${color}-900 hover:bg-${color}-300 focus:text-${color}-900 focus:bg-${color}-300` ? `text-${color}-800 bg-${color}-200 hover:text-${color}-900 hover:bg-${color}-300 focus:text-${color}-900 focus:bg-${color}-300`
: `text-white bg-accent hover:bg-accentDark focus:bg-accentDark`, : `text-white bg-accent hover:bg-accentDark focus:bg-accentDark`,
label ? 'px-4' : 'px-2', label ? 'px-4' : 'px-2',
rounded ? 'rounded-full' : 'rounded-lg', rounded ? 'rounded-full' : 'rounded',
{ 'opacity-50 cursor-not-allowed': disabled }, { 'opacity-50 cursor-not-allowed': disabled },
{ 'pointer-events-none': loading }, { 'pointer-events-none': loading },
{ 'px-6 py-4 text-lg': large }, { 'px-6 py-4 text-lg': large },
@@ -53,9 +53,9 @@
class="svg-icons" class="svg-icons"
/> />
{{ label }} {{ label }}
<div v-if="shortcuts.length && SHORTCUTS_INDICATOR_ENABLED" class="ml-2"> <div v-if="shortcut.length && SHORTCUT_INDICATOR" class="ml-2">
<kbd <kbd
v-for="(key, index) in shortcuts" v-for="(key, index) in shortcut"
:key="`key-${index}`" :key="`key-${index}`"
class="bg-accentLight rounded ml-1 px-1 inline-flex" class="bg-accentLight rounded ml-1 px-1 inline-flex"
> >
@@ -132,21 +132,19 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
shortcuts: { shortcut: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
}, },
data() { data() {
return { return {
SHORTCUTS_INDICATOR_ENABLED: null, SHORTCUT_INDICATOR: null,
} }
}, },
subscriptions() { subscriptions() {
return { return {
SHORTCUTS_INDICATOR_ENABLED: getSettingSubject( SHORTCUT_INDICATOR: getSettingSubject("SHORTCUT_INDICATOR"),
"SHORTCUTS_INDICATOR_ENABLED"
),
} }
}, },
} }

View File

@@ -15,9 +15,9 @@
:class="[ :class="[
color color
? `text-${color}-400 hover:text-${color}-600 focus:text-${color}-600` ? `text-${color}-400 hover:text-${color}-600 focus:text-${color}-600`
: 'text-secondary hover:text-secondaryDark focus:text-secondaryDark', : 'text-secondary hover:text-secondaryDark hover:bg-primaryDark focus:text-secondaryDark',
label ? 'px-3' : 'px-2', label ? 'px-3' : 'px-2',
rounded ? 'rounded-full' : 'rounded-lg', rounded ? 'rounded-full' : 'rounded',
{ 'opacity-50 cursor-not-allowed': disabled }, { 'opacity-50 cursor-not-allowed': disabled },
{ 'flex-row-reverse': reverse }, { 'flex-row-reverse': reverse },
{ {
@@ -41,9 +41,9 @@
class="svg-icons" class="svg-icons"
/> />
{{ label }} {{ label }}
<div v-if="shortcuts.length && SHORTCUTS_INDICATOR_ENABLED" class="ml-2"> <div v-if="shortcut.length && SHORTCUT_INDICATOR" class="ml-2">
<kbd <kbd
v-for="(key, index) in shortcuts" v-for="(key, index) in shortcut"
:key="`key-${index}`" :key="`key-${index}`"
class=" class="
bg-dividerLight bg-dividerLight
@@ -109,21 +109,19 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
shortcuts: { shortcut: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
}, },
data() { data() {
return { return {
SHORTCUTS_INDICATOR_ENABLED: null, SHORTCUT_INDICATOR: null,
} }
}, },
subscriptions() { subscriptions() {
return { return {
SHORTCUTS_INDICATOR_ENABLED: getSettingSubject( SHORTCUT_INDICATOR: getSettingSubject("SHORTCUT_INDICATOR"),
"SHORTCUTS_INDICATOR_ENABLED"
),
} }
}, },
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<AppSection <AppSection
label="collections" label="collections"
:class="{ 'rounded-lg border-2 border-divider': savingMode }" :class="{ 'rounded border-2 border-divider': savingMode }"
> >
<div <div
class="flex flex-col top-10 z-10 sticky" class="flex flex-col top-10 z-10 sticky"

View File

@@ -1,7 +1,7 @@
<template> <template>
<AppSection <AppSection
label="collections" label="collections"
:class="{ 'rounded-lg border-2 border-divider': saveRequest }" :class="{ 'rounded border-2 border-divider': saveRequest }"
> >
<div <div
class="bg-primary flex flex-col top-0 z-10 sticky" class="bg-primary flex flex-col top-0 z-10 sticky"

View File

@@ -120,7 +120,7 @@ export default {
@apply p-4; @apply p-4;
@apply mt-4; @apply mt-4;
@apply border border-divider; @apply border border-divider;
@apply rounded-lg; @apply rounded;
h4 { h4 {
@apply mt-4; @apply mt-4;

View File

@@ -17,7 +17,7 @@
v-model="contentType" v-model="contentType"
class=" class="
bg-primary bg-primary
rounded-lg rounded
flex flex
font-semibold font-mono font-semibold font-mono
text-xs text-xs

View File

@@ -24,7 +24,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border-b border-dividerLight border-b border-dividerLight
rounded-lg rounded
cursor-pointer cursor-pointer
flex flex
font-semibold font-semibold
@@ -79,7 +79,7 @@
showPrintMargin: false, showPrintMargin: false,
useWorker: false, useWorker: false,
}" }"
styles="rounded-lg" styles="rounded"
/> />
</div> </div>
</template> </template>

View File

@@ -16,7 +16,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
cursor-pointer cursor-pointer
flex flex
font-mono font-mono
@@ -75,7 +75,7 @@
id="send" id="send"
class="rounded-none" class="rounded-none"
:label="!loading ? $t('send') : $t('cancel')" :label="!loading ? $t('send') : $t('cancel')"
:shortcuts="[getSpecialKey(), 'G']" :shortcut="[getSpecialKey(), 'G']"
outline outline
@click.native="!loading ? newSendRequest() : cancelRequest()" @click.native="!loading ? newSendRequest() : cancelRequest()"
/> />
@@ -125,7 +125,7 @@
<ButtonSecondary <ButtonSecondary
class="rounded-r-none ml-2" class="rounded-r-none ml-2"
:label="$t('save')" :label="$t('save')"
:shortcuts="[getSpecialKey(), 'S']" :shortcut="[getSpecialKey(), 'S']"
outline outline
@click.native="newSendRequest" @click.native="newSendRequest"
/> />

View File

@@ -1,8 +1,22 @@
<template> <template>
<div> <div>
<div v-if="results"> <div v-if="results.tests">
<span
v-if="results.tests.description"
class="font-semibold text-secondaryDark text-xs"
>
{{ results.tests.description }}
</span>
<HttpTestResult
v-for="(result, index) in results.tests"
:key="`result-${index}`"
class="divide-y divide-dividerLight"
:results="result"
/>
</div>
<div v-if="results.expectResults">
<div <div
v-for="(result, index) in results" v-for="(result, index) in results.expectResults"
:key="`result-${index}`" :key="`result-${index}`"
class="flex py-2 px-4 items-center" class="flex py-2 px-4 items-center"
> >
@@ -27,14 +41,6 @@
</span> </span>
</div> </div>
</div> </div>
<div v-if="results.tests">
<HttpTestResult
v-for="(result, index) in results.expectResults"
:key="`result-${index}`"
class="divide-y divide-dividerLight"
:results="results.expectResults"
/>
</div>
</div> </div>
</template> </template>
@@ -45,7 +51,7 @@ import { HoppTestResult } from "~/helpers/types/HoppTestResult"
export default defineComponent({ export default defineComponent({
props: { props: {
results: { results: {
type: Array as PropType<HoppTestResult>, type: Object as PropType<HoppTestResult>,
default: null, default: null,
}, },
}, },

View File

@@ -36,9 +36,6 @@
}" }"
complete-mode="test" complete-mode="test"
/> />
<pre>
{{ testResults }}
</pre>
<div v-if="testResults"> <div v-if="testResults">
<div class="flex flex-1 pl-4 items-center justify-between"> <div class="flex flex-1 pl-4 items-center justify-between">
<div> <div>
@@ -60,22 +57,7 @@
@click.native="clearContent()" @click.native="clearContent()"
/> />
</div> </div>
<div v-if="testResults.expectResults"> <HttpTestResult v-if="testResults" :results="testResults" />
<HttpTestResult
v-for="(result, index) in testResults.expectResults"
:key="`result-${index}`"
class="divide-y divide-dividerLight"
:results="testResults.expectResults"
/>
</div>
<div v-if="testResults.tests">
<HttpTestResult
v-for="(result, index) in testResults.tests"
:key="`result-${index}`"
class="divide-y divide-dividerLight"
:results="testResults.tests"
/>
</div>
</div> </div>
</AppSection> </AppSection>
</template> </template>

View File

@@ -38,7 +38,7 @@
svg="github" svg="github"
large large
rounded rounded
:shortcuts="['30k Stars']" :shortcut="['30k Stars']"
/> />
</div> </div>
<LandingStats /> <LandingStats />

View File

@@ -14,7 +14,7 @@
:alt="alt" :alt="alt"
loading="lazy" loading="lazy"
/> />
<div class="rounded-lg shadow-inner inset-0 absolute"></div> <div class="rounded shadow-inner inset-0 absolute"></div>
</div> </div>
</template> </template>

View File

@@ -14,7 +14,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
font-mono font-mono
text-secondaryDark text-secondaryDark
w-full w-full

View File

@@ -15,7 +15,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
font-mono font-mono
text-secondaryDark text-secondaryDark
w-full w-full

View File

@@ -12,7 +12,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
font-mono font-mono
text-secondaryDark text-secondaryDark
w-full w-full

View File

@@ -11,7 +11,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
font-mono font-mono
text-secondaryDark text-secondaryDark
w-full w-full

View File

@@ -14,7 +14,7 @@
@apply inline-flex; @apply inline-flex;
@apply items-center; @apply items-center;
@apply justify-center; @apply justify-center;
@apply rounded-lg; @apply rounded;
@apply m-1; @apply m-1;
@apply pl-4; @apply pl-4;
@apply bg-primaryDark; @apply bg-primaryDark;

View File

@@ -4,7 +4,7 @@
:exact="exact" :exact="exact"
:blank="blank" :blank="blank"
class=" class="
rounded-lg rounded
font-semibold font-semibold
text-xs text-xs
py-2 py-2

View File

@@ -22,7 +22,7 @@
<div <div
class=" class="
bg-primary bg-primary
rounded-lg rounded
flex flex-col flex flex-col
max-w-md max-h-lg max-w-md max-h-lg
flex-1 flex-1

View File

@@ -4,7 +4,7 @@
:exact="exact" :exact="exact"
:blank="blank" :blank="blank"
class=" class="
rounded-lg rounded
font-semibold font-semibold
py-2 py-2
px-4 px-4

View File

@@ -36,7 +36,7 @@ export default function getEnvironmentVariablesFromScript(script: string) {
// run pre-request script within this function so that it has access to the pw object. // run pre-request script within this function so that it has access to the pw object.
// eslint-disable-next-line no-new-func // eslint-disable-next-line no-new-func
new Function("pw", script)(pw) new Function("pw", script)(pw)
} catch (_e) { } } catch (_e) {}
return _variables return _variables
} }

View File

@@ -11,3 +11,7 @@ export const knownContentTypes = {
} }
export type ValidContentTypes = keyof typeof knownContentTypes export type ValidContentTypes = keyof typeof knownContentTypes
export function isJSONContentType(contentType: string) {
return /\bjson\b/i.test(contentType)
}

View File

@@ -59,7 +59,7 @@
"status": "Status", "status": "Status",
"headers": "Headers", "headers": "Headers",
"websocket": "WebSocket", "websocket": "WebSocket",
"waiting_for_connection": "(waiting for connection)", "waiting_for_connection": "waiting for connection",
"message": "Message", "message": "Message",
"sse": "SSE", "sse": "SSE",
"server": "Server", "server": "Server",

View File

@@ -17,44 +17,14 @@
<AppHeader /> <AppHeader />
</Pane> </Pane>
<Pane class="flex flex-1 overflow-auto"> <Pane class="flex flex-1 overflow-auto">
<nuxt class="flex flex-1" :hide-right-pane="RIGHT_SIDEBAR" /> <nuxt class="flex flex-1" />
</Pane> </Pane>
</Splitpanes> </Splitpanes>
</Pane> </Pane>
</Splitpanes> </Splitpanes>
</Pane> </Pane>
<Pane style="height: auto"> <Pane style="height: auto">
<div class="flex justify-between"> <AppFooter />
<div>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="LEFT_SIDEBAR ? $t('hide_sidebar') : $t('show_sidebar')"
icon="menu_open"
:class="{ 'transform rotate-180': !LEFT_SIDEBAR }"
@click.native="toggleSetting('LEFT_SIDEBAR')"
/>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="`${ZEN_MODE ? $t('turn_off') : $t('turn_on')} ${$t(
'zen_mode'
)}`"
:icon="ZEN_MODE ? 'fullscreen_exit' : 'fullscreen'"
:class="{
'text-accent focus:text-accent hover:text-accent': ZEN_MODE,
}"
@click.native="toggleSetting('ZEN_MODE')"
/>
</div>
<div>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="RIGHT_SIDEBAR ? $t('hide_sidebar') : $t('show_sidebar')"
icon="menu_open"
:class="['transform rotate-180', { 'rotate-0': !RIGHT_SIDEBAR }]"
@click.native="toggleSetting('RIGHT_SIDEBAR')"
/>
</div>
</div>
</Pane> </Pane>
</Splitpanes> </Splitpanes>
</div> </div>
@@ -69,38 +39,24 @@ import { performMigrations } from "~/helpers/migrations"
import { initUserInfo } from "~/helpers/teams/BackendUserInfo" import { initUserInfo } from "~/helpers/teams/BackendUserInfo"
import { registerApolloAuthUpdate } from "~/helpers/apollo" import { registerApolloAuthUpdate } from "~/helpers/apollo"
import { initializeFirebase } from "~/helpers/fb" import { initializeFirebase } from "~/helpers/fb"
import { import { getSettingSubject } from "~/newstore/settings"
defaultSettings,
getSettingSubject,
applySetting,
toggleSetting,
} from "~/newstore/settings"
import { logPageView } from "~/helpers/fb/analytics" import { logPageView } from "~/helpers/fb/analytics"
import type { KeysMatching } from "~/types/ts-utils"
type SettingsType = typeof defaultSettings
export default defineComponent({ export default defineComponent({
components: { Splitpanes, Pane }, components: { Splitpanes, Pane },
data() { data() {
return { return {
LEFT_SIDEBAR: null, LEFT_SIDEBAR: null,
RIGHT_SIDEBAR: null,
ZEN_MODE: null, ZEN_MODE: null,
} }
}, },
subscriptions() { subscriptions() {
return { return {
LEFT_SIDEBAR: getSettingSubject("LEFT_SIDEBAR"), LEFT_SIDEBAR: getSettingSubject("LEFT_SIDEBAR"),
RIGHT_SIDEBAR: getSettingSubject("RIGHT_SIDEBAR"),
ZEN_MODE: getSettingSubject("ZEN_MODE"), ZEN_MODE: getSettingSubject("ZEN_MODE"),
} }
}, },
watch: { watch: {
ZEN_MODE(ZEN_MODE) {
this.applySetting("LEFT_SIDEBAR", !ZEN_MODE)
this.applySetting("RIGHT_SIDEBAR", !ZEN_MODE)
},
$route(to) { $route(to) {
logPageView(to.fullPath) logPageView(to.fullPath)
}, },
@@ -159,13 +115,5 @@ export default defineComponent({
beforeDestroy() { beforeDestroy() {
document.removeEventListener("keydown", this._keyListener) document.removeEventListener("keydown", this._keyListener)
}, },
methods: {
toggleSetting<K extends KeysMatching<SettingsType, boolean>>(key: K) {
toggleSetting(key)
},
applySetting<K extends keyof SettingsType>(key: K, value: SettingsType[K]) {
applySetting(key, value)
},
},
}) })
</script> </script>

3
layouts/empty.vue Normal file
View File

@@ -0,0 +1,3 @@
<template>
<Nuxt />
</template>

View File

@@ -1,7 +1,5 @@
# MIDDLEWARE # MIDDLEWARE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your application middleware. This directory contains your application middleware.
Middleware let you define custom functions that can be run before rendering either a page or a group of pages. Middleware let you define custom functions that can be run before rendering either a page or a group of pages.

View File

@@ -44,7 +44,7 @@ export type SettingsType = {
THEME_COLOR: HoppAccentColor THEME_COLOR: HoppAccentColor
BG_COLOR: HoppBgColor BG_COLOR: HoppBgColor
TELEMETRY_ENABLED: boolean TELEMETRY_ENABLED: boolean
SHORTCUTS_INDICATOR_ENABLED: boolean SHORTCUT_INDICATOR: boolean
LEFT_SIDEBAR: boolean LEFT_SIDEBAR: boolean
RIGHT_SIDEBAR: boolean RIGHT_SIDEBAR: boolean
ZEN_MODE: boolean ZEN_MODE: boolean
@@ -70,7 +70,7 @@ export const defaultSettings: SettingsType = {
THEME_COLOR: "green", THEME_COLOR: "green",
BG_COLOR: "system", BG_COLOR: "system",
TELEMETRY_ENABLED: true, TELEMETRY_ENABLED: true,
SHORTCUTS_INDICATOR_ENABLED: false, SHORTCUT_INDICATOR: false,
LEFT_SIDEBAR: true, LEFT_SIDEBAR: true,
RIGHT_SIDEBAR: true, RIGHT_SIDEBAR: true,
ZEN_MODE: false, ZEN_MODE: false,

View File

@@ -1,8 +1,12 @@
<template> <template>
<div class="flex flex-col min-h-screen"> <div class="flex flex-col min-h-screen items-center justify-center">
<span v-if="signingInWithEmail">{{ $t("loading") }}</span> <span v-if="signingInWithEmail">
<span v-else>{{ $t("waiting_for_connection") }}</span> <SmartSpinner />
<pre v-if="error">{{ error }}</pre> </span>
<span v-else class="text-secondaryLight text-xs">
{{ $t("waiting_for_connection") }}
</span>
<pre v-if="error" class="font-mono text-xs">{{ error }}</pre>
</div> </div>
</template> </template>
@@ -13,6 +17,7 @@ import { isSignInWithEmailLink, signInWithEmailLink } from "~/helpers/fb/auth"
import { getLocalConfig, removeLocalConfig } from "~/newstore/localpersistence" import { getLocalConfig, removeLocalConfig } from "~/newstore/localpersistence"
export default Vue.extend({ export default Vue.extend({
layout: "empty",
data() { data() {
return { return {
signingInWithEmail: false, signingInWithEmail: false,

View File

@@ -15,7 +15,7 @@
class=" class="
bg-primaryLight bg-primaryLight
border border-divider border border-divider
rounded-l-lg rounded-l
font-mono font-mono
text-secondaryDark text-secondaryDark
w-full w-full

View File

@@ -173,13 +173,11 @@
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
<SmartToggle <SmartToggle
:on="SHORTCUTS_INDICATOR_ENABLED" :on="SHORTCUT_INDICATOR"
@change="toggleSetting('SHORTCUTS_INDICATOR_ENABLED')" @change="toggleSetting('SHORTCUT_INDICATOR')"
> >
{{ $t("shortcuts_indicator") }} {{ $t("shortcuts_indicator") }}
{{ {{ SHORTCUT_INDICATOR ? $t("enabled") : $t("disabled") }}
SHORTCUTS_INDICATOR_ENABLED ? $t("enabled") : $t("disabled")
}}
</SmartToggle> </SmartToggle>
</div> </div>
<div class="flex items-center"> <div class="flex items-center">
@@ -229,6 +227,26 @@
{{ $t("extension_ver_not_reported") }} {{ $t("extension_ver_not_reported") }}
</span> </span>
</div> </div>
<div class="flex flex-col space-y-2 py-4">
<span>
<SmartItem
to="https://addons.mozilla.org/en-US/firefox/addon/hoppscotch"
blank
svg="firefox"
label="Firefox"
:info-icon="hasFirefoxExtInstalled ? 'check_circle' : ''"
/>
</span>
<span>
<SmartItem
to="https://chrome.google.com/webstore/detail/hoppscotch-browser-extens/amknoiejhlmhancpahfcfcfhllgkpbld"
blank
svg="chrome"
label="Chrome"
:info-icon="hasChromeExtInstalled ? 'check_circle' : ''"
/>
</span>
</div>
<div class="space-y-4 mt-4"> <div class="space-y-4 mt-4">
<div class="flex items-center"> <div class="flex items-center">
<SmartToggle <SmartToggle
@@ -318,7 +336,11 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api" import { defineComponent } from "@nuxtjs/composition-api"
import { hasExtensionInstalled } from "../helpers/strategies/ExtensionStrategy" import {
hasExtensionInstalled,
hasChromeExtensionInstalled,
hasFirefoxExtensionInstalled,
} from "~/helpers/strategies/ExtensionStrategy"
import { import {
applySetting, applySetting,
toggleSetting, toggleSetting,
@@ -345,7 +367,7 @@ export default defineComponent({
SYNC_ENVIRONMENTS: useSetting("syncEnvironments"), SYNC_ENVIRONMENTS: useSetting("syncEnvironments"),
SYNC_HISTORY: useSetting("syncHistory"), SYNC_HISTORY: useSetting("syncHistory"),
TELEMETRY_ENABLED: useSetting("TELEMETRY_ENABLED"), TELEMETRY_ENABLED: useSetting("TELEMETRY_ENABLED"),
SHORTCUTS_INDICATOR_ENABLED: useSetting("SHORTCUTS_INDICATOR_ENABLED"), SHORTCUT_INDICATOR: useSetting("SHORTCUT_INDICATOR"),
LEFT_SIDEBAR: useSetting("LEFT_SIDEBAR"), LEFT_SIDEBAR: useSetting("LEFT_SIDEBAR"),
ZEN_MODE: useSetting("ZEN_MODE"), ZEN_MODE: useSetting("ZEN_MODE"),
currentUser: useReadonlyStream(currentUser$, currentUser$.value), currentUser: useReadonlyStream(currentUser$, currentUser$.value),
@@ -357,6 +379,9 @@ export default defineComponent({
? window.__POSTWOMAN_EXTENSION_HOOK__.getVersion() ? window.__POSTWOMAN_EXTENSION_HOOK__.getVersion()
: null, : null,
hasChromeExtInstalled: hasChromeExtensionInstalled(),
hasFirefoxExtInstalled: hasFirefoxExtensionInstalled(),
clearIcon: "clear_all", clearIcon: "clear_all",
showLogin: false, showLogin: false,