tinacms 1.5.18 → 1.5.20

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.
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const ErrorDialog: (props: {
3
+ title: string;
4
+ message: string;
5
+ error: Error;
6
+ }) => JSX.Element;
@@ -3,6 +3,6 @@ import { NavigateFunction } from 'react-router-dom';
3
3
  import { TinaCMS } from '@tinacms/toolkit';
4
4
  import type { CollectionResponse, DocumentSys } from '../types';
5
5
  import type { Collection } from '@tinacms/schema-tools';
6
- export declare const handleNavigate: (navigate: NavigateFunction, cms: TinaCMS, collection: CollectionResponse, collectionDefinition: Collection<true>, document: DocumentSys) => any;
6
+ export declare const handleNavigate: (navigate: NavigateFunction, cms: TinaCMS, collection: CollectionResponse, collectionDefinition: Collection<true>, document: DocumentSys) => Promise<any>;
7
7
  declare const CollectionListPage: () => JSX.Element;
8
8
  export default CollectionListPage;
package/dist/client.js CHANGED
@@ -2,7 +2,9 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("fetch-ponyfill")) : typeof define === "function" && define.amd ? define(["exports", "fetch-ponyfill"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP));
3
3
  })(this, function(exports2, fetchPonyfill) {
4
4
  "use strict";
5
- const { fetch, Headers } = fetchPonyfill();
5
+ const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
6
+ const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
7
+ const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
6
8
  const TINA_HOST = "content.tinajs.io";
7
9
  class TinaClient {
8
10
  constructor({ token, url, queries }) {
@@ -11,7 +13,7 @@
11
13
  this.queries = queries(this);
12
14
  }
13
15
  async request(args) {
14
- const headers = new Headers();
16
+ const headers = new HeadersDefined();
15
17
  if (this.readonlyToken) {
16
18
  headers.append("X-API-KEY", this.readonlyToken);
17
19
  }
@@ -21,7 +23,7 @@
21
23
  variables: (args == null ? void 0 : args.variables) || {}
22
24
  });
23
25
  const url = (args == null ? void 0 : args.url) || this.apiUrl;
24
- const res = await fetch(url, {
26
+ const res = await fetchDefined(url, {
25
27
  method: "POST",
26
28
  headers,
27
29
  body: bodyString,
package/dist/client.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  import fetchPonyfill from "fetch-ponyfill";
2
- const { fetch, Headers } = fetchPonyfill();
2
+ const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
3
+ const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
4
+ const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
3
5
  const TINA_HOST = "content.tinajs.io";
4
6
  class TinaClient {
5
7
  constructor({ token, url, queries }) {
@@ -8,7 +10,7 @@ class TinaClient {
8
10
  this.queries = queries(this);
9
11
  }
10
12
  async request(args) {
11
- const headers = new Headers();
13
+ const headers = new HeadersDefined();
12
14
  if (this.readonlyToken) {
13
15
  headers.append("X-API-KEY", this.readonlyToken);
14
16
  }
@@ -18,7 +20,7 @@ class TinaClient {
18
20
  variables: (args == null ? void 0 : args.variables) || {}
19
21
  });
20
22
  const url = (args == null ? void 0 : args.url) || this.apiUrl;
21
- const res = await fetch(url, {
23
+ const res = await fetchDefined(url, {
22
24
  method: "POST",
23
25
  headers,
24
26
  body: bodyString,
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { useDocumentCreatorPlugin } from './hooks/use-content-creator';
9
9
  export { TinaAdmin } from './admin';
10
10
  export { RouteMappingPlugin } from './admin/plugins/route-mapping';
11
11
  export { TinaAdminApi } from './admin/api';
12
+ export { ErrorDialog } from './admin/components/ErrorDialog';
12
13
  export * from './toolkit';
13
14
  export { Form } from './toolkit/forms/form';
14
15
  export { MdxFieldPluginExtendible } from '@tinacms/toolkit';
package/dist/index.js CHANGED
@@ -8485,8 +8485,12 @@ var __publicField = (obj, key, value) => {
8485
8485
  const [error, setError] = React.useState(void 0);
8486
8486
  React__namespace.useEffect(() => {
8487
8487
  const fetchEvents = async () => {
8488
- var _a, _b;
8489
- if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi) && cms.api.tina.isAuthorized()) {
8488
+ var _a, _b, _c, _d;
8489
+ let doFetchEvents = false;
8490
+ if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi)) {
8491
+ doFetchEvents = await ((_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isAuthenticated());
8492
+ }
8493
+ if (doFetchEvents) {
8490
8494
  try {
8491
8495
  const { events: nextEvents, cursor: nextCursor2 } = await cms.api.tina.fetchEvents(15, cursor);
8492
8496
  setEvents([...existingEvents, ...nextEvents]);
@@ -8510,11 +8514,16 @@ var __publicField = (obj, key, value) => {
8510
8514
  return { events, cursor: nextCursor, loading, error };
8511
8515
  };
8512
8516
  function useSyncStatus$1(cms) {
8517
+ var _a, _b;
8513
8518
  const [syncStatus, setSyncStatus] = React.useState({ state: "loading", message: "Loading..." });
8514
8519
  React__namespace.useEffect(() => {
8515
8520
  const interval = setInterval(async () => {
8516
- var _a, _b;
8517
- if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi) && cms.api.tina.isAuthorized()) {
8521
+ var _a2, _b2, _c, _d;
8522
+ let doFetchEvents = false;
8523
+ if (!((_b2 = (_a2 = cms.api) == null ? void 0 : _a2.tina) == null ? void 0 : _b2.isCustomContentApi)) {
8524
+ doFetchEvents = await ((_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isAuthenticated());
8525
+ }
8526
+ if (doFetchEvents) {
8518
8527
  const { events } = await cms.api.tina.fetchEvents();
8519
8528
  if (events.length === 0) {
8520
8529
  setSyncStatus({ state: "success", message: "No Events" });
@@ -8533,7 +8542,7 @@ var __publicField = (obj, key, value) => {
8533
8542
  }
8534
8543
  }, 5e3);
8535
8544
  return () => clearInterval(interval);
8536
- }, [cms]);
8545
+ }, [(_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi]);
8537
8546
  return syncStatus;
8538
8547
  }
8539
8548
  const SyncErrorWidget = ({ cms }) => {
@@ -8646,6 +8655,9 @@ var __publicField = (obj, key, value) => {
8646
8655
  function closeEventsModal() {
8647
8656
  setEventsOpen(false);
8648
8657
  }
8658
+ const WrappedSyncStatus = React__namespace.forwardRef(
8659
+ (props2, ref) => /* @__PURE__ */ React__namespace.createElement(SyncStatus, { ...props2 })
8660
+ );
8649
8661
  return /* @__PURE__ */ React__namespace.createElement(
8650
8662
  "div",
8651
8663
  {
@@ -8697,18 +8709,30 @@ var __publicField = (obj, key, value) => {
8697
8709
  sidebarWidth: null,
8698
8710
  resizingSidebar: false
8699
8711
  });
8700
- if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
8701
- await cms.api.tina.logout();
8702
- if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
8703
- await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
8712
+ try {
8713
+ if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
8714
+ await cms.api.tina.logout();
8715
+ if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
8716
+ await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
8717
+ }
8704
8718
  }
8719
+ setEdit(false);
8720
+ } catch (e) {
8721
+ cms.alerts.error(`Error logging out: ${e}`);
8722
+ console.error("Unexpected error calling logout");
8723
+ console.error(e);
8705
8724
  }
8706
- setEdit(false);
8707
8725
  }
8708
8726
  },
8709
8727
  /* @__PURE__ */ React__namespace.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
8710
8728
  " Log Out"
8711
- )), /* @__PURE__ */ React__namespace.createElement(react.Menu.Item, null, /* @__PURE__ */ React__namespace.createElement(SyncStatus, { cms, setEventsOpen })))
8729
+ )), /* @__PURE__ */ React__namespace.createElement(react.Menu.Item, null, /* @__PURE__ */ React__namespace.createElement(
8730
+ WrappedSyncStatus,
8731
+ {
8732
+ cms,
8733
+ setEventsOpen
8734
+ }
8735
+ )))
8712
8736
  ))))),
8713
8737
  eventsOpen && /* @__PURE__ */ React__namespace.createElement(SyncStatusModal, { cms, closeEventsModal }),
8714
8738
  children,
@@ -26368,7 +26392,7 @@ var __publicField = (obj, key, value) => {
26368
26392
  }
26369
26393
  class Client {
26370
26394
  constructor({ tokenStorage = "MEMORY", ...options }) {
26371
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
26395
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X;
26372
26396
  this.events = new EventBus();
26373
26397
  this.protectedBranches = [];
26374
26398
  this.usingEditorialWorkflow = false;
@@ -26433,6 +26457,9 @@ mutation addPendingDocumentMutation(
26433
26457
  if ((_B = (_A = (_z = (_y = options.schema) == null ? void 0 : _y.config) == null ? void 0 : _z.admin) == null ? void 0 : _A.auth) == null ? void 0 : _B.authenticate) {
26434
26458
  this.authenticate = (_F = (_E = (_D = (_C = options.schema) == null ? void 0 : _C.config) == null ? void 0 : _D.admin) == null ? void 0 : _E.auth) == null ? void 0 : _F.authenticate;
26435
26459
  }
26460
+ if ((_J = (_I = (_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.admin) == null ? void 0 : _I.auth) == null ? void 0 : _J.authorize) {
26461
+ this.authorize = (_N = (_M = (_L = (_K = options.schema) == null ? void 0 : _K.config) == null ? void 0 : _L.admin) == null ? void 0 : _M.auth) == null ? void 0 : _N.authorize;
26462
+ }
26436
26463
  if (options.schema) {
26437
26464
  const enrichedSchema = new schemaTools.TinaSchema({
26438
26465
  version: { fullVersion: "", major: "", minor: "", patch: "" },
@@ -26442,7 +26469,7 @@ mutation addPendingDocumentMutation(
26442
26469
  this.schema = enrichedSchema;
26443
26470
  }
26444
26471
  this.options = options;
26445
- if ((_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.contentApiUrlOverride) {
26472
+ if ((_P = (_O = options.schema) == null ? void 0 : _O.config) == null ? void 0 : _P.contentApiUrlOverride) {
26446
26473
  this.options.customContentApiUrl = options.schema.config.contentApiUrlOverride;
26447
26474
  }
26448
26475
  this.setBranch(options.branch);
@@ -26496,8 +26523,8 @@ mutation addPendingDocumentMutation(
26496
26523
  this.getToken = options.getTokenFn;
26497
26524
  break;
26498
26525
  }
26499
- if ((_L = (_K = (_J = (_I = options.schema) == null ? void 0 : _I.config) == null ? void 0 : _J.admin) == null ? void 0 : _K.auth) == null ? void 0 : _L.getToken) {
26500
- this.getToken = (_P = (_O = (_N = (_M = options.schema) == null ? void 0 : _M.config) == null ? void 0 : _N.admin) == null ? void 0 : _O.auth) == null ? void 0 : _P.getToken;
26526
+ if ((_T = (_S = (_R = (_Q = options.schema) == null ? void 0 : _Q.config) == null ? void 0 : _R.admin) == null ? void 0 : _S.auth) == null ? void 0 : _T.getToken) {
26527
+ this.getToken = (_X = (_W = (_V = (_U = options.schema) == null ? void 0 : _U.config) == null ? void 0 : _V.admin) == null ? void 0 : _W.auth) == null ? void 0 : _X.getToken;
26501
26528
  }
26502
26529
  }
26503
26530
  get isLocalMode() {
@@ -26541,12 +26568,14 @@ mutation addPendingDocumentMutation(
26541
26568
  if (resBody.message) {
26542
26569
  errorMessage = `${errorMessage}, Response: ${resBody.message}`;
26543
26570
  }
26544
- errorMessage = `${errorMessage}, Please check that the following information is correct:
26571
+ if (!this.isCustomContentApi) {
26572
+ errorMessage = `${errorMessage}, Please check that the following information is correct:
26545
26573
  clientId: ${this.options.clientId}
26546
26574
  branch: ${this.branch}.`;
26547
- if (this.branch !== "main") {
26548
- errorMessage = `${errorMessage}
26575
+ if (this.branch !== "main") {
26576
+ errorMessage = `${errorMessage}
26549
26577
  Note: This error can occur if the branch does not exist on GitHub or on Tina Cloud`;
26578
+ }
26550
26579
  }
26551
26580
  throw new Error(errorMessage);
26552
26581
  }
@@ -26673,8 +26702,8 @@ mutation addPendingDocumentMutation(
26673
26702
  }
26674
26703
  return Promise.resolve({ access_token, id_token, refresh_token });
26675
26704
  }
26676
- async isAuthorized() {
26677
- return this.isAuthenticated();
26705
+ async isAuthorized(context) {
26706
+ return !!await this.authorize(context);
26678
26707
  }
26679
26708
  async isAuthenticated() {
26680
26709
  return !!await this.getUser();
@@ -26687,6 +26716,9 @@ mutation addPendingDocumentMutation(
26687
26716
  this.setToken(token);
26688
26717
  return token;
26689
26718
  }
26719
+ async authorize(context) {
26720
+ return this.getToken();
26721
+ }
26690
26722
  /**
26691
26723
  * Wraps the normal fetch function with same API but adds the authorization header token.
26692
26724
  *
@@ -27376,26 +27408,49 @@ mutation addPendingDocumentMutation(
27376
27408
  const client = cms.api.tina;
27377
27409
  const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
27378
27410
  const [activeModal, setActiveModal] = React.useState(null);
27411
+ const [errorMessage, setErrorMessage] = React.useState();
27379
27412
  const [showChildren, setShowChildren] = React.useState(false);
27380
27413
  React.useEffect(() => {
27381
27414
  client.isAuthenticated().then((isAuthenticated) => {
27382
27415
  if (isAuthenticated) {
27383
- setShowChildren(true);
27384
- cms.enable();
27416
+ client.isAuthorized().then((isAuthorized) => {
27417
+ if (isAuthorized) {
27418
+ setShowChildren(true);
27419
+ cms.enable();
27420
+ } else {
27421
+ setErrorMessage({
27422
+ title: "Access Denied:",
27423
+ message: "Not Authorized To Edit"
27424
+ });
27425
+ setActiveModal("error");
27426
+ }
27427
+ }).catch((e) => {
27428
+ console.error(e);
27429
+ setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27430
+ setActiveModal("error");
27431
+ });
27385
27432
  } else {
27386
27433
  sleep(500).then(() => {
27387
27434
  setActiveModal("authenticate");
27388
27435
  });
27389
27436
  }
27437
+ }).catch((e) => {
27438
+ console.error(e);
27439
+ setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27440
+ setActiveModal("error");
27390
27441
  });
27391
27442
  }, []);
27392
- const onAuthSuccess = async () => {
27393
- if (await client.isAuthenticated()) {
27443
+ const onAuthenticated = async () => {
27444
+ if (await client.isAuthorized()) {
27394
27445
  setShowChildren(true);
27395
27446
  setActiveModal(null);
27396
27447
  cms.events.dispatch({ type: "cms:login" });
27397
27448
  } else {
27398
- throw new Error("No access to repo");
27449
+ setErrorMessage({
27450
+ title: "Access Denied:",
27451
+ message: "Not Authorized To Edit"
27452
+ });
27453
+ setActiveModal("error");
27399
27454
  }
27400
27455
  };
27401
27456
  const otherModalActions = getModalActions ? getModalActions({
@@ -27407,7 +27462,7 @@ mutation addPendingDocumentMutation(
27407
27462
  ModalBuilder,
27408
27463
  {
27409
27464
  title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27410
- message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
27465
+ message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get committed using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
27411
27466
  close,
27412
27467
  actions: [
27413
27468
  ...otherModalActions,
@@ -27422,11 +27477,55 @@ mutation addPendingDocumentMutation(
27422
27477
  {
27423
27478
  name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
27424
27479
  action: async () => {
27425
- const token = await client.authenticate();
27426
- if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27427
- await (client == null ? void 0 : client.onLogin({ token }));
27480
+ try {
27481
+ const token = await client.authenticate();
27482
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27483
+ await (client == null ? void 0 : client.onLogin({ token }));
27484
+ }
27485
+ return onAuthenticated();
27486
+ } catch (e) {
27487
+ console.error(e);
27488
+ setActiveModal("error");
27489
+ setErrorMessage({
27490
+ title: "Unexpected Error:",
27491
+ message: `${e}`
27492
+ });
27493
+ }
27494
+ },
27495
+ primary: true
27496
+ }
27497
+ ]
27498
+ }
27499
+ ), activeModal === "error" && errorMessage && /* @__PURE__ */ React.createElement(
27500
+ ModalBuilder,
27501
+ {
27502
+ title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27503
+ message: errorMessage.title,
27504
+ error: errorMessage.message,
27505
+ close,
27506
+ actions: [
27507
+ ...otherModalActions,
27508
+ {
27509
+ name: "Retry",
27510
+ action: async () => {
27511
+ try {
27512
+ setActiveModal(null);
27513
+ setErrorMessage(void 0);
27514
+ await client.logout();
27515
+ await client.onLogout();
27516
+ const token = await client.authenticate();
27517
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27518
+ await (client == null ? void 0 : client.onLogin({ token }));
27519
+ }
27520
+ return onAuthenticated();
27521
+ } catch (e) {
27522
+ console.error(e);
27523
+ setActiveModal("error");
27524
+ setErrorMessage({
27525
+ title: "Unexpected Error:",
27526
+ message: `${e}`
27527
+ });
27428
27528
  }
27429
- onAuthSuccess();
27430
27529
  },
27431
27530
  primary: true
27432
27531
  }
@@ -28776,15 +28875,15 @@ This will work when developing locally but NOT when deployed to production.
28776
28875
  )))))
28777
28876
  )));
28778
28877
  };
28779
- const handleNavigate = (navigate, cms, collection, collectionDefinition, document2) => {
28878
+ const handleNavigate = async (navigate, cms, collection, collectionDefinition, document2) => {
28780
28879
  var _a, _b;
28781
28880
  const plugins2 = cms.plugins.all("tina-admin");
28782
28881
  const routeMapping = plugins2.find(({ name }) => name === "route-mapping");
28783
28882
  const tinaPreview = cms.flags.get("tina-preview") || false;
28784
- let routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? (_b = collectionDefinition.ui) == null ? void 0 : _b.router({
28883
+ let routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? await ((_b = collectionDefinition.ui) == null ? void 0 : _b.router({
28785
28884
  document: document2,
28786
28885
  collection: collectionDefinition
28787
- }) : routeMapping ? routeMapping.mapper(collection, document2) : void 0;
28886
+ })) : routeMapping ? routeMapping.mapper(collection, document2) : void 0;
28788
28887
  if (routeOverride) {
28789
28888
  if (routeOverride.startsWith("/")) {
28790
28889
  routeOverride = routeOverride.slice(1);
@@ -29432,6 +29531,54 @@ This will work when developing locally but NOT when deployed to production.
29432
29531
  "Rename"
29433
29532
  ))));
29434
29533
  };
29534
+ const ErrorDialog = (props) => {
29535
+ return /* @__PURE__ */ React.createElement(
29536
+ "div",
29537
+ {
29538
+ style: {
29539
+ background: "#efefef",
29540
+ display: "flex",
29541
+ alignItems: "center",
29542
+ justifyContent: "center"
29543
+ }
29544
+ },
29545
+ /* @__PURE__ */ React.createElement("style", null, " body { margin: 0; } "),
29546
+ /* @__PURE__ */ React.createElement(
29547
+ "div",
29548
+ {
29549
+ style: {
29550
+ background: "#fff",
29551
+ maxWidth: "400px",
29552
+ padding: "20px",
29553
+ fontFamily: "'Inter', sans-serif",
29554
+ borderRadius: "5px",
29555
+ boxShadow: "0 6px 24px rgb(0 37 91 / 5%), 0 2px 4px rgb(0 37 91 / 3%)"
29556
+ }
29557
+ },
29558
+ /* @__PURE__ */ React.createElement("h3", { style: { color: "#eb6337" } }, props.title),
29559
+ /* @__PURE__ */ React.createElement("p", null, props.message, ":"),
29560
+ /* @__PURE__ */ React.createElement(
29561
+ "pre",
29562
+ {
29563
+ style: { marginTop: "1rem", overflowX: "auto" }
29564
+ },
29565
+ `${props.error}`
29566
+ ),
29567
+ /* @__PURE__ */ React.createElement("p", null, "See our", " ", /* @__PURE__ */ React.createElement(
29568
+ "a",
29569
+ {
29570
+ className: "text-gray-600",
29571
+ style: { textDecoration: "underline" },
29572
+ href: "https://tina.io/docs/errors/faq/",
29573
+ target: "_blank"
29574
+ },
29575
+ " ",
29576
+ "Error FAQ",
29577
+ " "
29578
+ ), " ", "for more information.")
29579
+ )
29580
+ );
29581
+ };
29435
29582
  const createDocument = async (cms, collection, template, mutationInfo, folder, values) => {
29436
29583
  const api = new TinaAdminApi(cms);
29437
29584
  const { filename, ...leftover } = values;
@@ -29645,10 +29792,16 @@ This will work when developing locally but NOT when deployed to production.
29645
29792
  const defaultErrorText = "There was a problem saving your document.";
29646
29793
  if (error.message.includes("already exists")) {
29647
29794
  cms.alerts.error(
29648
- `${defaultErrorText} The "Filename" is alredy used for another document, please modify it.`
29795
+ `${defaultErrorText} The "Filename" is already used for another document, please modify it.`
29649
29796
  );
29650
29797
  } else {
29651
- cms.alerts.error(defaultErrorText);
29798
+ cms.alerts.error(
29799
+ () => ErrorDialog({
29800
+ title: defaultErrorText,
29801
+ message: "Tina caught an error while creating the page",
29802
+ error
29803
+ })
29804
+ );
29652
29805
  }
29653
29806
  throw new Error(
29654
29807
  `[${error.name}] CreateDocument failed: ${error.message}`
@@ -29873,6 +30026,13 @@ This will work when developing locally but NOT when deployed to production.
29873
30026
  );
29874
30027
  cms.alerts.success("Document updated!");
29875
30028
  } catch (error) {
30029
+ cms.alerts.error(
30030
+ () => ErrorDialog({
30031
+ title: "There was a problem saving your document",
30032
+ message: "Tina caught an error while updating the page",
30033
+ error
30034
+ })
30035
+ );
29876
30036
  console.error(error);
29877
30037
  throw new Error(
29878
30038
  `[${error.name}] UpdateDocument failed: ${error.message}`
@@ -30153,6 +30313,7 @@ This will work when developing locally but NOT when deployed to production.
30153
30313
  if (e.message.includes("has not been indexed by Tina Cloud")) {
30154
30314
  setSchemaMissingError(true);
30155
30315
  } else {
30316
+ cms.alerts.error(`Unexpected error checking schema: ${e}`);
30156
30317
  throw e;
30157
30318
  }
30158
30319
  });
@@ -30400,6 +30561,7 @@ This will work when developing locally but NOT when deployed to production.
30400
30561
  exports2.EditIcon = EditIcon;
30401
30562
  exports2.EditoralBranchSwitcher = EditoralBranchSwitcher;
30402
30563
  exports2.EllipsisVerticalIcon = EllipsisVerticalIcon;
30564
+ exports2.ErrorDialog = ErrorDialog;
30403
30565
  exports2.ErrorIcon = ErrorIcon;
30404
30566
  exports2.EventBus = EventBus;
30405
30567
  exports2.ExitIcon = ExitIcon;
package/dist/index.mjs CHANGED
@@ -8491,8 +8491,12 @@ const useGetEvents = (cms, cursor, existingEvents) => {
8491
8491
  const [error, setError] = useState(void 0);
8492
8492
  React.useEffect(() => {
8493
8493
  const fetchEvents = async () => {
8494
- var _a, _b;
8495
- if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi) && cms.api.tina.isAuthorized()) {
8494
+ var _a, _b, _c, _d;
8495
+ let doFetchEvents = false;
8496
+ if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi)) {
8497
+ doFetchEvents = await ((_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isAuthenticated());
8498
+ }
8499
+ if (doFetchEvents) {
8496
8500
  try {
8497
8501
  const { events: nextEvents, cursor: nextCursor2 } = await cms.api.tina.fetchEvents(15, cursor);
8498
8502
  setEvents([...existingEvents, ...nextEvents]);
@@ -8516,11 +8520,16 @@ const useGetEvents = (cms, cursor, existingEvents) => {
8516
8520
  return { events, cursor: nextCursor, loading, error };
8517
8521
  };
8518
8522
  function useSyncStatus$1(cms) {
8523
+ var _a, _b;
8519
8524
  const [syncStatus, setSyncStatus] = useState({ state: "loading", message: "Loading..." });
8520
8525
  React.useEffect(() => {
8521
8526
  const interval = setInterval(async () => {
8522
- var _a, _b;
8523
- if (!((_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi) && cms.api.tina.isAuthorized()) {
8527
+ var _a2, _b2, _c, _d;
8528
+ let doFetchEvents = false;
8529
+ if (!((_b2 = (_a2 = cms.api) == null ? void 0 : _a2.tina) == null ? void 0 : _b2.isCustomContentApi)) {
8530
+ doFetchEvents = await ((_d = (_c = cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.isAuthenticated());
8531
+ }
8532
+ if (doFetchEvents) {
8524
8533
  const { events } = await cms.api.tina.fetchEvents();
8525
8534
  if (events.length === 0) {
8526
8535
  setSyncStatus({ state: "success", message: "No Events" });
@@ -8539,7 +8548,7 @@ function useSyncStatus$1(cms) {
8539
8548
  }
8540
8549
  }, 5e3);
8541
8550
  return () => clearInterval(interval);
8542
- }, [cms]);
8551
+ }, [(_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isCustomContentApi]);
8543
8552
  return syncStatus;
8544
8553
  }
8545
8554
  const SyncErrorWidget = ({ cms }) => {
@@ -8652,6 +8661,9 @@ const Nav = ({
8652
8661
  function closeEventsModal() {
8653
8662
  setEventsOpen(false);
8654
8663
  }
8664
+ const WrappedSyncStatus = React.forwardRef(
8665
+ (props2, ref) => /* @__PURE__ */ React.createElement(SyncStatus, { ...props2 })
8666
+ );
8655
8667
  return /* @__PURE__ */ React.createElement(
8656
8668
  "div",
8657
8669
  {
@@ -8703,18 +8715,30 @@ const Nav = ({
8703
8715
  sidebarWidth: null,
8704
8716
  resizingSidebar: false
8705
8717
  });
8706
- if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
8707
- await cms.api.tina.logout();
8708
- if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
8709
- await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
8718
+ try {
8719
+ if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
8720
+ await cms.api.tina.logout();
8721
+ if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
8722
+ await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
8723
+ }
8710
8724
  }
8725
+ setEdit(false);
8726
+ } catch (e) {
8727
+ cms.alerts.error(`Error logging out: ${e}`);
8728
+ console.error("Unexpected error calling logout");
8729
+ console.error(e);
8711
8730
  }
8712
- setEdit(false);
8713
8731
  }
8714
8732
  },
8715
8733
  /* @__PURE__ */ React.createElement(BiExit, { className: "w-6 h-auto mr-2 text-blue-400" }),
8716
8734
  " Log Out"
8717
- )), /* @__PURE__ */ React.createElement(Menu.Item, null, /* @__PURE__ */ React.createElement(SyncStatus, { cms, setEventsOpen })))
8735
+ )), /* @__PURE__ */ React.createElement(Menu.Item, null, /* @__PURE__ */ React.createElement(
8736
+ WrappedSyncStatus,
8737
+ {
8738
+ cms,
8739
+ setEventsOpen
8740
+ }
8741
+ )))
8718
8742
  ))))),
8719
8743
  eventsOpen && /* @__PURE__ */ React.createElement(SyncStatusModal, { cms, closeEventsModal }),
8720
8744
  children,
@@ -26374,7 +26398,7 @@ function asyncPoll(fn, pollInterval = 5 * 1e3, pollTimeout = 30 * 1e3) {
26374
26398
  }
26375
26399
  class Client {
26376
26400
  constructor({ tokenStorage = "MEMORY", ...options }) {
26377
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
26401
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X;
26378
26402
  this.events = new EventBus();
26379
26403
  this.protectedBranches = [];
26380
26404
  this.usingEditorialWorkflow = false;
@@ -26439,6 +26463,9 @@ mutation addPendingDocumentMutation(
26439
26463
  if ((_B = (_A = (_z = (_y = options.schema) == null ? void 0 : _y.config) == null ? void 0 : _z.admin) == null ? void 0 : _A.auth) == null ? void 0 : _B.authenticate) {
26440
26464
  this.authenticate = (_F = (_E = (_D = (_C = options.schema) == null ? void 0 : _C.config) == null ? void 0 : _D.admin) == null ? void 0 : _E.auth) == null ? void 0 : _F.authenticate;
26441
26465
  }
26466
+ if ((_J = (_I = (_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.admin) == null ? void 0 : _I.auth) == null ? void 0 : _J.authorize) {
26467
+ this.authorize = (_N = (_M = (_L = (_K = options.schema) == null ? void 0 : _K.config) == null ? void 0 : _L.admin) == null ? void 0 : _M.auth) == null ? void 0 : _N.authorize;
26468
+ }
26442
26469
  if (options.schema) {
26443
26470
  const enrichedSchema = new TinaSchema({
26444
26471
  version: { fullVersion: "", major: "", minor: "", patch: "" },
@@ -26448,7 +26475,7 @@ mutation addPendingDocumentMutation(
26448
26475
  this.schema = enrichedSchema;
26449
26476
  }
26450
26477
  this.options = options;
26451
- if ((_H = (_G = options.schema) == null ? void 0 : _G.config) == null ? void 0 : _H.contentApiUrlOverride) {
26478
+ if ((_P = (_O = options.schema) == null ? void 0 : _O.config) == null ? void 0 : _P.contentApiUrlOverride) {
26452
26479
  this.options.customContentApiUrl = options.schema.config.contentApiUrlOverride;
26453
26480
  }
26454
26481
  this.setBranch(options.branch);
@@ -26502,8 +26529,8 @@ mutation addPendingDocumentMutation(
26502
26529
  this.getToken = options.getTokenFn;
26503
26530
  break;
26504
26531
  }
26505
- if ((_L = (_K = (_J = (_I = options.schema) == null ? void 0 : _I.config) == null ? void 0 : _J.admin) == null ? void 0 : _K.auth) == null ? void 0 : _L.getToken) {
26506
- this.getToken = (_P = (_O = (_N = (_M = options.schema) == null ? void 0 : _M.config) == null ? void 0 : _N.admin) == null ? void 0 : _O.auth) == null ? void 0 : _P.getToken;
26532
+ if ((_T = (_S = (_R = (_Q = options.schema) == null ? void 0 : _Q.config) == null ? void 0 : _R.admin) == null ? void 0 : _S.auth) == null ? void 0 : _T.getToken) {
26533
+ this.getToken = (_X = (_W = (_V = (_U = options.schema) == null ? void 0 : _U.config) == null ? void 0 : _V.admin) == null ? void 0 : _W.auth) == null ? void 0 : _X.getToken;
26507
26534
  }
26508
26535
  }
26509
26536
  get isLocalMode() {
@@ -26547,12 +26574,14 @@ mutation addPendingDocumentMutation(
26547
26574
  if (resBody.message) {
26548
26575
  errorMessage = `${errorMessage}, Response: ${resBody.message}`;
26549
26576
  }
26550
- errorMessage = `${errorMessage}, Please check that the following information is correct:
26577
+ if (!this.isCustomContentApi) {
26578
+ errorMessage = `${errorMessage}, Please check that the following information is correct:
26551
26579
  clientId: ${this.options.clientId}
26552
26580
  branch: ${this.branch}.`;
26553
- if (this.branch !== "main") {
26554
- errorMessage = `${errorMessage}
26581
+ if (this.branch !== "main") {
26582
+ errorMessage = `${errorMessage}
26555
26583
  Note: This error can occur if the branch does not exist on GitHub or on Tina Cloud`;
26584
+ }
26556
26585
  }
26557
26586
  throw new Error(errorMessage);
26558
26587
  }
@@ -26679,8 +26708,8 @@ mutation addPendingDocumentMutation(
26679
26708
  }
26680
26709
  return Promise.resolve({ access_token, id_token, refresh_token });
26681
26710
  }
26682
- async isAuthorized() {
26683
- return this.isAuthenticated();
26711
+ async isAuthorized(context) {
26712
+ return !!await this.authorize(context);
26684
26713
  }
26685
26714
  async isAuthenticated() {
26686
26715
  return !!await this.getUser();
@@ -26693,6 +26722,9 @@ mutation addPendingDocumentMutation(
26693
26722
  this.setToken(token);
26694
26723
  return token;
26695
26724
  }
26725
+ async authorize(context) {
26726
+ return this.getToken();
26727
+ }
26696
26728
  /**
26697
26729
  * Wraps the normal fetch function with same API but adds the authorization header token.
26698
26730
  *
@@ -27382,26 +27414,49 @@ const AuthWallInner = ({
27382
27414
  const client = cms.api.tina;
27383
27415
  const isTinaCloud = !client.isLocalMode && !((_e = (_d = (_c = (_b = (_a = client.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.config) == null ? void 0 : _c.admin) == null ? void 0 : _d.auth) == null ? void 0 : _e.customAuth);
27384
27416
  const [activeModal, setActiveModal] = useState(null);
27417
+ const [errorMessage, setErrorMessage] = useState();
27385
27418
  const [showChildren, setShowChildren] = useState(false);
27386
27419
  React__default.useEffect(() => {
27387
27420
  client.isAuthenticated().then((isAuthenticated) => {
27388
27421
  if (isAuthenticated) {
27389
- setShowChildren(true);
27390
- cms.enable();
27422
+ client.isAuthorized().then((isAuthorized) => {
27423
+ if (isAuthorized) {
27424
+ setShowChildren(true);
27425
+ cms.enable();
27426
+ } else {
27427
+ setErrorMessage({
27428
+ title: "Access Denied:",
27429
+ message: "Not Authorized To Edit"
27430
+ });
27431
+ setActiveModal("error");
27432
+ }
27433
+ }).catch((e) => {
27434
+ console.error(e);
27435
+ setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27436
+ setActiveModal("error");
27437
+ });
27391
27438
  } else {
27392
27439
  sleep(500).then(() => {
27393
27440
  setActiveModal("authenticate");
27394
27441
  });
27395
27442
  }
27443
+ }).catch((e) => {
27444
+ console.error(e);
27445
+ setErrorMessage({ title: "Unexpected Error:", message: `${e}` });
27446
+ setActiveModal("error");
27396
27447
  });
27397
27448
  }, []);
27398
- const onAuthSuccess = async () => {
27399
- if (await client.isAuthenticated()) {
27449
+ const onAuthenticated = async () => {
27450
+ if (await client.isAuthorized()) {
27400
27451
  setShowChildren(true);
27401
27452
  setActiveModal(null);
27402
27453
  cms.events.dispatch({ type: "cms:login" });
27403
27454
  } else {
27404
- throw new Error("No access to repo");
27455
+ setErrorMessage({
27456
+ title: "Access Denied:",
27457
+ message: "Not Authorized To Edit"
27458
+ });
27459
+ setActiveModal("error");
27405
27460
  }
27406
27461
  };
27407
27462
  const otherModalActions = getModalActions ? getModalActions({
@@ -27413,7 +27468,7 @@ const AuthWallInner = ({
27413
27468
  ModalBuilder,
27414
27469
  {
27415
27470
  title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27416
- message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get commited using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
27471
+ message: isTinaCloud ? "To save edits, Tina Cloud authorization is required. On save, changes will get committed using your account." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
27417
27472
  close,
27418
27473
  actions: [
27419
27474
  ...otherModalActions,
@@ -27428,11 +27483,55 @@ const AuthWallInner = ({
27428
27483
  {
27429
27484
  name: isTinaCloud ? "Continue to Tina Cloud" : "Enter Edit Mode",
27430
27485
  action: async () => {
27431
- const token = await client.authenticate();
27432
- if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27433
- await (client == null ? void 0 : client.onLogin({ token }));
27486
+ try {
27487
+ const token = await client.authenticate();
27488
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27489
+ await (client == null ? void 0 : client.onLogin({ token }));
27490
+ }
27491
+ return onAuthenticated();
27492
+ } catch (e) {
27493
+ console.error(e);
27494
+ setActiveModal("error");
27495
+ setErrorMessage({
27496
+ title: "Unexpected Error:",
27497
+ message: `${e}`
27498
+ });
27499
+ }
27500
+ },
27501
+ primary: true
27502
+ }
27503
+ ]
27504
+ }
27505
+ ), activeModal === "error" && errorMessage && /* @__PURE__ */ React__default.createElement(
27506
+ ModalBuilder,
27507
+ {
27508
+ title: isTinaCloud ? "Tina Cloud Authorization" : "Enter into edit mode",
27509
+ message: errorMessage.title,
27510
+ error: errorMessage.message,
27511
+ close,
27512
+ actions: [
27513
+ ...otherModalActions,
27514
+ {
27515
+ name: "Retry",
27516
+ action: async () => {
27517
+ try {
27518
+ setActiveModal(null);
27519
+ setErrorMessage(void 0);
27520
+ await client.logout();
27521
+ await client.onLogout();
27522
+ const token = await client.authenticate();
27523
+ if (typeof (client == null ? void 0 : client.onLogin) === "function") {
27524
+ await (client == null ? void 0 : client.onLogin({ token }));
27525
+ }
27526
+ return onAuthenticated();
27527
+ } catch (e) {
27528
+ console.error(e);
27529
+ setActiveModal("error");
27530
+ setErrorMessage({
27531
+ title: "Unexpected Error:",
27532
+ message: `${e}`
27533
+ });
27434
27534
  }
27435
- onAuthSuccess();
27436
27535
  },
27437
27536
  primary: true
27438
27537
  }
@@ -28782,15 +28881,15 @@ const TemplateMenu = ({
28782
28881
  )))))
28783
28882
  )));
28784
28883
  };
28785
- const handleNavigate = (navigate, cms, collection, collectionDefinition, document2) => {
28884
+ const handleNavigate = async (navigate, cms, collection, collectionDefinition, document2) => {
28786
28885
  var _a, _b;
28787
28886
  const plugins2 = cms.plugins.all("tina-admin");
28788
28887
  const routeMapping = plugins2.find(({ name }) => name === "route-mapping");
28789
28888
  const tinaPreview = cms.flags.get("tina-preview") || false;
28790
- let routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? (_b = collectionDefinition.ui) == null ? void 0 : _b.router({
28889
+ let routeOverride = ((_a = collectionDefinition.ui) == null ? void 0 : _a.router) ? await ((_b = collectionDefinition.ui) == null ? void 0 : _b.router({
28791
28890
  document: document2,
28792
28891
  collection: collectionDefinition
28793
- }) : routeMapping ? routeMapping.mapper(collection, document2) : void 0;
28892
+ })) : routeMapping ? routeMapping.mapper(collection, document2) : void 0;
28794
28893
  if (routeOverride) {
28795
28894
  if (routeOverride.startsWith("/")) {
28796
28895
  routeOverride = routeOverride.slice(1);
@@ -29438,6 +29537,54 @@ const RenameModal = ({
29438
29537
  "Rename"
29439
29538
  ))));
29440
29539
  };
29540
+ const ErrorDialog = (props) => {
29541
+ return /* @__PURE__ */ React__default.createElement(
29542
+ "div",
29543
+ {
29544
+ style: {
29545
+ background: "#efefef",
29546
+ display: "flex",
29547
+ alignItems: "center",
29548
+ justifyContent: "center"
29549
+ }
29550
+ },
29551
+ /* @__PURE__ */ React__default.createElement("style", null, " body { margin: 0; } "),
29552
+ /* @__PURE__ */ React__default.createElement(
29553
+ "div",
29554
+ {
29555
+ style: {
29556
+ background: "#fff",
29557
+ maxWidth: "400px",
29558
+ padding: "20px",
29559
+ fontFamily: "'Inter', sans-serif",
29560
+ borderRadius: "5px",
29561
+ boxShadow: "0 6px 24px rgb(0 37 91 / 5%), 0 2px 4px rgb(0 37 91 / 3%)"
29562
+ }
29563
+ },
29564
+ /* @__PURE__ */ React__default.createElement("h3", { style: { color: "#eb6337" } }, props.title),
29565
+ /* @__PURE__ */ React__default.createElement("p", null, props.message, ":"),
29566
+ /* @__PURE__ */ React__default.createElement(
29567
+ "pre",
29568
+ {
29569
+ style: { marginTop: "1rem", overflowX: "auto" }
29570
+ },
29571
+ `${props.error}`
29572
+ ),
29573
+ /* @__PURE__ */ React__default.createElement("p", null, "See our", " ", /* @__PURE__ */ React__default.createElement(
29574
+ "a",
29575
+ {
29576
+ className: "text-gray-600",
29577
+ style: { textDecoration: "underline" },
29578
+ href: "https://tina.io/docs/errors/faq/",
29579
+ target: "_blank"
29580
+ },
29581
+ " ",
29582
+ "Error FAQ",
29583
+ " "
29584
+ ), " ", "for more information.")
29585
+ )
29586
+ );
29587
+ };
29441
29588
  const createDocument = async (cms, collection, template, mutationInfo, folder, values) => {
29442
29589
  const api = new TinaAdminApi(cms);
29443
29590
  const { filename, ...leftover } = values;
@@ -29651,10 +29798,16 @@ const RenderForm$1 = ({
29651
29798
  const defaultErrorText = "There was a problem saving your document.";
29652
29799
  if (error.message.includes("already exists")) {
29653
29800
  cms.alerts.error(
29654
- `${defaultErrorText} The "Filename" is alredy used for another document, please modify it.`
29801
+ `${defaultErrorText} The "Filename" is already used for another document, please modify it.`
29655
29802
  );
29656
29803
  } else {
29657
- cms.alerts.error(defaultErrorText);
29804
+ cms.alerts.error(
29805
+ () => ErrorDialog({
29806
+ title: defaultErrorText,
29807
+ message: "Tina caught an error while creating the page",
29808
+ error
29809
+ })
29810
+ );
29658
29811
  }
29659
29812
  throw new Error(
29660
29813
  `[${error.name}] CreateDocument failed: ${error.message}`
@@ -29879,6 +30032,13 @@ const RenderForm = ({
29879
30032
  );
29880
30033
  cms.alerts.success("Document updated!");
29881
30034
  } catch (error) {
30035
+ cms.alerts.error(
30036
+ () => ErrorDialog({
30037
+ title: "There was a problem saving your document",
30038
+ message: "Tina caught an error while updating the page",
30039
+ error
30040
+ })
30041
+ );
29882
30042
  console.error(error);
29883
30043
  throw new Error(
29884
30044
  `[${error.name}] UpdateDocument failed: ${error.message}`
@@ -30159,6 +30319,7 @@ const CheckSchema = ({
30159
30319
  if (e.message.includes("has not been indexed by Tina Cloud")) {
30160
30320
  setSchemaMissingError(true);
30161
30321
  } else {
30322
+ cms.alerts.error(`Unexpected error checking schema: ${e}`);
30162
30323
  throw e;
30163
30324
  }
30164
30325
  });
@@ -30399,6 +30560,7 @@ export {
30399
30560
  EditIcon,
30400
30561
  EditoralBranchSwitcher,
30401
30562
  EllipsisVerticalIcon,
30563
+ ErrorDialog,
30402
30564
  ErrorIcon,
30403
30565
  EventBus,
30404
30566
  ExitIcon,
@@ -189,10 +189,11 @@ export declare class Client {
189
189
  }>;
190
190
  parseJwt(token: any): any;
191
191
  getRefreshedToken(tokens: string): Promise<TokenObject>;
192
- isAuthorized(): Promise<boolean>;
192
+ isAuthorized(context?: any): Promise<boolean>;
193
193
  isAuthenticated(): Promise<boolean>;
194
194
  logout(): Promise<void>;
195
195
  authenticate(): Promise<TokenObject>;
196
+ authorize(context?: any): Promise<any>;
196
197
  /**
197
198
  * Wraps the normal fetch function with same API but adds the authorization header token.
198
199
  *
@@ -1,6 +1,3 @@
1
- /**
2
-
3
- */
4
1
  export declare const TINA_HOST = "content.tinajs.io";
5
2
  export interface TinaClientArgs<GenQueries = Record<string, unknown>> {
6
3
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "1.5.18",
3
+ "version": "1.5.20",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "exports": {
@@ -69,8 +69,8 @@
69
69
  "@react-types/combobox": "^3.2.0",
70
70
  "@react-types/shared": "^3.10.0",
71
71
  "@sambego/storybook-styles": "^1.0.0",
72
- "@tinacms/schema-tools": "1.4.10",
73
- "@tinacms/search": "1.0.8",
72
+ "@tinacms/schema-tools": "1.4.12",
73
+ "@tinacms/search": "1.0.10",
74
74
  "@tinacms/sharedctx": "1.0.2",
75
75
  "@udecode/plate-headless": "^21.4.0",
76
76
  "atob": "2.1.2",