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.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, useCMS, Nav, BranchBanner, LocalWarning, BillingWarning, Select, Message, OverflowMenu, CursorPaginator, Input, PopupModal, BaseTextField, Form, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
2
+ import { EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, useCMS, Nav, BranchBanner, LocalWarning, BillingWarning, CreateBranchModel, Select, Message, OverflowMenu, CursorPaginator, Input, PopupModal, BaseTextField, Form, wrapFieldsWithMeta, FormStatus, FormBuilder, useBranchData, formatBranchName } from "@tinacms/toolkit";
3
3
  export * from "@tinacms/toolkit";
4
4
  export { MdxFieldPluginExtendible } from "@tinacms/toolkit";
5
5
  import { getIntrospectionQuery, buildClientSchema, print, parse, buildSchema } from "graphql";
@@ -191,7 +191,9 @@ const parseRefForBranchName = (ref) => {
191
191
  return matches[1];
192
192
  };
193
193
  const ListBranchResponse = z.object({
194
- name: z.string()
194
+ name: z.string(),
195
+ protected: z.boolean().optional().default(false),
196
+ githubPullRequestUrl: z.string().optional()
195
197
  }).array();
196
198
  const IndexStatusResponse = z.object({
197
199
  status: z.union([
@@ -230,6 +232,8 @@ class Client {
230
232
  constructor({ tokenStorage = "MEMORY", ...options }) {
231
233
  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;
232
234
  this.events = new EventBus();
235
+ this.protectedBranches = [];
236
+ this.usingEditorialWorkflow = false;
233
237
  this.addPendingContent = async (props) => {
234
238
  const mutation = `#graphql
235
239
  mutation addPendingDocumentMutation(
@@ -420,6 +424,41 @@ mutation addPendingDocumentMutation(
420
424
  const jsonRes = await res.json();
421
425
  return jsonRes;
422
426
  }
427
+ async getProject() {
428
+ const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
429
+ method: "GET"
430
+ });
431
+ const val = await res.json();
432
+ return val;
433
+ }
434
+ async createPullRequest({
435
+ baseBranch,
436
+ branch,
437
+ title
438
+ }) {
439
+ const url = `${this.contentApiBase}/github/${this.clientId}/create_pull_request`;
440
+ try {
441
+ const res = await this.fetchWithToken(url, {
442
+ method: "POST",
443
+ body: JSON.stringify({
444
+ baseBranch,
445
+ branch,
446
+ title
447
+ }),
448
+ headers: {
449
+ "Content-Type": "application/json"
450
+ }
451
+ });
452
+ if (!res.ok) {
453
+ throw new Error(`There was an error creating a new branch. ${res.statusText}`);
454
+ }
455
+ const values = await res.json();
456
+ return values;
457
+ } catch (error) {
458
+ console.error("There was an error creating a new branch.", error);
459
+ throw error;
460
+ }
461
+ }
423
462
  async fetchEvents(limit, cursor) {
424
463
  if (this.isLocalMode) {
425
464
  return {
@@ -437,12 +476,6 @@ mutation addPendingDocumentMutation(
437
476
  }).join(""));
438
477
  return JSON.parse(jsonPayload);
439
478
  }
440
- async getProject() {
441
- const res = await this.fetchWithToken(`${this.identityApiUrl}/v2/apps/${this.clientId}`, {
442
- method: "GET"
443
- });
444
- return res.json();
445
- }
446
479
  async getRefreshedToken(tokens) {
447
480
  const { access_token, id_token, refresh_token } = JSON.parse(tokens);
448
481
  const { exp, iss, client_id } = this.parseJwt(access_token);
@@ -546,6 +579,7 @@ mutation addPendingDocumentMutation(
546
579
  }
547
580
  }
548
581
  waitForIndexStatus({ ref }) {
582
+ let unknownCount = 0;
549
583
  try {
550
584
  const [prom, cancel] = asyncPoll(async () => {
551
585
  try {
@@ -556,6 +590,12 @@ mutation addPendingDocumentMutation(
556
590
  data: result
557
591
  });
558
592
  } else {
593
+ if (result.status === "unknown") {
594
+ unknownCount++;
595
+ if (unknownCount > 5) {
596
+ throw new Error("AsyncPoller: status unknown for too long, please check indexing progress the Tina Cloud dashboard");
597
+ }
598
+ }
559
599
  return Promise.resolve({
560
600
  done: false
561
601
  });
@@ -568,9 +608,8 @@ mutation addPendingDocumentMutation(
568
608
  } catch (error) {
569
609
  if (error.message === "AsyncPoller: reached timeout") {
570
610
  console.warn(error);
571
- return {
572
- status: "timeout"
573
- };
611
+ return [Promise.resolve({ status: "timeout" }), () => {
612
+ }];
574
613
  }
575
614
  throw error;
576
615
  }
@@ -582,7 +621,7 @@ mutation addPendingDocumentMutation(
582
621
  const parsedResult = IndexStatusResponse.parse(result);
583
622
  return parsedResult;
584
623
  }
585
- async listBranches() {
624
+ async listBranches(args) {
586
625
  try {
587
626
  const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
588
627
  const res = await this.fetchWithToken(url, {
@@ -590,6 +629,9 @@ mutation addPendingDocumentMutation(
590
629
  });
591
630
  const branches = await res.json();
592
631
  const parsedBranches = ListBranchResponse.parse(branches);
632
+ if ((args == null ? void 0 : args.includeIndexStatus) === false) {
633
+ return parsedBranches;
634
+ }
593
635
  const indexStatusPromises = parsedBranches.map(async (branch) => {
594
636
  const indexStatus2 = await this.getIndexStatus({ ref: branch.name });
595
637
  return {
@@ -597,6 +639,7 @@ mutation addPendingDocumentMutation(
597
639
  indexStatus: indexStatus2
598
640
  };
599
641
  });
642
+ this.protectedBranches = parsedBranches.filter((x) => x.protected).map((x) => x.name);
600
643
  const indexStatus = await Promise.all(indexStatusPromises);
601
644
  return indexStatus;
602
645
  } catch (error) {
@@ -604,6 +647,10 @@ mutation addPendingDocumentMutation(
604
647
  throw error;
605
648
  }
606
649
  }
650
+ usingProtectedBranch() {
651
+ var _a;
652
+ return this.usingEditorialWorkflow && ((_a = this.protectedBranches) == null ? void 0 : _a.includes(this.branch));
653
+ }
607
654
  async createBranch({ baseBranch, branchName }) {
608
655
  const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
609
656
  try {
@@ -617,10 +664,16 @@ mutation addPendingDocumentMutation(
617
664
  "Content-Type": "application/json"
618
665
  }
619
666
  });
620
- return await res.json().then((r) => parseRefForBranchName(r.data.ref));
667
+ if (!res.ok) {
668
+ console.error("There was an error creating a new branch.");
669
+ const error = await res.json();
670
+ throw new Error(error == null ? void 0 : error.message);
671
+ }
672
+ const values = await res.json();
673
+ return parseRefForBranchName(values.data.ref);
621
674
  } catch (error) {
622
675
  console.error("There was an error creating a new branch.", error);
623
- return null;
676
+ throw error;
624
677
  }
625
678
  }
626
679
  }
@@ -1100,6 +1153,7 @@ const AuthWallInner = ({
1100
1153
  if (await client.isAuthenticated()) {
1101
1154
  setShowChildren(true);
1102
1155
  setActiveModal(null);
1156
+ cms.events.dispatch({ type: "cms:login" });
1103
1157
  } else {
1104
1158
  throw new Error("No access to repo");
1105
1159
  }
@@ -1138,6 +1192,7 @@ const AuthWallInner = ({
1138
1192
  }), showChildren ? children : loginScreen ? loginScreen : null);
1139
1193
  };
1140
1194
  const TinaCloudProvider = (props) => {
1195
+ var _a, _b, _c, _d, _e;
1141
1196
  const baseBranch = props.branch || "main";
1142
1197
  const [currentBranch, setCurrentBranch] = useLocalStorage("tinacms-current-branch", baseBranch);
1143
1198
  useTinaAuthRedirect();
@@ -1153,16 +1208,16 @@ const TinaCloudProvider = (props) => {
1153
1208
  cms.api.tina.setBranch(currentBranch);
1154
1209
  }
1155
1210
  useEffect(() => {
1156
- var _a, _b, _c, _d;
1211
+ var _a2, _b2, _c2, _d2;
1157
1212
  let searchClient;
1158
1213
  if (props.isLocalClient) {
1159
1214
  searchClient = new LocalSearchClient(cms.api.tina);
1160
1215
  } else {
1161
- const hasTinaSearch = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
1216
+ const hasTinaSearch = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.search) == null ? void 0 : _b2.tina);
1162
1217
  if (hasTinaSearch) {
1163
1218
  searchClient = new TinaCMSSearchClient(cms.api.tina);
1164
1219
  } else {
1165
- searchClient = (_d = (_c = props.schema.config) == null ? void 0 : _c.search) == null ? void 0 : _d.searchClient;
1220
+ searchClient = (_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.search) == null ? void 0 : _d2.searchClient;
1166
1221
  }
1167
1222
  }
1168
1223
  if (searchClient) {
@@ -1173,12 +1228,12 @@ const TinaCloudProvider = (props) => {
1173
1228
  cms.registerApi("admin", new TinaAdminApi(cms));
1174
1229
  }
1175
1230
  const setupMedia = async () => {
1176
- var _a, _b, _c, _d, _e, _f, _g;
1177
- const hasTinaMedia = Boolean((_b = (_a = props.schema.config) == null ? void 0 : _a.media) == null ? void 0 : _b.tina);
1231
+ var _a2, _b2, _c2, _d2, _e2, _f, _g;
1232
+ const hasTinaMedia = Boolean((_b2 = (_a2 = props.schema.config) == null ? void 0 : _a2.media) == null ? void 0 : _b2.tina);
1178
1233
  if (hasTinaMedia) {
1179
1234
  cms.media.store = new TinaMediaStore(cms);
1180
- } else if (((_d = (_c = props.schema.config) == null ? void 0 : _c.media) == null ? void 0 : _d.loadCustomStore) || props.mediaStore) {
1181
- const mediaStoreFromProps = ((_f = (_e = props.schema.config) == null ? void 0 : _e.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1235
+ } else if (((_d2 = (_c2 = props.schema.config) == null ? void 0 : _c2.media) == null ? void 0 : _d2.loadCustomStore) || props.mediaStore) {
1236
+ const mediaStoreFromProps = ((_f = (_e2 = props.schema.config) == null ? void 0 : _e2.media) == null ? void 0 : _f.loadCustomStore) || props.mediaStore;
1182
1237
  if ((_g = mediaStoreFromProps.prototype) == null ? void 0 : _g.persist) {
1183
1238
  cms.media.store = new mediaStoreFromProps(cms.api.tina);
1184
1239
  } else {
@@ -1189,6 +1244,8 @@ const TinaCloudProvider = (props) => {
1189
1244
  cms.media.store = new DummyMediaStore();
1190
1245
  }
1191
1246
  };
1247
+ const client = cms.api.tina;
1248
+ 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);
1192
1249
  const handleListBranches = async () => {
1193
1250
  const { owner, repo } = props;
1194
1251
  const branches = await cms.api.tina.listBranches({ owner, repo });
@@ -1231,6 +1288,27 @@ const TinaCloudProvider = (props) => {
1231
1288
  props.cmsCallback(cms);
1232
1289
  }
1233
1290
  }, []);
1291
+ React.useEffect(() => {
1292
+ const setupEditorialWorkflow = () => {
1293
+ client.getProject().then((project) => {
1294
+ var _a2;
1295
+ if ((_a2 = project == null ? void 0 : project.features) == null ? void 0 : _a2.includes("editorial-workflow")) {
1296
+ cms.flags.set("branch-switcher", true);
1297
+ client.usingEditorialWorkflow = true;
1298
+ client.protectedBranches = project.protectedBranches;
1299
+ }
1300
+ });
1301
+ };
1302
+ if (isTinaCloud) {
1303
+ setupEditorialWorkflow();
1304
+ }
1305
+ const unsubscribe = cms.events.subscribe("cms:login", () => {
1306
+ if (isTinaCloud) {
1307
+ setupEditorialWorkflow();
1308
+ }
1309
+ });
1310
+ return unsubscribe;
1311
+ }, [isTinaCloud, cms]);
1234
1312
  return /* @__PURE__ */ React.createElement(BranchDataProvider, {
1235
1313
  currentBranch,
1236
1314
  setCurrentBranch: (b) => {
@@ -1560,6 +1638,343 @@ var styles = `.tina-tailwind {
1560
1638
  --tw-backdrop-saturate: ;
1561
1639
  --tw-backdrop-sepia: ;
1562
1640
  }
1641
+ .tina-prose {
1642
+ color: var(--tw-prose-body);
1643
+ max-width: 65ch;
1644
+ }
1645
+ .tina-prose :where([class~="lead"]):not(:where([class~="not-tina-prose"] *)) {
1646
+ color: var(--tw-prose-lead);
1647
+ font-size: 1.25em;
1648
+ line-height: 1.6;
1649
+ margin-top: 1.2em;
1650
+ margin-bottom: 1.2em;
1651
+ }
1652
+ .tina-prose :where(a):not(:where([class~="not-tina-prose"] *)) {
1653
+ color: var(--tw-prose-links);
1654
+ text-decoration: underline;
1655
+ font-weight: 500;
1656
+ }
1657
+ .tina-prose :where(strong):not(:where([class~="not-tina-prose"] *)) {
1658
+ color: var(--tw-prose-bold);
1659
+ font-weight: 600;
1660
+ }
1661
+ .tina-prose :where(ol):not(:where([class~="not-tina-prose"] *)) {
1662
+ list-style-type: decimal;
1663
+ padding-left: 1.625em;
1664
+ }
1665
+ .tina-prose :where(ol[type="A"]):not(:where([class~="not-tina-prose"] *)) {
1666
+ list-style-type: upper-alpha;
1667
+ }
1668
+ .tina-prose :where(ol[type="a"]):not(:where([class~="not-tina-prose"] *)) {
1669
+ list-style-type: lower-alpha;
1670
+ }
1671
+ .tina-prose :where(ol[type="A" s]):not(:where([class~="not-tina-prose"] *)) {
1672
+ list-style-type: upper-alpha;
1673
+ }
1674
+ .tina-prose :where(ol[type="a" s]):not(:where([class~="not-tina-prose"] *)) {
1675
+ list-style-type: lower-alpha;
1676
+ }
1677
+ .tina-prose :where(ol[type="I"]):not(:where([class~="not-tina-prose"] *)) {
1678
+ list-style-type: upper-roman;
1679
+ }
1680
+ .tina-prose :where(ol[type="i"]):not(:where([class~="not-tina-prose"] *)) {
1681
+ list-style-type: lower-roman;
1682
+ }
1683
+ .tina-prose :where(ol[type="I" s]):not(:where([class~="not-tina-prose"] *)) {
1684
+ list-style-type: upper-roman;
1685
+ }
1686
+ .tina-prose :where(ol[type="i" s]):not(:where([class~="not-tina-prose"] *)) {
1687
+ list-style-type: lower-roman;
1688
+ }
1689
+ .tina-prose :where(ol[type="1"]):not(:where([class~="not-tina-prose"] *)) {
1690
+ list-style-type: decimal;
1691
+ }
1692
+ .tina-prose :where(ul):not(:where([class~="not-tina-prose"] *)) {
1693
+ list-style-type: disc;
1694
+ padding-left: 1.625em;
1695
+ }
1696
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *))::marker {
1697
+ font-weight: 400;
1698
+ color: var(--tw-prose-counters);
1699
+ }
1700
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *))::marker {
1701
+ color: var(--tw-prose-bullets);
1702
+ }
1703
+ .tina-prose :where(hr):not(:where([class~="not-tina-prose"] *)) {
1704
+ border-color: var(--tw-prose-hr);
1705
+ border-top-width: 1px;
1706
+ margin-top: 3em;
1707
+ margin-bottom: 3em;
1708
+ }
1709
+ .tina-prose :where(blockquote):not(:where([class~="not-tina-prose"] *)) {
1710
+ font-weight: 500;
1711
+ font-style: italic;
1712
+ color: var(--tw-prose-quotes);
1713
+ border-left-width: 0.25rem;
1714
+ border-left-color: var(--tw-prose-quote-borders);
1715
+ quotes: "\\201C""\\201D""\\2018""\\2019";
1716
+ margin-top: 1.6em;
1717
+ margin-bottom: 1.6em;
1718
+ padding-left: 1em;
1719
+ }
1720
+ .tina-prose :where(blockquote p:first-of-type):not(:where([class~="not-tina-prose"] *))::before {
1721
+ content: open-quote;
1722
+ }
1723
+ .tina-prose :where(blockquote p:last-of-type):not(:where([class~="not-tina-prose"] *))::after {
1724
+ content: close-quote;
1725
+ }
1726
+ .tina-prose :where(h1):not(:where([class~="not-tina-prose"] *)) {
1727
+ color: var(--tw-prose-headings);
1728
+ font-weight: 800;
1729
+ font-size: 2.25em;
1730
+ margin-top: 0;
1731
+ margin-bottom: 0.8888889em;
1732
+ line-height: 1.1111111;
1733
+ }
1734
+ .tina-prose :where(h1 strong):not(:where([class~="not-tina-prose"] *)) {
1735
+ font-weight: 900;
1736
+ }
1737
+ .tina-prose :where(h2):not(:where([class~="not-tina-prose"] *)) {
1738
+ color: var(--tw-prose-headings);
1739
+ font-weight: 700;
1740
+ font-size: 1.5em;
1741
+ margin-top: 2em;
1742
+ margin-bottom: 1em;
1743
+ line-height: 1.3333333;
1744
+ }
1745
+ .tina-prose :where(h2 strong):not(:where([class~="not-tina-prose"] *)) {
1746
+ font-weight: 800;
1747
+ }
1748
+ .tina-prose :where(h3):not(:where([class~="not-tina-prose"] *)) {
1749
+ color: var(--tw-prose-headings);
1750
+ font-weight: 600;
1751
+ font-size: 1.25em;
1752
+ margin-top: 1.6em;
1753
+ margin-bottom: 0.6em;
1754
+ line-height: 1.6;
1755
+ }
1756
+ .tina-prose :where(h3 strong):not(:where([class~="not-tina-prose"] *)) {
1757
+ font-weight: 700;
1758
+ }
1759
+ .tina-prose :where(h4):not(:where([class~="not-tina-prose"] *)) {
1760
+ color: var(--tw-prose-headings);
1761
+ font-weight: 600;
1762
+ margin-top: 1.5em;
1763
+ margin-bottom: 0.5em;
1764
+ line-height: 1.5;
1765
+ }
1766
+ .tina-prose :where(h4 strong):not(:where([class~="not-tina-prose"] *)) {
1767
+ font-weight: 700;
1768
+ }
1769
+ .tina-prose :where(figure > *):not(:where([class~="not-tina-prose"] *)) {
1770
+ margin-top: 0;
1771
+ margin-bottom: 0;
1772
+ }
1773
+ .tina-prose :where(figcaption):not(:where([class~="not-tina-prose"] *)) {
1774
+ color: var(--tw-prose-captions);
1775
+ font-size: 0.875em;
1776
+ line-height: 1.4285714;
1777
+ margin-top: 0.8571429em;
1778
+ }
1779
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *)) {
1780
+ color: var(--tw-prose-code);
1781
+ font-weight: 600;
1782
+ font-size: 0.875em;
1783
+ }
1784
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::before {
1785
+ content: "\`";
1786
+ }
1787
+ .tina-prose :where(code):not(:where([class~="not-tina-prose"] *))::after {
1788
+ content: "\`";
1789
+ }
1790
+ .tina-prose :where(a code):not(:where([class~="not-tina-prose"] *)) {
1791
+ color: var(--tw-prose-links);
1792
+ }
1793
+ .tina-prose :where(pre):not(:where([class~="not-tina-prose"] *)) {
1794
+ color: var(--tw-prose-pre-code);
1795
+ background-color: var(--tw-prose-pre-bg);
1796
+ overflow-x: auto;
1797
+ font-weight: 400;
1798
+ font-size: 0.875em;
1799
+ line-height: 1.7142857;
1800
+ margin-top: 1.7142857em;
1801
+ margin-bottom: 1.7142857em;
1802
+ border-radius: 0.375rem;
1803
+ padding-top: 0.8571429em;
1804
+ padding-right: 1.1428571em;
1805
+ padding-bottom: 0.8571429em;
1806
+ padding-left: 1.1428571em;
1807
+ }
1808
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *)) {
1809
+ background-color: transparent;
1810
+ border-width: 0;
1811
+ border-radius: 0;
1812
+ padding: 0;
1813
+ font-weight: inherit;
1814
+ color: inherit;
1815
+ font-size: inherit;
1816
+ font-family: inherit;
1817
+ line-height: inherit;
1818
+ }
1819
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::before {
1820
+ content: none;
1821
+ }
1822
+ .tina-prose :where(pre code):not(:where([class~="not-tina-prose"] *))::after {
1823
+ content: none;
1824
+ }
1825
+ .tina-prose :where(table):not(:where([class~="not-tina-prose"] *)) {
1826
+ width: 100%;
1827
+ table-layout: auto;
1828
+ text-align: left;
1829
+ margin-top: 2em;
1830
+ margin-bottom: 2em;
1831
+ font-size: 0.875em;
1832
+ line-height: 1.7142857;
1833
+ }
1834
+ .tina-prose :where(thead):not(:where([class~="not-tina-prose"] *)) {
1835
+ border-bottom-width: 1px;
1836
+ border-bottom-color: var(--tw-prose-th-borders);
1837
+ }
1838
+ .tina-prose :where(thead th):not(:where([class~="not-tina-prose"] *)) {
1839
+ color: var(--tw-prose-headings);
1840
+ font-weight: 600;
1841
+ vertical-align: bottom;
1842
+ padding-right: 0.5714286em;
1843
+ padding-bottom: 0.5714286em;
1844
+ padding-left: 0.5714286em;
1845
+ }
1846
+ .tina-prose :where(tbody tr):not(:where([class~="not-tina-prose"] *)) {
1847
+ border-bottom-width: 1px;
1848
+ border-bottom-color: var(--tw-prose-td-borders);
1849
+ }
1850
+ .tina-prose :where(tbody tr:last-child):not(:where([class~="not-tina-prose"] *)) {
1851
+ border-bottom-width: 0;
1852
+ }
1853
+ .tina-prose :where(tbody td):not(:where([class~="not-tina-prose"] *)) {
1854
+ vertical-align: baseline;
1855
+ padding-top: 0.5714286em;
1856
+ padding-right: 0.5714286em;
1857
+ padding-bottom: 0.5714286em;
1858
+ padding-left: 0.5714286em;
1859
+ }
1860
+ .tina-prose {
1861
+ --tw-prose-body: #374151;
1862
+ --tw-prose-headings: #111827;
1863
+ --tw-prose-lead: #4b5563;
1864
+ --tw-prose-links: #111827;
1865
+ --tw-prose-bold: #111827;
1866
+ --tw-prose-counters: #6b7280;
1867
+ --tw-prose-bullets: #d1d5db;
1868
+ --tw-prose-hr: #e5e7eb;
1869
+ --tw-prose-quotes: #111827;
1870
+ --tw-prose-quote-borders: #e5e7eb;
1871
+ --tw-prose-captions: #6b7280;
1872
+ --tw-prose-code: #111827;
1873
+ --tw-prose-pre-code: #e5e7eb;
1874
+ --tw-prose-pre-bg: #1f2937;
1875
+ --tw-prose-th-borders: #d1d5db;
1876
+ --tw-prose-td-borders: #e5e7eb;
1877
+ --tw-prose-invert-body: #d1d5db;
1878
+ --tw-prose-invert-headings: #fff;
1879
+ --tw-prose-invert-lead: #9ca3af;
1880
+ --tw-prose-invert-links: #fff;
1881
+ --tw-prose-invert-bold: #fff;
1882
+ --tw-prose-invert-counters: #9ca3af;
1883
+ --tw-prose-invert-bullets: #4b5563;
1884
+ --tw-prose-invert-hr: #374151;
1885
+ --tw-prose-invert-quotes: #f3f4f6;
1886
+ --tw-prose-invert-quote-borders: #374151;
1887
+ --tw-prose-invert-captions: #9ca3af;
1888
+ --tw-prose-invert-code: #fff;
1889
+ --tw-prose-invert-pre-code: #d1d5db;
1890
+ --tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);
1891
+ --tw-prose-invert-th-borders: #4b5563;
1892
+ --tw-prose-invert-td-borders: #374151;
1893
+ font-size: 1rem;
1894
+ line-height: 1.75;
1895
+ }
1896
+ .tina-prose :where(p):not(:where([class~="not-tina-prose"] *)) {
1897
+ margin-top: 1.25em;
1898
+ margin-bottom: 1.25em;
1899
+ }
1900
+ .tina-prose :where(img):not(:where([class~="not-tina-prose"] *)) {
1901
+ margin-top: 2em;
1902
+ margin-bottom: 2em;
1903
+ }
1904
+ .tina-prose :where(video):not(:where([class~="not-tina-prose"] *)) {
1905
+ margin-top: 2em;
1906
+ margin-bottom: 2em;
1907
+ }
1908
+ .tina-prose :where(figure):not(:where([class~="not-tina-prose"] *)) {
1909
+ margin-top: 2em;
1910
+ margin-bottom: 2em;
1911
+ }
1912
+ .tina-prose :where(h2 code):not(:where([class~="not-tina-prose"] *)) {
1913
+ font-size: 0.875em;
1914
+ }
1915
+ .tina-prose :where(h3 code):not(:where([class~="not-tina-prose"] *)) {
1916
+ font-size: 0.9em;
1917
+ }
1918
+ .tina-prose :where(li):not(:where([class~="not-tina-prose"] *)) {
1919
+ margin-top: 0.5em;
1920
+ margin-bottom: 0.5em;
1921
+ }
1922
+ .tina-prose :where(ol > li):not(:where([class~="not-tina-prose"] *)) {
1923
+ padding-left: 0.375em;
1924
+ }
1925
+ .tina-prose :where(ul > li):not(:where([class~="not-tina-prose"] *)) {
1926
+ padding-left: 0.375em;
1927
+ }
1928
+ .tina-prose > :where(ul > li p):not(:where([class~="not-tina-prose"] *)) {
1929
+ margin-top: 0.75em;
1930
+ margin-bottom: 0.75em;
1931
+ }
1932
+ .tina-prose > :where(ul > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1933
+ margin-top: 1.25em;
1934
+ }
1935
+ .tina-prose > :where(ul > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1936
+ margin-bottom: 1.25em;
1937
+ }
1938
+ .tina-prose > :where(ol > li > *:first-child):not(:where([class~="not-tina-prose"] *)) {
1939
+ margin-top: 1.25em;
1940
+ }
1941
+ .tina-prose > :where(ol > li > *:last-child):not(:where([class~="not-tina-prose"] *)) {
1942
+ margin-bottom: 1.25em;
1943
+ }
1944
+ .tina-prose :where(ul ul, ul ol, ol ul, ol ol):not(:where([class~="not-tina-prose"] *)) {
1945
+ margin-top: 0.75em;
1946
+ margin-bottom: 0.75em;
1947
+ }
1948
+ .tina-prose :where(hr + *):not(:where([class~="not-tina-prose"] *)) {
1949
+ margin-top: 0;
1950
+ }
1951
+ .tina-prose :where(h2 + *):not(:where([class~="not-tina-prose"] *)) {
1952
+ margin-top: 0;
1953
+ }
1954
+ .tina-prose :where(h3 + *):not(:where([class~="not-tina-prose"] *)) {
1955
+ margin-top: 0;
1956
+ }
1957
+ .tina-prose :where(h4 + *):not(:where([class~="not-tina-prose"] *)) {
1958
+ margin-top: 0;
1959
+ }
1960
+ .tina-prose :where(thead th:first-child):not(:where([class~="not-tina-prose"] *)) {
1961
+ padding-left: 0;
1962
+ }
1963
+ .tina-prose :where(thead th:last-child):not(:where([class~="not-tina-prose"] *)) {
1964
+ padding-right: 0;
1965
+ }
1966
+ .tina-prose :where(tbody td:first-child):not(:where([class~="not-tina-prose"] *)) {
1967
+ padding-left: 0;
1968
+ }
1969
+ .tina-prose :where(tbody td:last-child):not(:where([class~="not-tina-prose"] *)) {
1970
+ padding-right: 0;
1971
+ }
1972
+ .tina-prose > :where(:first-child):not(:where([class~="not-tina-prose"] *)) {
1973
+ margin-top: 0;
1974
+ }
1975
+ .tina-prose > :where(:last-child):not(:where([class~="not-tina-prose"] *)) {
1976
+ margin-bottom: 0;
1977
+ }
1563
1978
  .tina-tailwind .pointer-events-none {
1564
1979
  pointer-events: none;
1565
1980
  }
@@ -1628,18 +2043,9 @@ var styles = `.tina-tailwind {
1628
2043
  .tina-tailwind .-ml-px {
1629
2044
  margin-left: -1px;
1630
2045
  }
1631
- .tina-tailwind .-mt-0 {
1632
- margin-top: -0px;
1633
- }
1634
- .tina-tailwind .-mt-0\\.5 {
1635
- margin-top: -2px;
1636
- }
1637
2046
  .tina-tailwind .mb-1 {
1638
2047
  margin-bottom: 4px;
1639
2048
  }
1640
- .tina-tailwind .mb-2 {
1641
- margin-bottom: 8px;
1642
- }
1643
2049
  .tina-tailwind .mb-4 {
1644
2050
  margin-bottom: 16px;
1645
2051
  }
@@ -1769,12 +2175,21 @@ var styles = `.tina-tailwind {
1769
2175
  .tina-tailwind .flex-shrink-0 {
1770
2176
  flex-shrink: 0;
1771
2177
  }
2178
+ .tina-tailwind .shrink {
2179
+ flex-shrink: 1;
2180
+ }
1772
2181
  .tina-tailwind .shrink-0 {
1773
2182
  flex-shrink: 0;
1774
2183
  }
1775
2184
  .tina-tailwind .flex-grow-0 {
1776
2185
  flex-grow: 0;
1777
2186
  }
2187
+ .tina-tailwind .grow-0 {
2188
+ flex-grow: 0;
2189
+ }
2190
+ .tina-tailwind .basis-0 {
2191
+ flex-basis: 0px;
2192
+ }
1778
2193
  .tina-tailwind .table-auto {
1779
2194
  table-layout: auto;
1780
2195
  }
@@ -1810,6 +2225,15 @@ var styles = `.tina-tailwind {
1810
2225
  .tina-tailwind .transform {
1811
2226
  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));
1812
2227
  }
2228
+ @keyframes spin {
2229
+
2230
+ to {
2231
+ transform: rotate(360deg);
2232
+ }
2233
+ }
2234
+ .tina-tailwind .animate-spin {
2235
+ animation: spin 1s linear infinite;
2236
+ }
1813
2237
  .tina-tailwind .cursor-pointer {
1814
2238
  cursor: pointer;
1815
2239
  }
@@ -1855,6 +2279,9 @@ var styles = `.tina-tailwind {
1855
2279
  .tina-tailwind .gap-1 {
1856
2280
  gap: 4px;
1857
2281
  }
2282
+ .tina-tailwind .gap-1\\.5 {
2283
+ gap: 6px;
2284
+ }
1858
2285
  .tina-tailwind .gap-2 {
1859
2286
  gap: 8px;
1860
2287
  }
@@ -2004,6 +2431,9 @@ var styles = `.tina-tailwind {
2004
2431
  .tina-tailwind .p-0 {
2005
2432
  padding: 0px;
2006
2433
  }
2434
+ .tina-tailwind .p-6 {
2435
+ padding: 24px;
2436
+ }
2007
2437
  .tina-tailwind .p-8 {
2008
2438
  padding: 32px;
2009
2439
  }
@@ -2067,6 +2497,9 @@ var styles = `.tina-tailwind {
2067
2497
  padding-top: 32px;
2068
2498
  padding-bottom: 32px;
2069
2499
  }
2500
+ .tina-tailwind .pb-4 {
2501
+ padding-bottom: 16px;
2502
+ }
2070
2503
  .tina-tailwind .pl-18 {
2071
2504
  padding-left: 72px;
2072
2505
  }
@@ -2094,6 +2527,9 @@ var styles = `.tina-tailwind {
2094
2527
  .tina-tailwind .pt-12 {
2095
2528
  padding-top: 48px;
2096
2529
  }
2530
+ .tina-tailwind .pt-3 {
2531
+ padding-top: 12px;
2532
+ }
2097
2533
  .tina-tailwind .pt-4 {
2098
2534
  padding-top: 16px;
2099
2535
  }
@@ -2137,6 +2573,9 @@ var styles = `.tina-tailwind {
2137
2573
  font-size: 13px;
2138
2574
  line-height: 1.33;
2139
2575
  }
2576
+ .tina-tailwind .font-bold {
2577
+ font-weight: 700;
2578
+ }
2140
2579
  .tina-tailwind .font-medium {
2141
2580
  font-weight: 500;
2142
2581
  }
@@ -2173,9 +2612,6 @@ var styles = `.tina-tailwind {
2173
2612
  --tw-text-opacity: 1;
2174
2613
  color: rgb(5 116 228 / var(--tw-text-opacity));
2175
2614
  }
2176
- .tina-tailwind .text-current {
2177
- color: currentColor;
2178
- }
2179
2615
  .tina-tailwind .text-gray-200 {
2180
2616
  --tw-text-opacity: 1;
2181
2617
  color: rgb(225 221 236 / var(--tw-text-opacity));
@@ -2216,6 +2652,10 @@ var styles = `.tina-tailwind {
2216
2652
  --tw-text-opacity: 1;
2217
2653
  color: rgb(239 68 68 / var(--tw-text-opacity));
2218
2654
  }
2655
+ .tina-tailwind .text-red-700 {
2656
+ --tw-text-opacity: 1;
2657
+ color: rgb(185 28 28 / var(--tw-text-opacity));
2658
+ }
2219
2659
  .tina-tailwind .text-white {
2220
2660
  --tw-text-opacity: 1;
2221
2661
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -2241,8 +2681,8 @@ var styles = `.tina-tailwind {
2241
2681
  .tina-tailwind .opacity-20 {
2242
2682
  opacity: .2;
2243
2683
  }
2244
- .tina-tailwind .opacity-50 {
2245
- opacity: .5;
2684
+ .tina-tailwind .opacity-30 {
2685
+ opacity: .3;
2246
2686
  }
2247
2687
  .tina-tailwind .opacity-70 {
2248
2688
  opacity: .7;
@@ -2301,11 +2741,6 @@ var styles = `.tina-tailwind {
2301
2741
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2302
2742
  transition-duration: 150ms;
2303
2743
  }
2304
- .tina-tailwind .transition-colors {
2305
- transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
2306
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
2307
- transition-duration: 150ms;
2308
- }
2309
2744
  .tina-tailwind .transition-opacity {
2310
2745
  transition-property: opacity;
2311
2746
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
@@ -2361,6 +2796,9 @@ var styles = `.tina-tailwind {
2361
2796
  --tw-text-opacity: 1;
2362
2797
  color: rgb(5 116 228 / var(--tw-text-opacity));
2363
2798
  }
2799
+ .tina-tailwind .hover\\:underline:hover {
2800
+ text-decoration-line: underline;
2801
+ }
2364
2802
  .tina-tailwind .hover\\:decoration-blue-400:hover {
2365
2803
  text-decoration-color: #2296fe;
2366
2804
  }
@@ -2374,17 +2812,10 @@ var styles = `.tina-tailwind {
2374
2812
  --tw-border-opacity: 1;
2375
2813
  border-color: rgb(0 132 255 / var(--tw-border-opacity));
2376
2814
  }
2377
- .tina-tailwind .focus\\:text-blue-400:focus {
2378
- --tw-text-opacity: 1;
2379
- color: rgb(34 150 254 / var(--tw-text-opacity));
2380
- }
2381
2815
  .tina-tailwind .focus\\:text-gray-900:focus {
2382
2816
  --tw-text-opacity: 1;
2383
2817
  color: rgb(37 35 54 / var(--tw-text-opacity));
2384
2818
  }
2385
- .tina-tailwind .focus\\:underline:focus {
2386
- text-decoration-line: underline;
2387
- }
2388
2819
  .tina-tailwind .focus\\:shadow-outline:focus {
2389
2820
  --tw-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
2390
2821
  --tw-shadow-colored: 0 0 0 3px var(--tw-shadow-color);
@@ -2615,8 +3046,6 @@ class ErrorBoundary extends React.Component {
2615
3046
  return { hasError: true, message: error.message };
2616
3047
  }
2617
3048
  render() {
2618
- const branchData = window.localStorage && window.localStorage.getItem("tinacms-current-branch");
2619
- const hasBranchData = branchData && branchData.length > 0;
2620
3049
  if (this.state.hasError && !this.state.pageRefresh) {
2621
3050
  return /* @__PURE__ */ React.createElement("div", {
2622
3051
  style: {
@@ -2650,18 +3079,7 @@ class ErrorBoundary extends React.Component {
2650
3079
  this.setState({ pageRefresh: true });
2651
3080
  setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
2652
3081
  }
2653
- }, "Refresh"), hasBranchData && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.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.createElement("p", null, "See our", " ", /* @__PURE__ */ React.createElement("a", {
2654
- className: "text-gray-600",
2655
- style: { textDecoration: "underline" },
2656
- href: "https://tina.io/docs/errors/faq/",
2657
- target: "_blank"
2658
- }, " ", "Error FAQ", " "), " ", "for more information."), /* @__PURE__ */ React.createElement("button", {
2659
- style: errorButtonStyles,
2660
- onClick: () => {
2661
- window.localStorage.removeItem("tinacms-current-branch");
2662
- window.location.reload();
2663
- }
2664
- }, "Switch to default branch"))));
3082
+ }, "Refresh")));
2665
3083
  }
2666
3084
  if (this.state.pageRefresh) {
2667
3085
  return /* @__PURE__ */ React.createElement(Loader, null, "Let's try that again.");
@@ -2965,6 +3383,9 @@ function BiFile(props) {
2965
3383
  function BiFolder(props) {
2966
3384
  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);
2967
3385
  }
3386
+ function BiLoaderAlt(props) {
3387
+ 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);
3388
+ }
2968
3389
  function BiLogIn(props) {
2969
3390
  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);
2970
3391
  }
@@ -3755,7 +4176,7 @@ const CollectionListPage = () => {
3755
4176
  const allowCreate = (_g = (_f = (_e = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _e.allowedActions) == null ? void 0 : _f.create) != null ? _g : true;
3756
4177
  const allowDelete = (_j = (_i = (_h = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _h.allowedActions) == null ? void 0 : _i.delete) != null ? _j : true;
3757
4178
  const folderView = folder.fullyQualifiedName !== "";
3758
- return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && /* @__PURE__ */ React.createElement(DeleteModal, {
4179
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, deleteModalOpen && !cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(DeleteModal, {
3759
4180
  filename: vars.relativePath,
3760
4181
  deleteFunc: async () => {
3761
4182
  try {
@@ -3769,6 +4190,22 @@ const CollectionListPage = () => {
3769
4190
  }
3770
4191
  },
3771
4192
  close: () => setDeleteModalOpen(false)
4193
+ }), deleteModalOpen && cms.api.tina.usingProtectedBranch() && /* @__PURE__ */ React.createElement(CreateBranchModel, {
4194
+ crudType: "delete",
4195
+ relativePath: collectionExtra.path + "/" + vars.relativePath,
4196
+ values: vars,
4197
+ close: () => setDeleteModalOpen(false),
4198
+ safeSubmit: async () => {
4199
+ try {
4200
+ await admin.deleteDocument(vars);
4201
+ cms.alerts.info("Document was successfully deleted");
4202
+ reFetchCollection();
4203
+ } catch (error) {
4204
+ cms.alerts.warn("Document was not deleted, ask a developer for help or check the console for an error message");
4205
+ console.error(error);
4206
+ throw error;
4207
+ }
4208
+ }
3772
4209
  }), renameModalOpen && /* @__PURE__ */ React.createElement(RenameModal, {
3773
4210
  filename: vars.relativePath,
3774
4211
  newRelativePath: vars.newRelativePath,
@@ -4231,9 +4668,6 @@ const RenameModal = ({
4231
4668
  }
4232
4669
  }, "Rename"))));
4233
4670
  };
4234
- function HiChevronRight(props) {
4235
- 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);
4236
- }
4237
4671
  function FaLock(props) {
4238
4672
  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);
4239
4673
  }
@@ -4334,17 +4768,22 @@ const RenderForm$1 = ({
4334
4768
  const defaultItem = customDefaults || ((_d = template.ui) == null ? void 0 : _d.defaultItem) || (template == null ? void 0 : template.defaultItem);
4335
4769
  const form = useMemo(() => {
4336
4770
  var _a2, _b2;
4771
+ const folderName = folder.fullyQualifiedName ? folder.name : "";
4337
4772
  return new Form({
4773
+ crudType: "create",
4338
4774
  initialValues: typeof defaultItem === "function" ? defaultItem() : defaultItem,
4339
4775
  extraSubscribeValues: { active: true, submitting: true, touched: true },
4340
4776
  onChange: (values) => {
4341
- var _a3;
4342
- if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_a3 = values.touched) == null ? void 0 : _a3.filename)) {
4777
+ var _a3, _b3;
4778
+ if (!(values == null ? void 0 : values.submitting)) {
4779
+ form.relativePath = schemaCollection.path + folderName + `/${(_a3 = values == null ? void 0 : values.values) == null ? void 0 : _a3.filename}.${schemaCollection.format || "md"}`;
4780
+ }
4781
+ if (slugFunction && (values == null ? void 0 : values.active) !== "filename" && !(values == null ? void 0 : values.submitting) && !((_b3 = values.touched) == null ? void 0 : _b3.filename)) {
4343
4782
  const value = slugFunction(values == null ? void 0 : values.values);
4344
4783
  form.finalForm.change("filename", value);
4345
4784
  }
4346
4785
  },
4347
- id: "create-form",
4786
+ id: schemaCollection.path + folderName + `/new-post.${schemaCollection.format || "md"}`,
4348
4787
  label: "form",
4349
4788
  fields: [
4350
4789
  ...formInfo.fields,
@@ -4388,8 +4827,8 @@ const RenderForm$1 = ({
4388
4827
  ],
4389
4828
  onSubmit: async (values) => {
4390
4829
  try {
4391
- const folderName = folder.fullyQualifiedName ? folder.name : "";
4392
- await createDocument(cms, collection, template, mutationInfo, folderName, values);
4830
+ const folderName2 = folder.fullyQualifiedName ? folder.name : "";
4831
+ await createDocument(cms, collection, template, mutationInfo, folderName2, values);
4393
4832
  cms.alerts.success("Document created!");
4394
4833
  setTimeout(() => {
4395
4834
  navigate(`/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`);
@@ -4424,21 +4863,17 @@ const RenderForm$1 = ({
4424
4863
  }
4425
4864
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4426
4865
  return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React.createElement(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4427
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4866
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4428
4867
  }, /* @__PURE__ */ React.createElement("div", {
4429
- className: "max-w-form mx-auto"
4430
- }, /* @__PURE__ */ React.createElement("div", {
4431
- className: "mb-2"
4432
- }, /* @__PURE__ */ React.createElement("span", {
4433
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
4868
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4434
4869
  }, /* @__PURE__ */ React.createElement(Link, {
4435
4870
  to: `/collections/${collection.name}${folder.fullyQualifiedName ? `/${folder.fullyQualifiedName}` : ""}`,
4436
- 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"
4437
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
4438
- className: "inline-block -mt-0.5 opacity-50"
4439
- })), /* @__PURE__ */ React.createElement("span", {
4440
- className: "text-xl text-gray-700 font-medium leading-tight"
4441
- }, "Create New")), /* @__PURE__ */ React.createElement(FormStatus, {
4871
+ 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"
4872
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement("span", {
4873
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
4874
+ }, "/"), /* @__PURE__ */ React.createElement("span", {
4875
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
4876
+ }, "Create New"), /* @__PURE__ */ React.createElement(FormStatus, {
4442
4877
  pristine: formIsPristine
4443
4878
  }))), activeForm && /* @__PURE__ */ React.createElement(FormBuilder, {
4444
4879
  form: activeForm,
@@ -4584,7 +5019,7 @@ const RenderForm = ({
4584
5019
  });
4585
5020
  const form = useMemo(() => {
4586
5021
  return new Form({
4587
- id: "update-form",
5022
+ id: `${schemaCollection.path}/${relativePath2}`,
4588
5023
  label: "form",
4589
5024
  fields: formInfo.fields,
4590
5025
  initialValues: document._values,
@@ -4616,21 +5051,17 @@ const RenderForm = ({
4616
5051
  }
4617
5052
  const activeForm = cms.state.forms.find(({ tinaForm }) => tinaForm.id === form.id);
4618
5053
  return /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React.createElement(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
4619
- className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
4620
- }, /* @__PURE__ */ React.createElement("div", {
4621
- className: "max-w-form mx-auto"
5054
+ className: `pt-3 pb-4 border-b border-gray-200 bg-white w-full grow-0 shrink basis-0 flex justify-center ${headerPadding}`
4622
5055
  }, /* @__PURE__ */ React.createElement("div", {
4623
- className: "mb-2"
4624
- }, /* @__PURE__ */ React.createElement("span", {
4625
- className: "block text-sm leading-tight uppercase text-gray-400 mb-1"
5056
+ className: "w-full max-w-form flex gap-1.5 justify-between items-center"
4626
5057
  }, /* @__PURE__ */ React.createElement(Link, {
4627
5058
  to: `/collections/${collection.name}/~${parentFolder2}`,
4628
- 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"
4629
- }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement(HiChevronRight, {
4630
- className: "inline-block -mt-0.5 opacity-50"
4631
- })), /* @__PURE__ */ React.createElement("span", {
4632
- className: "text-xl text-gray-700 font-medium leading-tight"
4633
- }, "Edit ", `${filename}.${collection.format}`)), /* @__PURE__ */ React.createElement(FormStatus, {
5059
+ 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"
5060
+ }, collection.label ? collection.label : collection.name), /* @__PURE__ */ React.createElement("span", {
5061
+ className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0"
5062
+ }, "/"), /* @__PURE__ */ React.createElement("span", {
5063
+ className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate"
5064
+ }, `${filename}.${collection.format}`), /* @__PURE__ */ React.createElement(FormStatus, {
4634
5065
  pristine: formIsPristine
4635
5066
  }))), activeForm && /* @__PURE__ */ React.createElement(FormBuilder, {
4636
5067
  form: activeForm,
@@ -4658,6 +5089,127 @@ const ScreenPage = () => {
4658
5089
  })));
4659
5090
  });
4660
5091
  };
5092
+ const IndexingPage = () => {
5093
+ const cms = useCMS();
5094
+ const tinaApi = cms.api.tina;
5095
+ const currentBranch = tinaApi.branch;
5096
+ const kind = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.kind");
5097
+ const { setCurrentBranch } = useBranchData();
5098
+ const [state, setState] = React.useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState"));
5099
+ const [errorMessage, setErrorMessage] = React.useState("");
5100
+ const [baseBranch, setBaseBranch] = React.useState(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.baseBranch"));
5101
+ const [searchParams] = useSearchParams();
5102
+ const back = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.back");
5103
+ const fullPath = localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.fullPath");
5104
+ const values = JSON.parse(localStorage == null ? void 0 : localStorage.getItem("tina.createBranchState.values"));
5105
+ const [branch, setBranch] = React.useState("tina/" + searchParams.get("branch"));
5106
+ useEffect(() => {
5107
+ const run = async () => {
5108
+ if (state === "starting") {
5109
+ try {
5110
+ console.log("starting", branch, formatBranchName(branch));
5111
+ const name = await tinaApi.createBranch({
5112
+ branchName: formatBranchName(branch),
5113
+ baseBranch: currentBranch
5114
+ });
5115
+ if (!name) {
5116
+ throw new Error("Branch creation failed.");
5117
+ }
5118
+ setBranch(name);
5119
+ localStorage.setItem("tina.createBranchState", "indexing");
5120
+ cms.alerts.success("Branch created.");
5121
+ setState("indexing");
5122
+ } catch (e) {
5123
+ console.error(e);
5124
+ cms.alerts.error("Branch creation failed: " + e.message);
5125
+ setErrorMessage("Branch creation failed, please try again. By refreshing the page.");
5126
+ setState("error");
5127
+ }
5128
+ }
5129
+ if (state === "indexing") {
5130
+ try {
5131
+ const [
5132
+ waitForIndexStatusPromise,
5133
+ _cancelWaitForIndexFunc
5134
+ ] = tinaApi.waitForIndexStatus({
5135
+ ref: branch
5136
+ });
5137
+ await waitForIndexStatusPromise;
5138
+ cms.alerts.success("Branch indexed.");
5139
+ localStorage.setItem("tina.createBranchState", "submitting");
5140
+ setState("submitting");
5141
+ } catch {
5142
+ cms.alerts.error("Branch indexing failed.");
5143
+ 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.');
5144
+ setState("error");
5145
+ }
5146
+ }
5147
+ if (state === "submitting") {
5148
+ try {
5149
+ setBaseBranch(tinaApi.branch);
5150
+ localStorage.setItem("tina.createBranchState.baseBranch", tinaApi.branch);
5151
+ setCurrentBranch(branch);
5152
+ const collection = tinaApi.schema.getCollectionByFullPath(fullPath);
5153
+ const api = new TinaAdminApi(cms);
5154
+ const params = api.schema.transformPayload(collection.name, values);
5155
+ const relativePath2 = fullPath.replace(`${collection.path}/`, "");
5156
+ if (await api.isAuthenticated()) {
5157
+ if (kind === "delete") {
5158
+ await api.deleteDocument(values);
5159
+ } else if (kind === "create") {
5160
+ await api.createDocument(collection, relativePath2, params);
5161
+ } else {
5162
+ await api.updateDocument(collection, relativePath2, params);
5163
+ }
5164
+ } else {
5165
+ const authMessage = `UpdateDocument failed: User is no longer authenticated; please login and try again.`;
5166
+ cms.alerts.error(authMessage);
5167
+ console.error(authMessage);
5168
+ return false;
5169
+ }
5170
+ localStorage.setItem("tina.createBranchState", "creatingPR");
5171
+ cms.alerts.success("Content saved.");
5172
+ setState("creatingPR");
5173
+ } catch (e) {
5174
+ console.error(e);
5175
+ cms.alerts.error("Content save failed.");
5176
+ setErrorMessage("Content save failed, please try again. If the problem persists please contact support.");
5177
+ setState("error");
5178
+ }
5179
+ }
5180
+ if (state === "creatingPR") {
5181
+ const foo = await tinaApi.createPullRequest({
5182
+ baseBranch,
5183
+ branch,
5184
+ title: "PR from TinaCMS"
5185
+ });
5186
+ console.log("PR created", foo);
5187
+ cms.alerts.success("Pull request created.");
5188
+ localStorage.setItem("tina.createBranchState", "done");
5189
+ setState("done");
5190
+ }
5191
+ if (state === "done") {
5192
+ window.location.href = back;
5193
+ }
5194
+ };
5195
+ if (fullPath && values && branch && back) {
5196
+ run();
5197
+ }
5198
+ }, [state]);
5199
+ if (!back || !fullPath || !values || !branch) {
5200
+ return /* @__PURE__ */ React.createElement(Wrapper, null, /* @__PURE__ */ React.createElement("p", null, "Missing params please try again."));
5201
+ }
5202
+ return /* @__PURE__ */ React.createElement(Wrapper, null, state !== "done" && state !== "error" && /* @__PURE__ */ React.createElement(BiLoaderAlt, {
5203
+ className: `opacity-70 text-blue-400 animate-spin w-10 h-auto`
5204
+ }), (state === "starting" || state === "creatingBranch") && /* @__PURE__ */ React.createElement("p", null, "Creating branch\u2026"), state === "indexing" && /* @__PURE__ */ React.createElement("p", null, "Indexing Content\u2026"), state === "submitting" && /* @__PURE__ */ React.createElement("p", null, "Saving content\u2026"), state === "creatingPR" && /* @__PURE__ */ React.createElement("p", null, "Creating Pull Request\u2026"), state === "error" && /* @__PURE__ */ React.createElement("p", {
5205
+ className: "flex items-center gap-1 text-red-700"
5206
+ }, /* @__PURE__ */ React.createElement(BiError, {
5207
+ className: "w-7 h-auto text-red-400 flex-shrink-0"
5208
+ }), " ", /* @__PURE__ */ React.createElement("b", null, "Error:"), " ", errorMessage, " "));
5209
+ };
5210
+ const Wrapper = ({ children }) => /* @__PURE__ */ React.createElement("div", {
5211
+ className: "w-full h-full flex flex-col justify-center items-center gap-4 p-6 text-xl text-gray-700"
5212
+ }, children);
4661
5213
  const Redirect = () => {
4662
5214
  React.useEffect(() => {
4663
5215
  if (window) {
@@ -4733,6 +5285,8 @@ const CheckSchema = ({
4733
5285
  const cms = useCMS();
4734
5286
  const api = new TinaAdminApi(cms);
4735
5287
  const url = api.api.contentApiUrl;
5288
+ const [schemaMissingError, setSchemaMissingError] = React.useState(false);
5289
+ const currentBranch = decodeURIComponent(cms.api.tina.branch);
4736
5290
  useEffect(() => {
4737
5291
  if (schemaJson && cms) {
4738
5292
  api.checkGraphqlSchema({
@@ -4741,10 +5295,32 @@ const CheckSchema = ({
4741
5295
  if (x === false) {
4742
5296
  cms.alerts.error("GraphQL Schema Mismatch. Editing may not work. If you just switched branches, try going back to the previous branch");
4743
5297
  }
5298
+ }).catch((e) => {
5299
+ if (e.message.includes("has not been indexed by Tina Cloud")) {
5300
+ setSchemaMissingError(true);
5301
+ } else {
5302
+ throw e;
5303
+ }
4744
5304
  });
4745
5305
  }
4746
5306
  }, [cms, JSON.stringify(schemaJson || {}), url]);
4747
- return children;
5307
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, schemaMissingError ? /* @__PURE__ */ React.createElement(Modal, null, /* @__PURE__ */ React.createElement(PopupModal, null, /* @__PURE__ */ React.createElement(ModalHeader, null, "Branch Not Found"), /* @__PURE__ */ React.createElement(ModalBody, {
5308
+ padded: true
5309
+ }, /* @__PURE__ */ React.createElement("div", {
5310
+ className: "tina-prose"
5311
+ }, "The current branch (", /* @__PURE__ */ React.createElement("span", {
5312
+ className: "font-bold"
5313
+ }, currentBranch), ") has either been merged or deleted.")), /* @__PURE__ */ React.createElement(ModalActions, null, /* @__PURE__ */ React.createElement("div", {
5314
+ className: "flex-1"
5315
+ }), /* @__PURE__ */ React.createElement(Button, {
5316
+ style: { flexGrow: 1 },
5317
+ className: "w-full",
5318
+ variant: "primary",
5319
+ onClick: () => {
5320
+ window.localStorage.removeItem("tinacms-current-branch");
5321
+ window.location.reload();
5322
+ }
5323
+ }, "Switch back to default branch")))) : children);
4748
5324
  };
4749
5325
  const TinaAdmin = ({
4750
5326
  preview,
@@ -4770,7 +5346,7 @@ const TinaAdmin = ({
4770
5346
  return typeof ((_a2 = x == null ? void 0 : x.ui) == null ? void 0 : _a2.router) === "function";
4771
5347
  });
4772
5348
  const hasRouter = Boolean(collectionWithRouter);
4773
- return /* @__PURE__ */ React.createElement(CheckSchema, {
5349
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckSchema, {
4774
5350
  schemaJson
4775
5351
  }, /* @__PURE__ */ React.createElement(HashRouter, null, /* @__PURE__ */ React.createElement(SetPreviewFlag, {
4776
5352
  preview,
@@ -4784,6 +5360,11 @@ const TinaAdmin = ({
4784
5360
  }), /* @__PURE__ */ React.createElement(Route, {
4785
5361
  path: "graphql",
4786
5362
  element: /* @__PURE__ */ React.createElement(PlainLayout, null, /* @__PURE__ */ React.createElement(Playground, null))
5363
+ }), /* @__PURE__ */ React.createElement(Route, {
5364
+ path: "branch/new",
5365
+ element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
5366
+ cms
5367
+ }, /* @__PURE__ */ React.createElement(IndexingPage, null))
4787
5368
  }), /* @__PURE__ */ React.createElement(Route, {
4788
5369
  path: "collections/new/:collectionName",
4789
5370
  element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
@@ -4841,7 +5422,7 @@ const TinaAdmin = ({
4841
5422
  }, /* @__PURE__ */ React.createElement(DefaultWrapper, {
4842
5423
  cms
4843
5424
  }, /* @__PURE__ */ React.createElement(DashboardPage, null)))
4844
- }))));
5425
+ })))));
4845
5426
  } else {
4846
5427
  return /* @__PURE__ */ React.createElement(Layout, null, /* @__PURE__ */ React.createElement(HashRouter, null, /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
4847
5428
  path: "logout",