@scalar/api-client
Version:
the open source API testing client
119 lines (118 loc) • 5.09 kB
JavaScript
import { defineComponent as _, createElementBlock as r, openBlock as d, Fragment as c, createElementVNode as e, createVNode as n, unref as l, createTextVNode as m, toDisplayString as k, withCtx as f } from "vue";
import { useModal as C, ScalarToggle as y, ScalarIcon as p, ScalarButton as M, ScalarModal as U } from "@scalar/components";
import { useRouter as D } from "vue-router";
import N from "../../components/Sidebar/Actions/DeleteSidebarListElement.vue.js";
import { PathId as v } from "../../routes.js";
import { useActiveEntities as S } from "../../store/active-entities.js";
import { useWorkspace as W } from "../../store/store.js";
const T = { class: "flex h-full w-full flex-col gap-12 px-1.5 pt-8" }, V = { class: "flex flex-col gap-2" }, A = { class: "bg-b-2 rounded-lg border text-sm" }, B = { class: "bg-b-1 flex items-center justify-between gap-4 rounded-t-lg p-3" }, E = { class: "text-c-1 flex items-center overflow-x-auto border-t py-1.5 whitespace-nowrap" }, I = { class: "flex items-center" }, $ = ["href"], L = { class: "flex flex-col gap-4" }, O = { class: "flex items-center justify-between rounded-lg border p-3 text-sm" }, H = /* @__PURE__ */ _({
__name: "CollectionSettings",
setup(P) {
const { activeCollection: o, activeWorkspace: i, activeWorkspaceCollections: x } = S(), { collectionMutators: u } = W(), { replace: g } = D(), s = C();
function h() {
o.value && o.value?.documentUrl && u.edit(
o.value.uid,
"watchMode",
!o.value?.watchMode
);
}
function b() {
if (!o.value || !i.value)
return;
u.delete(o.value, i.value);
const a = x.value[0];
a && g({
name: "collection",
params: {
[v.Workspace]: i.value.uid,
[v.Collection]: a.uid
}
}), s.hide();
}
return (a, t) => (d(), r(c, null, [
e("div", T, [
e("div", V, [
t[5] || (t[5] = e("div", { class: "flex h-8 items-center" }, [
e("h3", { class: "font-bold" }, "Features")
], -1)),
e("div", A, [
e("div", B, [
t[2] || (t[2] = e("div", null, [
e("h4", null, "Watch Mode"),
e("p", { class: "text-c-2 mt-1" }, " When enabled, the OpenAPI document will be polled for changes. The collection will be updated automatically. ")
], -1)),
n(l(y), {
class: "w-4",
disabled: !l(o)?.documentUrl,
modelValue: l(o)?.watchMode ?? !1,
"onUpdate:modelValue": h
}, null, 8, ["disabled", "modelValue"])
]),
e("div", E, [
e("div", I, [
l(o)?.documentUrl ? (d(), r(c, { key: 0 }, [
t[3] || (t[3] = e("span", { class: "bg-b-2 sticky left-0 pr-2 pl-3" }, "Source", -1)),
e("a", {
class: "text-c-2 group rounded pr-3 no-underline hover:underline",
href: l(o).documentUrl,
target: "_blank"
}, [
m(k(l(o).documentUrl) + " ", 1),
n(l(p), {
class: "ml-1 hidden w-2.5 group-hover:inline",
icon: "ExternalLink"
})
], 8, $)
], 64)) : (d(), r(c, { key: 1 }, [
n(l(p), {
class: "text-c-2 mr-2 ml-3 w-4",
icon: "NotAllowed",
size: "sm"
}),
t[4] || (t[4] = e("span", { class: "text-c-2 pr-3" }, " No URL configured. Try importing an OpenAPI document from an URL. ", -1))
], 64))
])
])
])
]),
e("div", L, [
t[8] || (t[8] = e("h3", { class: "font-bold" }, "Danger Zone", -1)),
e("div", O, [
t[7] || (t[7] = e("div", null, [
e("h4", null, "Delete Collection"),
e("p", { class: "text-c-2 mt-1" }, " Be careful, my friend. Once deleted, there is no way to recover the collection. ")
], -1)),
n(l(M), {
class: "custom-scroll h-8 gap-1.5 px-2.5 font-medium whitespace-nowrap shadow-none focus:outline-none",
variant: "danger",
onClick: t[0] || (t[0] = (w) => l(s).show())
}, {
default: f(() => [...t[6] || (t[6] = [
m(" Delete Collection ", -1)
])]),
_: 1
})
])
])
]),
n(l(U), {
size: "xxs",
state: l(s),
title: `Delete ${l(o)?.info?.title}`
}, {
default: f(() => [
n(N, {
variableName: l(o)?.info?.title ?? "",
warningMessage: "This action cannot be undone.",
onClose: t[1] || (t[1] = (w) => l(s).hide()),
onDelete: b
}, null, 8, ["variableName"])
]),
_: 1
}, 8, ["state", "title"])
], 64));
}
});
export {
H as default
};