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