tinacms 1.5.11 → 1.5.12

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/dist/index.js CHANGED
@@ -206,7 +206,9 @@
206
206
  return matches[1];
207
207
  };
208
208
  const ListBranchResponse = zod.z.object({
209
- name: zod.z.string()
209
+ name: zod.z.string(),
210
+ protected: zod.z.boolean().optional().default(false),
211
+ githubPullRequestUrl: zod.z.string().optional()
210
212
  }).array();
211
213
  const IndexStatusResponse = zod.z.object({
212
214
  status: zod.z.union([
@@ -245,6 +247,8 @@
245
247
  constructor({ tokenStorage = "MEMORY", ...options }) {
246
248
  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;
247
249
  this.events = new toolkit.EventBus();
250
+ this.protectedBranches = [];
251
+ this.usingEditorialWorkflow = false;
248
252
  this.addPendingContent = async (props) => {
249
253
  const mutation = `#graphql
250
254
  mutation addPendingDocumentMutation(
@@ -435,6 +439,41 @@ mutation addPendingDocumentMutation(
435
439
  const jsonRes = await res.json();
436
440
  return jsonRes;
437
441
  }
442
+ async getProject() {
443
+ const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
444
+ method: "GET"
445
+ });
446
+ const val = await res.json();
447
+ return val;
448
+ }
449
+ async createPullRequest({
450
+ baseBranch,
451
+ branch,
452
+ title
453
+ }) {
454
+ const url = `${this.contentApiBase}/github/${this.clientId}/create_pull_request`;
455
+ try {
456
+ const res = await this.fetchWithToken(url, {
457
+ method: "POST",
458
+ body: JSON.stringify({
459
+ baseBranch,
460
+ branch,
461
+ title
462
+ }),
463
+ headers: {
464
+ "Content-Type": "application/json"
465
+ }
466
+ });
467
+ if (!res.ok) {
468
+ throw new Error(`There was an error creating a new branch. ${res.statusText}`);
469
+ }
470
+ const values = await res.json();
471
+ return values;
472
+ } catch (error) {
473
+ console.error("There was an error creating a new branch.", error);
474
+ throw error;
475
+ }
476
+ }
438
477
  async fetchEvents(limit, cursor) {
439
478
  if (this.isLocalMode) {
440
479
  return {
@@ -452,12 +491,6 @@ mutation addPendingDocumentMutation(
452
491
  }).join(""));
453
492
  return JSON.parse(jsonPayload);
454
493
  }
455
- async getProject() {
456
- const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
457
- method: "GET"
458
- });
459
- return res.json();
460
- }
461
494
  async getRefreshedToken(tokens) {
462
495
  const { access_token, id_token, refresh_token } = JSON.parse(tokens);
463
496
  const { exp, iss, client_id } = this.parseJwt(access_token);
@@ -561,6 +594,7 @@ mutation addPendingDocumentMutation(
561
594
  }
562
595
  }
563
596
  waitForIndexStatus({ ref }) {
597
+ let unknownCount = 0;
564
598
  try {
565
599
  const [prom, cancel] = asyncPoll(async () => {
566
600
  try {
@@ -571,6 +605,12 @@ mutation addPendingDocumentMutation(
571
605
  data: result
572
606
  });
573
607
  } else {
608
+ if (result.status === "unknown") {
609
+ unknownCount++;
610
+ if (unknownCount > 5) {
611
+ throw new Error("AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard");
612
+ }
613
+ }
574
614
  return Promise.resolve({
575
615
  done: false
576
616
  });
@@ -583,9 +623,8 @@ mutation addPendingDocumentMutation(
583
623
  } catch (error) {
584
624
  if (error.message === "AsyncPoller: reached timeout") {
585
625
  console.warn(error);
586
- return {
587
- status: "timeout"
588
- };
626
+ return [Promise.resolve({ status: "timeout" }), () => {
627
+ }];
589
628
  }
590
629
  throw error;
591
630
  }
@@ -597,7 +636,7 @@ mutation addPendingDocumentMutation(
597
636
  const parsedResult = IndexStatusResponse.parse(result);
598
637
  return parsedResult;
599
638
  }
600
- async listBranches() {
639
+ async listBranches(args) {
601
640
  try {
602
641
  const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
603
642
  const res = await this.fetchWithToken(url, {
@@ -605,6 +644,9 @@ mutation addPendingDocumentMutation(
605
644
  });
606
645
  const branches = await res.json();
607
646
  const parsedBranches = ListBranchResponse.parse(branches);
647
+ if ((args == null ? void 0 : args.includeIndexStatus) === false) {
648
+ return parsedBranches;
649
+ }
608
650
  const indexStatusPromises = parsedBranches.map(async (branch) => {
609
651
  const indexStatus2 = await this.getIndexStatus({ ref: branch.name });
610
652
  return {
@@ -612,6 +654,7 @@ mutation addPendingDocumentMutation(
612
654
  indexStatus: indexStatus2
613
655
  };
614
656
  });
657
+ this.protectedBranches = parsedBranches.filter((x) => x.protected).map((x) => x.name);
615
658
  const indexStatus = await Promise.all(indexStatusPromises);
616
659
  return indexStatus;
617
660
  } catch (error) {
@@ -619,6 +662,10 @@ mutation addPendingDocumentMutation(
619
662
  throw error;
620
663
  }
621
664
  }
665
+ usingProtectedBranch() {
666
+ var _a;
667
+ return this.usingEditorialWorkflow && ((_a = this.protectedBranches) == null ? void 0 : _a.includes(this.branch));
668
+ }
622
669
  async createBranch({ baseBranch, branchName }) {
623
670
  const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
624
671
  try {
@@ -632,10 +679,16 @@ mutation addPendingDocumentMutation(
632
679
  "Content-Type": "application/json"
633
680
  }
634
681
  });
635
- return await res.json().then((r) => parseRefForBranchName(r.data.ref));
682
+ if (!res.ok) {
683
+ console.error("There was an error creating a new branch.");
684
+ const error = await res.json();
685
+ throw new Error(error == null ? void 0 : error.message);
686
+ }
687
+ const values = await res.json();
688
+ return parseRefForBranchName(values.data.ref);
636
689
  } catch (error) {
637
690
  console.error("There was an error creating a new branch.", error);
638
- return null;
691
+ throw error;
639
692
  }
640
693
  }
641
694
  }
@@ -1115,6 +1168,7 @@ mutation addPendingDocumentMutation(
1115
1168
  if (await client.isAuthenticated()) {
1116
1169
  setShowChildren(true);
1117
1170
  setActiveModal(null);
1171
+ cms.events.dispatch({ type: "cms:login" });
1118
1172
  } else {
1119
1173
  throw new Error("No access to repo");
1120
1174
  }
@@ -1153,6 +1207,7 @@ mutation addPendingDocumentMutation(
1153
1207
  }), showChildren ? children : loginScreen ? loginScreen : null);
1154
1208
  };
1155
1209
  const TinaCloudProvider = (props) => {
1210
+ var _a, _b, _c, _d, _e;
1156
1211
  const baseBranch = props.branch || "main";
1157
1212
  const [currentBranch, setCurrentBranch] = toolkit.useLocalStorage("tinacms-current-branch", baseBranch);
1158
1213
  useTinaAuthRedirect();
@@ -1168,16 +1223,16 @@ mutation addPendingDocumentMutation(
1168
1223
  cms.api.tina.setBranch(currentBranch);
1169
1224
  }
1170
1225
  React.useEffect(() => {
1171
- var _a, _b, _c, _d;
1226
+ var _a2, _b2, _c2, _d2;
1172
1227
  let searchClient;
1173
1228
  if (props.isLocalClient) {
1174
1229
  searchClient = new LocalSearchClient(cms.api.tina);
1175
1230
  } else {
1176
- const hasTinaSearch = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
1231
+ const hasTinaSearch = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.search) == null ? void 0 : _b2.tina);
1177
1232
  if (hasTinaSearch) {
1178
1233
  searchClient = new TinaCMSSearchClient(cms.api.tina);
1179
1234
  } else {
1180
- searchClient = (_d = (_c = props.schema.config) == null ? void 0 : _c.search) == null ? void 0 : _d.searchClient;
1235
+ searchClient = (_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d2.searchClient;
1181
1236
  }
1182
1237
  }
1183
1238
  if (searchClient) {
@@ -1188,12 +1243,12 @@ mutation addPendingDocumentMutation(
1188
1243
  cms.registerApi("admin", new TinaAdminApi(cms));
1189
1244
  }
1190
1245
  const setupMedia = async () => {
1191
- var _a, _b, _c, _d, _e, _f, _g;
1192
- const hasTinaMedia = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina);
1246
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1247
+ const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
1193
1248
  if (hasTinaMedia) {
1194
1249
  cms.media.store = new toolkit.TinaMediaStore(cms);
1195
- } else if (((_d = (_c = props.schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.loadCustomStore) || props.mediaStore) {
1196
- const mediaStoreFromProps = ((_f = (_e = props.schema.config) == null ? void 0 : _e.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1250
+ } else if (((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore) {
1251
+ const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1197
1252
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
1198
1253
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
1199
1254
  } else {
@@ -1204,6 +1259,8 @@ mutation addPendingDocumentMutation(
1204
1259
  cms.media.store = new toolkit.DummyMediaStore();
1205
1260
  }
1206
1261
  };
1262
+ const client = cms.api.tina;
1263
+ 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);
1207
1264
  const handleListBranches = async () => {
1208
1265
  const { owner, repo } = props;
1209
1266
  const branches = await cms.api.tina.listBranches({ owner, repo });
@@ -1246,6 +1303,27 @@ mutation addPendingDocumentMutation(
1246
1303
  props.cmsCallback(cms);
1247
1304
  }
1248
1305
  }, []);
1306
+ React__default["default"].useEffect(() => {
1307
+ const setupEditorialWorkflow = () => {
1308
+ client.getProject().then((project) => {
1309
+ var _a2;
1310
+ if ((_a2 = project == null ? void 0 : project.features) == null ? void 0 : _a2.includes("editorial-workflow")) {
1311
+ cms.flags.set("branch-switcher", true);
1312
+ client.usingEditorialWorkflow = true;
1313
+ client.protectedBranches = project.protectedBranches;
1314
+ }
1315
+ });
1316
+ };
1317
+ if (isTinaCloud) {
1318
+ setupEditorialWorkflow();
1319
+ }
1320
+ const unsubscribe = cms.events.subscribe("cms:login", () => {
1321
+ if (isTinaCloud) {
1322
+ setupEditorialWorkflow();
1323
+ }
1324
+ });
1325
+ return unsubscribe;
1326
+ }, [isTinaCloud, cms]);
1249
1327
  return /* @__PURE__ */ React__default["default"].createElement(toolkit.BranchDataProvider, {
1250
1328
  currentBranch,
1251
1329
  setCurrentBranch: (b) => {
@@ -1575,6 +1653,343 @@ mutation addPendingDocumentMutation(
1575
1653
  --tw-backdrop-saturate: ;
1576
1654
  --tw-backdrop-sepia: ;
1577
1655
  }
1656
+ .tina-prose {
1657
+ color: var(--tw-prose-body);
1658
+ max-width: 65ch;
1659
+ }
1660
+ .tina-prose :where([class~="lead"]):not(:where([class~="not-tina-prose"] *)) {
1661
+ color: var(--tw-prose-lead);
1662
+ font-size: 1.25em;
1663
+ line-height: 1.6;
1664
+ margin-top: 1.2em;
1665
+ margin-bottom: 1.2em;
1666
+ }
1667
+ .tina-prose :where(a):not(:where([class~="not-tina-prose"] *)) {
1668
+ color: var(--tw-prose-links);
1669
+ text-decoration: underline;
1670
+ font-weight: 500;
1671
+ }
1672
+ .tina-prose :where(strong):not(:where([class~="not-tina-prose"] *)) {
1673
+ color: var(--tw-prose-bold);
1674
+ font-weight: 600;
1675
+ }
1676
+ .tina-prose :where(ol):not(:where([class~="not-tina-prose"] *)) {
1677
+ list-style-type: decimal;
1678
+ padding-left: 1.625em;
1679
+ }
1680
+ .tina-prose :where(ol[type="A"]):not(:where([class~="not-tina-prose"] *)) {
1681
+ list-style-type: upper-alpha;
1682
+ }
1683
+ .tina-prose :where(ol[type="a"]):not(:where([class~="not-tina-prose"] *)) {
1684
+ list-style-type: lower-alpha;
1685
+ }
1686
+ .tina-prose :where(ol[type="A" s]):not(:where([class~="not-tina-prose"] *)) {
1687
+ list-style-type: upper-alpha;
1688
+ }
1689
+ .tina-prose :where(ol[type="a" s]):not(:where([class~="not-tina-prose"] *)) {
1690
+ list-style-type: lower-alpha;
1691
+ }
1692
+ .tina-prose :where(ol[type="I"]):not(:where([class~="not-tina-prose"] *)) {
1693
+ list-style-type: upper-roman;
1694
+ }
1695
+ .tina-prose :where(ol[type="i"]):not(:where([class~="not-tina-prose"] *)) {
1696
+ list-style-type: lower-roman;
1697
+ }
1698
+ .tina-prose :where(ol[type="I" s]):not(:where([class~="not-tina-prose"] *)) {
1699
+ list-style-type: upper-roman;
1700
+ }
1701
+ .tina-prose :where(ol[type="i" s]):not(:where([class~="not-tina-prose"] *)) {
1702
+ list-style-type: lower-roman;
1703
+ }
1704
+ .tina-prose :where(ol[type="1"]):not(:where([class~="not-tina-prose"] *)) {
1705
+ list-style-type: decimal;
1706
+ }
1707
+ .tina-prose :where(ul):not(:where([class~="not-tina-prose"] *)) {
1708
+ list-style-type: disc;
1709
+ padding-left: 1.625em;
1710
+ }
1711
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *))::marker {
1712
+ font-weight: 400;
1713
+ color: var(--tw-prose-counters);
1714
+ }
1715
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *))::marker {
1716
+ color: var(--tw-prose-bullets);
1717
+ }
1718
+ .tina-prose :where(hr):not(:where([class~="not-tina-prose"] *)) {
1719
+ border-color: var(--tw-prose-hr);
1720
+ border-top-width: 1px;
1721
+ margin-top: 3em;
1722
+ margin-bottom: 3em;
1723
+ }
1724
+ .tina-prose :where(blockquote):not(:where([class~="not-tina-prose"] *)) {
1725
+ font-weight: 500;
1726
+ font-style: italic;
1727
+ color: var(--tw-prose-quotes);
1728
+ border-left-width: 0.25rem;
1729
+ border-left-color: var(--tw-prose-quote-borders);
1730
+ quotes: "\\201C""\\201D""\\2018""\\2019";
1731
+ margin-top: 1.6em;
1732
+ margin-bottom: 1.6em;
1733
+ padding-left: 1em;
1734
+ }
1735
+ .tina-prose :where(blockquote p:first-of-type):not(:where([class~="not-tina-prose"] *))::before {
1736
+ content: open-quote;
1737
+ }
1738
+ .tina-prose :where(blockquote p:last-of-type):not(:where([class~="not-tina-prose"] *))::after {
1739
+ content: close-quote;
1740
+ }
1741
+ .tina-prose :where(h1):not(:where([class~="not-tina-prose"] *)) {
1742
+ color: var(--tw-prose-headings);
1743
+ font-weight: 800;
1744
+ font-size: 2.25em;
1745
+ margin-top: 0;
1746
+ margin-bottom: 0.8888889em;
1747
+ line-height: 1.1111111;
1748
+ }
1749
+ .tina-prose :where(h1 strong):not(:where([class~="not-tina-prose"] *)) {
1750
+ font-weight: 900;
1751
+ }
1752
+ .tina-prose :where(h2):not(:where([class~="not-tina-prose"] *)) {
1753
+ color: var(--tw-prose-headings);
1754
+ font-weight: 700;
1755
+ font-size: 1.5em;
1756
+ margin-top: 2em;
1757
+ margin-bottom: 1em;
1758
+ line-height: 1.3333333;
1759
+ }
1760
+ .tina-prose :where(h2 strong):not(:where([class~="not-tina-prose"] *)) {
1761
+ font-weight: 800;
1762
+ }
1763
+ .tina-prose :where(h3):not(:where([class~="not-tina-prose"] *)) {
1764
+ color: var(--tw-prose-headings);
1765
+ font-weight: 600;
1766
+ font-size: 1.25em;
1767
+ margin-top: 1.6em;
1768
+ margin-bottom: 0.6em;
1769
+ line-height: 1.6;
1770
+ }
1771
+ .tina-prose :where(h3 strong):not(:where([class~="not-tina-prose"] *)) {
1772
+ font-weight: 700;
1773
+ }
1774
+ .tina-prose :where(h4):not(:where([class~="not-tina-prose"] *)) {
1775
+ color: var(--tw-prose-headings);
1776
+ font-weight: 600;
1777
+ margin-top: 1.5em;
1778
+ margin-bottom: 0.5em;
1779
+ line-height: 1.5;
1780
+ }
1781
+ .tina-prose :where(h4 strong):not(:where([class~="not-tina-prose"] *)) {
1782
+ font-weight: 700;
1783
+ }
1784
+ .tina-prose :where(figure > *):not(:where([class~="not-tina-prose"] *)) {
1785
+ margin-top: 0;
1786
+ margin-bottom: 0;
1787
+ }
1788
+ .tina-prose :where(figcaption):not(:where([class~="not-tina-prose"] *)) {
1789
+ color: var(--tw-prose-captions);
1790
+ font-size: 0.875em;
1791
+ line-height: 1.4285714;
1792
+ margin-top: 0.8571429em;
1793
+ }
1794
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *)) {
1795
+ color: var(--tw-prose-code);
1796
+ font-weight: 600;
1797
+ font-size: 0.875em;
1798
+ }
1799
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::before {
1800
+ content: "\`";
1801
+ }
1802
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::after {
1803
+ content: "\`";
1804
+ }
1805
+ .tina-prose :where(a code):not(:where([class~="not-tina-prose"] *)) {
1806
+ color: var(--tw-prose-links);
1807
+ }
1808
+ .tina-prose :where(pre):not(:where([class~="not-tina-prose"] *)) {
1809
+ color: var(--tw-prose-pre-code);
1810
+ background-color: var(--tw-prose-pre-bg);
1811
+ overflow-x: auto;
1812
+ font-weight: 400;
1813
+ font-size: 0.875em;
1814
+ line-height: 1.7142857;
1815
+ margin-top: 1.7142857em;
1816
+ margin-bottom: 1.7142857em;
1817
+ border-radius: 0.375rem;
1818
+ padding-top: 0.8571429em;
1819
+ padding-right: 1.1428571em;
1820
+ padding-bottom: 0.8571429em;
1821
+ padding-left: 1.1428571em;
1822
+ }
1823
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *)) {
1824
+ background-color: transparent;
1825
+ border-width: 0;
1826
+ border-radius: 0;
1827
+ padding: 0;
1828
+ font-weight: inherit;
1829
+ color: inherit;
1830
+ font-size: inherit;
1831
+ font-family: inherit;
1832
+ line-height: inherit;
1833
+ }
1834
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::before {
1835
+ content: none;
1836
+ }
1837
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::after {
1838
+ content: none;
1839
+ }
1840
+ .tina-prose :where(table):not(:where([class~="not-tina-prose"] *)) {
1841
+ width: 100%;
1842
+ table-layout: auto;
1843
+ text-align: left;
1844
+ margin-top: 2em;
1845
+ margin-bottom: 2em;
1846
+ font-size: 0.875em;
1847
+ line-height: 1.7142857;
1848
+ }
1849
+ .tina-prose :where(thead):not(:where([class~="not-tina-prose"] *)) {
1850
+ border-bottom-width: 1px;
1851
+ border-bottom-color: var(--tw-prose-th-borders);
1852
+ }
1853
+ .tina-prose :where(thead th):not(:where([class~="not-tina-prose"] *)) {
1854
+ color: var(--tw-prose-headings);
1855
+ font-weight: 600;
1856
+ vertical-align: bottom;
1857
+ padding-right: 0.5714286em;
1858
+ padding-bottom: 0.5714286em;
1859
+ padding-left: 0.5714286em;
1860
+ }
1861
+ .tina-prose :where(tbody tr):not(:where([class~="not-tina-prose"] *)) {
1862
+ border-bottom-width: 1px;
1863
+ border-bottom-color: var(--tw-prose-td-borders);
1864
+ }
1865
+ .tina-prose :where(tbody tr:last-child):not(:where([class~="not-tina-prose"] *)) {
1866
+ border-bottom-width: 0;
1867
+ }
1868
+ .tina-prose :where(tbody td):not(:where([class~="not-tina-prose"] *)) {
1869
+ vertical-align: baseline;
1870
+ padding-top: 0.5714286em;
1871
+ padding-right: 0.5714286em;
1872
+ padding-bottom: 0.5714286em;
1873
+ padding-left: 0.5714286em;
1874
+ }
1875
+ .tina-prose {
1876
+ --tw-prose-body: #374151;
1877
+ --tw-prose-headings: #111827;
1878
+ --tw-prose-lead: #4b5563;
1879
+ --tw-prose-links: #111827;
1880
+ --tw-prose-bold: #111827;
1881
+ --tw-prose-counters: #6b7280;
1882
+ --tw-prose-bullets: #d1d5db;
1883
+ --tw-prose-hr: #e5e7eb;
1884
+ --tw-prose-quotes: #111827;
1885
+ --tw-prose-quote-borders: #e5e7eb;
1886
+ --tw-prose-captions: #6b7280;
1887
+ --tw-prose-code: #111827;
1888
+ --tw-prose-pre-code: #e5e7eb;
1889
+ --tw-prose-pre-bg: #1f2937;
1890
+ --tw-prose-th-borders: #d1d5db;
1891
+ --tw-prose-td-borders: #e5e7eb;
1892
+ --tw-prose-invert-body: #d1d5db;
1893
+ --tw-prose-invert-headings: #fff;
1894
+ --tw-prose-invert-lead: #9ca3af;
1895
+ --tw-prose-invert-links: #fff;
1896
+ --tw-prose-invert-bold: #fff;
1897
+ --tw-prose-invert-counters: #9ca3af;
1898
+ --tw-prose-invert-bullets: #4b5563;
1899
+ --tw-prose-invert-hr: #374151;
1900
+ --tw-prose-invert-quotes: #f3f4f6;
1901
+ --tw-prose-invert-quote-borders: #374151;
1902
+ --tw-prose-invert-captions: #9ca3af;
1903
+ --tw-prose-invert-code: #fff;
1904
+ --tw-prose-invert-pre-code: #d1d5db;
1905
+ --tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);
1906
+ --tw-prose-invert-th-borders: #4b5563;
1907
+ --tw-prose-invert-td-borders: #374151;
1908
+ font-size: 1rem;
1909
+ line-height: 1.75;
1910
+ }
1911
+ .tina-prose :where(p):not(:where([class~="not-tina-prose"] *)) {
1912
+ margin-top: 1.25em;
1913
+ margin-bottom: 1.25em;
1914
+ }
1915
+ .tina-prose :where(img):not(:where([class~="not-tina-prose"] *)) {
1916
+ margin-top: 2em;
1917
+ margin-bottom: 2em;
1918
+ }
1919
+ .tina-prose :where(video):not(:where([class~="not-tina-prose"] *)) {
1920
+ margin-top: 2em;
1921
+ margin-bottom: 2em;
1922
+ }
1923
+ .tina-prose :where(figure):not(:where([class~="not-tina-prose"] *)) {
1924
+ margin-top: 2em;
1925
+ margin-bottom: 2em;
1926
+ }
1927
+ .tina-prose :where(h2 code):not(:where([class~="not-tina-prose"] *)) {
1928
+ font-size: 0.875em;
1929
+ }
1930
+ .tina-prose :where(h3 code):not(:where([class~="not-tina-prose"] *)) {
1931
+ font-size: 0.9em;
1932
+ }
1933
+ .tina-prose :where(li):not(:where([class~="not-tina-prose"] *)) {
1934
+ margin-top: 0.5em;
1935
+ margin-bottom: 0.5em;
1936
+ }
1937
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *)) {
1938
+ padding-left: 0.375em;
1939
+ }
1940
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *)) {
1941
+ padding-left: 0.375em;
1942
+ }
1943
+ .tina-prose > :where(ul > li p):not(:where([class~="not-tina-prose"] *)) {
1944
+ margin-top: 0.75em;
1945
+ margin-bottom: 0.75em;
1946
+ }
1947
+ .tina-prose > :where(ul > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1948
+ margin-top: 1.25em;
1949
+ }
1950
+ .tina-prose > :where(ul > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1951
+ margin-bottom: 1.25em;
1952
+ }
1953
+ .tina-prose > :where(ol > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1954
+ margin-top: 1.25em;
1955
+ }
1956
+ .tina-prose > :where(ol > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1957
+ margin-bottom: 1.25em;
1958
+ }
1959
+ .tina-prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-tina-prose"] *)) {
1960
+ margin-top: 0.75em;
1961
+ margin-bottom: 0.75em;
1962
+ }
1963
+ .tina-prose :where(hr + *):not(:where([class~="not-tina-prose"] *)) {
1964
+ margin-top: 0;
1965
+ }
1966
+ .tina-prose :where(h2 + *):not(:where([class~="not-tina-prose"] *)) {
1967
+ margin-top: 0;
1968
+ }
1969
+ .tina-prose :where(h3 + *):not(:where([class~="not-tina-prose"] *)) {
1970
+ margin-top: 0;
1971
+ }
1972
+ .tina-prose :where(h4 + *):not(:where([class~="not-tina-prose"] *)) {
1973
+ margin-top: 0;
1974
+ }
1975
+ .tina-prose :where(thead th:first-child):not(:where([class~="not-tina-prose"] *)) {
1976
+ padding-left: 0;
1977
+ }
1978
+ .tina-prose :where(thead th:last-child):not(:where([class~="not-tina-prose"] *)) {
1979
+ padding-right: 0;
1980
+ }
1981
+ .tina-prose :where(tbody td:first-child):not(:where([class~="not-tina-prose"] *)) {
1982
+ padding-left: 0;
1983
+ }
1984
+ .tina-prose :where(tbody td:last-child):not(:where([class~="not-tina-prose"] *)) {
1985
+ padding-right: 0;
1986
+ }
1987
+ .tina-prose > :where(:first-child):not(:where([class~="not-tina-prose"] *)) {
1988
+ margin-top: 0;
1989
+ }
1990
+ .tina-prose > :where(:last-child):not(:where([class~="not-tina-prose"] *)) {
1991
+ margin-bottom: 0;
1992
+ }
1578
1993
  .tina-tailwind .pointer-events-none {
1579
1994
  pointer-events: none;
1580
1995
  }
@@ -1643,18 +2058,9 @@ mutation addPendingDocumentMutation(
1643
2058
  .tina-tailwind .-ml-px {
1644
2059
  margin-left: -1px;
1645
2060
  }
1646
- .tina-tailwind .-mt-0 {
1647
- margin-top: -0px;
1648
- }
1649
- .tina-tailwind .-mt-0\\.5 {
1650
- margin-top: -2px;
1651
- }
1652
2061
  .tina-tailwind .mb-1 {
1653
2062
  margin-bottom: 4px;
1654
2063
  }
1655
- .tina-tailwind .mb-2 {
1656
- margin-bottom: 8px;
1657
- }
1658
2064
  .tina-tailwind .mb-4 {
1659
2065
  margin-bottom: 16px;
1660
2066
  }
@@ -1784,12 +2190,21 @@ mutation addPendingDocumentMutation(
1784
2190
  .tina-tailwind .flex-shrink-0 {
1785
2191
  flex-shrink: 0;
1786
2192
  }
2193
+ .tina-tailwind .shrink {
2194
+ flex-shrink: 1;
2195
+ }
1787
2196
  .tina-tailwind .shrink-0 {
1788
2197
  flex-shrink: 0;
1789
2198
  }
1790
2199
  .tina-tailwind .flex-grow-0 {
1791
2200
  flex-grow: 0;
1792
2201
  }
2202
+ .tina-tailwind .grow-0 {
2203
+ flex-grow: 0;
2204
+ }
2205
+ .tina-tailwind .basis-0 {
2206
+ flex-basis: 0px;
2207
+ }
1793
2208
  .tina-tailwind .table-auto {
1794
2209
  table-layout: auto;
1795
2210
  }
@@ -1825,6 +2240,15 @@ mutation addPendingDocumentMutation(
1825
2240
  .tina-tailwind .transform {
1826
2241
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
1827
2242
  }
2243
+ @keyframes spin {
2244
+
2245
+ to {
2246
+ transform: rotate(360deg);
2247
+ }
2248
+ }
2249
+ .tina-tailwind .animate-spin {
2250
+ animation: spin 1s linear infinite;
2251
+ }
1828
2252
  .tina-tailwind .cursor-pointer {
1829
2253
  cursor: pointer;
1830
2254
  }
@@ -1870,6 +2294,9 @@ mutation addPendingDocumentMutation(
1870
2294
  .tina-tailwind .gap-1 {
1871
2295
  gap: 4px;
1872
2296
  }
2297
+ .tina-tailwind .gap-1\\.5 {
2298
+ gap: 6px;
2299
+ }
1873
2300
  .tina-tailwind .gap-2 {
1874
2301
  gap: 8px;
1875
2302
  }
@@ -2019,6 +2446,9 @@ mutation addPendingDocumentMutation(
2019
2446
  .tina-tailwind .p-0 {
2020
2447
  padding: 0px;
2021
2448
  }
2449
+ .tina-tailwind .p-6 {
2450
+ padding: 24px;
2451
+ }
2022
2452
  .tina-tailwind .p-8 {
2023
2453
  padding: 32px;
2024
2454
  }
@@ -2082,6 +2512,9 @@ mutation addPendingDocumentMutation(
2082
2512
  padding-top: 32px;
2083
2513
  padding-bottom: 32px;
2084
2514
  }
2515
+ .tina-tailwind .pb-4 {
2516
+ padding-bottom: 16px;
2517
+ }
2085
2518
  .tina-tailwind .pl-18 {
2086
2519
  padding-left: 72px;
2087
2520
  }
@@ -2109,6 +2542,9 @@ mutation addPendingDocumentMutation(
2109
2542
  .tina-tailwind .pt-12 {
2110
2543
  padding-top: 48px;
2111
2544
  }
2545
+ .tina-tailwind .pt-3 {
2546
+ padding-top: 12px;
2547
+ }
2112
2548
  .tina-tailwind .pt-4 {
2113
2549
  padding-top: 16px;
2114
2550
  }
@@ -2152,6 +2588,9 @@ mutation addPendingDocumentMutation(
2152
2588
  font-size: 13px;
2153
2589
  line-height: 1.33;
2154
2590
  }
2591
+ .tina-tailwind .font-bold {
2592
+ font-weight: 700;
2593
+ }
2155
2594
  .tina-tailwind .font-medium {
2156
2595
  font-weight: 500;
2157
2596
  }
@@ -2188,9 +2627,6 @@ mutation addPendingDocumentMutation(
2188
2627
  --tw-text-opacity: 1;
2189
2628
  color: rgb(5 116 228 / var(--tw-text-opacity));
2190
2629
  }
2191
- .tina-tailwind .text-current {
2192
- color: currentColor;
2193
- }
2194
2630
  .tina-tailwind .text-gray-200 {
2195
2631
  --tw-text-opacity: 1;
2196
2632
  color: rgb(225 221 236 / var(--tw-text-opacity));
@@ -2231,6 +2667,10 @@ mutation addPendingDocumentMutation(
2231
2667
  --tw-text-opacity: 1;
2232
2668
  color: rgb(239 68 68 / var(--tw-text-opacity));
2233
2669
  }
2670
+ .tina-tailwind .text-red-700 {
2671
+ --tw-text-opacity: 1;
2672
+ color: rgb(185 28 28 / var(--tw-text-opacity));
2673
+ }
2234
2674
  .tina-tailwind .text-white {
2235
2675
  --tw-text-opacity: 1;
2236
2676
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -2256,8 +2696,8 @@ mutation addPendingDocumentMutation(
2256
2696
  .tina-tailwind .opacity-20 {
2257
2697
  opacity: .2;
2258
2698
  }
2259
- .tina-tailwind .opacity-50 {
2260
- opacity: .5;
2699
+ .tina-tailwind .opacity-30 {
2700
+ opacity: .3;
2261
2701
  }
2262
2702
  .tina-tailwind .opacity-70 {
2263
2703
  opacity: .7;
@@ -2316,11 +2756,6 @@ mutation addPendingDocumentMutation(
2316
2756
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2317
2757
  transition-duration: 150ms;
2318
2758
  }
2319
- .tina-tailwind .transition-colors {
2320
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
2321
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2322
- transition-duration: 150ms;
2323
- }
2324
2759
  .tina-tailwind .transition-opacity {
2325
2760
  transition-property: opacity;
2326
2761
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -2376,6 +2811,9 @@ mutation addPendingDocumentMutation(
2376
2811
  --tw-text-opacity: 1;
2377
2812
  color: rgb(5 116 228 / var(--tw-text-opacity));
2378
2813
  }
2814
+ .tina-tailwind .hover\\:underline:hover {
2815
+ text-decoration-line: underline;
2816
+ }
2379
2817
  .tina-tailwind .hover\\:decoration-blue-400:hover {
2380
2818
  text-decoration-color: #2296fe;
2381
2819
  }
@@ -2389,17 +2827,10 @@ mutation addPendingDocumentMutation(
2389
2827
  --tw-border-opacity: 1;
2390
2828
  border-color: rgb(0 132 255 / var(--tw-border-opacity));
2391
2829
  }
2392
- .tina-tailwind .focus\\:text-blue-400:focus {
2393
- --tw-text-opacity: 1;
2394
- color: rgb(34 150 254 / var(--tw-text-opacity));
2395
- }
2396
2830
  .tina-tailwind .focus\\:text-gray-900:focus {
2397
2831
  --tw-text-opacity: 1;
2398
2832
  color: rgb(37 35 54 / var(--tw-text-opacity));
2399
2833
  }
2400
- .tina-tailwind .focus\\:underline:focus {
2401
- text-decoration-line: underline;
2402
- }
2403
2834
  .tina-tailwind .focus\\:shadow-outline:focus {
2404
2835
  --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
2405
2836
  --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);
@@ -2630,8 +3061,6 @@ mutation addPendingDocumentMutation(
2630
3061
  return { hasError: true, message: error.message };
2631
3062
  }
2632
3063
  render() {
2633
- const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2634
- const hasBranchData = branchData && branchData.length > 0;
2635
3064
  if (this.state.hasError && !this.state.pageRefresh) {
2636
3065
  return /* @__PURE__ */ React__default["default"].createElement("div", {
2637
3066
  style: {
@@ -2665,18 +3094,7 @@ mutation addPendingDocumentMutation(
2665
3094
  this.setState({ pageRefresh: true });
2666
3095
  setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
2667
3096
  }
2668
- }, "Refresh"), hasBranchData && /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("p", null, `If you're using the branch switcher, you may currently be on a "stale" branch that has been deleted or whose content is not compatible with the latest version of the site's layout. Click the button below to switch back to the default branch for this deployment.`), /* @__PURE__ */ React__default["default"].createElement("p", null, "See our", " ", /* @__PURE__ */ React__default["default"].createElement("a", {
2669
- className: "text-gray-600",
2670
- style: { textDecoration: "underline" },
2671
- href: "https://tina.io/docs/errors/faq/",
2672
- target: "_blank"
2673
- }, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React__default["default"].createElement("button", {
2674
- style: errorButtonStyles,
2675
- onClick: () => {
2676
- window.localStorage.removeItem("tinacms-current-branch");
2677
- window.location.reload();
2678
- }
2679
- }, "Switch to default branch"))));
3097
+ }, "Refresh")));
2680
3098
  }
2681
3099
  if (this.state.pageRefresh) {
2682
3100
  return /* @__PURE__ */ React__default["default"].createElement(Loader, null, "Let's try that again.");
@@ -2980,6 +3398,9 @@ This will work when developing locally but NOT when deployed to production.
2980
3398
  function BiFolder(props) {
2981
3399
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M20 5h-8.586L9.707 3.293A.997.997 0 0 0 9 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V7c0-1.103-.897-2-2-2zM4 19V7h16l.002 12H4z" } }] })(props);
2982
3400
  }
3401
+ function BiLoaderAlt(props) {
3402
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M12 22c5.421 0 10-4.579 10-10h-2c0 4.337-3.663 8-8 8s-8-3.663-8-8c0-4.336 3.663-8 8-8V2C6.579 2 2 6.58 2 12c0 5.421 4.579 10 10 10z" } }] })(props);
3403
+ }
2983
3404
  function BiLogIn(props) {
2984
3405
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
2985
3406
  }
@@ -3770,7 +4191,7 @@ This will work when developing locally but NOT when deployed to production.
3770
4191
  const allowCreate = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) != null ? _g : true;
3771
4192
  const allowDelete = (_j = (_i = (_h = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _h.allowedActions) == null ? void 0 : _i.delete) != null ? _j : true;
3772
4193
  const folderView = folder.fullyQualifiedName !== "";
3773
- return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
4194
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default["default"].createElement(DeleteModal, {
3774
4195
  filename: vars.relativePath,
3775
4196
  deleteFunc: async () => {
3776
4197
  try {
@@ -3784,6 +4205,22 @@ This will work when developing locally but NOT when deployed to production.
3784
4205
  }
3785
4206
  },
3786
4207
  close: () => setDeleteModalOpen(false)
4208
+ }), deleteModalOpen && cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React__default["default"].createElement(toolkit.CreateBranchModel, {
4209
+ crudType: "delete",
4210
+ relativePath: collectionExtra.path + "/" + vars.relativePath,
4211
+ values: vars,
4212
+ close: () => setDeleteModalOpen(false),
4213
+ safeSubmit: async () => {
4214
+ try {
4215
+ await admin.deleteDocument(vars);
4216
+ cms.alerts.info("Document was successfully deleted");
4217
+ reFetchCollection();
4218
+ } catch (error) {
4219
+ cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
4220
+ console.error(error);
4221
+ throw error;
4222
+ }
4223
+ }
3787
4224
  }), renameModalOpen && /* @__PURE__ */ React__default["default"].createElement(RenameModal, {
3788
4225
  filename: vars.relativePath,
3789
4226
  newRelativePath: vars.newRelativePath,
@@ -4246,9 +4683,6 @@ This will work when developing locally but NOT when deployed to production.
4246
4683
  }
4247
4684
  }, "Rename"))));
4248
4685
  };
4249
- function HiChevronRight(props) {
4250
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z", "clipRule": "evenodd" } }] })(props);
4251
- }
4252
4686
  function FaLock(props) {
4253
4687
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z" } }] })(props);
4254
4688
  }
@@ -4349,17 +4783,22 @@ This will work when developing locally but NOT when deployed to production.
4349
4783
  const defaultItem = customDefaults || ((_d = template.ui) == null ? void 0 : _d.defaultItem) || (template == null ? void 0 : template.defaultItem);
4350
4784
  const form = React.useMemo(() => {
4351
4785
  var _a2, _b2;
4786
+ const folderName = folder.fullyQualifiedName ? folder.name : "";
4352
4787
  return new toolkit.Form({
4788
+ crudType: "create",
4353
4789
  initialValues: typeof defaultItem === "function" ? defaultItem() : defaultItem,
4354
4790
  extraSubscribeValues: { active: true, submitting: true, touched: true },
4355
4791
  onChange: (values) => {
4356
- var _a3;
4357
- if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_a3 = values.touched) == null ? void 0 : _a3.filename)) {
4792
+ var _a3, _b3;
4793
+ if (!(values == null ? void 0 : values.submitting)) {
4794
+ form.relativePath = schemaCollection.path + folderName + `/${(_a3 = values == null ? void 0 : values.values) == null ? void 0 : _a3.filename}.${schemaCollection.format || "md"}`;
4795
+ }
4796
+ if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_b3 = values.touched) == null ? void 0 : _b3.filename)) {
4358
4797
  const value = slugFunction(values == null ? void 0 : values.values);
4359
4798
  form.finalForm.change("filename", value);
4360
4799
  }
4361
4800
  },
4362
- id: "create-form",
4801
+ id: schemaCollection.path + folderName + `/new-post.${schemaCollection.format || "md"}`,
4363
4802
  label: "form",
4364
4803
  fields: [
4365
4804
  ...formInfo.fields,
@@ -4403,8 +4842,8 @@ This will work when developing locally but NOT when deployed to production.
4403
4842
  ],
4404
4843
  onSubmit: async (values) => {
4405
4844
  try {
4406
- const folderName = folder.fullyQualifiedName ? folder.name : "";
4407
- await createDocument(cms, collection, template, mutationInfo, folderName, values);
4845
+ const folderName2 = folder.fullyQualifiedName ? folder.name : "";
4846
+ await createDocument(cms, collection, template, mutationInfo, folderName2, values);
4408
4847
  cms.alerts.success("Document created!");
4409
4848
  setTimeout(() => {
4410
4849
  navigate(`/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`);
@@ -4439,21 +4878,17 @@ This will work when developing locally but NOT when deployed to production.
4439
4878
  }
4440
4879
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4441
4880
  return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
4442
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4443
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4444
- className: "max-w-form mx-auto"
4881
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4445
4882
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
4446
- className: "mb-2"
4447
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4448
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
4883
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4449
4884
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4450
4885
  to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
4451
- className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
4452
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement(HiChevronRight, {
4453
- className: "inline-block -mt-0.5 opacity-50"
4454
- })), /* @__PURE__ */ React__default["default"].createElement("span", {
4455
- className: "text-xl text-gray-700 font-medium leading-tight"
4456
- }, "Create New")), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
4886
+ className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
4887
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement("span", {
4888
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
4889
+ }, "/"), /* @__PURE__ */ React__default["default"].createElement("span", {
4890
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
4891
+ }, "Create New"), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
4457
4892
  pristine: formIsPristine
4458
4893
  }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
4459
4894
  form: activeForm,
@@ -4599,7 +5034,7 @@ This will work when developing locally but NOT when deployed to production.
4599
5034
  });
4600
5035
  const form = React.useMemo(() => {
4601
5036
  return new toolkit.Form({
4602
- id: "update-form",
5037
+ id: `${schemaCollection.path}/${relativePath2}`,
4603
5038
  label: "form",
4604
5039
  fields: formInfo.fields,
4605
5040
  initialValues: document._values,
@@ -4631,21 +5066,17 @@ This will work when developing locally but NOT when deployed to production.
4631
5066
  }
4632
5067
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4633
5068
  return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
4634
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4635
- }, /* @__PURE__ */ React__default["default"].createElement("div", {
4636
- className: "max-w-form mx-auto"
5069
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4637
5070
  }, /* @__PURE__ */ React__default["default"].createElement("div", {
4638
- className: "mb-2"
4639
- }, /* @__PURE__ */ React__default["default"].createElement("span", {
4640
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
5071
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4641
5072
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
4642
5073
  to: `/collections/${collection.name}/~${parentFolder2}`,
4643
- className: "inline-block text-current hover:text-blue-400 focus:underline focus:outline-none focus:text-blue-400 font-medium transition-colors duration-150 ease-out"
4644
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement(HiChevronRight, {
4645
- className: "inline-block -mt-0.5 opacity-50"
4646
- })), /* @__PURE__ */ React__default["default"].createElement("span", {
4647
- className: "text-xl text-gray-700 font-medium leading-tight"
4648
- }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
5074
+ className: "flex-0 text-blue-500 hover:text-blue-400 hover:underline underline decoration-blue-200 hover:decoration-blue-400 text-sm leading-tight whitespace-nowrap truncate transition-all duration-150 ease-out"
5075
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React__default["default"].createElement("span", {
5076
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
5077
+ }, "/"), /* @__PURE__ */ React__default["default"].createElement("span", {
5078
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
5079
+ }, `${filename}.${collection.format}`), /* @__PURE__ */ React__default["default"].createElement(toolkit.FormStatus, {
4649
5080
  pristine: formIsPristine
4650
5081
  }))), activeForm && /* @__PURE__ */ React__default["default"].createElement(toolkit.FormBuilder, {
4651
5082
  form: activeForm,
@@ -4673,6 +5104,127 @@ This will work when developing locally but NOT when deployed to production.
4673
5104
  })));
4674
5105
  });
4675
5106
  };
5107
+ const IndexingPage = () => {
5108
+ const cms = toolkit.useCMS();
5109
+ const tinaApi = cms.api.tina;
5110
+ const currentBranch = tinaApi.branch;
5111
+ const kind = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.kind");
5112
+ const { setCurrentBranch } = toolkit.useBranchData();
5113
+ const [state, setState] = React__default["default"].useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState"));
5114
+ const [errorMessage, setErrorMessage] = React__default["default"].useState("");
5115
+ const [baseBranch, setBaseBranch] = React__default["default"].useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.baseBranch"));
5116
+ const [searchParams] = reactRouterDom.useSearchParams();
5117
+ const back = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.back");
5118
+ const fullPath = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.fullPath");
5119
+ const values = JSON.parse(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.values"));
5120
+ const [branch, setBranch] = React__default["default"].useState("tina/" + searchParams.get("branch"));
5121
+ React.useEffect(() => {
5122
+ const run = async () => {
5123
+ if (state === "starting") {
5124
+ try {
5125
+ console.log("starting", branch, toolkit.formatBranchName(branch));
5126
+ const name = await tinaApi.createBranch({
5127
+ branchName: toolkit.formatBranchName(branch),
5128
+ baseBranch: currentBranch
5129
+ });
5130
+ if (!name) {
5131
+ throw new Error("Branch creation failed.");
5132
+ }
5133
+ setBranch(name);
5134
+ localStorage.setItem("tina.createBranchState", "indexing");
5135
+ cms.alerts.success("Branch created.");
5136
+ setState("indexing");
5137
+ } catch (e) {
5138
+ console.error(e);
5139
+ cms.alerts.error("Branch creation failed: " + e.message);
5140
+ setErrorMessage("Branch creation failed, please try again. By refreshing the page.");
5141
+ setState("error");
5142
+ }
5143
+ }
5144
+ if (state === "indexing") {
5145
+ try {
5146
+ const [
5147
+ waitForIndexStatusPromise,
5148
+ _cancelWaitForIndexFunc
5149
+ ] = tinaApi.waitForIndexStatus({
5150
+ ref: branch
5151
+ });
5152
+ await waitForIndexStatusPromise;
5153
+ cms.alerts.success("Branch indexed.");
5154
+ localStorage.setItem("tina.createBranchState", "submitting");
5155
+ setState("submitting");
5156
+ } catch {
5157
+ cms.alerts.error("Branch indexing failed.");
5158
+ setErrorMessage('Branch indexing failed, please check the Tina Cloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.');
5159
+ setState("error");
5160
+ }
5161
+ }
5162
+ if (state === "submitting") {
5163
+ try {
5164
+ setBaseBranch(tinaApi.branch);
5165
+ localStorage.setItem("tina.createBranchState.baseBranch", tinaApi.branch);
5166
+ setCurrentBranch(branch);
5167
+ const collection = tinaApi.schema.getCollectionByFullPath(fullPath);
5168
+ const api = new TinaAdminApi(cms);
5169
+ const params = api.schema.transformPayload(collection.name, values);
5170
+ const relativePath2 = fullPath.replace(`${collection.path}/`, "");
5171
+ if (await api.isAuthenticated()) {
5172
+ if (kind === "delete") {
5173
+ await api.deleteDocument(values);
5174
+ } else if (kind === "create") {
5175
+ await api.createDocument(collection, relativePath2, params);
5176
+ } else {
5177
+ await api.updateDocument(collection, relativePath2, params);
5178
+ }
5179
+ } else {
5180
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5181
+ cms.alerts.error(authMessage);
5182
+ console.error(authMessage);
5183
+ return false;
5184
+ }
5185
+ localStorage.setItem("tina.createBranchState", "creatingPR");
5186
+ cms.alerts.success("Content saved.");
5187
+ setState("creatingPR");
5188
+ } catch (e) {
5189
+ console.error(e);
5190
+ cms.alerts.error("Content save failed.");
5191
+ setErrorMessage("Content save failed, please try again. If the problem persists please contact support.");
5192
+ setState("error");
5193
+ }
5194
+ }
5195
+ if (state === "creatingPR") {
5196
+ const foo = await tinaApi.createPullRequest({
5197
+ baseBranch,
5198
+ branch,
5199
+ title: "PR from TinaCMS"
5200
+ });
5201
+ console.log("PR created", foo);
5202
+ cms.alerts.success("Pull request created.");
5203
+ localStorage.setItem("tina.createBranchState", "done");
5204
+ setState("done");
5205
+ }
5206
+ if (state === "done") {
5207
+ window.location.href = back;
5208
+ }
5209
+ };
5210
+ if (fullPath && values && branch && back) {
5211
+ run();
5212
+ }
5213
+ }, [state]);
5214
+ if (!back || !fullPath || !values || !branch) {
5215
+ return /* @__PURE__ */ React__default["default"].createElement(Wrapper, null, /* @__PURE__ */ React__default["default"].createElement("p", null, "Missing params please try again."));
5216
+ }
5217
+ return /* @__PURE__ */ React__default["default"].createElement(Wrapper, null, state !== "done" && state !== "error" && /* @__PURE__ */ React__default["default"].createElement(BiLoaderAlt, {
5218
+ className: `opacity-70 text-blue-400 animate-spin w-10 h-auto`
5219
+ }), (state === "starting" || state === "creatingBranch") && /* @__PURE__ */ React__default["default"].createElement("p", null, "Creating branch\u2026"), state === "indexing" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Indexing Content\u2026"), state === "submitting" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Saving content\u2026"), state === "creatingPR" && /* @__PURE__ */ React__default["default"].createElement("p", null, "Creating Pull Request\u2026"), state === "error" && /* @__PURE__ */ React__default["default"].createElement("p", {
5220
+ className: "flex items-center gap-1 text-red-700"
5221
+ }, /* @__PURE__ */ React__default["default"].createElement(BiError, {
5222
+ className: "w-7 h-auto text-red-400 flex-shrink-0"
5223
+ }), " ", /* @__PURE__ */ React__default["default"].createElement("b", null, "Error:"), " ", errorMessage, " "));
5224
+ };
5225
+ const Wrapper = ({ children }) => /* @__PURE__ */ React__default["default"].createElement("div", {
5226
+ className: "w-full h-full flex flex-col justify-center items-center gap-4 p-6 text-xl text-gray-700"
5227
+ }, children);
4676
5228
  const Redirect = () => {
4677
5229
  React__default["default"].useEffect(() => {
4678
5230
  if (window) {
@@ -4748,6 +5300,8 @@ This will work when developing locally but NOT when deployed to production.
4748
5300
  const cms = toolkit.useCMS();
4749
5301
  const api = new TinaAdminApi(cms);
4750
5302
  const url = api.api.contentApiUrl;
5303
+ const [schemaMissingError, setSchemaMissingError] = React__default["default"].useState(false);
5304
+ const currentBranch = decodeURIComponent(cms.api.tina.branch);
4751
5305
  React.useEffect(() => {
4752
5306
  if (schemaJson && cms) {
4753
5307
  api.checkGraphqlSchema({
@@ -4756,10 +5310,32 @@ This will work when developing locally but NOT when deployed to production.
4756
5310
  if (x === false) {
4757
5311
  cms.alerts.error("GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch");
4758
5312
  }
5313
+ }).catch((e) => {
5314
+ if (e.message.includes("has not been indexed by Tina Cloud")) {
5315
+ setSchemaMissingError(true);
5316
+ } else {
5317
+ throw e;
5318
+ }
4759
5319
  });
4760
5320
  }
4761
5321
  }, [cms, JSON.stringify(schemaJson || {}), url]);
4762
- return children;
5322
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, schemaMissingError ? /* @__PURE__ */ React__default["default"].createElement(toolkit.Modal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.PopupModal, null, /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalHeader, null, "Branch Not Found"), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalBody, {
5323
+ padded: true
5324
+ }, /* @__PURE__ */ React__default["default"].createElement("div", {
5325
+ className: "tina-prose"
5326
+ }, "The current branch (", /* @__PURE__ */ React__default["default"].createElement("span", {
5327
+ className: "font-bold"
5328
+ }, currentBranch), ") has either been merged or deleted.")), /* @__PURE__ */ React__default["default"].createElement(toolkit.ModalActions, null, /* @__PURE__ */ React__default["default"].createElement("div", {
5329
+ className: "flex-1"
5330
+ }), /* @__PURE__ */ React__default["default"].createElement(toolkit.Button, {
5331
+ style: { flexGrow: 1 },
5332
+ className: "w-full",
5333
+ variant: "primary",
5334
+ onClick: () => {
5335
+ window.localStorage.removeItem("tinacms-current-branch");
5336
+ window.location.reload();
5337
+ }
5338
+ }, "Switch back to default branch")))) : children);
4763
5339
  };
4764
5340
  const TinaAdmin = ({
4765
5341
  preview,
@@ -4785,7 +5361,7 @@ This will work when developing locally but NOT when deployed to production.
4785
5361
  return typeof ((_a2 = x == null ? void 0 : x.ui) == null ? void 0 : _a2.router) === "function";
4786
5362
  });
4787
5363
  const hasRouter = Boolean(collectionWithRouter);
4788
- return /* @__PURE__ */ React__default["default"].createElement(CheckSchema, {
5364
+ return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement(CheckSchema, {
4789
5365
  schemaJson
4790
5366
  }, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React__default["default"].createElement(SetPreviewFlag, {
4791
5367
  preview,
@@ -4799,6 +5375,11 @@ This will work when developing locally but NOT when deployed to production.
4799
5375
  }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
4800
5376
  path: "graphql",
4801
5377
  element: /* @__PURE__ */ React__default["default"].createElement(PlainLayout, null, /* @__PURE__ */ React__default["default"].createElement(Playground, null))
5378
+ }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
5379
+ path: "branch/new",
5380
+ element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
5381
+ cms
5382
+ }, /* @__PURE__ */ React__default["default"].createElement(IndexingPage, null))
4802
5383
  }), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
4803
5384
  path: "collections/new/:collectionName",
4804
5385
  element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
@@ -4856,7 +5437,7 @@ This will work when developing locally but NOT when deployed to production.
4856
5437
  }, /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
4857
5438
  cms
4858
5439
  }, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))
4859
- }))));
5440
+ })))));
4860
5441
  } else {
4861
5442
  return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.HashRouter, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Routes, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
4862
5443
  path: "logout",