@v1ct0rbr/minivault-web 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -849,7 +849,7 @@ function K() {
849
849
  busy: b.isPending,
850
850
  onCancel: () => c(null),
851
851
  onConfirm: () => {
852
- b.mutate(s.id), c(null);
852
+ b.mutate(s.id, { onSettled: () => c(null) });
853
853
  }
854
854
  })
855
855
  ] });
@@ -1535,43 +1535,43 @@ function te(e) {
1535
1535
  //#endregion
1536
1536
  //#region src/components/StorageExplorerTab.tsx
1537
1537
  function X({ storageType: e = "LOCAL", storageConfig: n }) {
1538
- let i = b(), a = d(), [s, c] = o(""), [h, g] = o([]), [_, v] = o(/* @__PURE__ */ new Set()), [y, x] = o(null), S = n?.type ?? e, { data: C, isLoading: w } = u({
1538
+ let i = b(), s = d(), [c, h] = o(""), [g, _] = o([]), [v, y] = o(/* @__PURE__ */ new Set()), [x, S] = o(null), C = n?.type ?? e, { data: w, isLoading: T } = u({
1539
1539
  queryKey: [
1540
1540
  "storage-files",
1541
- S,
1542
- s,
1541
+ C,
1542
+ c,
1543
1543
  n
1544
1544
  ],
1545
- queryFn: () => i.listStorageFiles(S, s || void 0, n)
1546
- }), T = l({
1547
- mutationFn: (e) => i.deleteStorageFile(e, S, n),
1545
+ queryFn: () => i.listStorageFiles(C, c || void 0, n)
1546
+ }), E = l({
1547
+ mutationFn: (e) => i.deleteStorageFile(e, C, n),
1548
1548
  onSuccess: () => {
1549
- a.invalidateQueries({ queryKey: ["storage-files"] }), x(null);
1549
+ s.invalidateQueries({ queryKey: ["storage-files"] }), S(null);
1550
1550
  }
1551
- }), E = t((e) => {
1552
- c(e), g(e ? e.split("/").filter(Boolean) : []), v(/* @__PURE__ */ new Set());
1553
- }, []), D = t((e) => {
1554
- let t = h.slice(0, e + 1).join("/");
1555
- E(t);
1556
- }, [h, E]);
1551
+ }), D = a(!1), O = t((e) => {
1552
+ h(e), _(e ? e.split("/").filter(Boolean) : []), y(/* @__PURE__ */ new Set());
1553
+ }, []), k = t((e) => {
1554
+ let t = g.slice(0, e + 1).join("/");
1555
+ O(t);
1556
+ }, [g, O]);
1557
1557
  r(() => {
1558
- g(s ? s.split("/").filter(Boolean) : []);
1559
- }, [s]);
1560
- let O = (e) => {
1561
- v((t) => {
1558
+ _(c ? c.split("/").filter(Boolean) : []);
1559
+ }, [c]);
1560
+ let A = (e) => {
1561
+ y((t) => {
1562
1562
  let n = new Set(t);
1563
1563
  return n.has(e) ? n.delete(e) : n.add(e), n;
1564
1564
  });
1565
- }, k = () => {
1566
- C && (_.size === C.length ? v(/* @__PURE__ */ new Set()) : v(new Set(C.map((e) => e.path))));
1567
- }, A = async (e) => {
1565
+ }, j = () => {
1566
+ w && (v.size === w.length ? y(/* @__PURE__ */ new Set()) : y(new Set(w.map((e) => e.path))));
1567
+ }, M = async (e) => {
1568
1568
  try {
1569
- let t = await i.downloadStorageFile(e, S, n), r = e.split("/").pop() ?? e, a = window.URL.createObjectURL(t), o = document.createElement("a");
1569
+ let t = await i.downloadStorageFile(e, C, n), r = e.split("/").pop() ?? e, a = window.URL.createObjectURL(t), o = document.createElement("a");
1570
1570
  o.href = a, o.download = r, document.body.appendChild(o), o.click(), o.remove(), window.URL.revokeObjectURL(a);
1571
1571
  } catch {}
1572
- }, j = async () => {
1573
- for (let e of _) await A(e);
1574
- }, M = (e) => e ? R(e) : "-";
1572
+ }, N = async () => {
1573
+ for (let e of v) await M(e);
1574
+ }, P = (e) => e ? R(e) : "-";
1575
1575
  return /* @__PURE__ */ m("div", {
1576
1576
  className: "space-y-3",
1577
1577
  children: [
@@ -1584,27 +1584,27 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1584
1584
  "Explorador de Storage",
1585
1585
  /* @__PURE__ */ p("span", {
1586
1586
  className: "badge bg-secondary ms-2",
1587
- children: S
1587
+ children: C
1588
1588
  })
1589
1589
  ]
1590
1590
  }), /* @__PURE__ */ p("div", {
1591
1591
  className: "d-flex gap-2",
1592
- children: _.size > 0 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("button", {
1592
+ children: v.size > 0 && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("button", {
1593
1593
  className: "btn btn-sm btn-outline-primary",
1594
- onClick: j,
1594
+ onClick: N,
1595
1595
  children: [
1596
1596
  /* @__PURE__ */ p("i", { className: "bi bi-download me-1" }),
1597
1597
  "Baixar (",
1598
- _.size,
1598
+ v.size,
1599
1599
  ")"
1600
1600
  ]
1601
1601
  }), /* @__PURE__ */ m("button", {
1602
1602
  className: "btn btn-sm btn-outline-danger",
1603
- onClick: () => x("multiple"),
1603
+ onClick: () => S("multiple"),
1604
1604
  children: [
1605
1605
  /* @__PURE__ */ p("i", { className: "bi bi-trash me-1" }),
1606
1606
  "Excluir (",
1607
- _.size,
1607
+ v.size,
1608
1608
  ")"
1609
1609
  ]
1610
1610
  })] })
@@ -1615,19 +1615,19 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1615
1615
  children: /* @__PURE__ */ m("ol", {
1616
1616
  className: "breadcrumb mb-0 small",
1617
1617
  children: [/* @__PURE__ */ p("li", {
1618
- className: `breadcrumb-item ${h.length === 0 ? "active" : ""}`,
1619
- style: { cursor: h.length > 0 ? "pointer" : "default" },
1620
- onClick: () => E(""),
1618
+ className: `breadcrumb-item ${g.length === 0 ? "active" : ""}`,
1619
+ style: { cursor: g.length > 0 ? "pointer" : "default" },
1620
+ onClick: () => O(""),
1621
1621
  children: /* @__PURE__ */ p("i", { className: "bi bi-house" })
1622
- }), h.map((e, t) => /* @__PURE__ */ p("li", {
1623
- className: `breadcrumb-item ${t === h.length - 1 ? "active" : ""}`,
1624
- style: { cursor: t < h.length - 1 ? "pointer" : "default" },
1625
- onClick: () => t < h.length - 1 && D(t),
1622
+ }), g.map((e, t) => /* @__PURE__ */ p("li", {
1623
+ className: `breadcrumb-item ${t === g.length - 1 ? "active" : ""}`,
1624
+ style: { cursor: t < g.length - 1 ? "pointer" : "default" },
1625
+ onClick: () => t < g.length - 1 && k(t),
1626
1626
  children: e
1627
1627
  }, t))]
1628
1628
  })
1629
1629
  }),
1630
- w ? /* @__PURE__ */ m("div", {
1630
+ T ? /* @__PURE__ */ m("div", {
1631
1631
  className: "text-center py-5",
1632
1632
  children: [/* @__PURE__ */ p("div", {
1633
1633
  className: "spinner-border text-primary",
@@ -1636,14 +1636,14 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1636
1636
  className: "mt-2 small text-muted",
1637
1637
  children: "Carregando arquivos..."
1638
1638
  })]
1639
- }) : !C || C.length === 0 ? /* @__PURE__ */ m("div", {
1639
+ }) : !w || w.length === 0 ? /* @__PURE__ */ m("div", {
1640
1640
  className: "text-center py-5 text-muted",
1641
1641
  children: [
1642
1642
  /* @__PURE__ */ p("i", { className: "bi bi-folder-x fs-1 d-block mb-2" }),
1643
1643
  "Nenhum arquivo encontrado",
1644
- s && /* @__PURE__ */ p("button", {
1644
+ c && /* @__PURE__ */ p("button", {
1645
1645
  className: "btn btn-sm btn-link mt-2",
1646
- onClick: () => E(""),
1646
+ onClick: () => O(""),
1647
1647
  children: "Voltar ao inicio"
1648
1648
  })
1649
1649
  ]
@@ -1651,11 +1651,11 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1651
1651
  className: "d-flex align-items-center gap-2 mb-2",
1652
1652
  children: [/* @__PURE__ */ m("button", {
1653
1653
  className: "btn btn-sm btn-outline-secondary",
1654
- onClick: k,
1655
- children: [_.size === C.length ? "Desmarcar" : "Selecionar", " Todos"]
1654
+ onClick: j,
1655
+ children: [v.size === w.length ? "Desmarcar" : "Selecionar", " Todos"]
1656
1656
  }), /* @__PURE__ */ m("span", {
1657
1657
  className: "small text-muted",
1658
- children: [C.length, " item(ns)"]
1658
+ children: [w.length, " item(ns)"]
1659
1659
  })]
1660
1660
  }), /* @__PURE__ */ p("div", {
1661
1661
  className: "table-responsive",
@@ -1679,18 +1679,18 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1679
1679
  children: "Acoes"
1680
1680
  })
1681
1681
  ] })
1682
- }), /* @__PURE__ */ p("tbody", { children: C.map((e) => /* @__PURE__ */ m("tr", {
1683
- className: _.has(e.path) ? "table-active" : "",
1682
+ }), /* @__PURE__ */ p("tbody", { children: w.map((e) => /* @__PURE__ */ m("tr", {
1683
+ className: v.has(e.path) ? "table-active" : "",
1684
1684
  children: [
1685
1685
  /* @__PURE__ */ p("td", { children: /* @__PURE__ */ p("input", {
1686
1686
  type: "checkbox",
1687
1687
  className: "form-check-input",
1688
- checked: _.has(e.path),
1689
- onChange: () => O(e.path)
1688
+ checked: v.has(e.path),
1689
+ onChange: () => A(e.path)
1690
1690
  }) }),
1691
1691
  /* @__PURE__ */ p("td", { children: e.directory ? /* @__PURE__ */ m("button", {
1692
1692
  className: "btn btn-sm btn-link text-decoration-none p-0 text-start",
1693
- onClick: () => E(e.path),
1693
+ onClick: () => O(e.path),
1694
1694
  children: [/* @__PURE__ */ p("i", { className: "bi bi-folder-fill text-warning me-2" }), /* @__PURE__ */ p("span", {
1695
1695
  className: "font-monospace",
1696
1696
  children: e.name
@@ -1705,19 +1705,19 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1705
1705
  }),
1706
1706
  /* @__PURE__ */ p("td", {
1707
1707
  className: "text-muted small",
1708
- children: M(e.lastModified)
1708
+ children: P(e.lastModified)
1709
1709
  }),
1710
1710
  /* @__PURE__ */ p("td", { children: !e.directory && /* @__PURE__ */ m("div", {
1711
1711
  className: "d-flex gap-1",
1712
1712
  children: [/* @__PURE__ */ p("button", {
1713
1713
  className: "btn btn-sm btn-outline-primary py-0",
1714
1714
  title: "Baixar",
1715
- onClick: () => A(e.path),
1715
+ onClick: () => M(e.path),
1716
1716
  children: /* @__PURE__ */ p("i", { className: "bi bi-download" })
1717
1717
  }), /* @__PURE__ */ p("button", {
1718
1718
  className: "btn btn-sm btn-outline-danger py-0",
1719
1719
  title: "Excluir",
1720
- onClick: () => x(e.path),
1720
+ onClick: () => S(e.path),
1721
1721
  children: /* @__PURE__ */ p("i", { className: "bi bi-trash" })
1722
1722
  })]
1723
1723
  }) })
@@ -1725,7 +1725,7 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1725
1725
  }, e.path)) })]
1726
1726
  })
1727
1727
  })] }),
1728
- y && /* @__PURE__ */ p("div", {
1728
+ x && /* @__PURE__ */ p("div", {
1729
1729
  className: "modal d-block",
1730
1730
  tabIndex: -1,
1731
1731
  style: { background: "rgba(0,0,0,.5)" },
@@ -1741,38 +1741,60 @@ function X({ storageType: e = "LOCAL", storageConfig: n }) {
1741
1741
  children: "Confirmar exclusao"
1742
1742
  }), /* @__PURE__ */ p("button", {
1743
1743
  className: "btn-close",
1744
- onClick: () => x(null)
1744
+ onClick: () => S(null)
1745
1745
  })]
1746
1746
  }),
1747
1747
  /* @__PURE__ */ m("div", {
1748
1748
  className: "modal-body",
1749
- children: [y === "multiple" ? /* @__PURE__ */ m("p", { children: [
1750
- "Excluir ",
1751
- _.size,
1752
- " arquivo(s) selecionado(s)?"
1753
- ] }) : /* @__PURE__ */ m("p", { children: [
1754
- "Excluir ",
1755
- /* @__PURE__ */ p("code", { children: y.split("/").pop() }),
1756
- "?"
1757
- ] }), /* @__PURE__ */ p("p", {
1758
- className: "text-danger small mb-0",
1759
- children: "Esta acao nao pode ser desfeita."
1760
- })]
1749
+ children: [
1750
+ x === "multiple" ? /* @__PURE__ */ m("p", { children: [
1751
+ "Excluir ",
1752
+ v.size,
1753
+ " arquivo(s) selecionado(s)?"
1754
+ ] }) : /* @__PURE__ */ m("p", { children: [
1755
+ "Excluir ",
1756
+ /* @__PURE__ */ p("code", { children: x.split("/").pop() }),
1757
+ "?"
1758
+ ] }),
1759
+ /* @__PURE__ */ p("p", {
1760
+ className: "text-danger small mb-0",
1761
+ children: "Esta acao nao pode ser desfeita."
1762
+ }),
1763
+ E.isError && /* @__PURE__ */ m("div", {
1764
+ className: "alert alert-danger small mt-2 mb-0 py-1",
1765
+ children: [
1766
+ /* @__PURE__ */ p("i", {
1767
+ className: "bi bi-exclamation-triangle me-1",
1768
+ "aria-hidden": !0
1769
+ }),
1770
+ "Falha ao excluir:",
1771
+ " ",
1772
+ E.error instanceof Error ? E.error.message : String(E.error)
1773
+ ]
1774
+ })
1775
+ ]
1761
1776
  }),
1762
1777
  /* @__PURE__ */ m("div", {
1763
1778
  className: "modal-footer",
1764
1779
  children: [/* @__PURE__ */ p("button", {
1765
1780
  className: "btn btn-sm btn-secondary",
1766
- onClick: () => x(null),
1781
+ onClick: () => S(null),
1767
1782
  children: "Cancelar"
1768
1783
  }), /* @__PURE__ */ p("button", {
1769
1784
  className: "btn btn-sm btn-danger",
1770
- disabled: T.isPending,
1785
+ disabled: E.isPending,
1771
1786
  onClick: async () => {
1772
- if (y === "multiple") for (let e of _) await T.mutateAsync(e);
1773
- else await T.mutateAsync(y);
1787
+ if (!D.current) {
1788
+ D.current = !0;
1789
+ try {
1790
+ if (x === "multiple") for (let e of v) await E.mutateAsync(e);
1791
+ else await E.mutateAsync(x);
1792
+ } finally {
1793
+ D.current = !1;
1794
+ }
1795
+ }
1774
1796
  },
1775
- children: T.isPending ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", { className: "spinner-border spinner-border-sm me-1" }), "Excluindo..."] }) : "Excluir"
1797
+ children: E.isPending ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("span", { className: "spinner-border spinner-border-sm me-1" }), "Excluindo..."] }) : "Excluir"
1776
1798
  })]
1777
1799
  })
1778
1800
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v1ct0rbr/minivault-web",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Módulo independente de gerenciamento de backups (minivault). Consumível como pacote npm em qualquer app React. Cliente do minivault REST API (acesso tipicamente via proxy autenticado).",
5
5
  "author": "Victor Queiroga (https://www.linkedin.com/in/victor-queiroga)",
6
6
  "license": "MIT",