jazz-tools 0.19.2 → 0.19.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.
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  subscribeToCoValue,
43
43
  unstable_loadUnique,
44
44
  zodReExport_exports
45
- } from "./chunk-NCNM6UDZ.js";
45
+ } from "./chunk-JPWM4CS2.js";
46
46
  import {
47
47
  createSSRJazzAgent
48
48
  } from "./chunk-M2HGBOXS.js";
@@ -33212,6 +33212,11 @@ function Grid(props) {
33212
33212
  }
33213
33213
  }
33214
33214
 
33215
+ // src/inspector/utils/permissions.ts
33216
+ function isWriter(role) {
33217
+ return role === "writer" || role === "admin" || role === "manager" || role === "writeOnly";
33218
+ }
33219
+
33215
33220
  // src/inspector/viewer/grid-view.tsx
33216
33221
  var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
33217
33222
  function GridItem({
@@ -33286,7 +33291,7 @@ function GridItem({
33286
33291
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Text, { strong: true, children: key }),
33287
33292
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Badge, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ResolveIcon, { coId: value, node }) })
33288
33293
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Text, { strong: true, children: key }) }),
33289
- coValue && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionButtons, { children: [
33294
+ coValue && isWriter(coValue.group.myRole()) && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionButtons, { children: [
33290
33295
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
33291
33296
  EditButton,
33292
33297
  {
@@ -34439,7 +34444,9 @@ function getTransactionChanges(tx, coValue) {
34439
34444
  if (tx.isValid === false && tx.tx.privacy === "private") {
34440
34445
  const readKey = coValue.core.getReadKey(tx.tx.keyUsed);
34441
34446
  if (!readKey) {
34442
- throw new Error("Read key not found");
34447
+ return [
34448
+ `Unable to decrypt transaction: read key ${tx.tx.keyUsed} not found.`
34449
+ ];
34443
34450
  }
34444
34451
  return coValue.core.verified.decryptTransaction(
34445
34452
  tx.txID.sessionID,
@@ -34623,7 +34630,14 @@ function CoMapView({
34623
34630
  }
34624
34631
  ),
34625
34632
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { children: [
34626
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AddPropertyModal, { coValue, node }),
34633
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
34634
+ AddPropertyModal,
34635
+ {
34636
+ disabled: !isWriter(coValue.group.myRole()),
34637
+ coValue,
34638
+ node
34639
+ }
34640
+ ),
34627
34641
  " ",
34628
34642
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(RestoreSnapshotModal, { coValue })
34629
34643
  ] })
@@ -34631,7 +34645,8 @@ function CoMapView({
34631
34645
  }
34632
34646
  function AddPropertyModal({
34633
34647
  coValue,
34634
- node
34648
+ node,
34649
+ disabled
34635
34650
  }) {
34636
34651
  const [isAddPropertyModalOpen, setIsAddPropertyModalOpen] = (0, import_react20.useState)(false);
34637
34652
  const [propertyName, setPropertyName] = (0, import_react20.useState)("");
@@ -34649,8 +34664,9 @@ function AddPropertyModal({
34649
34664
  {
34650
34665
  title: "Add Property",
34651
34666
  variant: "secondary",
34667
+ disabled,
34652
34668
  onClick: openAddPropertyModal,
34653
- children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Icon, { name: "edit" })
34669
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Icon, { name: "add" })
34654
34670
  }
34655
34671
  ),
34656
34672
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
@@ -34716,6 +34732,7 @@ function RestoreSnapshotModal({ coValue }) {
34716
34732
  const handleClose = () => {
34717
34733
  setIsRestoreModalOpen(false);
34718
34734
  };
34735
+ const canRestore = isWriter(coValue.group.myRole());
34719
34736
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
34720
34737
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { title: "Timeline", variant: "secondary", onClick: openRestoreModal, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Icon, { name: "history" }) }),
34721
34738
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
@@ -34728,7 +34745,7 @@ function RestoreSnapshotModal({ coValue }) {
34728
34745
  cancelText: "Cancel",
34729
34746
  onConfirm: handleRestore,
34730
34747
  onCancel: handleClose,
34731
- showButtons: timestamps.length > 1,
34748
+ showButtons: timestamps.length > 1 && canRestore,
34732
34749
  children: [
34733
34750
  timestamps.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
34734
34751
  /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(RangeContainer, { children: [
@@ -34746,7 +34763,7 @@ function RestoreSnapshotModal({ coValue }) {
34746
34763
  ),
34747
34764
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(TimestampDisplay, { children: timestamps[selectedIndex] !== void 0 ? new Date(timestamps[selectedIndex]).toISOString() : "No timestamps available" })
34748
34765
  ] }),
34749
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(CheckboxContainer, { children: [
34766
+ canRestore && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(CheckboxContainer, { children: [
34750
34767
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
34751
34768
  CheckboxInput,
34752
34769
  {
@@ -35775,4 +35792,4 @@ react/cjs/react-jsx-runtime.development.js:
35775
35792
  * LICENSE file in the root directory of this source tree.
35776
35793
  *)
35777
35794
  */
35778
- //# sourceMappingURL=custom-element-ABVPHX53.js.map
35795
+ //# sourceMappingURL=custom-element-3JAYHXWQ.js.map