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.
@@ -1428,6 +1428,11 @@ function Grid(props) {
1428
1428
  }
1429
1429
  }
1430
1430
 
1431
+ // src/inspector/utils/permissions.ts
1432
+ function isWriter(role) {
1433
+ return role === "writer" || role === "admin" || role === "manager" || role === "writeOnly";
1434
+ }
1435
+
1431
1436
  // src/inspector/viewer/grid-view.tsx
1432
1437
  import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
1433
1438
  function GridItem({
@@ -1502,7 +1507,7 @@ function GridItem({
1502
1507
  /* @__PURE__ */ jsx22(Text, { strong: true, children: key }),
1503
1508
  /* @__PURE__ */ jsx22(Badge, { children: /* @__PURE__ */ jsx22(ResolveIcon, { coId: value, node }) })
1504
1509
  ] }) : /* @__PURE__ */ jsx22(Text, { strong: true, children: key }) }),
1505
- coValue && /* @__PURE__ */ jsxs10(ActionButtons, { children: [
1510
+ coValue && isWriter(coValue.group.myRole()) && /* @__PURE__ */ jsxs10(ActionButtons, { children: [
1506
1511
  /* @__PURE__ */ jsx22(
1507
1512
  EditButton,
1508
1513
  {
@@ -2655,7 +2660,9 @@ function getTransactionChanges(tx, coValue) {
2655
2660
  if (tx.isValid === false && tx.tx.privacy === "private") {
2656
2661
  const readKey = coValue.core.getReadKey(tx.tx.keyUsed);
2657
2662
  if (!readKey) {
2658
- throw new Error("Read key not found");
2663
+ return [
2664
+ `Unable to decrypt transaction: read key ${tx.tx.keyUsed} not found.`
2665
+ ];
2659
2666
  }
2660
2667
  return coValue.core.verified.decryptTransaction(
2661
2668
  tx.txID.sessionID,
@@ -2839,7 +2846,14 @@ function CoMapView({
2839
2846
  }
2840
2847
  ),
2841
2848
  /* @__PURE__ */ jsxs21("div", { children: [
2842
- /* @__PURE__ */ jsx33(AddPropertyModal, { coValue, node }),
2849
+ /* @__PURE__ */ jsx33(
2850
+ AddPropertyModal,
2851
+ {
2852
+ disabled: !isWriter(coValue.group.myRole()),
2853
+ coValue,
2854
+ node
2855
+ }
2856
+ ),
2843
2857
  " ",
2844
2858
  /* @__PURE__ */ jsx33(RestoreSnapshotModal, { coValue })
2845
2859
  ] })
@@ -2847,7 +2861,8 @@ function CoMapView({
2847
2861
  }
2848
2862
  function AddPropertyModal({
2849
2863
  coValue,
2850
- node
2864
+ node,
2865
+ disabled
2851
2866
  }) {
2852
2867
  const [isAddPropertyModalOpen, setIsAddPropertyModalOpen] = useState12(false);
2853
2868
  const [propertyName, setPropertyName] = useState12("");
@@ -2865,8 +2880,9 @@ function AddPropertyModal({
2865
2880
  {
2866
2881
  title: "Add Property",
2867
2882
  variant: "secondary",
2883
+ disabled,
2868
2884
  onClick: openAddPropertyModal,
2869
- children: /* @__PURE__ */ jsx33(Icon, { name: "edit" })
2885
+ children: /* @__PURE__ */ jsx33(Icon, { name: "add" })
2870
2886
  }
2871
2887
  ),
2872
2888
  /* @__PURE__ */ jsxs21(
@@ -2932,6 +2948,7 @@ function RestoreSnapshotModal({ coValue }) {
2932
2948
  const handleClose = () => {
2933
2949
  setIsRestoreModalOpen(false);
2934
2950
  };
2951
+ const canRestore = isWriter(coValue.group.myRole());
2935
2952
  return /* @__PURE__ */ jsxs21(Fragment11, { children: [
2936
2953
  /* @__PURE__ */ jsx33(Button, { title: "Timeline", variant: "secondary", onClick: openRestoreModal, children: /* @__PURE__ */ jsx33(Icon, { name: "history" }) }),
2937
2954
  /* @__PURE__ */ jsxs21(
@@ -2944,7 +2961,7 @@ function RestoreSnapshotModal({ coValue }) {
2944
2961
  cancelText: "Cancel",
2945
2962
  onConfirm: handleRestore,
2946
2963
  onCancel: handleClose,
2947
- showButtons: timestamps.length > 1,
2964
+ showButtons: timestamps.length > 1 && canRestore,
2948
2965
  children: [
2949
2966
  timestamps.length > 1 && /* @__PURE__ */ jsxs21(Fragment11, { children: [
2950
2967
  /* @__PURE__ */ jsxs21(RangeContainer, { children: [
@@ -2962,7 +2979,7 @@ function RestoreSnapshotModal({ coValue }) {
2962
2979
  ),
2963
2980
  /* @__PURE__ */ jsx33(TimestampDisplay, { children: timestamps[selectedIndex] !== void 0 ? new Date(timestamps[selectedIndex]).toISOString() : "No timestamps available" })
2964
2981
  ] }),
2965
- /* @__PURE__ */ jsxs21(CheckboxContainer, { children: [
2982
+ canRestore && /* @__PURE__ */ jsxs21(CheckboxContainer, { children: [
2966
2983
  /* @__PURE__ */ jsx33(
2967
2984
  CheckboxInput,
2968
2985
  {