@scalar/api-client
Version:
the open source API testing client
67 lines (66 loc) • 2.35 kB
JavaScript
import { defineComponent as E, ref as y, createElementBlock as u, openBlock as s, Fragment as v, createElementVNode as T, createVNode as l, renderList as b, createBlock as g, unref as r, withCtx as h, createTextVNode as k } from "vue";
import { useModal as d, ScalarButton as M } from "@scalar/components";
import { ScalarIconPlus as N } from "@scalar/icons";
import S from "./components/EnvironmentCreateModal.vue.js";
import w from "./components/EnvironmentDeleteModal.vue.js";
import C from "./components/Environment.vue.js";
const D = { class: "text-c-3 flex h-full items-center justify-center rounded-lg border p-4" }, z = /* @__PURE__ */ E({
__name: "EnvironmentsList",
props: {
environments: {},
eventBus: {},
collectionType: {}
},
setup(i) {
const m = d(), c = d(), n = y(null), p = (e) => {
n.value = e, c.show();
}, f = () => {
n.value && i.eventBus.emit("environment:delete:environment", {
environmentName: n.value,
collectionType: i.collectionType
});
}, a = (e) => {
n.value = e ?? null, m.show();
};
return (e, t) => (s(), u(v, null, [
(s(!0), u(v, null, b(Object.entries(e.environments), ([o, B]) => (s(), g(C, {
key: o,
collectionType: e.collectionType,
environment: B,
environmentName: o,
eventBus: e.eventBus,
onDelete: () => p(o),
onEdit: () => a(o)
}, null, 8, ["collectionType", "environment", "environmentName", "eventBus", "onDelete", "onEdit"]))), 128)),
T("div", D, [
l(r(M), {
class: "hover:bg-b-2 hover:text-c-1 flex items-center gap-2",
size: "sm",
variant: "ghost",
onClick: t[0] || (t[0] = () => a())
}, {
default: h(() => [
l(r(N)),
t[1] || (t[1] = k(" Add Environment ", -1))
]),
_: 1
})
]),
l(S, {
collectionType: e.collectionType,
environments: e.environments,
eventBus: e.eventBus,
selectedEnvironmentName: n.value,
state: r(m)
}, null, 8, ["collectionType", "environments", "eventBus", "selectedEnvironmentName", "state"]),
l(w, {
name: n.value,
state: r(c),
onSubmit: f
}, null, 8, ["name", "state"])
], 64));
}
});
export {
z as default
};