@vdatacloud/cx-commons 0.5.0 → 0.6.1

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/README.md CHANGED
@@ -96,7 +96,7 @@ How a party signs one version of an agreement, mirroring daml-escrow-commons `ag
96
96
 
97
97
  One worklist for acts waiting on several people's approval, whatever the act (daml-escrow PLAN.md Phase 91.4, the shared approval process). `mountPendingApprovals(host, items, { me, onDecide })` shows each request's description, proposer, progress (n of N, with a progress bar) and who approved, with the decisions the viewer may take: the proposer withdraws; someone who approved does nothing more; anyone else approves or rejects (`noApprove` hides approve, e.g. for a stale act or the viewer's own appointment). Each decision confirms and asks for a reason before `onDecide(item, decision, reason)`; the app sends it and reloads. Text is never parsed as markup; pass a `Node` for a rich description. Strings are `cx.approvals.*` (en, fr). `decisionsFor` is tested against daml-escrow-commons `approval/testdata/decisions.json`, the server's rule.
98
98
 
99
- An act that isn't a proposal (daml-escrow PLAN.md Phase 92.5: a staged release its approvers approve, a compliance review's outcome) leaves `proposedBy` out and passes its own `actions` (`{ id, label, tone?, reason?: 'required' | 'optional' | 'none', confirm? }`) in place of approve / reject / withdraw: each confirms, asks for a reason as it says, then calls `onAction(item, actionId, reason)`. Someone who has approved is offered none (`actionsFor`).
99
+ An act that isn't a proposal (daml-escrow PLAN.md Phase 92.5: a staged release its approvers approve, a compliance review's outcome) leaves `proposedBy` out and passes its own `actions` (`{ id, label, tone?, reason?: 'required' | 'optional' | 'none', confirm?, approved? }`) in place of approve / reject / withdraw: each confirms, asks for a reason as it says, then calls `onAction(item, actionId, reason)`. Someone who has approved is offered only the actions marked `approved: true` (e.g. revoking their approval), which nobody else sees (`actionsFor`).
100
100
 
101
101
  ---
102
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vdatacloud/cx-commons",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Product CX Commons - Shared design system, UI components, and Astro integration for Data Cloud web applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,8 @@
30
30
  "scripts": {
31
31
  "build": "tsc",
32
32
  "test": "vitest run",
33
- "sync:api-error-fixtures": "scripts/sync-api-error-fixtures.sh"
33
+ "sync:api-error-fixtures": "scripts/sync-api-error-fixtures.sh",
34
+ "vuln-check": "npm audit --audit-level=high"
34
35
  },
35
36
  "peerDependencies": {
36
37
  "@tailwindcss/typography": "^0.5.0",
@@ -39,8 +40,8 @@
39
40
  },
40
41
  "devDependencies": {
41
42
  "@tailwindcss/typography": "^0.5.20",
42
- "astro": "^7.3.2",
43
- "happy-dom": "^20.14.5",
43
+ "astro": "^7.4.5",
44
+ "happy-dom": "^21.0.4",
44
45
  "typescript": "^5.7.0",
45
46
  "vitest": "^5.0.3"
46
47
  },
@@ -14,7 +14,8 @@
14
14
  // An act that isn't a proposal (daml-escrow PLAN.md Phase 92.5: a staged
15
15
  // release its approvers approve, a compliance review's outcome) names no
16
16
  // proposer and brings its own actions instead: each with its label, tone and
17
- // whether it asks for a reason. Someone who has approved is offered none.
17
+ // whether it asks for a reason. Someone who has approved is offered only the
18
+ // actions marked for them (revoking their approval, say).
18
19
 
19
20
  import { confirmDialog, promptDialog } from './dialogs';
20
21
  import { renderCantonId } from './canton-id-view';
@@ -57,6 +58,8 @@ export interface ApprovalAction {
57
58
  reason?: 'required' | 'optional' | 'none';
58
59
  /** The confirmation's question (default cx.approvals.confirm with the label). */
59
60
  confirm?: string;
61
+ /** Offered only to someone who has approved (e.g. revoking their approval), and to nobody else. */
62
+ approved?: boolean;
60
63
  }
61
64
 
62
65
  export interface PendingApprovalsOptions {
@@ -104,10 +107,10 @@ export function decisionsFor(item: PendingApproval, me?: string): ApprovalDecisi
104
107
  return item.noApprove ? ['reject'] : ['approve', 'reject'];
105
108
  }
106
109
 
107
- /** The item's own actions viewer `me` is offered: none once they have approved. */
110
+ /** The item's own actions viewer `me` is offered: once they have approved, only those marked `approved`. */
108
111
  export function actionsFor(item: PendingApproval, me?: string): ApprovalAction[] {
109
- if (me && item.approvals.includes(me)) return [];
110
- return item.actions ?? [];
112
+ const done = !!me && item.approvals.includes(me);
113
+ return (item.actions ?? []).filter((a) => !!a.approved === done);
111
114
  }
112
115
 
113
116
  // act confirms, asks for the reason the action wants, then hands it to the app.