chore: improve UI flow and add i18n

This commit is contained in:
nivedin
2023-11-09 14:07:56 +05:30
committed by Andrew Bastin
parent 1896e5afe1
commit f8aeb42da5
7 changed files with 55 additions and 29 deletions

View File

@@ -17,6 +17,7 @@
--lower-tertiary-sticky-fold: 7.125rem; --lower-tertiary-sticky-fold: 7.125rem;
--lower-fourth-sticky-fold: 9.188rem; --lower-fourth-sticky-fold: 9.188rem;
--sidebar-primary-sticky-fold: 2rem; --sidebar-primary-sticky-fold: 2rem;
--properties-primary-sticky-fold: 2.05rem;
} }
@mixin light-theme { @mixin light-theme {

View File

@@ -356,6 +356,8 @@
"offline_short": "You're using Hoppscotch offline.", "offline_short": "You're using Hoppscotch offline.",
"post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.", "post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.",
"pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.", "pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.",
"collection_properties_authorization": " This authorization will be set for every request in this collection.",
"collection_properties_header": "This header will be set for every request in this collection.",
"script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.", "script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.",
"test_script_fail": "There seems to be an error with test script. Please fix the errors and run tests again", "test_script_fail": "There seems to be an error with test script. Please fix the errors and run tests again",
"tests": "Write a test script to automate debugging." "tests": "Write a test script to automate debugging."

View File

@@ -3,19 +3,44 @@
v-if="show" v-if="show"
dialog dialog
:title="t('collection.properties')" :title="t('collection.properties')"
:full-width-body="true"
@close="hideModal" @close="hideModal"
> >
<template #body> <template #body>
<HoppSmartTabs <HoppSmartTabs
v-model="selectedOptionTab" v-model="selectedOptionTab"
styles="sticky overflow-x-auto flex-shrink-0 bg-primary z-10" styles="sticky overflow-x-auto flex-shrink-0 bg-primary top-0 z-10 !-py-4"
render-inactive-tabs render-inactive-tabs
> >
<HoppSmartTab :id="'headers'" :label="`${t('tab.headers')}`"> <HoppSmartTab :id="'headers'" :label="`${t('tab.headers')}`">
<HttpHeaders <HttpHeaders
v-model="editableCollection" v-model="editableCollection"
:is-collection-property="true"
@change-tab="changeOptionTab" @change-tab="changeOptionTab"
/> />
<AppBanner
:banner="{
type: 'info',
alternateText: 'This is an alternate text',
}"
class="sticky bottom-0 z-10"
>
<span>
{{ t("helpers.collection_properties_header") }}
<a href="hopp.sh" target="_blank" class="underline">{{
t("action.learn_more")
}}</a>
</span>
</AppBanner>
</HoppSmartTab>
<HoppSmartTab
:id="'authorization'"
:label="`${t('tab.authorization')}`"
>
<HttpAuthorization
v-model="editableCollection.auth"
:is-collection-property="true"
/>
<AppBanner <AppBanner
:banner="{ :banner="{
type: 'info', type: 'info',
@@ -23,26 +48,10 @@
}" }"
> >
<span> <span>
This header will be set for every request in this collection. {{ t("helpers.collection_properties_authorization") }}
<a href="hopp.sh" class="underline">Learn More</a> <a href="hopp.sh" target="_blank" class="underline">{{
</span> t("action.learn_more")
</AppBanner> }}</a>
</HoppSmartTab>
<HoppSmartTab
:id="'authorization'"
:label="`${t('tab.authorization')}`"
>
<HttpAuthorization v-model="editableCollection.auth" />
<AppBanner
:banner="{
type: 'info',
alternateText: 'This is an alternate text',
}"
>
<span>
This authorization will be set for every request in this
collection.
<a href="hopp.sh" class="underline">Learn More</a>
</span> </span>
</AppBanner> </AppBanner>
</HoppSmartTab> </HoppSmartTab>
@@ -72,6 +81,7 @@ import { watch, ref } from "vue"
import { useI18n } from "@composables/i18n" import { useI18n } from "@composables/i18n"
import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data" import { HoppCollection, HoppRESTRequest } from "@hoppscotch/data"
import { TeamCollection } from "~/helpers/backend/graphql" import { TeamCollection } from "~/helpers/backend/graphql"
import { RESTOptionTabs } from "../http/RequestOptions.vue"
const t = useI18n() const t = useI18n()
@@ -103,13 +113,11 @@ const editableCollection = ref({
authType: "none", authType: "none",
authActive: false, authActive: false,
}, },
}) }) as any
type Tab = "headers" | "authorization"
const selectedOptionTab = ref("headers") const selectedOptionTab = ref("headers")
const changeOptionTab = (tab: Tab) => { const changeOptionTab = (tab: RESTOptionTabs) => {
selectedOptionTab.value = tab selectedOptionTab.value = tab
} }

View File

@@ -2,6 +2,11 @@
<div class="flex flex-1 flex-col"> <div class="flex flex-1 flex-col">
<div <div
class="sticky z-10 flex flex-shrink-0 items-center justify-between overflow-x-auto border-b border-dividerLight bg-primary pl-4" class="sticky z-10 flex flex-shrink-0 items-center justify-between overflow-x-auto border-b border-dividerLight bg-primary pl-4"
:class="{
'top-upperMobileSecondaryStickyFold sm:top-upperSecondaryStickyFold':
!isCollectionProperty,
'top-propertiesPrimaryStickyFold': isCollectionProperty,
}"
> >
<span class="flex items-center"> <span class="flex items-center">
<label class="truncate font-semibold text-secondaryLight"> <label class="truncate font-semibold text-secondaryLight">
@@ -188,6 +193,7 @@ const colorMode = useColorMode()
const props = defineProps<{ const props = defineProps<{
modelValue: HoppRESTAuth modelValue: HoppRESTAuth
isCollectionProperty?: boolean
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{

View File

@@ -2,6 +2,11 @@
<div class="flex flex-1 flex-col"> <div class="flex flex-1 flex-col">
<div <div
class="sticky z-10 flex flex-shrink-0 items-center justify-between overflow-x-auto border-b border-dividerLight bg-primary pl-4" class="sticky z-10 flex flex-shrink-0 items-center justify-between overflow-x-auto border-b border-dividerLight bg-primary pl-4"
:class="{
'top-upperMobileSecondaryStickyFold sm:top-upperSecondaryStickyFold':
!isCollectionProperty,
'top-propertiesPrimaryStickyFold': isCollectionProperty,
}"
> >
<label class="truncate font-semibold text-secondaryLight"> <label class="truncate font-semibold text-secondaryLight">
{{ t("request.header_list") }} {{ t("request.header_list") }}
@@ -288,9 +293,10 @@ const linewrapEnabled = ref(true)
const deletionToast = ref<{ goAway: (delay: number) => void } | null>(null) const deletionToast = ref<{ goAway: (delay: number) => void } | null>(null)
// v-model integration with props and emit // v-model integration with props and emit
const props = defineProps<{ modelValue: HoppRESTRequest }>() const props = defineProps<{
modelValue: HoppRESTRequest
console.log(props.modelValue) isCollectionProperty?: boolean
}>()
const emit = defineEmits<{ const emit = defineEmits<{
(e: "change-tab", value: RESTOptionTabs): void (e: "change-tab", value: RESTOptionTabs): void

View File

@@ -22,6 +22,7 @@
--lower-tertiary-sticky-fold: 7.125rem; --lower-tertiary-sticky-fold: 7.125rem;
--lower-fourth-sticky-fold: 9.188rem; --lower-fourth-sticky-fold: 9.188rem;
--sidebar-primary-sticky-fold: 2rem; --sidebar-primary-sticky-fold: 2rem;
--properties-primary-sticky-fold: 2.05rem;
} }
@mixin dark-theme { @mixin dark-theme {

View File

@@ -59,7 +59,7 @@
</div> </div>
<div <div
class="flex flex-col overflow-y-auto max-h-[55vh]" class="flex flex-col overflow-y-auto max-h-[55vh]"
:class="{ 'p-4': !fullWidth }" :class="{ 'p-4': !fullWidth && !fullWidthBody }"
> >
<slot name="body"></slot> <slot name="body"></slot>
</div> </div>
@@ -117,6 +117,7 @@ withDefaults(
dimissible: boolean dimissible: boolean
placement: string placement: string
fullWidth: boolean fullWidth: boolean
fullWidthBody: boolean
styles: string styles: string
closeText: string | null closeText: string | null
}>(), }>(),
@@ -126,6 +127,7 @@ withDefaults(
dimissible: true, dimissible: true,
placement: "top", placement: "top",
fullWidth: false, fullWidth: false,
fullWidthBody: false,
styles: "sm:max-w-lg", styles: "sm:max-w-lg",
closeText: null, closeText: null,
} }