@xh/hoist 76.0.0-SNAPSHOT.1756835394167 → 76.0.0-SNAPSHOT.1756991850787

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.
@@ -705,11 +705,13 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
705
705
  const latestInfo = latest.info,
706
706
  {typeDisplayName, globalDisplayName} = this,
707
707
  msgs: ReactNode[] = [`Save ${view.typedName}?`];
708
+
708
709
  if (isGlobal) {
709
710
  msgs.push(
710
711
  span(
711
- `This is a ${globalDisplayName} ${typeDisplayName}. `,
712
- strong('Changes will be visible to all users.')
712
+ strong(
713
+ `This is a ${globalDisplayName} ${typeDisplayName}. Changes will be visible to all users.`
714
+ )
713
715
  )
714
716
  );
715
717
  }
@@ -725,7 +727,9 @@ export class ViewManagerModel<T = PlainObject> extends HoistModel {
725
727
  return XH.confirm({
726
728
  message: fragment(msgs.map(m => p(m))),
727
729
  confirmProps: {
728
- text: 'Yes, save changes',
730
+ text: isGlobal
731
+ ? `Yes, update ${globalDisplayName} ${typeDisplayName}`
732
+ : 'Yes, save changes',
729
733
  intent: 'primary',
730
734
  outlined: true,
731
735
  autoFocus: false
@@ -7,7 +7,7 @@
7
7
  import {PlainObject, XH} from '@xh/hoist/core';
8
8
  import {FetchOptions} from '@xh/hoist/svc';
9
9
  import {pluralize} from '@xh/hoist/utils/js';
10
- import {isPlainObject, truncate} from 'lodash';
10
+ import {isPlainObject, isString, truncate} from 'lodash';
11
11
  import {FetchException, HoistException, TimeoutException, TimeoutExceptionConfig} from './Types';
12
12
 
13
13
  /**
@@ -91,14 +91,13 @@ export class Exception {
91
91
  try {
92
92
  const cType = headers.get('Content-Type');
93
93
  if (cType?.includes('application/json')) {
94
- const obj = safeParseJson(responseText),
95
- message = obj ? obj.message : truncate(responseText?.trim(), {length: 255});
94
+ const parsedResp = safeParseJson(responseText);
96
95
  return this.createFetchException({
97
96
  ...defaults,
98
- name: obj?.name ?? defaults.name,
99
- message: message ?? statusText,
100
- isRoutine: obj?.isRoutine ?? false,
101
- serverDetails: obj ?? responseText
97
+ name: parsedResp?.name ?? defaults.name,
98
+ message: extractMessage(parsedResp, responseText, statusText),
99
+ isRoutine: parsedResp?.isRoutine ?? false,
100
+ serverDetails: parsedResp ?? responseText
102
101
  });
103
102
  }
104
103
  } catch (ignored) {}
@@ -234,6 +233,24 @@ function safeParseJson(txt: string): PlainObject {
234
233
  }
235
234
  }
236
235
 
236
+ function extractMessage(parsedResp: PlainObject, responseText: string, statusText: string): string {
237
+ let ret: string;
238
+ if (parsedResp) {
239
+ // From parsed response, including cause if provided (e.g. ExternalHttpException)
240
+ ret = parsedResp.message;
241
+ if (isString(parsedResp.cause)) {
242
+ const cause = truncate(parsedResp.cause, {length: 255});
243
+ ret = ret ? `${ret} (Caused by: ${cause})` : cause;
244
+ }
245
+ } else {
246
+ // Use raw text if not JSON parseable
247
+ ret = truncate(responseText?.trim(), {length: 255});
248
+ }
249
+
250
+ // Fallback to statusText if we have nothing else.
251
+ return ret || statusText;
252
+ }
253
+
237
254
  export function isHoistException(src: unknown): src is HoistException {
238
255
  return src?.['isHoistException'];
239
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "76.0.0-SNAPSHOT.1756835394167",
3
+ "version": "76.0.0-SNAPSHOT.1756991850787",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",