tinacms 0.66.7 → 0.66.8
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 +10 -0
- package/dist/admin/api.d.ts +2 -0
- package/dist/index.es.js +98 -79
- package/dist/index.js +98 -79
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# tinacms
|
|
2
2
|
|
|
3
|
+
## 0.66.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4923a2d66: Checks isAuthenticated() before making requests to the GraphQL client
|
|
8
|
+
- Updated dependencies [106549814]
|
|
9
|
+
- Updated dependencies [4923a2d66]
|
|
10
|
+
- Updated dependencies [a07ff39bb]
|
|
11
|
+
- @tinacms/toolkit@0.56.17
|
|
12
|
+
|
|
3
13
|
## 0.66.7
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/admin/api.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export declare class TinaAdminApi {
|
|
|
17
17
|
request: (query: string, { variables }: {
|
|
18
18
|
variables: object;
|
|
19
19
|
}) => any;
|
|
20
|
+
isAuthenticated: () => boolean;
|
|
20
21
|
};
|
|
21
22
|
constructor(cms: TinaCMS);
|
|
23
|
+
isAuthenticated(): Promise<boolean>;
|
|
22
24
|
fetchCollections(): Promise<{
|
|
23
25
|
getCollections: Collection[];
|
|
24
26
|
}>;
|
package/dist/index.es.js
CHANGED
|
@@ -1161,6 +1161,9 @@ class TinaAdminApi {
|
|
|
1161
1161
|
constructor(cms) {
|
|
1162
1162
|
this.api = cms.api.tina;
|
|
1163
1163
|
}
|
|
1164
|
+
async isAuthenticated() {
|
|
1165
|
+
return await this.api.isAuthenticated();
|
|
1166
|
+
}
|
|
1164
1167
|
async fetchCollections() {
|
|
1165
1168
|
const response = await this.api.request(`#graphql
|
|
1166
1169
|
query{
|
|
@@ -2293,16 +2296,18 @@ const useGetCollections = (cms) => {
|
|
|
2293
2296
|
const [error, setError] = useState(void 0);
|
|
2294
2297
|
useEffect(() => {
|
|
2295
2298
|
const fetchCollections = async () => {
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2299
|
+
if (await api.isAuthenticated()) {
|
|
2300
|
+
try {
|
|
2301
|
+
const response = await api.fetchCollections();
|
|
2302
|
+
setCollections(response.getCollections);
|
|
2303
|
+
} catch (error2) {
|
|
2304
|
+
cms.alerts.error(`[${error2.name}] GetCollections failed: ${error2.message}`, 30 * 1e3);
|
|
2305
|
+
console.error(error2);
|
|
2306
|
+
setCollections([]);
|
|
2307
|
+
setError(error2);
|
|
2308
|
+
}
|
|
2309
|
+
setLoading(false);
|
|
2304
2310
|
}
|
|
2305
|
-
setLoading(false);
|
|
2306
2311
|
};
|
|
2307
2312
|
setLoading(true);
|
|
2308
2313
|
fetchCollections();
|
|
@@ -2591,16 +2596,18 @@ const useGetCollection = (cms, collectionName, includeDocuments = true) => {
|
|
|
2591
2596
|
const [error, setError] = useState(void 0);
|
|
2592
2597
|
useEffect(() => {
|
|
2593
2598
|
const fetchCollection = async () => {
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2599
|
+
if (await api.isAuthenticated()) {
|
|
2600
|
+
try {
|
|
2601
|
+
const response = await api.fetchCollection(collectionName, includeDocuments);
|
|
2602
|
+
setCollection(response.getCollection);
|
|
2603
|
+
} catch (error2) {
|
|
2604
|
+
cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
|
|
2605
|
+
console.error(error2);
|
|
2606
|
+
setCollection(void 0);
|
|
2607
|
+
setError(error2);
|
|
2608
|
+
}
|
|
2609
|
+
setLoading(false);
|
|
2602
2610
|
}
|
|
2603
|
-
setLoading(false);
|
|
2604
2611
|
};
|
|
2605
2612
|
setLoading(true);
|
|
2606
2613
|
fetchCollection();
|
|
@@ -2614,13 +2621,11 @@ const GetCollection = ({
|
|
|
2614
2621
|
children
|
|
2615
2622
|
}) => {
|
|
2616
2623
|
const { collection, loading, error } = useGetCollection(cms, collectionName, includeDocuments);
|
|
2617
|
-
if (
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
return null;
|
|
2623
|
-
}
|
|
2624
|
+
if (error) {
|
|
2625
|
+
return null;
|
|
2626
|
+
}
|
|
2627
|
+
if (loading) {
|
|
2628
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
2624
2629
|
}
|
|
2625
2630
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, loading));
|
|
2626
2631
|
};
|
|
@@ -2740,37 +2745,39 @@ const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
|
2740
2745
|
const [error, setError] = useState(void 0);
|
|
2741
2746
|
useEffect(() => {
|
|
2742
2747
|
const fetchDocumentFields = async () => {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2748
|
+
if (await api.isAuthenticated()) {
|
|
2749
|
+
try {
|
|
2750
|
+
const response = await api.fetchDocumentFields();
|
|
2751
|
+
const documentFields = response.getDocumentFields;
|
|
2752
|
+
const collection = documentFields[collectionName].collection;
|
|
2753
|
+
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
2754
|
+
let fields = void 0;
|
|
2755
|
+
let template = void 0;
|
|
2756
|
+
if (templateName && documentFields[collectionName].templates && documentFields[collectionName].templates[templateName]) {
|
|
2757
|
+
template = documentFields[collectionName].templates[templateName].template;
|
|
2758
|
+
fields = documentFields[collectionName].templates[templateName].fields;
|
|
2759
|
+
} else {
|
|
2760
|
+
fields = documentFields[collectionName].fields;
|
|
2761
|
+
}
|
|
2762
|
+
setInfo({
|
|
2763
|
+
collection,
|
|
2764
|
+
template,
|
|
2765
|
+
fields,
|
|
2766
|
+
mutationInfo
|
|
2767
|
+
});
|
|
2768
|
+
} catch (error2) {
|
|
2769
|
+
cms.alerts.error(`[${error2.name}] GetDocumentFields failed: ${error2.message}`, 30 * 1e3);
|
|
2770
|
+
console.error(error2);
|
|
2771
|
+
setInfo({
|
|
2772
|
+
collection: void 0,
|
|
2773
|
+
template: void 0,
|
|
2774
|
+
fields: void 0,
|
|
2775
|
+
mutationInfo: void 0
|
|
2776
|
+
});
|
|
2777
|
+
setError(error2);
|
|
2755
2778
|
}
|
|
2756
|
-
|
|
2757
|
-
collection,
|
|
2758
|
-
template,
|
|
2759
|
-
fields,
|
|
2760
|
-
mutationInfo
|
|
2761
|
-
});
|
|
2762
|
-
} catch (error2) {
|
|
2763
|
-
cms.alerts.error(`[${error2.name}] GetDocumentFields failed: ${error2.message}`, 30 * 1e3);
|
|
2764
|
-
console.error(error2);
|
|
2765
|
-
setInfo({
|
|
2766
|
-
collection: void 0,
|
|
2767
|
-
template: void 0,
|
|
2768
|
-
fields: void 0,
|
|
2769
|
-
mutationInfo: void 0
|
|
2770
|
-
});
|
|
2771
|
-
setError(error2);
|
|
2779
|
+
setLoading(false);
|
|
2772
2780
|
}
|
|
2773
|
-
setLoading(false);
|
|
2774
2781
|
};
|
|
2775
2782
|
setLoading(true);
|
|
2776
2783
|
fetchDocumentFields();
|
|
@@ -2784,13 +2791,11 @@ const GetDocumentFields = ({
|
|
|
2784
2791
|
children
|
|
2785
2792
|
}) => {
|
|
2786
2793
|
const { collection, template, fields, mutationInfo, loading, error } = useGetDocumentFields(cms, collectionName, templateName);
|
|
2787
|
-
if (
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
return null;
|
|
2793
|
-
}
|
|
2794
|
+
if (error) {
|
|
2795
|
+
return null;
|
|
2796
|
+
}
|
|
2797
|
+
if (loading) {
|
|
2798
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
2794
2799
|
}
|
|
2795
2800
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ collection, template, fields, mutationInfo, loading }));
|
|
2796
2801
|
};
|
|
@@ -2805,7 +2810,14 @@ const createDocument = async (cms, collection, template, mutationInfo, values) =
|
|
|
2805
2810
|
includeCollection,
|
|
2806
2811
|
includeTemplate
|
|
2807
2812
|
});
|
|
2808
|
-
await api.
|
|
2813
|
+
if (await api.isAuthenticated()) {
|
|
2814
|
+
await api.createDocument(collection.name, relativePath, params);
|
|
2815
|
+
} else {
|
|
2816
|
+
const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
2817
|
+
cms.alerts.error(authMessage, 30 * 1e3);
|
|
2818
|
+
console.error(authMessage);
|
|
2819
|
+
return false;
|
|
2820
|
+
}
|
|
2809
2821
|
};
|
|
2810
2822
|
const CollectionCreatePage = () => {
|
|
2811
2823
|
const { collectionName, templateName } = useParams();
|
|
@@ -2892,16 +2904,18 @@ const useGetDocument = (cms, collectionName, relativePath) => {
|
|
|
2892
2904
|
const [error, setError] = useState(void 0);
|
|
2893
2905
|
useEffect(() => {
|
|
2894
2906
|
const fetchDocument = async () => {
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2907
|
+
if (api.isAuthenticated()) {
|
|
2908
|
+
try {
|
|
2909
|
+
const response = await api.fetchDocument(collectionName, relativePath);
|
|
2910
|
+
setDocument(response.getDocument);
|
|
2911
|
+
} catch (error2) {
|
|
2912
|
+
cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
|
|
2913
|
+
console.error(error2);
|
|
2914
|
+
setDocument(void 0);
|
|
2915
|
+
setError(error2);
|
|
2916
|
+
}
|
|
2917
|
+
setLoading(false);
|
|
2903
2918
|
}
|
|
2904
|
-
setLoading(false);
|
|
2905
2919
|
};
|
|
2906
2920
|
setLoading(true);
|
|
2907
2921
|
fetchDocument();
|
|
@@ -2915,13 +2929,11 @@ const GetDocument = ({
|
|
|
2915
2929
|
children
|
|
2916
2930
|
}) => {
|
|
2917
2931
|
const { document, loading, error } = useGetDocument(cms, collectionName, relativePath);
|
|
2918
|
-
if (
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
return null;
|
|
2924
|
-
}
|
|
2932
|
+
if (error) {
|
|
2933
|
+
return null;
|
|
2934
|
+
}
|
|
2935
|
+
if (loading) {
|
|
2936
|
+
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
2925
2937
|
}
|
|
2926
2938
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(document, loading));
|
|
2927
2939
|
};
|
|
@@ -2932,7 +2944,14 @@ const updateDocument = async (cms, relativePath, collection, mutationInfo, value
|
|
|
2932
2944
|
includeCollection,
|
|
2933
2945
|
includeTemplate
|
|
2934
2946
|
});
|
|
2935
|
-
await api.
|
|
2947
|
+
if (await api.isAuthenticated()) {
|
|
2948
|
+
await api.updateDocument(collection.name, relativePath, params);
|
|
2949
|
+
} else {
|
|
2950
|
+
const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
2951
|
+
cms.alerts.error(authMessage, 30 * 1e3);
|
|
2952
|
+
console.error(authMessage);
|
|
2953
|
+
return false;
|
|
2954
|
+
}
|
|
2936
2955
|
};
|
|
2937
2956
|
const CollectionUpdatePage = () => {
|
|
2938
2957
|
const { collectionName, filename } = useParams();
|
package/dist/index.js
CHANGED
|
@@ -1181,6 +1181,9 @@ mutation addPendingDocumentMutation(
|
|
|
1181
1181
|
constructor(cms) {
|
|
1182
1182
|
this.api = cms.api.tina;
|
|
1183
1183
|
}
|
|
1184
|
+
async isAuthenticated() {
|
|
1185
|
+
return await this.api.isAuthenticated();
|
|
1186
|
+
}
|
|
1184
1187
|
async fetchCollections() {
|
|
1185
1188
|
const response = await this.api.request(`#graphql
|
|
1186
1189
|
query{
|
|
@@ -2313,16 +2316,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2313
2316
|
const [error, setError] = React.useState(void 0);
|
|
2314
2317
|
React.useEffect(() => {
|
|
2315
2318
|
const fetchCollections = async () => {
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2319
|
+
if (await api.isAuthenticated()) {
|
|
2320
|
+
try {
|
|
2321
|
+
const response = await api.fetchCollections();
|
|
2322
|
+
setCollections(response.getCollections);
|
|
2323
|
+
} catch (error2) {
|
|
2324
|
+
cms.alerts.error(`[${error2.name}] GetCollections failed: ${error2.message}`, 30 * 1e3);
|
|
2325
|
+
console.error(error2);
|
|
2326
|
+
setCollections([]);
|
|
2327
|
+
setError(error2);
|
|
2328
|
+
}
|
|
2329
|
+
setLoading(false);
|
|
2324
2330
|
}
|
|
2325
|
-
setLoading(false);
|
|
2326
2331
|
};
|
|
2327
2332
|
setLoading(true);
|
|
2328
2333
|
fetchCollections();
|
|
@@ -2611,16 +2616,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2611
2616
|
const [error, setError] = React.useState(void 0);
|
|
2612
2617
|
React.useEffect(() => {
|
|
2613
2618
|
const fetchCollection = async () => {
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2619
|
+
if (await api.isAuthenticated()) {
|
|
2620
|
+
try {
|
|
2621
|
+
const response = await api.fetchCollection(collectionName, includeDocuments);
|
|
2622
|
+
setCollection(response.getCollection);
|
|
2623
|
+
} catch (error2) {
|
|
2624
|
+
cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
|
|
2625
|
+
console.error(error2);
|
|
2626
|
+
setCollection(void 0);
|
|
2627
|
+
setError(error2);
|
|
2628
|
+
}
|
|
2629
|
+
setLoading(false);
|
|
2622
2630
|
}
|
|
2623
|
-
setLoading(false);
|
|
2624
2631
|
};
|
|
2625
2632
|
setLoading(true);
|
|
2626
2633
|
fetchCollection();
|
|
@@ -2634,13 +2641,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2634
2641
|
children
|
|
2635
2642
|
}) => {
|
|
2636
2643
|
const { collection, loading, error } = useGetCollection(cms, collectionName, includeDocuments);
|
|
2637
|
-
if (
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
return null;
|
|
2643
|
-
}
|
|
2644
|
+
if (error) {
|
|
2645
|
+
return null;
|
|
2646
|
+
}
|
|
2647
|
+
if (loading) {
|
|
2648
|
+
return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
|
|
2644
2649
|
}
|
|
2645
2650
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collection, loading));
|
|
2646
2651
|
};
|
|
@@ -2760,37 +2765,39 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2760
2765
|
const [error, setError] = React.useState(void 0);
|
|
2761
2766
|
React.useEffect(() => {
|
|
2762
2767
|
const fetchDocumentFields = async () => {
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2768
|
+
if (await api.isAuthenticated()) {
|
|
2769
|
+
try {
|
|
2770
|
+
const response = await api.fetchDocumentFields();
|
|
2771
|
+
const documentFields = response.getDocumentFields;
|
|
2772
|
+
const collection = documentFields[collectionName].collection;
|
|
2773
|
+
const mutationInfo = documentFields[collectionName].mutationInfo;
|
|
2774
|
+
let fields = void 0;
|
|
2775
|
+
let template = void 0;
|
|
2776
|
+
if (templateName && documentFields[collectionName].templates && documentFields[collectionName].templates[templateName]) {
|
|
2777
|
+
template = documentFields[collectionName].templates[templateName].template;
|
|
2778
|
+
fields = documentFields[collectionName].templates[templateName].fields;
|
|
2779
|
+
} else {
|
|
2780
|
+
fields = documentFields[collectionName].fields;
|
|
2781
|
+
}
|
|
2782
|
+
setInfo({
|
|
2783
|
+
collection,
|
|
2784
|
+
template,
|
|
2785
|
+
fields,
|
|
2786
|
+
mutationInfo
|
|
2787
|
+
});
|
|
2788
|
+
} catch (error2) {
|
|
2789
|
+
cms.alerts.error(`[${error2.name}] GetDocumentFields failed: ${error2.message}`, 30 * 1e3);
|
|
2790
|
+
console.error(error2);
|
|
2791
|
+
setInfo({
|
|
2792
|
+
collection: void 0,
|
|
2793
|
+
template: void 0,
|
|
2794
|
+
fields: void 0,
|
|
2795
|
+
mutationInfo: void 0
|
|
2796
|
+
});
|
|
2797
|
+
setError(error2);
|
|
2775
2798
|
}
|
|
2776
|
-
|
|
2777
|
-
collection,
|
|
2778
|
-
template,
|
|
2779
|
-
fields,
|
|
2780
|
-
mutationInfo
|
|
2781
|
-
});
|
|
2782
|
-
} catch (error2) {
|
|
2783
|
-
cms.alerts.error(`[${error2.name}] GetDocumentFields failed: ${error2.message}`, 30 * 1e3);
|
|
2784
|
-
console.error(error2);
|
|
2785
|
-
setInfo({
|
|
2786
|
-
collection: void 0,
|
|
2787
|
-
template: void 0,
|
|
2788
|
-
fields: void 0,
|
|
2789
|
-
mutationInfo: void 0
|
|
2790
|
-
});
|
|
2791
|
-
setError(error2);
|
|
2799
|
+
setLoading(false);
|
|
2792
2800
|
}
|
|
2793
|
-
setLoading(false);
|
|
2794
2801
|
};
|
|
2795
2802
|
setLoading(true);
|
|
2796
2803
|
fetchDocumentFields();
|
|
@@ -2804,13 +2811,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2804
2811
|
children
|
|
2805
2812
|
}) => {
|
|
2806
2813
|
const { collection, template, fields, mutationInfo, loading, error } = useGetDocumentFields(cms, collectionName, templateName);
|
|
2807
|
-
if (
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
return null;
|
|
2813
|
-
}
|
|
2814
|
+
if (error) {
|
|
2815
|
+
return null;
|
|
2816
|
+
}
|
|
2817
|
+
if (loading) {
|
|
2818
|
+
return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
|
|
2814
2819
|
}
|
|
2815
2820
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children({ collection, template, fields, mutationInfo, loading }));
|
|
2816
2821
|
};
|
|
@@ -2825,7 +2830,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2825
2830
|
includeCollection,
|
|
2826
2831
|
includeTemplate
|
|
2827
2832
|
});
|
|
2828
|
-
await api.
|
|
2833
|
+
if (await api.isAuthenticated()) {
|
|
2834
|
+
await api.createDocument(collection.name, relativePath, params);
|
|
2835
|
+
} else {
|
|
2836
|
+
const authMessage = `[Error] CreateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
2837
|
+
cms.alerts.error(authMessage, 30 * 1e3);
|
|
2838
|
+
console.error(authMessage);
|
|
2839
|
+
return false;
|
|
2840
|
+
}
|
|
2829
2841
|
};
|
|
2830
2842
|
const CollectionCreatePage = () => {
|
|
2831
2843
|
const { collectionName, templateName } = reactRouterDom.useParams();
|
|
@@ -2912,16 +2924,18 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2912
2924
|
const [error, setError] = React.useState(void 0);
|
|
2913
2925
|
React.useEffect(() => {
|
|
2914
2926
|
const fetchDocument = async () => {
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2927
|
+
if (api.isAuthenticated()) {
|
|
2928
|
+
try {
|
|
2929
|
+
const response = await api.fetchDocument(collectionName, relativePath);
|
|
2930
|
+
setDocument(response.getDocument);
|
|
2931
|
+
} catch (error2) {
|
|
2932
|
+
cms.alerts.error(`[${error2.name}] GetDocument failed: ${error2.message}`, 30 * 1e3);
|
|
2933
|
+
console.error(error2);
|
|
2934
|
+
setDocument(void 0);
|
|
2935
|
+
setError(error2);
|
|
2936
|
+
}
|
|
2937
|
+
setLoading(false);
|
|
2923
2938
|
}
|
|
2924
|
-
setLoading(false);
|
|
2925
2939
|
};
|
|
2926
2940
|
setLoading(true);
|
|
2927
2941
|
fetchDocument();
|
|
@@ -2935,13 +2949,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2935
2949
|
children
|
|
2936
2950
|
}) => {
|
|
2937
2951
|
const { document, loading, error } = useGetDocument(cms, collectionName, relativePath);
|
|
2938
|
-
if (
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
return null;
|
|
2944
|
-
}
|
|
2952
|
+
if (error) {
|
|
2953
|
+
return null;
|
|
2954
|
+
}
|
|
2955
|
+
if (loading) {
|
|
2956
|
+
return /* @__PURE__ */ React__default["default"].createElement(LoadingPage, null);
|
|
2945
2957
|
}
|
|
2946
2958
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document, loading));
|
|
2947
2959
|
};
|
|
@@ -2952,7 +2964,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2952
2964
|
includeCollection,
|
|
2953
2965
|
includeTemplate
|
|
2954
2966
|
});
|
|
2955
|
-
await api.
|
|
2967
|
+
if (await api.isAuthenticated()) {
|
|
2968
|
+
await api.updateDocument(collection.name, relativePath, params);
|
|
2969
|
+
} else {
|
|
2970
|
+
const authMessage = `[Error] UpdateDocument failed: User is no longer authenticated; please login and try again.`;
|
|
2971
|
+
cms.alerts.error(authMessage, 30 * 1e3);
|
|
2972
|
+
console.error(authMessage);
|
|
2973
|
+
return false;
|
|
2974
|
+
}
|
|
2956
2975
|
};
|
|
2957
2976
|
const CollectionUpdatePage = () => {
|
|
2958
2977
|
const { collectionName, filename } = reactRouterDom.useParams();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "0.66.
|
|
3
|
+
"version": "0.66.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@headlessui/react": "^1.4.1",
|
|
26
26
|
"@heroicons/react": "^1.0.4",
|
|
27
27
|
"@tinacms/sharedctx": "0.1.0",
|
|
28
|
-
"@tinacms/toolkit": "0.56.
|
|
28
|
+
"@tinacms/toolkit": "0.56.17",
|
|
29
29
|
"crypto-js": "^4.0.0",
|
|
30
30
|
"final-form": "4.20.1",
|
|
31
31
|
"graphql": "^15.1.0",
|