tinacms 1.4.1 → 1.4.2

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
@@ -3063,7 +3063,20 @@ const GetCollection = ({
3063
3063
  children,
3064
3064
  filterArgs
3065
3065
  }) => {
3066
+ const navigate = useNavigate();
3066
3067
  const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey, filterArgs) || {};
3068
+ useEffect(() => {
3069
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3070
+ if (loading)
3071
+ return;
3072
+ const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
3073
+ const allowCreate = (_c = (_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) != null ? _c : true;
3074
+ const allowDelete = (_f = (_e = (_d = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _d.allowedActions) == null ? void 0 : _e.delete) != null ? _f : true;
3075
+ if (!allowCreate && !allowDelete && ((_h = (_g = collection.documents) == null ? void 0 : _g.edges) == null ? void 0 : _h.length) === 1) {
3076
+ const doc = collection.documents.edges[0].node;
3077
+ handleNavigate(navigate, cms, collection, collectionDefinition, doc);
3078
+ }
3079
+ }, [(collection == null ? void 0 : collection.name) || "", loading]);
3067
3080
  if (error) {
3068
3081
  return /* @__PURE__ */ React.createElement(FullscreenError, null);
3069
3082
  }
package/dist/index.js CHANGED
@@ -3078,7 +3078,20 @@ This will work when developing locally but NOT when deployed to production.
3078
3078
  children,
3079
3079
  filterArgs
3080
3080
  }) => {
3081
+ const navigate = reactRouterDom.useNavigate();
3081
3082
  const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey, filterArgs) || {};
3083
+ React.useEffect(() => {
3084
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3085
+ if (loading)
3086
+ return;
3087
+ const collectionDefinition = cms.api.tina.schema.getCollection(collection.name);
3088
+ const allowCreate = (_c = (_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) != null ? _c : true;
3089
+ const allowDelete = (_f = (_e = (_d = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _d.allowedActions) == null ? void 0 : _e.delete) != null ? _f : true;
3090
+ if (!allowCreate && !allowDelete && ((_h = (_g = collection.documents) == null ? void 0 : _g.edges) == null ? void 0 : _h.length) === 1) {
3091
+ const doc = collection.documents.edges[0].node;
3092
+ handleNavigate(navigate, cms, collection, collectionDefinition, doc);
3093
+ }
3094
+ }, [(collection == null ? void 0 : collection.name) || "", loading]);
3082
3095
  if (error) {
3083
3096
  return /* @__PURE__ */ React__default["default"].createElement(FullscreenError, null);
3084
3097
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {
@@ -56,7 +56,7 @@
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",
59
+ "@tinacms/schema-tools": "1.4.2",
60
60
  "@tinacms/sharedctx": "1.0.1",
61
61
  "@tinacms/toolkit": "1.6.1",
62
62
  "crypto-js": "^4.0.0",