@boxyhq/react-ui
Version:
React UI components from BoxyHQ
917 lines (916 loc) • 28.7 kB
JavaScript
import { j as t, S as C, B as U, c as J, a as B } from "./index-CL4_ByuK.js";
import { useState as x, useEffect as Z } from "react";
import { I as R, S as ge, a as de, C as he, s as O, L as me, P as be, b as Ce, N as ye, c as fe, T as ke } from "./index-YXTuPJxR.js";
var Y = /* @__PURE__ */ ((e) => (e["azure-scim-v2"] = "Entra ID SCIM v2.0", e["onelogin-scim-v2"] = "OneLogin SCIM v2.0", e["okta-scim-v2"] = "Okta SCIM v2.0", e["jumpcloud-scim-v2"] = "JumpCloud v2.0", e["generic-scim-v2"] = "Generic SCIM v2.0", e.google = "Google", e))(Y || {});
const _e = "_heading_h67it_3", je = "_fieldContainer_h67it_17", xe = "_formAction_h67it_22", W = {
heading: _e,
fieldContainer: je,
formAction: xe
}, ve = {
name: "",
tenant: "",
product: "",
webhook_url: "",
webhook_secret: "",
type: "azure-scim-v2",
google_domain: "",
log_webhook_events: !1
};
function Ne(e) {
var f, _, v, E;
const [c, w] = x(() => ve), [S, T] = x(() => !1), [L, N] = x(() => !1);
function I() {
var o;
return (o = Object.entries(Y)) == null ? void 0 : o.map(([i, r]) => ({
value: i,
text: r
})).filter(({ value: i }) => e.disableGoogleProvider ? i !== "google" : !0);
}
function a(o) {
var r;
const i = (r = o == null ? void 0 : o.target) == null ? void 0 : r.value;
T(i === "google"), w({
...c,
type: i
});
}
function y() {
var o, i, r, j, n, s;
return {
fieldContainer: J(
(o = e.classNames) == null ? void 0 : o.fieldContainer,
W.fieldContainer
),
inputField: {
label: (i = e.classNames) == null ? void 0 : i.label,
input: (r = e.classNames) == null ? void 0 : r.input,
container: (j = e.classNames) == null ? void 0 : j.fieldContainer
},
select: {
label: (n = e.classNames) == null ? void 0 : n.label,
select: (s = e.classNames) == null ? void 0 : s.select
}
};
}
function m() {
return e.displayHeader !== void 0 ? e.displayHeader : !0;
}
function F(o) {
return {
...c,
...o
};
}
function u(o) {
const i = o.target, r = i.type === "checkbox" ? i.checked : i.value;
w(
F({
[i.id]: r
})
);
}
function l(o) {
o.preventDefault();
async function i(r, j) {
N(!0);
const n = await O(j, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(r)
});
N(!1), n && typeof n == "object" && ("error" in n && n.error ? typeof e.errorCallback == "function" && e.errorCallback(n.error.message) : "data" in n && n.data && typeof e.successCallback == "function" && e.successCallback({
operation: "CREATE",
connection: n.data
}));
}
i(c, e.urls.post);
}
function k(o) {
var i;
return !!((i = e.excludeFields) != null && i.includes(
o
));
}
return Z(() => {
w(
F({
tenant: e.tenant ?? c.tenant,
product: e.product ?? c.product,
webhook_url: e.defaultWebhookEndpoint ?? c.webhook_url,
webhook_secret: e.defaultWebhookSecret ?? c.webhook_secret
})
);
}, [e.tenant, e.product, e.defaultWebhookEndpoint]), /* @__PURE__ */ t.jsxs("div", { children: [
m() ? /* @__PURE__ */ t.jsx("h2", { className: W.heading, children: "Create Directory" }) : null,
/* @__PURE__ */ t.jsxs("form", { onSubmit: (o) => l(o), children: [
k("name") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Directory name",
id: "name",
name: "name",
value: c.name,
handleInputChange: u,
required: !0,
classNames: y().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
k("type") ? null : /* @__PURE__ */ t.jsxs("div", { className: y().fieldContainer, children: [
/* @__PURE__ */ t.jsx(
ge,
{
label: "Directory provider",
name: "type",
id: "type",
classNames: y().select,
options: I(),
selectedValue: c.type,
handleChange: a
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
S ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Directory domain",
id: "google_domain",
name: "google_domain",
title: "Please enter a valid domain (e.g: boxyhq.com)",
value: c.google_domain || "",
handleInputChange: u,
pattern: "^[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*.[a-zA-Z]{2,}$",
classNames: y().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }) : null,
k("tenant") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Tenant",
id: "tenant",
name: "tenant",
value: c.tenant,
handleInputChange: u,
required: !0,
classNames: y().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
k("product") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Product",
id: "product",
name: "product",
value: c.product,
handleInputChange: u,
required: !0,
classNames: y().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
k("webhook_url") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
type: "url",
label: "Webhook URL",
id: "webhook_url",
name: "webhook_url",
value: c.webhook_url,
handleInputChange: u,
classNames: y().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
k("webhook_secret") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
de,
{
label: "Webhook secret",
id: "webhook_secret",
name: "webhook_secret",
value: c.webhook_secret,
handleChange: u,
classNames: y().inputField,
required: !1,
readOnly: !1
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
k("log_webhook_events") ? null : /* @__PURE__ */ t.jsxs("div", { className: W.checkboxFieldsDiv, children: [
/* @__PURE__ */ t.jsx(
he,
{
label: "Enable Webhook events logging",
id: "log_webhook_events",
name: "log_webhook_events",
checked: c.log_webhook_events,
handleChange: u
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
/* @__PURE__ */ t.jsxs("div", { className: W.formAction, children: [
typeof e.cancelCallback == "function" ? /* @__PURE__ */ t.jsx(
U,
{
type: "button",
name: "Cancel",
variant: "outline",
handleClick: e.cancelCallback,
classNames: (_ = (f = e.classNames) == null ? void 0 : f.button) == null ? void 0 : _.cancel
}
) : null,
/* @__PURE__ */ t.jsx(
U,
{
variant: "primary",
type: "submit",
name: "Create Directory",
classNames: (E = (v = e.classNames) == null ? void 0 : v.button) == null ? void 0 : E.ctoa,
isLoading: L
}
)
] })
] })
] });
}
const we = "_iconSpan_qz43r_5", De = {
iconSpan: we
}, Pe = {
directoryListData: []
};
function Se(e) {
var j;
const [c, w] = x(
() => Pe.directoryListData
);
function S() {
var n;
return (n = Object.entries(Y)) == null ? void 0 : n.map(
([s, D]) => ({
value: s,
text: D
})
);
}
const [T, L] = x(
() => !0
), [N, I] = x(() => ({})), [a, y] = x(() => !1), [m, F] = x(() => "");
function u() {
return e.urls.get;
}
function l() {
var n;
return ((n = e.paginate) == null ? void 0 : n.itemsPerPage) !== void 0;
}
function k() {
return e.hideViewAction ? [
{
icon: "PencilIcon",
label: "Edit",
handleClick: (n) => e.handleActionClick("edit", n)
}
] : [
{
icon: "EyeIcon",
label: "View",
handleClick: (n) => e.handleActionClick("view", n)
},
{
icon: "PencilIcon",
label: "Edit",
handleClick: (n) => e.handleActionClick("edit", n)
}
];
}
function f() {
return (e.cols || ["name", "tenant", "product", "type", "status", "actions"]).map((n) => n === "status" ? {
name: "status",
badge: {
position: "surround",
variantSelector(s) {
let D;
return s.deactivated && (D = "warning"), s.deactivated || (D = "success"), D;
}
}
} : n);
}
function _(n) {
let s = n.getUrl;
const [D, H] = s.split("?"), P = new URLSearchParams(H);
return n.tenant && P.set("tenant", n.tenant), n.product && P.set("product", n.product), n.pageToken && P.set("pageToken", n.pageToken), (n == null ? void 0 : n.offset) !== void 0 && (P.set("pageOffset", `${n.offset}`), P.set("pageLimit", `${n.limit}`)), P.toString() ? `${D}?${P}` : s;
}
function v() {
return _({
getUrl: u(),
tenant: e.tenant,
product: e.product
});
}
function E() {
var n;
return {
...e.tableProps,
classNames: {
...(n = e.tableProps) == null ? void 0 : n.classNames,
iconSpan: De.iconSpan
}
};
}
function o(n, s) {
return {
...N,
[n]: s
};
}
async function i(n) {
const s = await O(n);
if (L(!1), s && typeof s == "object") {
if ("error" in s && s.error)
y(!0), F(s.error.message), typeof e.errorCallback == "function" && e.errorCallback(s.error.message);
else if ("data" in s) {
const D = "pageToken" in s, H = D ? s.data.data : s.data;
if (Array.isArray(H)) {
const P = H.map((A) => {
var q;
return {
...A,
id: A.id,
name: A.name,
tenant: A.tenant,
product: A.product,
type: (q = S().find(({ value: V }) => V === A.type)) == null ? void 0 : q.text,
status: A.deactivated ? "Inactive" : "Active"
};
});
w(P), typeof e.handleListFetchComplete == "function" && e.handleListFetchComplete(P);
}
if (D)
return s.pageToken;
}
}
}
async function r(n) {
const s = await i(
_({
getUrl: v(),
...n
})
);
s && I(o(n.offset, s));
}
return Z(() => {
l() || i(v());
}, [v(), l()]), /* @__PURE__ */ t.jsxs(me, { isBusy: T, children: [
l() ? /* @__PURE__ */ t.jsx(
be,
{
itemsPerPage: e.paginate.itemsPerPage,
currentPageItemsCount: c.length,
handlePageChange: (j = e.paginate) == null ? void 0 : j.handlePageChange,
reFetch: r,
pageTokenMap: N,
children: /* @__PURE__ */ t.jsx(
Ce,
{
emptyStateMessage: "No directories found.",
cols: f(),
data: c,
actions: k(),
showErrorComponent: a,
errorMessage: m,
tableProps: E()
}
)
}
) : null,
l() ? null : /* @__PURE__ */ t.jsx(
ye,
{
emptyStateMessage: "No directories found.",
cols: f(),
data: c,
actions: k(),
showErrorComponent: a,
errorMessage: m,
tableProps: E()
}
)
] });
}
const Te = "_container_r3olf_1", Fe = {
container: Te
};
function Ee(e) {
var m, F, u;
const [c, w] = x(() => !1);
function S() {
var l;
return (l = e.connection) != null && l.deactivated ? "Inactive" : "Active";
}
function T() {
var l;
return (l = e.connection) != null && l.deactivated ? "activate" : "deactivate";
}
function L() {
w(!0);
}
function N() {
w(!1);
}
function I() {
var l;
y(!((l = e.connection) != null && l.deactivated));
}
function a() {
var l;
return {
container: J(
(l = e.classNames) == null ? void 0 : l.container,
Fe.container
)
};
}
function y(l) {
async function k() {
var v;
const f = {
directoryId: (v = e.connection) == null ? void 0 : v.id,
deactivated: l
}, _ = await O(e.urls.patch, {
method: "PATCH",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(f)
});
w(!1), _ && typeof _ == "object" && ("error" in _ && _.error ? typeof e.errorCallback == "function" && e.errorCallback(_.error.message) : typeof e.successCallback == "function" && e.successCallback({
operation: "UPDATE"
}));
}
k();
}
return /* @__PURE__ */ t.jsx(t.Fragment, { children: e.connection !== void 0 || e.connection !== null ? /* @__PURE__ */ t.jsx(t.Fragment, { children: /* @__PURE__ */ t.jsxs("div", { className: a().container, children: [
c ? /* @__PURE__ */ t.jsx(
fe,
{
ctoaVariant: (m = e.connection) != null && m.deactivated ? "primary" : "destructive",
classNames: (F = e.classNames) == null ? void 0 : F.confirmationPrompt,
cancelCallback: N,
confirmationCallback: I,
promptMessage: `Do you want to ${T()} the connection?`
}
) : null,
c ? null : /* @__PURE__ */ t.jsx(
ke,
{
label: S(),
disabled: c,
checked: !((u = e.connection) != null && u.deactivated),
handleChange: L
}
)
] }) }) : null });
}
const Le = "_headingContainer_gj246_2", Ae = "_heading_gj246_2", Ie = "_section_gj246_27", $e = "_info_gj246_39", ze = "_sectionHeading_gj246_43", Me = "_sectionPara_gj246_48", Re = "_formAction_gj246_52", He = "_hint_gj246_57", z = {
headingContainer: Le,
heading: Ae,
section: Ie,
info: $e,
sectionHeading: ze,
sectionPara: Me,
formAction: Re,
hint: He
}, Ue = {
name: "",
log_webhook_events: !1,
webhook_url: "",
webhook_secret: "",
google_domain: "",
google_authorization_url: ""
};
function Oe(e) {
var o, i, r, j, n, s, D, H, P, A, q, V, K, Q, X, p, ee, te, ne, ae, oe, ie, se, ce, le, re;
const [c, w] = x(() => !1);
function S() {
w(!c);
}
const [T, L] = x(() => !1), [N, I] = x(() => !0), [a, y] = x(
() => Ue
);
function m() {
var b, h, d, g;
return {
inputField: {
label: (b = e.classNames) == null ? void 0 : b.label,
input: (h = e.classNames) == null ? void 0 : h.input,
container: (d = e.classNames) == null ? void 0 : d.fieldContainer
},
section: J(
(g = e.classNames) == null ? void 0 : g.section,
z.section
)
};
}
function F(b, h) {
return {
...a,
[b]: h
};
}
function u(b) {
const h = b.target, d = h.id, g = h.type === "checkbox" ? h.checked : h.value;
y(F(d, g));
}
function l(b) {
b.preventDefault(), L(!0);
async function h(d) {
const g = await O(d, {
method: "PATCH",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(a)
});
L(!1), g && typeof g == "object" && ("error" in g && g.error ? typeof e.errorCallback == "function" && e.errorCallback(g.error.message) : "data" in g && g.data && typeof e.successCallback == "function" && e.successCallback({
operation: "UPDATE",
connection: g.data
}));
}
h(e.urls.patch);
}
function k() {
async function b(h) {
const d = await O(h, {
method: "DELETE"
});
d && typeof d == "object" && (d.error ? typeof e.errorCallback == "function" && e.errorCallback(d.error.message) : typeof e.successCallback == "function" && e.successCallback({
operation: "DELETE"
}));
}
b(e.urls.delete);
}
function f(b) {
var h;
return !!((h = e.excludeFields) != null && h.includes(b));
}
function _() {
return e.displayHeader !== void 0 ? e.displayHeader : !0;
}
function v() {
return e.urls.get;
}
function E() {
if (!a.google_authorization_url)
return;
let b = a.google_authorization_url;
const [h, d] = b.split("?"), g = new URLSearchParams(d);
return g.set("directoryId", a.id), `${h}?${g}`;
}
return Z(() => {
async function b(h) {
var g, ue;
const d = await O(h);
if (I(!1), d && typeof d == "object") {
if ("error" in d && d.error)
typeof e.errorCallback == "function" && e.errorCallback(d.error.message);
else if ("data" in d) {
const $ = d.data;
y({
...$,
name: $.name,
log_webhook_events: $.log_webhook_events,
webhook_url: ((g = $.webhook) == null ? void 0 : g.endpoint) || "",
webhook_secret: ((ue = $.webhook) == null ? void 0 : ue.secret) || "",
google_authorization_url: $.google_authorization_url || "",
google_domain: $.google_domain || "",
deactivated: $.deactivated
});
}
}
}
b(v());
}, [v()]), /* @__PURE__ */ t.jsxs(me, { isBusy: N, children: [
/* @__PURE__ */ t.jsxs("div", { className: z.headingContainer, children: [
_() ? /* @__PURE__ */ t.jsx("h2", { className: z.heading, children: "Update Directory" }) : null,
/* @__PURE__ */ t.jsx(
Ee,
{
connection: a,
urls: {
patch: e.urls.patch
},
classNames: {
confirmationPrompt: {
button: {
ctoa: `${(r = (i = (o = e.classNames) == null ? void 0 : o.confirmationPrompt) == null ? void 0 : i.button) == null ? void 0 : r.ctoa} ${a != null && a.deactivated ? (n = (j = e.classNames) == null ? void 0 : j.button) == null ? void 0 : n.ctoa : (D = (s = e.classNames) == null ? void 0 : s.button) == null ? void 0 : D.destructive}`.trim(),
cancel: (A = (P = (H = e.classNames) == null ? void 0 : H.confirmationPrompt) == null ? void 0 : P.button) == null ? void 0 : A.cancel
}
}
},
errorCallback: e.errorCallback,
successCallback: e.successCallback
}
)
] }),
/* @__PURE__ */ t.jsxs("form", { onSubmit: (b) => l(b), children: [
f("name") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Directory name",
id: "name",
value: a.name,
handleInputChange: u,
required: !0,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
!f("scim_endpoint") && (a == null ? void 0 : a.type) !== "google" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
B,
{
label: "SCIM Endpoint",
text: (q = a.scim) == null ? void 0 : q.endpoint,
copyDoneCallback: e.successCallback,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }) : null,
!f("scim_token") && (a == null ? void 0 : a.type) !== "google" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
B,
{
label: "SCIM Token",
text: (V = a.scim) == null ? void 0 : V.secret,
copyDoneCallback: e.successCallback,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }) : null,
!f("google_domain") && (a == null ? void 0 : a.type) === "google" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
label: "Directory domain",
id: "google_domain",
value: a.google_domain,
handleInputChange: u,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }) : null,
!f("google_authorization_url") && (a == null ? void 0 : a.type) === "google" && E() ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
B,
{
label: "Google SCIM Authorization url",
text: E(),
copyDoneCallback: e.successCallback,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx("div", { id: "scim-authz-hint", className: z.hint, children: "The URL that your tenant needs to authorize the application to access their Google Directory." }),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }) : null,
f("webhook_url") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
R,
{
type: "url",
label: "Webhook URL",
id: "webhook_url",
value: a.webhook_url,
handleInputChange: u,
classNames: m().inputField
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
f("webhook_secret") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
de,
{
label: "Webhook secret",
id: "webhook_secret",
classNames: m().inputField,
handleChange: u,
value: a.webhook_secret,
copyDoneCallback: e.successCallback,
required: !1,
readOnly: !1
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
f("log_webhook_events") ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx(
he,
{
label: "Enable Webhook events logging",
id: "log_webhook_events",
name: "log_webhook_events",
checked: a == null ? void 0 : a.log_webhook_events,
handleChange: u
}
),
/* @__PURE__ */ t.jsx(C, { y: 6 })
] }),
/* @__PURE__ */ t.jsxs("div", { className: z.formAction, children: [
typeof e.cancelCallback == "function" ? /* @__PURE__ */ t.jsx(
U,
{
type: "button",
name: "Cancel",
variant: "outline",
handleClick: e.cancelCallback,
classNames: (Q = (K = e.classNames) == null ? void 0 : K.button) == null ? void 0 : Q.cancel
}
) : null,
e.hideSave ? null : /* @__PURE__ */ t.jsx(
U,
{
type: "submit",
name: "Save",
variant: "primary",
classNames: (p = (X = e.classNames) == null ? void 0 : X.button) == null ? void 0 : p.ctoa,
isLoading: T
}
)
] })
] }),
/* @__PURE__ */ t.jsxs("section", { className: m().section, children: [
/* @__PURE__ */ t.jsxs("div", { className: z.info, children: [
/* @__PURE__ */ t.jsx("h6", { className: z.sectionHeading, children: "Delete this directory connection" }),
/* @__PURE__ */ t.jsx("p", { className: z.sectionPara, children: "All your apps using this connection will stop working." })
] }),
c ? null : /* @__PURE__ */ t.jsx(
U,
{
name: "Delete",
variant: "destructive",
type: "button",
handleClick: S,
classNames: (te = (ee = e.classNames) == null ? void 0 : ee.button) == null ? void 0 : te.destructive
}
),
c ? /* @__PURE__ */ t.jsx(
fe,
{
ctoaVariant: "destructive",
promptMessage: " Are you sure you want to delete the directory connection? This will permanently delete the directory connection, users, and groups.",
classNames: {
button: {
ctoa: `${(ae = (ne = e.classNames) == null ? void 0 : ne.button) == null ? void 0 : ae.destructive} ${(se = (ie = (oe = e.classNames) == null ? void 0 : oe.confirmationPrompt) == null ? void 0 : ie.button) == null ? void 0 : se.ctoa}`.trim(),
cancel: (re = (le = (ce = e.classNames) == null ? void 0 : ce.confirmationPrompt) == null ? void 0 : le.button) == null ? void 0 : re.cancel
}
},
cancelCallback: S,
confirmationCallback: k
}
) : null
] })
] });
}
const qe = "_header_z5rjx_1", Ve = "_h5_z5rjx_8", We = "_ctoa_z5rjx_15", M = {
header: qe,
h5: Ve,
ctoa: We
}, G = {
directoryListData: [],
view: "LIST",
directoryToEdit: {}
};
function Ze(e) {
var k, f, _, v, E;
const [c, w] = x(
() => G.directoryListData
), [S, T] = x(() => G.view);
function L(o) {
w(o);
}
const [N, I] = x(
() => G.directoryToEdit
);
function a() {
let o = e.urls.get;
const [i, r] = o.split("?"), j = new URLSearchParams(r);
return j.toString() ? `${i}/${N.id}?${j}` : `${i}/${N.id}`;
}
function y() {
T("CREATE");
}
function m(o) {
T("EDIT"), I(o);
}
function F(o, i) {
var r, j;
o === "edit" ? m(i) : typeof ((j = (r = e.componentProps) == null ? void 0 : r.directoryList) == null ? void 0 : j.handleActionClick) == "function" && e.componentProps.directoryList.handleActionClick("view", i);
}
function u() {
T("LIST");
}
function l(o) {
const { connection: i, operation: r } = o;
typeof e.successCallback == "function" && e.successCallback({
operation: r,
connection: i
}), r === "CREATE" ? m(i) : r !== "COPY" && u();
}
return /* @__PURE__ */ t.jsxs("div", { children: [
S === "LIST" ? /* @__PURE__ */ t.jsxs("div", { className: M.listview, children: [
/* @__PURE__ */ t.jsxs("div", { className: M.header, children: [
/* @__PURE__ */ t.jsx("h5", { className: M.h5, children: e.title || "Manage DSync Connections" }),
/* @__PURE__ */ t.jsx("div", { className: M.ctoa, children: /* @__PURE__ */ t.jsx(
U,
{
name: "New Directory",
handleClick: y,
classNames: (f = (k = e.classNames) == null ? void 0 : k.button) == null ? void 0 : f.ctoa
}
) })
] }),
/* @__PURE__ */ t.jsx(C, { y: 8 }),
/* @__PURE__ */ t.jsx(
Se,
{
...(_ = e.componentProps) == null ? void 0 : _.directoryList,
urls: {
get: e.urls.get
},
handleActionClick: F,
handleListFetchComplete: L,
tenant: e.tenant,
product: e.product
}
)
] }) : null,
S === "EDIT" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx("div", { className: M.header, children: /* @__PURE__ */ t.jsx("h5", { className: M.h5, children: "Edit DSync Connection" }) }),
/* @__PURE__ */ t.jsx(
Oe,
{
...(v = e.componentProps) == null ? void 0 : v.editDirectory,
classNames: e.classNames,
successCallback: l,
errorCallback: e.errorCallback,
cancelCallback: u,
displayHeader: !1,
urls: {
patch: `${e.urls.patch}/${N.id}`,
delete: `${e.urls.delete}/${N.id}`,
get: a()
}
}
)
] }) : null,
S === "CREATE" ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
/* @__PURE__ */ t.jsx("div", { className: M.header, children: /* @__PURE__ */ t.jsx("h5", { className: M.h5, children: "Create DSync Connection" }) }),
/* @__PURE__ */ t.jsx(C, { y: 5 }),
/* @__PURE__ */ t.jsx(
Ne,
{
...(E = e.componentProps) == null ? void 0 : E.createDirectory,
classNames: e.classNames,
successCallback: l,
errorCallback: e.errorCallback,
cancelCallback: u,
displayHeader: !1,
urls: {
post: e.urls.post
},
tenant: e.tenant,
product: e.product
}
)
] }) : null
] });
}
export {
Ne as CreateDirectory,
Ze as DirectoriesWrapper,
Se as DirectoryList,
Oe as EditDirectory
};
//# sourceMappingURL=dsync.js.map