@asteby/metacore-runtime-react 29.2.7 → 29.2.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 29.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - b705996: Fix row-action `condition` evaluation for nested fields and `equals`/`notEquals` operators. Hosts declaring `{ field: "user.verified", operator: "equals", value: false }` no longer show every action at once.
8
+
3
9
  ## 29.2.7
4
10
 
5
11
  ### Patch Changes
@@ -53,8 +53,11 @@ export declare const formatAggregateTotal: (col: ColumnDefinition, value: unknow
53
53
  export declare const isActionAllowedForRowState: (action: any, row: any) => boolean;
54
54
  /**
55
55
  * Declarative `condition` gate for a per-row action: shows the action only when
56
- * the row's `field` satisfies the `eq | neq | in | not_in` operator. No
57
- * condition declared always shown. Unknown operator permissive.
56
+ * the row's `field` satisfies the operator. Supports both the SDK dialect
57
+ * (`eq` | `neq` | `in` | `not_in`) and the common host dialect
58
+ * (`equals` | `notEquals` | `not_in`). Nested paths (`user.verified`) are
59
+ * resolved via `getNestedValue`. No condition → always shown. Unknown
60
+ * operator → permissive.
58
61
  */
59
62
  export declare const isActionConditionMet: (action: any, row: any) => boolean;
60
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-columns.d.ts","sourceRoot":"","sources":["../src/dynamic-columns.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAwC9C,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAER,iBAAiB,EACpB,MAAM,wBAAwB,CAAA;AAE/B,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EA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O,MAAM,gBAAgB,GACzB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,OAAO,GAAG,EACV,mBAAe,KAChB,MAAM,GAAG,SAcX,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,KAAK,gBAAgB,EAAE,KAAK,GAAG,KAAG,MAOzE,CAAA;AA+ID;;;;GAIG;AACH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACxC,CAqBA,CAAA;AAED,wBAAgB,4BAA4B,CACxC,OAAO,GAAE,qBAA0B,GACpC,iBAAiB,CA+mBnB;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBACL,CAAA"}
@@ -129,23 +129,43 @@ export const isActionAllowedForRowState = (action, row) => {
129
129
  };
130
130
  /**
131
131
  * Declarative `condition` gate for a per-row action: shows the action only when
132
- * the row's `field` satisfies the `eq | neq | in | not_in` operator. No
133
- * condition declared always shown. Unknown operator permissive.
132
+ * the row's `field` satisfies the operator. Supports both the SDK dialect
133
+ * (`eq` | `neq` | `in` | `not_in`) and the common host dialect
134
+ * (`equals` | `notEquals` | `not_in`). Nested paths (`user.verified`) are
135
+ * resolved via `getNestedValue`. No condition → always shown. Unknown
136
+ * operator → permissive.
134
137
  */
135
138
  export const isActionConditionMet = (action, row) => {
136
139
  if (!action?.condition)
137
140
  return true;
138
141
  const { field, operator, value } = action.condition;
139
- const rowValue = String(row?.[field] ?? '');
140
- const values = Array.isArray(value) ? value : [value];
141
- switch (operator) {
142
+ if (!field)
143
+ return true;
144
+ const coerce = (v) => {
145
+ if (v === null || v === undefined)
146
+ return '';
147
+ if (typeof v === 'boolean')
148
+ return v ? 'true' : 'false';
149
+ return String(v);
150
+ };
151
+ const raw = getNestedValue(row, field);
152
+ const rowValue = coerce(raw);
153
+ const values = (Array.isArray(value) ? value : [value]).map(coerce);
154
+ const op = String(operator ?? '').toLowerCase();
155
+ switch (op) {
142
156
  case 'eq':
157
+ case 'equals':
158
+ case '==':
143
159
  return rowValue === values[0];
144
160
  case 'neq':
161
+ case 'notequals':
162
+ case 'not_equals':
163
+ case '!=':
145
164
  return rowValue !== values[0];
146
165
  case 'in':
147
166
  return values.includes(rowValue);
148
167
  case 'not_in':
168
+ case 'notin':
149
169
  return !values.includes(rowValue);
150
170
  default:
151
171
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "29.2.7",
3
+ "version": "29.2.8",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,4 +77,19 @@ describe('isRowActionVisible', () => {
77
77
  expect(isActionConditionMet({ condition: { field: 's', operator: 'not_in', value: ['a', 'b'] } }, { s: 'c' })).toBe(true)
78
78
  expect(isActionConditionMet({ condition: { field: 's', operator: 'neq', value: 'a' } }, { s: 'a' })).toBe(false)
79
79
  })
80
+
81
+ it('isActionConditionMet resolves nested paths and equals/notEquals aliases', () => {
82
+ const approve = {
83
+ condition: { field: 'user.verified', operator: 'equals', value: false },
84
+ }
85
+ const revoke = {
86
+ condition: { field: 'user.verified', operator: 'equals', value: true },
87
+ }
88
+ expect(isActionConditionMet(approve, { user: { verified: false } })).toBe(true)
89
+ expect(isActionConditionMet(approve, { user: { verified: true } })).toBe(false)
90
+ expect(isActionConditionMet(revoke, { user: { verified: true } })).toBe(true)
91
+ expect(isActionConditionMet(revoke, { user: { verified: false } })).toBe(false)
92
+ // Flat lookup must NOT match nested conditions (regression of row[field]).
93
+ expect(isActionConditionMet(approve, { 'user.verified': false } as any)).toBe(false)
94
+ })
80
95
  })
@@ -226,22 +226,42 @@ export const isActionAllowedForRowState = (action: any, row: any): boolean => {
226
226
 
227
227
  /**
228
228
  * Declarative `condition` gate for a per-row action: shows the action only when
229
- * the row's `field` satisfies the `eq | neq | in | not_in` operator. No
230
- * condition declared always shown. Unknown operator permissive.
229
+ * the row's `field` satisfies the operator. Supports both the SDK dialect
230
+ * (`eq` | `neq` | `in` | `not_in`) and the common host dialect
231
+ * (`equals` | `notEquals` | `not_in`). Nested paths (`user.verified`) are
232
+ * resolved via `getNestedValue`. No condition → always shown. Unknown
233
+ * operator → permissive.
231
234
  */
232
235
  export const isActionConditionMet = (action: any, row: any): boolean => {
233
236
  if (!action?.condition) return true
234
237
  const { field, operator, value } = action.condition
235
- const rowValue = String(row?.[field] ?? '')
236
- const values = Array.isArray(value) ? value : [value]
237
- switch (operator) {
238
+ if (!field) return true
239
+
240
+ const coerce = (v: unknown): string => {
241
+ if (v === null || v === undefined) return ''
242
+ if (typeof v === 'boolean') return v ? 'true' : 'false'
243
+ return String(v)
244
+ }
245
+
246
+ const raw = getNestedValue(row, field)
247
+ const rowValue = coerce(raw)
248
+ const values = (Array.isArray(value) ? value : [value]).map(coerce)
249
+ const op = String(operator ?? '').toLowerCase()
250
+
251
+ switch (op) {
238
252
  case 'eq':
253
+ case 'equals':
254
+ case '==':
239
255
  return rowValue === values[0]
240
256
  case 'neq':
257
+ case 'notequals':
258
+ case 'not_equals':
259
+ case '!=':
241
260
  return rowValue !== values[0]
242
261
  case 'in':
243
262
  return values.includes(rowValue)
244
263
  case 'not_in':
264
+ case 'notin':
245
265
  return !values.includes(rowValue)
246
266
  default:
247
267
  return true