@scalar/api-client
Version:
the open source API testing client
106 lines (105 loc) • 4.14 kB
JavaScript
import { defineComponent as E, computed as U, createElementBlock as v, createBlock as m, unref as e, openBlock as r, normalizeClass as f, createElementVNode as P, createVNode as n, isRef as W, withCtx as k, createCommentVNode as H } from "vue";
import y from "../../components/EmptyState.vue.js";
import N from "../../components/ViewLayout/ViewLayout.vue.js";
import g from "../../components/ViewLayout/ViewLayoutContent.vue.js";
import { useSidebar as B } from "../../hooks/useSidebar.js";
import { importCurlCommand as I } from "../../libs/importers/curl.js";
import { useActiveEntities as L } from "../../store/active-entities.js";
import z from "./RequestSection/RequestSection.vue.js";
import A from "./RequestSubpageHeader.vue.js";
import D from "./ResponseSection/ResponseSection.vue.js";
import { useWorkspace as S } from "../../store/store.js";
import { useLayout as M } from "../../hooks/useLayout.js";
const O = { class: "flex h-full" }, T = {
key: 0,
class: "flex h-full flex-1 flex-col"
}, re = /* @__PURE__ */ E({
__name: "Request",
props: {
invalidParams: {},
selectedSecuritySchemeUids: {},
requestResult: {}
},
emits: ["newTab"],
setup($) {
const { events: b } = S(), { isSidebarOpen: s } = B(), R = S(), { layout: q } = M(), {
activeCollection: t,
activeExample: c,
activeRequest: a,
activeWorkspace: l,
activeServer: u,
activeEnvVariables: p,
activeEnvironment: d,
activeWorkspaceRequests: h
} = L(), { modalState: x, requestHistory: C } = R, V = U(
() => [...C].reverse().find((o) => o.request.uid === c.value?.uid)
);
function w(o) {
b.commandPalette.emit({
commandName: "Import from cURL",
metaData: {
parsedCurl: I(o),
collectionUid: t.value?.uid
}
});
}
return (o, i) => e(t) && e(l) ? (r(), v("div", {
key: 0,
class: f(["bg-b-1 relative z-0 flex h-full flex-1 flex-col overflow-hidden pt-0", {
"!mr-0 !mb-0 !border-0": e(q) === "modal"
}])
}, [
P("div", O, [
e(a) ? (r(), v("div", T, [
n(A, {
modelValue: e(s),
"onUpdate:modelValue": i[0] || (i[0] = (_) => W(s) ? s.value = _ : null),
collection: e(t),
envVariables: e(p),
environment: e(d),
operation: e(a),
server: e(u),
workspace: e(l),
onHideModal: i[1] || (i[1] = () => e(x).hide()),
onImportCurl: w
}, null, 8, ["modelValue", "collection", "envVariables", "environment", "operation", "server", "workspace"]),
n(N, null, {
default: k(() => [
e(c) ? (r(), m(g, {
key: 0,
class: f(["flex-1", [e(s) ? "sidebar-active-hide-layout" : ""]])
}, {
default: k(() => [
n(z, {
collection: e(t),
envVariables: e(p),
environment: e(d),
example: e(c),
invalidParams: o.invalidParams,
operation: e(a),
selectedSecuritySchemeUids: o.selectedSecuritySchemeUids,
server: e(u),
workspace: e(l)
}, null, 8, ["collection", "envVariables", "environment", "example", "invalidParams", "operation", "selectedSecuritySchemeUids", "server", "workspace"]),
n(D, {
collection: e(t),
numWorkspaceRequests: e(h).length,
operation: e(a),
requestResult: o.requestResult,
response: V.value?.response,
workspace: e(l)
}, null, 8, ["collection", "numWorkspaceRequests", "operation", "requestResult", "response", "workspace"])
]),
_: 1
}, 8, ["class"])) : H("", !0)
]),
_: 1
})
])) : (r(), m(y, { key: 1 }))
])
], 2)) : (r(), m(y, { key: 1 }));
}
});
export {
re as default
};