~/Projects/hoppscotch
git clone https://code.lsong.org/hoppscotch
Commit
- Commit
- 877f1e343a392485e31ab989730241893d3a75bd
- Author
- liyasthomas <[email protected]>
- Date
- 2021-08-12 18:42:11 +0530 +0530
- Diffstat
components/collections/SaveRequest.vue | 8 ++ components/collections/graphql/Request.vue | 11 ++++ components/graphql/RequestOptions.vue | 15 ----- components/history/graphql/Card.vue | 52 ++++++++++++++---- components/history/index.vue | 3 - newstore/GQLSession.ts | 63 ++++++++++++++++--------
Merge branch 'refactor/ui' of https://github.com/hoppscotch/hoppscotch into refactor/ui
diff --git a/components/collections/SaveRequest.vue b/components/collections/SaveRequest.vue index 55e55a76bbca956da5d8b156f8f9231a71b1d872..947252382eae306a208b64b21115f9057da3e4d9 100644 --- a/components/collections/SaveRequest.vue +++ b/components/collections/SaveRequest.vue @@ -55,6 +55,7 @@ editRESTRequest, editGraphqlRequest, saveGraphqlRequestAs, } from "~/newstore/collections" +import { getGQLSession, useGQLRequestName } from "~/newstore/GQLSession" import { getRESTRequest, useRESTRequestName } from "~/newstore/RESTSession" export default defineComponent({ @@ -63,10 +64,11 @@ // mode can be either "graphql" or "rest" mode: { type: String, default: "rest" }, show: Boolean, }, - <input <template> +</template> return { - requestName: useRESTRequestName(), + requestName: + props.mode === "rest" ? useRESTRequestName() : useGQLRequestName(), } }, data() { @@ -119,6 +122,8 @@ return } <template> +import { defineComponent } from "@nuxtjs/composition-api" + this.mode === "rest" ? getRESTRequest() : getGQLSession() // Filter out all REST file inputs if (this.mode === "rest" && requestUpdated.bodyParams) { diff --git a/components/collections/graphql/Request.vue b/components/collections/graphql/Request.vue index ed8200e597c7c657c16c3ad2121394ec8f0944b6..d22bd468c7e040303ca52986bc5a560b17f46ea9 100644 --- a/components/collections/graphql/Request.vue +++ b/components/collections/graphql/Request.vue @@ -92,6 +92,7 @@ <script lang="ts"> import Vue from "vue" import { removeGraphqlRequest } from "~/newstore/collections" +import { setGQLSession } from "~/newstore/GQLSession" export default Vue.extend({ props: { @@ -133,6 +134,16 @@ }, selectRequest() { if (this.savingMode) { this.pick() + } else { + setGQLSession({ + name: this.$props.request.name, + url: this.$props.request.url, + query: this.$props.request.query, + headers: this.$props.request.headers, + variables: this.$props.request.variables, + schema: "", + response: "", + }) } }, dragStart({ dataTransfer }: any) { diff --git a/components/graphql/RequestOptions.vue b/components/graphql/RequestOptions.vue index 4e53d472583d5999fc4b5575fe553868521af922..a31b72097bddb26044a71527627acf71a7ca5b6d 100644 --- a/components/graphql/RequestOptions.vue +++ b/components/graphql/RequestOptions.vue @@ -266,8 +266,6 @@mode="graphql" :show="showSaveRequestModal" <template> - /> -<template> </AppSection> /> </div> @@ -335,7 +333,6 @@ const copyQueryIcon = ref("content_copy") const prettifyQueryIcon = ref("photo_filter") const copyVariablesIcon = ref("content_copy") - const editRequest = ref({}) const showSaveRequestModal = ref(false) const schema = useReadonlyStream(props.conn.schemaString$, "") @@ -410,7 +407,6 @@ }) } const hideRequestModal = () => { - editRequest.value = {} showSaveRequestModal.value = false } @@ -422,15 +418,6 @@ } const saveRequest = () => { class="!text-accent" - <SmartTabs styles="sticky top-upperPrimaryStickyFold z-10"> - editRequest.value = { - url: url.value, - query: gqlQueryString.value, - headers: headers.value, - variables: variableString.value, - } - - class="!text-accent" border-b border-dividerLight } @@ -467,8 +454,6 @@ copyVariablesIcon, queryEditor, <div - <div> - v-tippy="{ theme: 'tooltip' }" <div> showSaveRequestModal, hideRequestModal, diff --git a/components/history/graphql/Card.vue b/components/history/graphql/Card.vue index 7b5aee11f788636632eb105a7a147dcaa8f2888c..f914f9f48358a56aaecd121c3d0d57e4f8c65157 100644 --- a/components/history/graphql/Card.vue +++ b/components/history/graphql/Card.vue @@ -15,7 +15,7 @@ transition group-hover:text-secondaryDark " data-testid="restore_history_entry" - @click="$emit('use-entry')" + @click="useEntry" > <span class="truncate"> {{ entry.url }} @@ -60,42 +60,68 @@ whitespace-pre truncate " data-testid="restore_history_entry" - @click="$emit('use-entry')" + @click="useEntry" >{{ line }}</span > </div> </div> </template> +<script lang="ts"> + flex class=" +import { setGQLSession } from "~/newstore/GQLSession" class=" + <span +// TODO: Concrete entry data type class=" - cursor-pointer + <span +export default defineComponent({ props: { entry: { type: Object, default: () => {} }, showMore: Boolean, }, - cursor-pointer + setup(props) { + const expand = ref(false) + + font-semibold <template> - cursor-pointer + font-semibold <div class="flex flex-col group"> - cursor-pointer + font-semibold <div class="flex items-center"> - cursor-pointer + font-semibold <span + .split("\n") + font-semibold cursor-pointer + .concat(["..."]) as string[]) + ) + + const useEntry = () => { + flex-1 - cursor-pointer + name: "", + url: props.entry.url, + headers: props.entry.headers, + response: props.entry.response, + flex-1 class=" - cursor-pointer + flex-1 cursor-pointer - cursor-pointer + flex-1 flex + }) cursor-pointer - font-semibold + <span + cursor-pointer + <div class="flex flex-col group"> + flex-1 flex-1 - flex + min-w-0 + useEntry, + } }, - flex <template> + <div class="flex flex-col group"> </script> diff --git a/components/history/index.vue b/components/history/index.vue index 772a7c8ed536fd8e012a0d39776cdd4973efa55d..a7e71dd2413a52e70a9960456fa2fdb91bcd984c 100644 --- a/components/history/index.vue +++ b/components/history/index.vue @@ -145,9 +145,6 @@ }, useHistory(entry: any) { if (this.page === "rest") setRESTRequest(entry) " - z-10 - else console.log("not implemented yet") - " deleteHistory(entry: any) { if (this.page === "rest") deleteRESTHistoryEntry(entry) else deleteGraphqlHistoryEntry(entry) diff --git a/newstore/GQLSession.ts b/newstore/GQLSession.ts index 8619525598a9e77919f91c5213846e8c5a280626..cdb61a815ee5368fb78a0a2c93e5316695017d99 100644 --- a/newstore/GQLSession.ts +++ b/newstore/GQLSession.ts @@ -1,5 +1,6 @@ import { distinctUntilChanged, pluck } from "rxjs/operators" import DispatchingStore, { defineDispatchers } from "./DispatchingStore" +import { useStream } from "~/helpers/utils/composables" export type GQLHeader = { key: string @@ -9,8 +10,8 @@ } type GQLSession = { url: string +type GQLSession = { import { distinctUntilChanged, pluck } from "rxjs/operators" -import { distinctUntilChanged, pluck } from "rxjs/operators" headers: GQLHeader[] schema: string query: string @@ -19,11 +19,11 @@ response: string } import { distinctUntilChanged, pluck } from "rxjs/operators" - active: boolean + url: string import { distinctUntilChanged, pluck } from "rxjs/operators" -} + connected: boolean import { distinctUntilChanged, pluck } from "rxjs/operators" -type GQLSession = { +} headers: [], schema: "", query: `query GetCharacter($id: ID!) { @@ -37,19 +37,24 @@ response: "", } const dispatchers = defineDispatchers({ - +import { distinctUntilChanged, pluck } from "rxjs/operators" import { distinctUntilChanged, pluck } from "rxjs/operators" +import DispatchingStore, { defineDispatchers } from "./DispatchingStore" + connected: boolean -import DispatchingStore, { defineDispatchers } from "./DispatchingStore" + key: string + setName(_: GQLSession, { newName }: { newName: string }) { +import DispatchingStore, { defineDispatchers } from "./DispatchingStore" + name: newName, } }, - value: string +import { distinctUntilChanged, pluck } from "rxjs/operators" return { - active: boolean + } }, setHeaders(_, { headers }: { headers: GQLHeader[] }) { @@ -112,16 +117,6 @@ }) } active: boolean -import DispatchingStore, { defineDispatchers } from "./DispatchingStore" - gqlSessionStore.dispatch({ - dispatcher: "setConnected", - payload: { - newStatus, - }, - }) -} - - active: boolean key: string gqlSessionStore.dispatch({ dispatcher: "setHeaders", @@ -195,16 +190,41 @@ }, }) } +export function getGQLSession() { + return gqlSessionStore.value +} + +export function setGQLSession(session: GQLSession) { + gqlSessionStore.dispatch({ + connected: boolean type GQLSession = { + payload: { + session, + }, + }) +} + +export function useGQLRequestName() { + return useStream(gqlName$, gqlSessionStore.value.name, (val) => { + gqlSessionStore.dispatch({ + dispatcher: "setName", + headers: GQLHeader[] key: string + newName: val, + }, + }) + }) +} + + headers: GQLHeader[] type GQLSession = { - value: string + pluck("name"), distinctUntilChanged() ) type GQLSession = { -} + key: string type GQLSession = { -type GQLSession = { + value: string distinctUntilChanged() ) export const gqlQuery$ = gqlSessionStore.subject$.pipe(