tinacms 0.61.1 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/index.es.js +40 -22
- package/dist/index.js +40 -22
- package/dist/tina-cms.d.ts +2 -0
- package/package.json +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# tinacms
|
|
2
2
|
|
|
3
|
+
## 0.62.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 70da62fe8: deprecated the use of `getStaticPropsForTina`
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 0afa75df1: 2342 - [TinaAdmin] Truncates the `filename` column for the Document List View
|
|
12
|
+
- 7dafce89d: Fixed issue where content creator was invalid
|
|
13
|
+
- 3de8c6165: Enabled branch creation in branch switcher
|
|
14
|
+
- fee183f8f: add "switch to default branch" recover option to error boundary
|
|
15
|
+
- 5c070a83f: feat: Add UI banner for when in localMode
|
|
16
|
+
- Updated dependencies [ddf81a4fd]
|
|
17
|
+
- Updated dependencies [20260a82d]
|
|
18
|
+
- Updated dependencies [0370147fb]
|
|
19
|
+
- Updated dependencies [3de8c6165]
|
|
20
|
+
- Updated dependencies [2eaad97bf]
|
|
21
|
+
- Updated dependencies [5c070a83f]
|
|
22
|
+
- @tinacms/toolkit@0.56.5
|
|
23
|
+
|
|
3
24
|
## 0.61.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/client/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export declare class Client {
|
|
|
42
42
|
private options;
|
|
43
43
|
events: EventBus;
|
|
44
44
|
constructor({ tokenStorage, ...options }: ServerOptions);
|
|
45
|
+
get isLocalMode(): boolean;
|
|
45
46
|
setBranch(branchName: string): void;
|
|
46
47
|
addPendingContent: (props: any) => Promise<unknown>;
|
|
47
48
|
getSchema: () => Promise<GraphQLSchema>;
|
package/dist/index.es.js
CHANGED
|
@@ -374,6 +374,11 @@ function assertIsUnionType(type) {
|
|
|
374
374
|
throw new Error(`Expected an instance of GraphQLUnionType for type ${type.name}`);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
+
const captureBranchName = /^refs\/heads\/(.*)/;
|
|
378
|
+
const parseRefForBranchName = (ref) => {
|
|
379
|
+
const matches = ref.match(captureBranchName);
|
|
380
|
+
return matches[1];
|
|
381
|
+
};
|
|
377
382
|
class Client {
|
|
378
383
|
constructor(_a) {
|
|
379
384
|
var _b = _a, { tokenStorage = "MEMORY" } = _b, options = __objRest(_b, ["tokenStorage"]);
|
|
@@ -464,6 +469,9 @@ mutation addPendingDocumentMutation(
|
|
|
464
469
|
break;
|
|
465
470
|
}
|
|
466
471
|
}
|
|
472
|
+
get isLocalMode() {
|
|
473
|
+
return this.contentApiUrl.includes("localhost");
|
|
474
|
+
}
|
|
467
475
|
setBranch(branchName) {
|
|
468
476
|
var _a, _b, _c;
|
|
469
477
|
const encodedBranch = encodeURIComponent(branchName);
|
|
@@ -591,15 +599,15 @@ mutation addPendingDocumentMutation(
|
|
|
591
599
|
try {
|
|
592
600
|
const res = await this.fetchWithToken(url, {
|
|
593
601
|
method: "POST",
|
|
594
|
-
body: {
|
|
602
|
+
body: JSON.stringify({
|
|
595
603
|
baseBranch,
|
|
596
604
|
branchName
|
|
597
|
-
},
|
|
605
|
+
}),
|
|
598
606
|
headers: {
|
|
599
607
|
"Content-Type": "application/json"
|
|
600
608
|
}
|
|
601
609
|
});
|
|
602
|
-
return
|
|
610
|
+
return await res.json().then((r) => parseRefForBranchName(r.data.ref));
|
|
603
611
|
} catch (error) {
|
|
604
612
|
console.error("There was an error creating a new branch.", error);
|
|
605
613
|
return null;
|
|
@@ -1370,7 +1378,7 @@ const useDocumentCreatorPlugin = (args) => {
|
|
|
1370
1378
|
}));
|
|
1371
1379
|
};
|
|
1372
1380
|
run();
|
|
1373
|
-
}, [cms
|
|
1381
|
+
}, [cms]);
|
|
1374
1382
|
React.useEffect(() => {
|
|
1375
1383
|
if (plugin) {
|
|
1376
1384
|
cms.plugins.add(plugin);
|
|
@@ -1382,6 +1390,18 @@ const useDocumentCreatorPlugin = (args) => {
|
|
|
1382
1390
|
};
|
|
1383
1391
|
}, [plugin]);
|
|
1384
1392
|
};
|
|
1393
|
+
const errorButtonStyles = {
|
|
1394
|
+
background: "#eb6337",
|
|
1395
|
+
padding: "12px 18px",
|
|
1396
|
+
cursor: "pointer",
|
|
1397
|
+
borderRadius: "50px",
|
|
1398
|
+
textTransform: "uppercase",
|
|
1399
|
+
letterSpacing: "2px",
|
|
1400
|
+
fontWeight: "bold",
|
|
1401
|
+
border: "none",
|
|
1402
|
+
color: "white",
|
|
1403
|
+
margin: "1rem 0"
|
|
1404
|
+
};
|
|
1385
1405
|
const SetupHooks = (props) => {
|
|
1386
1406
|
const cms = useCMS();
|
|
1387
1407
|
const [payload, isLoading] = useGraphqlForms({
|
|
@@ -1411,6 +1431,8 @@ class ErrorBoundary extends React.Component {
|
|
|
1411
1431
|
return { hasError: true, message: error.message };
|
|
1412
1432
|
}
|
|
1413
1433
|
render() {
|
|
1434
|
+
const branchData = window.localStorage.getItem("tinacms-current-branch");
|
|
1435
|
+
const hasBranchData = branchData && branchData.length > 0;
|
|
1414
1436
|
if (this.state.hasError && !this.state.pageRefresh) {
|
|
1415
1437
|
return /* @__PURE__ */ React.createElement("div", {
|
|
1416
1438
|
style: {
|
|
@@ -1431,25 +1453,21 @@ class ErrorBoundary extends React.Component {
|
|
|
1431
1453
|
}
|
|
1432
1454
|
}, /* @__PURE__ */ React.createElement("h3", {
|
|
1433
1455
|
style: { color: "#eb6337" }
|
|
1434
|
-
}, "TinaCMS Render Error"), /* @__PURE__ */ React.createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React.createElement("pre",
|
|
1435
|
-
style: {
|
|
1436
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
1437
|
-
style:
|
|
1438
|
-
background: "#eb6337",
|
|
1439
|
-
padding: "12px 18px",
|
|
1440
|
-
cursor: "pointer",
|
|
1441
|
-
borderRadius: "50px",
|
|
1442
|
-
textTransform: "uppercase",
|
|
1443
|
-
letterSpacing: "2px",
|
|
1444
|
-
fontWeight: "bold",
|
|
1445
|
-
border: "none",
|
|
1446
|
-
color: "white"
|
|
1447
|
-
},
|
|
1456
|
+
}, "TinaCMS Render Error"), /* @__PURE__ */ React.createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React.createElement("pre", {
|
|
1457
|
+
style: { marginTop: "1rem", overflowX: "auto" }
|
|
1458
|
+
}, this.state.message), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`), /* @__PURE__ */ React.createElement("button", {
|
|
1459
|
+
style: errorButtonStyles,
|
|
1448
1460
|
onClick: () => {
|
|
1449
1461
|
this.setState({ pageRefresh: true });
|
|
1450
1462
|
setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
|
|
1451
1463
|
}
|
|
1452
|
-
}, "Refresh"))
|
|
1464
|
+
}, "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("button", {
|
|
1465
|
+
style: errorButtonStyles,
|
|
1466
|
+
onClick: () => {
|
|
1467
|
+
window.localStorage.removeItem("tinacms-current-branch");
|
|
1468
|
+
window.location.reload();
|
|
1469
|
+
}
|
|
1470
|
+
}, "Switch to default branch"))));
|
|
1453
1471
|
}
|
|
1454
1472
|
if (this.state.pageRefresh) {
|
|
1455
1473
|
return /* @__PURE__ */ React.createElement(Loader, null, "Let's try that again.");
|
|
@@ -1973,11 +1991,11 @@ const CollectionListPage = () => {
|
|
|
1973
1991
|
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1974
1992
|
}, "Filename"), /* @__PURE__ */ React.createElement(Link, {
|
|
1975
1993
|
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1976
|
-
className: "h-5 leading-5
|
|
1994
|
+
className: "h-5 leading-5 flex max-w-xs"
|
|
1977
1995
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
1978
|
-
className: "leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
1996
|
+
className: "flex-shrink-1 leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
1979
1997
|
}, document2.node.sys.filename), /* @__PURE__ */ React.createElement("span", {
|
|
1980
|
-
className: "leading-5 text-base font-medium text-gray-300"
|
|
1998
|
+
className: "flex-shrink-0 leading-5 text-base font-medium text-gray-300"
|
|
1981
1999
|
}, document2.node.sys.extension))), /* @__PURE__ */ React.createElement("td", {
|
|
1982
2000
|
className: "px-5 py-3 whitespace-nowrap"
|
|
1983
2001
|
}, /* @__PURE__ */ React.createElement("span", {
|
package/dist/index.js
CHANGED
|
@@ -394,6 +394,11 @@ var __objRest = (source, exclude) => {
|
|
|
394
394
|
throw new Error(`Expected an instance of GraphQLUnionType for type ${type.name}`);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
+
const captureBranchName = /^refs\/heads\/(.*)/;
|
|
398
|
+
const parseRefForBranchName = (ref) => {
|
|
399
|
+
const matches = ref.match(captureBranchName);
|
|
400
|
+
return matches[1];
|
|
401
|
+
};
|
|
397
402
|
class Client {
|
|
398
403
|
constructor(_a) {
|
|
399
404
|
var _b = _a, { tokenStorage = "MEMORY" } = _b, options = __objRest(_b, ["tokenStorage"]);
|
|
@@ -484,6 +489,9 @@ mutation addPendingDocumentMutation(
|
|
|
484
489
|
break;
|
|
485
490
|
}
|
|
486
491
|
}
|
|
492
|
+
get isLocalMode() {
|
|
493
|
+
return this.contentApiUrl.includes("localhost");
|
|
494
|
+
}
|
|
487
495
|
setBranch(branchName) {
|
|
488
496
|
var _a, _b, _c;
|
|
489
497
|
const encodedBranch = encodeURIComponent(branchName);
|
|
@@ -611,15 +619,15 @@ mutation addPendingDocumentMutation(
|
|
|
611
619
|
try {
|
|
612
620
|
const res = await this.fetchWithToken(url, {
|
|
613
621
|
method: "POST",
|
|
614
|
-
body: {
|
|
622
|
+
body: JSON.stringify({
|
|
615
623
|
baseBranch,
|
|
616
624
|
branchName
|
|
617
|
-
},
|
|
625
|
+
}),
|
|
618
626
|
headers: {
|
|
619
627
|
"Content-Type": "application/json"
|
|
620
628
|
}
|
|
621
629
|
});
|
|
622
|
-
return
|
|
630
|
+
return await res.json().then((r) => parseRefForBranchName(r.data.ref));
|
|
623
631
|
} catch (error) {
|
|
624
632
|
console.error("There was an error creating a new branch.", error);
|
|
625
633
|
return null;
|
|
@@ -1390,7 +1398,7 @@ mutation addPendingDocumentMutation(
|
|
|
1390
1398
|
}));
|
|
1391
1399
|
};
|
|
1392
1400
|
run();
|
|
1393
|
-
}, [cms
|
|
1401
|
+
}, [cms]);
|
|
1394
1402
|
React__default["default"].useEffect(() => {
|
|
1395
1403
|
if (plugin) {
|
|
1396
1404
|
cms.plugins.add(plugin);
|
|
@@ -1402,6 +1410,18 @@ mutation addPendingDocumentMutation(
|
|
|
1402
1410
|
};
|
|
1403
1411
|
}, [plugin]);
|
|
1404
1412
|
};
|
|
1413
|
+
const errorButtonStyles = {
|
|
1414
|
+
background: "#eb6337",
|
|
1415
|
+
padding: "12px 18px",
|
|
1416
|
+
cursor: "pointer",
|
|
1417
|
+
borderRadius: "50px",
|
|
1418
|
+
textTransform: "uppercase",
|
|
1419
|
+
letterSpacing: "2px",
|
|
1420
|
+
fontWeight: "bold",
|
|
1421
|
+
border: "none",
|
|
1422
|
+
color: "white",
|
|
1423
|
+
margin: "1rem 0"
|
|
1424
|
+
};
|
|
1405
1425
|
const SetupHooks = (props) => {
|
|
1406
1426
|
const cms = toolkit.useCMS();
|
|
1407
1427
|
const [payload, isLoading] = useGraphqlForms({
|
|
@@ -1431,6 +1451,8 @@ mutation addPendingDocumentMutation(
|
|
|
1431
1451
|
return { hasError: true, message: error.message };
|
|
1432
1452
|
}
|
|
1433
1453
|
render() {
|
|
1454
|
+
const branchData = window.localStorage.getItem("tinacms-current-branch");
|
|
1455
|
+
const hasBranchData = branchData && branchData.length > 0;
|
|
1434
1456
|
if (this.state.hasError && !this.state.pageRefresh) {
|
|
1435
1457
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1436
1458
|
style: {
|
|
@@ -1451,25 +1473,21 @@ mutation addPendingDocumentMutation(
|
|
|
1451
1473
|
}
|
|
1452
1474
|
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1453
1475
|
style: { color: "#eb6337" }
|
|
1454
|
-
}, "TinaCMS Render Error"), /* @__PURE__ */ React__default["default"].createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React__default["default"].createElement("pre",
|
|
1455
|
-
style: {
|
|
1456
|
-
}, /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
1457
|
-
style:
|
|
1458
|
-
background: "#eb6337",
|
|
1459
|
-
padding: "12px 18px",
|
|
1460
|
-
cursor: "pointer",
|
|
1461
|
-
borderRadius: "50px",
|
|
1462
|
-
textTransform: "uppercase",
|
|
1463
|
-
letterSpacing: "2px",
|
|
1464
|
-
fontWeight: "bold",
|
|
1465
|
-
border: "none",
|
|
1466
|
-
color: "white"
|
|
1467
|
-
},
|
|
1476
|
+
}, "TinaCMS Render Error"), /* @__PURE__ */ React__default["default"].createElement("p", null, "Tina caught an error while updating the page:"), /* @__PURE__ */ React__default["default"].createElement("pre", {
|
|
1477
|
+
style: { marginTop: "1rem", overflowX: "auto" }
|
|
1478
|
+
}, this.state.message), /* @__PURE__ */ React__default["default"].createElement("br", null), /* @__PURE__ */ React__default["default"].createElement("p", null, `If you've just updated the form, undo your most recent changes and click "refresh". If after a few refreshes, you're still encountering this error. There is a bigger issue with the site. Please reach out to your site admin.`), /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
1479
|
+
style: errorButtonStyles,
|
|
1468
1480
|
onClick: () => {
|
|
1469
1481
|
this.setState({ pageRefresh: true });
|
|
1470
1482
|
setTimeout(() => this.setState({ hasError: false, pageRefresh: false }), 3e3);
|
|
1471
1483
|
}
|
|
1472
|
-
}, "Refresh"))
|
|
1484
|
+
}, "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("button", {
|
|
1485
|
+
style: errorButtonStyles,
|
|
1486
|
+
onClick: () => {
|
|
1487
|
+
window.localStorage.removeItem("tinacms-current-branch");
|
|
1488
|
+
window.location.reload();
|
|
1489
|
+
}
|
|
1490
|
+
}, "Switch to default branch"))));
|
|
1473
1491
|
}
|
|
1474
1492
|
if (this.state.pageRefresh) {
|
|
1475
1493
|
return /* @__PURE__ */ React__default["default"].createElement(Loader, null, "Let's try that again.");
|
|
@@ -1993,11 +2011,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1993
2011
|
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1994
2012
|
}, "Filename"), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1995
2013
|
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1996
|
-
className: "h-5 leading-5
|
|
2014
|
+
className: "h-5 leading-5 flex max-w-xs"
|
|
1997
2015
|
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1998
|
-
className: "leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
2016
|
+
className: "flex-shrink-1 leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
1999
2017
|
}, document2.node.sys.filename), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
2000
|
-
className: "leading-5 text-base font-medium text-gray-300"
|
|
2018
|
+
className: "flex-shrink-0 leading-5 text-base font-medium text-gray-300"
|
|
2001
2019
|
}, document2.node.sys.extension))), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
2002
2020
|
className: "px-5 py-3 whitespace-nowrap"
|
|
2003
2021
|
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
package/dist/tina-cms.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export declare const TinaCMSProvider2: ({ children, branch, clientId, isLocalCli
|
|
|
42
42
|
tinaioConfig?: TinaIOConfig;
|
|
43
43
|
}) => JSX.Element;
|
|
44
44
|
/**
|
|
45
|
+
* @deprecated v0.62.0: Use `staticRequest` and a "try catch" block instead. see https://tina.io/docs/features/data-fetching/#querying-tina-content-in-nextjs for more details
|
|
46
|
+
*
|
|
45
47
|
* A convenience function which makes a GraphQL request
|
|
46
48
|
* to a local GraphQL server and ensures the response fits
|
|
47
49
|
* the shape expected by Tina context in your application
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"types": "yarn tsc",
|
|
19
|
-
"build": "echo \"Run `yarn build` from the root of the repository instead\""
|
|
19
|
+
"build": "echo \"Run `yarn build` from the root of the repository instead\"",
|
|
20
|
+
"test": "jest --env=jsdom --passWithNoTests"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"@headlessui/react": "^1.4.1",
|
|
23
24
|
"@heroicons/react": "^1.0.4",
|
|
24
25
|
"@tinacms/sharedctx": "0.0.1",
|
|
25
|
-
"@tinacms/toolkit": "0.56.
|
|
26
|
+
"@tinacms/toolkit": "0.56.5",
|
|
26
27
|
"crypto-js": "^4.0.0",
|
|
27
28
|
"final-form": "4.20.1",
|
|
28
29
|
"graphql": "^15.1.0",
|
|
@@ -33,14 +34,20 @@
|
|
|
33
34
|
"yup": "^0.32.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@testing-library/jest-dom": "^5.11.9",
|
|
38
|
+
"@testing-library/react": "^12.0.0",
|
|
39
|
+
"@testing-library/user-event": "^12.7.0",
|
|
36
40
|
"@tinacms/scripts": "0.50.4",
|
|
41
|
+
"@types/jest": "^27.0.1",
|
|
37
42
|
"@types/lodash": "^4.14.169",
|
|
38
43
|
"@types/node": "^14.0.13",
|
|
39
44
|
"@types/react": "^16.9.38",
|
|
40
45
|
"@types/yup": "^0.29.10",
|
|
46
|
+
"jest": "^27.0.6",
|
|
41
47
|
"next": "9.4.2",
|
|
42
48
|
"react": "16.14.0",
|
|
43
49
|
"react-dom": "16.14.0",
|
|
50
|
+
"react-is": "^17.0.2",
|
|
44
51
|
"styled-components": "^5.2.0",
|
|
45
52
|
"typescript": "^4.3.5"
|
|
46
53
|
},
|