tinacms 1.4.1 → 1.4.3

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.
@@ -2,5 +2,10 @@
2
2
 
3
3
  */
4
4
  /// <reference types="react" />
5
+ import { NavigateFunction } from 'react-router-dom';
6
+ import { TinaCMS } from '@tinacms/toolkit';
7
+ import type { CollectionResponse, DocumentSys } from '../types';
8
+ import type { Collection } from '@tinacms/schema-tools';
9
+ export declare const handleNavigate: (navigate: NavigateFunction, cms: TinaCMS, collection: CollectionResponse, collectionDefinition: Collection<true>, document: DocumentSys) => any;
5
10
  declare const CollectionListPage: () => JSX.Element;
6
11
  export default CollectionListPage;
package/dist/index.es.js CHANGED
@@ -45,9 +45,7 @@ const parseRefForBranchName = (ref) => {
45
45
  return matches[1];
46
46
  };
47
47
  const ListBranchResponse = z.object({
48
- name: z.string(),
49
- protected: z.boolean(),
50
- commit: z.object({ sha: z.string(), url: z.string() })
48
+ name: z.string()
51
49
  }).array();
52
50
  const IndexStatusResponse = z.object({
53
51
  status: z.union([
@@ -3063,7 +3061,20 @@ const GetCollection = ({
3063
3061
  children,
3064
3062
  filterArgs
3065
3063
  }) => {
3064
+ const navigate = useNavigate();
3066
3065
  const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey, filterArgs) || {};
3066
+ useEffect(() => {
3067
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3068
+ if (loading)
3069
+ return;
3070
+ const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
3071
+ const allowCreate = (_c = (_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) != null ? _c : true;
3072
+ const allowDelete = (_f = (_e = (_d = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _d.allowedActions) == null ? void 0 : _e.delete) != null ? _f : true;
3073
+ if (!allowCreate && !allowDelete && ((_h = (_g = collection.documents) == null ? void 0 : _g.edges) == null ? void 0 : _h.length) === 1) {
3074
+ const doc = collection.documents.edges[0].node;
3075
+ handleNavigate(navigate, cms, collection, collectionDefinition, doc);
3076
+ }
3077
+ }, [(collection == null ? void 0 : collection.name) || "", loading]);
3067
3078
  if (error) {
3068
3079
  return /* @__PURE__ */ React.createElement(FullscreenError, null);
3069
3080
  }
package/dist/index.js CHANGED
@@ -60,9 +60,7 @@
60
60
  return matches[1];
61
61
  };
62
62
  const ListBranchResponse = zod.z.object({
63
- name: zod.z.string(),
64
- protected: zod.z.boolean(),
65
- commit: zod.z.object({ sha: zod.z.string(), url: zod.z.string() })
63
+ name: zod.z.string()
66
64
  }).array();
67
65
  const IndexStatusResponse = zod.z.object({
68
66
  status: zod.z.union([
@@ -3078,7 +3076,20 @@ This will work when developing locally but NOT when deployed to production.
3078
3076
  children,
3079
3077
  filterArgs
3080
3078
  }) => {
3079
+ const navigate = reactRouterDom.useNavigate();
3081
3080
  const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey, filterArgs) || {};
3081
+ React.useEffect(() => {
3082
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3083
+ if (loading)
3084
+ return;
3085
+ const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
3086
+ const allowCreate = (_c = (_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) != null ? _c : true;
3087
+ const allowDelete = (_f = (_e = (_d = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _d.allowedActions) == null ? void 0 : _e.delete) != null ? _f : true;
3088
+ if (!allowCreate && !allowDelete && ((_h = (_g = collection.documents) == null ? void 0 : _g.edges) == null ? void 0 : _h.length) === 1) {
3089
+ const doc = collection.documents.edges[0].node;
3090
+ handleNavigate(navigate, cms, collection, collectionDefinition, doc);
3091
+ }
3092
+ }, [(collection == null ? void 0 : collection.name) || "", loading]);
3082
3093
  if (error) {
3083
3094
  return /* @__PURE__ */ React__default["default"].createElement(FullscreenError, null);
3084
3095
  }
@@ -217,11 +217,6 @@ export declare class Client {
217
217
  timestamp?: number;
218
218
  };
219
219
  name?: string;
220
- protected?: boolean;
221
- commit?: {
222
- url?: string;
223
- sha?: string;
224
- };
225
220
  }[]>;
226
221
  createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
227
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -56,9 +56,6 @@
56
56
  "@headlessui/react": "^1.5.0",
57
57
  "@heroicons/react": "^1.0.4",
58
58
  "@react-hook/window-size": "^3.0.7",
59
- "@tinacms/schema-tools": "1.4.1",
60
- "@tinacms/sharedctx": "1.0.1",
61
- "@tinacms/toolkit": "1.6.1",
62
59
  "crypto-js": "^4.0.0",
63
60
  "encoding": "0.1.13",
64
61
  "fetch-ponyfill": "^7.1.0",
@@ -70,7 +67,10 @@
70
67
  "react-icons": "^4.3.1",
71
68
  "react-router-dom": "6",
72
69
  "yup": "^0.32.0",
73
- "zod": "^3.14.3"
70
+ "zod": "^3.14.3",
71
+ "@tinacms/schema-tools": "1.4.2",
72
+ "@tinacms/sharedctx": "1.0.1",
73
+ "@tinacms/toolkit": "1.6.2"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@graphql-tools/utils": "^8.6.1",
@@ -78,7 +78,6 @@
78
78
  "@testing-library/react": "^12.0.0",
79
79
  "@testing-library/react-hooks": "^7.0.2",
80
80
  "@testing-library/user-event": "^12.7.0",
81
- "@tinacms/scripts": "1.1.0",
82
81
  "@types/jest": "^27.0.1",
83
82
  "@types/lodash": "^4.14.169",
84
83
  "@types/node": "^14.0.13",
@@ -92,7 +91,8 @@
92
91
  "react": "17.0.2",
93
92
  "react-dom": "17.0.2",
94
93
  "react-is": "^17.0.2",
95
- "typescript": "4.3.5"
94
+ "typescript": "4.3.5",
95
+ "@tinacms/scripts": "1.1.0"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "react": ">=16.14.0",