feat: better route determination - fixed #1732

This commit is contained in:
liyasthomas
2021-06-21 15:33:51 +05:30
parent 5bb9b1b675
commit 6ddff58ba5
17 changed files with 127 additions and 107 deletions

View File

@@ -9,7 +9,7 @@
<nuxt-link <nuxt-link
v-tooltip.right="$t('home')" v-tooltip.right="$t('home')"
:to="localePath('index')" :to="localePath('index')"
:class="linkActive('/')" :class="linkActive('index')"
:aria-label="$t('home')" :aria-label="$t('home')"
> >
<AppLogo alt class="material-icons" style="height: 24px" /> <AppLogo alt class="material-icons" style="height: 24px" />
@@ -17,14 +17,14 @@
<nuxt-link <nuxt-link
v-tooltip.right="$t('realtime')" v-tooltip.right="$t('realtime')"
:to="localePath('realtime')" :to="localePath('realtime')"
:class="linkActive('/realtime')" :class="linkActive('realtime')"
> >
<i class="material-icons">language</i> <i class="material-icons">language</i>
</nuxt-link> </nuxt-link>
<nuxt-link <nuxt-link
v-tooltip.right="$t('graphql')" v-tooltip.right="$t('graphql')"
:to="localePath('graphql')" :to="localePath('graphql')"
:class="linkActive('/graphql')" :class="linkActive('graphql')"
:aria-label="$t('graphql')" :aria-label="$t('graphql')"
> >
<svg <svg
@@ -51,7 +51,7 @@
<nuxt-link <nuxt-link
v-tooltip.right="$t('documentation')" v-tooltip.right="$t('documentation')"
:to="localePath('doc')" :to="localePath('doc')"
:class="linkActive('/doc')" :class="linkActive('doc')"
:aria-label="$t('documentation')" :aria-label="$t('documentation')"
> >
<i class="material-icons">topic</i> <i class="material-icons">topic</i>
@@ -59,65 +59,24 @@
<nuxt-link <nuxt-link
v-tooltip.right="$t('settings')" v-tooltip.right="$t('settings')"
:to="localePath('settings')" :to="localePath('settings')"
:class="linkActive('/settings')" :class="linkActive('settings')"
:aria-label="$t('settings')" :aria-label="$t('settings')"
> >
<i class="material-icons">settings</i> <i class="material-icons">settings</i>
</nuxt-link> </nuxt-link>
</nav> </nav>
<nav v-if="$route.path == '/'" class="secondary-nav"> <nav
<a v-tooltip.right="$t('request')" href="#request"> v-for="(link, index) in currentNavigation"
<i class="material-icons">cloud_upload</i> :key="`link-${index}`"
</a> class="secondary-nav"
<a v-tooltip.right="$t('options')" href="#options"> >
<i class="material-icons">toc</i> <a
</a> v-for="(item, itemIndex) in link.secondary"
<a v-tooltip.right="$t('response')" href="#response"> :key="`item-${itemIndex}`"
<i class="material-icons">cloud_download</i> v-tooltip.right="$t(item.tooltip)"
</a> :href="item.target"
</nav> >
<nav v-else-if="$route.path.includes('/realtime')" class="secondary-nav"> <i class="material-icons">{{ item.icon }}</i>
<a v-tooltip.right="$t('request')" href="#request">
<i class="material-icons">cloud_upload</i>
</a>
<a v-tooltip.right="$t('communication')" href="#response">
<i class="material-icons">cloud_download</i>
</a>
</nav>
<nav v-else-if="$route.path.includes('/graphql')" class="secondary-nav">
<a v-tooltip.right="$t('endpoint')" href="#endpoint">
<i class="material-icons">cloud</i>
</a>
<a v-tooltip.right="$t('schema')" href="#schema">
<i class="material-icons">assignment_returned</i>
</a>
<a v-tooltip.right="$t('query')" href="#query">
<i class="material-icons">cloud_upload</i>
</a>
<a v-tooltip.right="$t('response')" href="#response">
<i class="material-icons">cloud_download</i>
</a>
</nav>
<nav v-else-if="$route.path.includes('/doc')" class="secondary-nav">
<a v-tooltip.right="$t('import')" href="#import">
<i class="material-icons">folder</i>
</a>
<a v-tooltip.right="$t('documentation')" href="#documentation">
<i class="material-icons">insert_drive_file</i>
</a>
</nav>
<nav v-else-if="$route.path.includes('/settings')" class="secondary-nav">
<a v-tooltip.right="$t('account')" href="#account">
<i class="material-icons">person</i>
</a>
<a v-tooltip.right="$t('theme')" href="#theme">
<i class="material-icons">brush</i>
</a>
<a v-tooltip.right="$t('extensions')" href="#extensions">
<i class="material-icons">extension</i>
</a>
<a v-tooltip.right="$t('proxy')" href="#proxy">
<i class="material-icons">public</i>
</a> </a>
</nav> </nav>
</aside> </aside>
@@ -126,6 +85,79 @@
<script> <script>
export default { export default {
data() {
return {
navigation: [
{
primary: "index",
secondary: [
{ tooltip: "request", target: "#request", icon: "cloud_upload" },
{ tooltip: "options", target: "#options", icon: "toc" },
{
tooltip: "response",
target: "#response",
icon: "cloud_download",
},
],
},
{
primary: "realtime",
secondary: [
{ tooltip: "request", target: "#request", icon: "cloud_upload" },
{
tooltip: "communication",
target: "#response",
icon: "cloud_download",
},
],
},
{
primary: "graphql",
secondary: [
{ tooltip: "endpoint", target: "#endpoint", icon: "cloud" },
{
tooltip: "schema",
target: "#schema",
icon: "assignment_returned",
},
{ tooltip: "query", target: "#query", icon: "cloud_upload" },
{
tooltip: "response",
target: "#response",
icon: "cloud_download",
},
],
},
{
primary: "doc",
secondary: [
{ tooltip: "import", target: "#import", icon: "folder" },
{
tooltip: "documentation",
target: "#documentation",
icon: "insert_drive_file",
},
],
},
{
primary: "settings",
secondary: [
{ tooltip: "account", target: "#account", icon: "person" },
{ tooltip: "theme", target: "#theme", icon: "brush" },
{ tooltip: "extensions", target: "#extensions", icon: "extension" },
{ tooltip: "proxy", target: "#proxy", icon: "public" },
],
},
],
}
},
computed: {
currentNavigation() {
return this.navigation.filter((item) =>
this.$route.name.includes(item.primary)
)
},
},
mounted() { mounted() {
window.addEventListener("scroll", () => { window.addEventListener("scroll", () => {
const mainNavLinks = document.querySelectorAll("nav.secondary-nav a") const mainNavLinks = document.querySelectorAll("nav.secondary-nav a")
@@ -147,8 +179,8 @@ export default {
methods: { methods: {
linkActive(path) { linkActive(path) {
return { return {
"nuxt-link-exact-active": this.$route.path === path, "nuxt-link-exact-active": this.$route.name.includes(path),
"nuxt-link-active": this.$route.path === path, "nuxt-link-active": this.$route.name.includes(path),
} }
}, },
}, },

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="collections" :label="$t('collections')"> <AppSection label="collections">
<div class="show-on-large-screen"> <div class="show-on-large-screen">
<input <input
v-if="showCollActions" v-if="showCollActions"

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="collections" :label="$t('collections')"> <AppSection label="collections">
<div class="show-on-large-screen"> <div class="show-on-large-screen">
<input <input
v-if="!saveRequest" v-if="!saveRequest"

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="environments" :label="$t('environments')"> <AppSection label="environments">
<div class="show-on-large-screen"> <div class="show-on-large-screen">
<span class="select-wrapper"> <span class="select-wrapper">
<select <select

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="history" :label="$t('history')"> <AppSection label="history">
<div class="show-on-large-screen"> <div class="show-on-large-screen">
<input <input
v-model="filterText" v-model="filterText"

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="headers" label="Headers"> <AppSection label="headers">
<ul v-if="headers.length !== 0"> <ul v-if="headers.length !== 0">
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="parameters" label="Parameters"> <AppSection label="parameters">
<ul v-if="params.length !== 0"> <ul v-if="params.length !== 0">
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection id="response" ref="response" :label="$t('response')"> <AppSection label="response">
<HttpResponseMeta :response="response" :active="active" /> <HttpResponseMeta :response="response" :active="active" />
<div v-if="response.body && response.body !== $t('loading')"> <div v-if="response.body && response.body !== $t('loading')">
<LensesResponseBodyRenderer :response="response" /> <LensesResponseBodyRenderer :response="response" />

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<AppSection :label="$t('request')"> <AppSection label="request">
<ul> <ul>
<li> <li>
<label for="mqtt-url">{{ $t("url") }}</label> <label for="mqtt-url">{{ $t("url") }}</label>
@@ -34,7 +34,7 @@
</ul> </ul>
</AppSection> </AppSection>
<AppSection :label="$t('communication')"> <AppSection label="response">
<ul> <ul>
<li> <li>
<RealtimeLog :title="$t('log')" :log="log" /> <RealtimeLog :title="$t('log')" :log="log" />

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<AppSection ref="request" :label="$t('request')"> <AppSection label="request">
<ul> <ul>
<li> <li>
<label for="socketio-url">{{ $t("url") }}</label> <label for="socketio-url">{{ $t("url") }}</label>
@@ -43,7 +43,7 @@
</ul> </ul>
</AppSection> </AppSection>
<AppSection id="response" ref="response" :label="$t('communication')"> <AppSection label="response">
<ul> <ul>
<li> <li>
<RealtimeLog :title="$t('log')" :log="communication.log" /> <RealtimeLog :title="$t('log')" :log="communication.log" />

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<AppSection ref="request" :label="$t('request')"> <AppSection label="request">
<ul> <ul>
<li> <li>
<label for="server">{{ $t("server") }}</label> <label for="server">{{ $t("server") }}</label>
@@ -36,7 +36,7 @@
</ul> </ul>
</AppSection> </AppSection>
<AppSection id="response" ref="response" :label="$t('communication')"> <AppSection label="response">
<ul> <ul>
<li> <li>
<RealtimeLog :title="$t('events')" :log="events.log" /> <RealtimeLog :title="$t('events')" :log="events.log" />

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<AppSection ref="request" :label="$t('request')"> <AppSection label="request">
<ul> <ul>
<li> <li>
<label for="websocket-url">{{ $t("url") }}</label> <label for="websocket-url">{{ $t("url") }}</label>
@@ -112,7 +112,7 @@
</ul> </ul>
</AppSection> </AppSection>
<AppSection id="response" ref="response" :label="$t('communication')"> <AppSection label="response">
<ul> <ul>
<li> <li>
<RealtimeLog :title="$t('log')" :log="communication.log" /> <RealtimeLog :title="$t('log')" :log="communication.log" />

View File

@@ -1,5 +1,5 @@
<template> <template>
<AppSection ref="teams" :label="$t('teams')"> <AppSection label="teams">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("teams") }}</label> <label>{{ $t("teams") }}</label>
<div v-if="currentUser"></div> <div v-if="currentUser"></div>

View File

@@ -2,7 +2,7 @@
<div class="page"> <div class="page">
<div class="content"> <div class="content">
<div class="page-columns inner-left"> <div class="page-columns inner-left">
<AppSection ref="import" :label="$t('import')"> <AppSection label="import">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("collection") }}</label> <label>{{ $t("collection") }}</label>
<p class="info"> <p class="info">
@@ -55,7 +55,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="documentation" :label="$t('documentation')"> <AppSection label="documentation">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("documentation") }}</label> <label>{{ $t("documentation") }}</label>
<p v-if="items.length === 0" class="info"> <p v-if="items.length === 0" class="info">

View File

@@ -2,7 +2,7 @@
<div class="page"> <div class="page">
<div class="content"> <div class="content">
<div class="page-columns inner-left"> <div class="page-columns inner-left">
<AppSection ref="endpoint" :label="$t('endpoint')"> <AppSection label="endpoint">
<ul> <ul>
<li> <li>
<label for="url">{{ $t("url") }}</label> <label for="url">{{ $t("url") }}</label>
@@ -37,7 +37,7 @@
</ul> </ul>
</AppSection> </AppSection>
<AppSection ref="headers" :label="$t('headers')"> <AppSection label="headers">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("headers") }}</label> <label>{{ $t("headers") }}</label>
<ul v-if="headers.length !== 0"> <ul v-if="headers.length !== 0">
@@ -150,7 +150,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="schema" :label="$t('schema')"> <AppSection label="schema">
<div class="row-wrapper"> <div class="row-wrapper">
<label>{{ $t("schema") }}</label> <label>{{ $t("schema") }}</label>
<div v-if="schema"> <div v-if="schema">
@@ -212,7 +212,7 @@
/> />
</AppSection> </AppSection>
<AppSection ref="query" :label="$t('query')"> <AppSection label="query">
<div class="row-wrapper gqlRunQuery"> <div class="row-wrapper gqlRunQuery">
<label for="gqlQuery">{{ $t("query") }}</label> <label for="gqlQuery">{{ $t("query") }}</label>
<div> <div>
@@ -266,7 +266,7 @@
/> />
</AppSection> </AppSection>
<AppSection ref="variables" :label="$t('variables')"> <AppSection label="variables">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("variables") }}</label> <label>{{ $t("variables") }}</label>
<SmartAceEditor <SmartAceEditor
@@ -285,7 +285,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="response" :label="$t('response')"> <AppSection label="response">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("response") }}</label> <label>{{ $t("response") }}</label>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -347,7 +347,7 @@
> >
<SmartTabs> <SmartTabs>
<SmartTab :id="'docs'" :label="`Docs`" :selected="true"> <SmartTab :id="'docs'" :label="`Docs`" :selected="true">
<AppSection ref="docs" :label="$t('docs')"> <AppSection label="docs">
<section class="flex-col"> <section class="flex-col">
<input <input
v-model="graphqlFieldsFilterText" v-model="graphqlFieldsFilterText"

View File

@@ -3,7 +3,7 @@
<div class="page"> <div class="page">
<div class="content"> <div class="content">
<div class="page-columns inner-left"> <div class="page-columns inner-left">
<AppSection :label="$t('request')" ref="request"> <AppSection label="request">
<ul> <ul>
<li class="shrink"> <li class="shrink">
<label for="method">{{ $t("method") }}</label> <label for="method">{{ $t("method") }}</label>
@@ -253,7 +253,7 @@
</SmartTab> </SmartTab>
<SmartTab :id="'authentication'" :label="$t('authentication')"> <SmartTab :id="'authentication'" :label="$t('authentication')">
<AppSection :label="$t('authentication')" ref="authentication"> <AppSection label="authentication">
<ul> <ul>
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -352,11 +352,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection <AppSection v-if="showTokenRequest" label="accessTokenRequest">
v-if="showTokenRequest"
label="Access Token Request"
ref="accessTokenRequest"
>
<ul> <ul>
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -478,11 +474,7 @@
:id="'pre_request_script'" :id="'pre_request_script'"
:label="$t('pre_request_script')" :label="$t('pre_request_script')"
> >
<AppSection <AppSection v-if="showPreRequestScript" label="preRequest">
v-if="showPreRequestScript"
:label="$t('pre_request_script')"
ref="preRequest"
>
<ul> <ul>
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -518,11 +510,7 @@
</SmartTab> </SmartTab>
<SmartTab :id="'tests'" :label="$t('tests')"> <SmartTab :id="'tests'" :label="$t('tests')">
<AppSection <AppSection v-if="testsEnabled" label="postRequestTests">
v-if="testsEnabled"
:label="$t('tests')"
ref="postRequestTests"
>
<ul> <ul>
<li> <li>
<div class="row-wrapper"> <div class="row-wrapper">

View File

@@ -4,7 +4,7 @@
<Teams /> <Teams />
</div> </div>
<AppSection ref="account" :label="$t('account')"> <AppSection label="account">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("account") }}</label> <label>{{ $t("account") }}</label>
<div v-if="currentUser"> <div v-if="currentUser">
@@ -67,7 +67,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="theme" :label="$t('theme')"> <AppSection label="theme">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("theme") }}</label> <label>{{ $t("theme") }}</label>
<SmartColorModePicker /> <SmartColorModePicker />
@@ -84,7 +84,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="extensions" :label="$t('extensions')"> <AppSection label="extensions">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("extensions") }}</label> <label>{{ $t("extensions") }}</label>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -106,7 +106,7 @@
</div> </div>
</AppSection> </AppSection>
<AppSection ref="proxy" :label="$t('proxy')"> <AppSection label="proxy">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("proxy") }}</label> <label>{{ $t("proxy") }}</label>
<div class="row-wrapper"> <div class="row-wrapper">
@@ -177,7 +177,7 @@
--> -->
</AppSection> </AppSection>
<AppSection ref="experiments" :label="$t('experiments')"> <AppSection label="experiments">
<div class="flex flex-col"> <div class="flex flex-col">
<label>{{ $t("experiments") }}</label> <label>{{ $t("experiments") }}</label>
<p class="info"> <p class="info">