tinacms 0.68.13 → 0.69.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/dist/admin/api.d.ts +1 -1
- package/dist/admin/components/GetCollection.d.ts +4 -2
- package/dist/client.es.js +11 -4
- package/dist/client.js +11 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +147 -63
- package/dist/index.js +145 -61
- package/dist/{rich-text.d.ts → rich-text/index.d.ts} +6 -0
- package/dist/rich-text/index.es.js +221 -0
- package/dist/{rich-text.js → rich-text/index.js} +142 -144
- package/dist/style.css +11 -2
- package/dist/tina-cms.d.ts +1 -131
- package/dist/types/cms.d.ts +64 -0
- package/dist/unifiedClient/index.d.ts +2 -2
- package/package.json +15 -8
- package/dist/rich-text.es.js +0 -223
package/dist/admin/api.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class TinaAdminApi {
|
|
|
25
25
|
collection: string;
|
|
26
26
|
relativePath: string;
|
|
27
27
|
}): Promise<void>;
|
|
28
|
-
fetchCollection(collectionName: string, includeDocuments: boolean, after?: string): Promise<Collection>;
|
|
28
|
+
fetchCollection(collectionName: string, includeDocuments: boolean, after?: string, sortKey?: string, order?: 'asc' | 'desc'): Promise<Collection>;
|
|
29
29
|
fetchDocument(collectionName: string, relativePath: string): Promise<{
|
|
30
30
|
document: DocumentForm;
|
|
31
31
|
}>;
|
|
@@ -12,17 +12,19 @@ limitations under the License.
|
|
|
12
12
|
*/
|
|
13
13
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
14
14
|
import type { Collection } from '../types';
|
|
15
|
-
export declare const useGetCollection: (cms: TinaCMS, collectionName: string, includeDocuments?: boolean, after?: string) => {
|
|
15
|
+
export declare const useGetCollection: (cms: TinaCMS, collectionName: string, includeDocuments?: boolean, after?: string, sortKey?: string) => {
|
|
16
16
|
collection: Collection;
|
|
17
17
|
loading: boolean;
|
|
18
18
|
error: Error;
|
|
19
19
|
reFetchCollection: () => void;
|
|
20
|
+
collectionExtra: import("@tinacms/schema-tools").TinaCloudCollection<true>;
|
|
20
21
|
};
|
|
21
|
-
declare const GetCollection: ({ cms, collectionName, includeDocuments, startCursor, children, }: {
|
|
22
|
+
declare const GetCollection: ({ cms, collectionName, includeDocuments, startCursor, sortKey, children, }: {
|
|
22
23
|
cms: TinaCMS;
|
|
23
24
|
collectionName: string;
|
|
24
25
|
includeDocuments?: boolean;
|
|
25
26
|
startCursor?: string;
|
|
27
|
+
sortKey?: string;
|
|
26
28
|
children: any;
|
|
27
29
|
}) => JSX.Element;
|
|
28
30
|
export default GetCollection;
|
package/dist/client.es.js
CHANGED
|
@@ -36,9 +36,7 @@ class TinaClient {
|
|
|
36
36
|
};
|
|
37
37
|
this.apiUrl = url;
|
|
38
38
|
this.readonlyToken = token;
|
|
39
|
-
|
|
40
|
-
this.queries = queries(this);
|
|
41
|
-
}
|
|
39
|
+
this.queries = queries(this);
|
|
42
40
|
}
|
|
43
41
|
async request(args) {
|
|
44
42
|
const headers = new Headers();
|
|
@@ -57,9 +55,18 @@ class TinaClient {
|
|
|
57
55
|
body: bodyString,
|
|
58
56
|
redirect: "follow"
|
|
59
57
|
});
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
let additionalInfo = "";
|
|
60
|
+
if (res.status === 401) {
|
|
61
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`);
|
|
64
|
+
}
|
|
60
65
|
const json = await res.json();
|
|
61
66
|
if (json.errors) {
|
|
62
|
-
throw new Error(`Unable to fetch,
|
|
67
|
+
throw new Error(`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
68
|
+
|
|
69
|
+
Errors:
|
|
63
70
|
${json.errors.map((error) => error.message).join("\n")}`);
|
|
64
71
|
}
|
|
65
72
|
return {
|
package/dist/client.js
CHANGED
|
@@ -43,9 +43,7 @@
|
|
|
43
43
|
};
|
|
44
44
|
this.apiUrl = url;
|
|
45
45
|
this.readonlyToken = token;
|
|
46
|
-
|
|
47
|
-
this.queries = queries(this);
|
|
48
|
-
}
|
|
46
|
+
this.queries = queries(this);
|
|
49
47
|
}
|
|
50
48
|
async request(args) {
|
|
51
49
|
const headers = new Headers();
|
|
@@ -64,9 +62,18 @@
|
|
|
64
62
|
body: bodyString,
|
|
65
63
|
redirect: "follow"
|
|
66
64
|
});
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
let additionalInfo = "";
|
|
67
|
+
if (res.status === 401) {
|
|
68
|
+
additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`);
|
|
71
|
+
}
|
|
67
72
|
const json = await res.json();
|
|
68
73
|
if (json.errors) {
|
|
69
|
-
throw new Error(`Unable to fetch,
|
|
74
|
+
throw new Error(`Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
|
|
75
|
+
|
|
76
|
+
Errors:
|
|
70
77
|
${json.errors.map((error) => error.message).join("\n")}`);
|
|
71
78
|
}
|
|
72
79
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ export * from '@tinacms/toolkit';
|
|
|
20
20
|
export { TinaAdmin } from './admin';
|
|
21
21
|
export { RouteMappingPlugin } from './admin/plugins/route-mapping';
|
|
22
22
|
export { TinaAdminApi } from './admin/api';
|
|
23
|
-
import { TinaCMSProvider2
|
|
23
|
+
import { TinaCMSProvider2 } from './tina-cms';
|
|
24
|
+
import type { TinaCMSProviderDefaultProps } from './types/cms';
|
|
24
25
|
export type { TinaCMSProviderDefaultProps };
|
|
25
26
|
export default TinaCMSProvider2;
|
|
26
27
|
import type { TinaCloudSchema as TinaCloudSchemaBase, TinaCloudCollection as TinaCloudCollectionBase, TinaCloudTemplateBase as TinaTemplate, TinaFieldBase } from '@tinacms/schema-tools';
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, OverflowMenu, CursorPaginator, PopupModal, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
1
|
+
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, Select, OverflowMenu, CursorPaginator, PopupModal, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
2
2
|
export * from "@tinacms/toolkit";
|
|
3
3
|
import * as G from "graphql";
|
|
4
4
|
import { TypeInfo, visit, visitWithTypeInfo, getNamedType, GraphQLObjectType, isLeafType, GraphQLUnionType, isScalarType as isScalarType$1, getIntrospectionQuery, buildClientSchema, print, parse } from "graphql";
|
|
@@ -2459,7 +2459,6 @@ class TinaAdminApi {
|
|
|
2459
2459
|
constructor(cms) {
|
|
2460
2460
|
this.api = cms.api.tina;
|
|
2461
2461
|
this.schema = cms.api.tina.schema;
|
|
2462
|
-
this.useDataLayer = cms.flags.get("experimentalData");
|
|
2463
2462
|
}
|
|
2464
2463
|
async isAuthenticated() {
|
|
2465
2464
|
return await this.api.isAuthenticated();
|
|
@@ -2484,11 +2483,10 @@ class TinaAdminApi {
|
|
|
2484
2483
|
}
|
|
2485
2484
|
}`, { variables: { collection, relativePath } });
|
|
2486
2485
|
}
|
|
2487
|
-
async fetchCollection(collectionName, includeDocuments, after) {
|
|
2486
|
+
async fetchCollection(collectionName, includeDocuments, after, sortKey, order) {
|
|
2488
2487
|
if (includeDocuments === true) {
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
const response = await this.api.request(`#graphql
|
|
2488
|
+
const sort = sortKey || this.schema.getIsTitleFieldName(collectionName);
|
|
2489
|
+
const response = order === "asc" ? await this.api.request(`#graphql
|
|
2492
2490
|
query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
|
|
2493
2491
|
collection(collection: $collection){
|
|
2494
2492
|
name
|
|
@@ -2522,45 +2520,56 @@ class TinaAdminApi {
|
|
|
2522
2520
|
}
|
|
2523
2521
|
}
|
|
2524
2522
|
}`, {
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2523
|
+
variables: {
|
|
2524
|
+
collection: collectionName,
|
|
2525
|
+
includeDocuments,
|
|
2526
|
+
sort,
|
|
2527
|
+
limit: 10,
|
|
2528
|
+
after
|
|
2529
|
+
}
|
|
2530
|
+
}) : await this.api.request(`#graphql
|
|
2531
|
+
query($collection: String!, $includeDocuments: Boolean!, $sort: String, $limit: Float, $after: String){
|
|
2532
|
+
collection(collection: $collection){
|
|
2533
|
+
name
|
|
2534
|
+
label
|
|
2535
|
+
format
|
|
2536
|
+
templates
|
|
2537
|
+
documents(sort: $sort, before: $after, last: $limit) @include(if: $includeDocuments) {
|
|
2538
|
+
totalCount
|
|
2539
|
+
pageInfo {
|
|
2540
|
+
hasPreviousPage
|
|
2541
|
+
hasNextPage
|
|
2542
|
+
startCursor
|
|
2543
|
+
endCursor
|
|
2544
|
+
}
|
|
2545
|
+
edges {
|
|
2546
|
+
node {
|
|
2547
|
+
... on Document {
|
|
2548
|
+
_sys {
|
|
2549
|
+
title
|
|
2550
|
+
template
|
|
2551
|
+
breadcrumbs
|
|
2552
|
+
path
|
|
2553
|
+
basename
|
|
2554
|
+
relativePath
|
|
2555
|
+
filename
|
|
2556
|
+
extension
|
|
2557
|
+
}
|
|
2555
2558
|
}
|
|
2556
2559
|
}
|
|
2557
2560
|
}
|
|
2558
2561
|
}
|
|
2559
2562
|
}
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2563
|
+
}`, {
|
|
2564
|
+
variables: {
|
|
2565
|
+
collection: collectionName,
|
|
2566
|
+
includeDocuments,
|
|
2567
|
+
sort,
|
|
2568
|
+
limit: 10,
|
|
2569
|
+
after
|
|
2570
|
+
}
|
|
2571
|
+
});
|
|
2572
|
+
return response.collection;
|
|
2564
2573
|
} else {
|
|
2565
2574
|
try {
|
|
2566
2575
|
const collection = this.schema.getCollection(collectionName);
|
|
@@ -3312,6 +3321,9 @@ var styles = /* @__PURE__ */ (() => `.tina-tailwind {
|
|
|
3312
3321
|
.tina-tailwind .gap-4 {
|
|
3313
3322
|
gap: 16px;
|
|
3314
3323
|
}
|
|
3324
|
+
.tina-tailwind .gap-2 {
|
|
3325
|
+
gap: 8px;
|
|
3326
|
+
}
|
|
3315
3327
|
.tina-tailwind .gap-3 {
|
|
3316
3328
|
gap: 12px;
|
|
3317
3329
|
}
|
|
@@ -3330,6 +3342,9 @@ var styles = /* @__PURE__ */ (() => `.tina-tailwind {
|
|
|
3330
3342
|
.tina-tailwind .overflow-y-auto {
|
|
3331
3343
|
overflow-y: auto;
|
|
3332
3344
|
}
|
|
3345
|
+
.tina-tailwind .whitespace-normal {
|
|
3346
|
+
white-space: normal;
|
|
3347
|
+
}
|
|
3333
3348
|
.tina-tailwind .whitespace-nowrap {
|
|
3334
3349
|
white-space: nowrap;
|
|
3335
3350
|
}
|
|
@@ -3451,8 +3466,8 @@ var styles = /* @__PURE__ */ (() => `.tina-tailwind {
|
|
|
3451
3466
|
.tina-tailwind .pb-4 {
|
|
3452
3467
|
padding-bottom: 16px;
|
|
3453
3468
|
}
|
|
3454
|
-
.tina-tailwind .pt-
|
|
3455
|
-
padding-top:
|
|
3469
|
+
.tina-tailwind .pt-16 {
|
|
3470
|
+
padding-top: 64px;
|
|
3456
3471
|
}
|
|
3457
3472
|
.tina-tailwind .pt-3 {
|
|
3458
3473
|
padding-top: 12px;
|
|
@@ -3496,6 +3511,9 @@ var styles = /* @__PURE__ */ (() => `.tina-tailwind {
|
|
|
3496
3511
|
.tina-tailwind .font-medium {
|
|
3497
3512
|
font-weight: 500;
|
|
3498
3513
|
}
|
|
3514
|
+
.tina-tailwind .font-semibold {
|
|
3515
|
+
font-weight: 600;
|
|
3516
|
+
}
|
|
3499
3517
|
.tina-tailwind .uppercase {
|
|
3500
3518
|
text-transform: uppercase;
|
|
3501
3519
|
}
|
|
@@ -3998,16 +4016,18 @@ const TinaCMSProvider2 = ({
|
|
|
3998
4016
|
...props
|
|
3999
4017
|
}) => {
|
|
4000
4018
|
var _a;
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
if (!apiURL && !validOldSetup) {
|
|
4004
|
-
throw new Error(`Must provide apiUrl or a client to the TinaWrapper component`);
|
|
4019
|
+
if (props == null ? void 0 : props.apiURL) {
|
|
4020
|
+
console.warn("The apiURL prop is deprecated. Please see https://tina.io/blog/tina-v-0.68.14 for information on how to upgrade to the new API");
|
|
4005
4021
|
}
|
|
4022
|
+
const apiURL = ((_a = props == null ? void 0 : props.client) == null ? void 0 : _a.apiUrl) || (props == null ? void 0 : props.apiURL);
|
|
4006
4023
|
const { branch, clientId, isLocalClient } = apiURL ? parseURL(apiURL) : {
|
|
4007
4024
|
branch: props.branch,
|
|
4008
4025
|
clientId: props.clientId,
|
|
4009
|
-
isLocalClient: props.isLocalClient
|
|
4026
|
+
isLocalClient: props == null ? void 0 : props.isLocalClient
|
|
4010
4027
|
};
|
|
4028
|
+
if (typeof isLocalClient === "undefined" || !isLocalClient && (!branch || !clientId)) {
|
|
4029
|
+
throw new Error("Invalid setup. See https://tina.io/docs/tina-cloud/connecting-site/ for more information.");
|
|
4030
|
+
}
|
|
4011
4031
|
if (!schema) {
|
|
4012
4032
|
throw new Error("`schema` is required to be passed as a property to `TinaProvider`. You can learn more about this change here: https://github.com/tinacms/tinacms/pull/2823");
|
|
4013
4033
|
}
|
|
@@ -4590,7 +4610,7 @@ const PageHeader = ({
|
|
|
4590
4610
|
isLocalMode,
|
|
4591
4611
|
children
|
|
4592
4612
|
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
|
|
4593
|
-
className: "bg-white pb-4 pt-
|
|
4613
|
+
className: "bg-white pb-4 pt-16 border-b border-gray-200 px-12"
|
|
4594
4614
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4595
4615
|
className: "w-full mx-auto max-w-screen-xl"
|
|
4596
4616
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -4717,8 +4737,10 @@ const LoadingPage = () => /* @__PURE__ */ React.createElement(React.Fragment, nu
|
|
|
4717
4737
|
fontWeight: "normal"
|
|
4718
4738
|
}
|
|
4719
4739
|
}, "Please wait, Tina is loading data..."))));
|
|
4720
|
-
const useGetCollection = (cms, collectionName, includeDocuments = true, after = "") => {
|
|
4740
|
+
const useGetCollection = (cms, collectionName, includeDocuments = true, after = "", sortKey) => {
|
|
4721
4741
|
const api = new TinaAdminApi(cms);
|
|
4742
|
+
const schema = cms.api.tina.schema;
|
|
4743
|
+
const collectionExtra = schema.getCollection(collectionName);
|
|
4722
4744
|
const [collection, setCollection] = useState(void 0);
|
|
4723
4745
|
const [loading, setLoading] = useState(true);
|
|
4724
4746
|
const [error, setError] = useState(void 0);
|
|
@@ -4726,8 +4748,10 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
|
|
|
4726
4748
|
useEffect(() => {
|
|
4727
4749
|
const fetchCollection = async () => {
|
|
4728
4750
|
if (await api.isAuthenticated()) {
|
|
4751
|
+
const { name, order } = JSON.parse(sortKey || "{}");
|
|
4752
|
+
const validSortKey = collectionExtra.fields.map((x) => x.name).includes(name) ? name : void 0;
|
|
4729
4753
|
try {
|
|
4730
|
-
const collection2 = await api.fetchCollection(collectionName, includeDocuments, after);
|
|
4754
|
+
const collection2 = await api.fetchCollection(collectionName, includeDocuments, after, validSortKey, order);
|
|
4731
4755
|
setCollection(collection2);
|
|
4732
4756
|
} catch (error2) {
|
|
4733
4757
|
cms.alerts.error(`[${error2.name}] GetCollection failed: ${error2.message}`, 30 * 1e3);
|
|
@@ -4740,26 +4764,29 @@ const useGetCollection = (cms, collectionName, includeDocuments = true, after =
|
|
|
4740
4764
|
};
|
|
4741
4765
|
setLoading(true);
|
|
4742
4766
|
fetchCollection();
|
|
4743
|
-
}, [cms, collectionName, resetState, after]);
|
|
4767
|
+
}, [cms, collectionName, resetState, after, sortKey]);
|
|
4744
4768
|
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
4745
|
-
return { collection, loading, error, reFetchCollection };
|
|
4769
|
+
return { collection, loading, error, reFetchCollection, collectionExtra };
|
|
4746
4770
|
};
|
|
4747
4771
|
const GetCollection = ({
|
|
4748
4772
|
cms,
|
|
4749
4773
|
collectionName,
|
|
4750
4774
|
includeDocuments = true,
|
|
4751
4775
|
startCursor,
|
|
4776
|
+
sortKey,
|
|
4752
4777
|
children
|
|
4753
4778
|
}) => {
|
|
4754
|
-
const { collection, loading, error, reFetchCollection } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "");
|
|
4779
|
+
const { collection, loading, error, reFetchCollection, collectionExtra } = useGetCollection(cms, collectionName, includeDocuments, startCursor || "", sortKey) || {};
|
|
4755
4780
|
if (error) {
|
|
4756
4781
|
return null;
|
|
4757
4782
|
}
|
|
4758
4783
|
if (loading) {
|
|
4759
4784
|
return /* @__PURE__ */ React.createElement(LoadingPage, null);
|
|
4760
4785
|
}
|
|
4761
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, loading, reFetchCollection));
|
|
4786
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
|
|
4762
4787
|
};
|
|
4788
|
+
const LOCAL_STORAGE_KEY = "tinacms.admin.collection.list.page";
|
|
4789
|
+
const isSSR = typeof window === "undefined";
|
|
4763
4790
|
const TemplateMenu = ({ templates }) => {
|
|
4764
4791
|
return /* @__PURE__ */ React.createElement(Menu, {
|
|
4765
4792
|
as: "div",
|
|
@@ -4808,8 +4835,17 @@ const CollectionListPage = () => {
|
|
|
4808
4835
|
});
|
|
4809
4836
|
const [endCursor, setEndCursor] = useState("");
|
|
4810
4837
|
const [prevCursors, setPrevCursors] = useState([]);
|
|
4838
|
+
const [sortKey, setSortKey] = useState(isSSR ? "" : window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
|
|
4839
|
+
order: "asc",
|
|
4840
|
+
name: ""
|
|
4841
|
+
}));
|
|
4842
|
+
const [sortOrder, setSortOrder] = useState("asc");
|
|
4811
4843
|
const loc = useLocation();
|
|
4812
4844
|
useEffect(() => {
|
|
4845
|
+
setSortKey(window.localStorage.getItem(`${LOCAL_STORAGE_KEY}.${collectionName}`) || JSON.stringify({
|
|
4846
|
+
order: "asc",
|
|
4847
|
+
name: ""
|
|
4848
|
+
}));
|
|
4813
4849
|
setEndCursor("");
|
|
4814
4850
|
setPrevCursors([]);
|
|
4815
4851
|
}, [loc]);
|
|
@@ -4818,14 +4854,15 @@ const CollectionListPage = () => {
|
|
|
4818
4854
|
cms,
|
|
4819
4855
|
collectionName,
|
|
4820
4856
|
includeDocuments: true,
|
|
4821
|
-
startCursor: endCursor
|
|
4822
|
-
|
|
4857
|
+
startCursor: endCursor,
|
|
4858
|
+
sortKey
|
|
4859
|
+
}, (collection, _loading, reFetchCollection, collectionExtra) => {
|
|
4823
4860
|
var _a, _b;
|
|
4824
4861
|
const totalCount = collection.documents.totalCount;
|
|
4825
4862
|
const documents = collection.documents.edges;
|
|
4826
4863
|
const admin = cms.api.admin;
|
|
4827
4864
|
const pageInfo = collection.documents.pageInfo;
|
|
4828
|
-
const
|
|
4865
|
+
const fields = collectionExtra.fields.filter((x) => ["string", "number", "datetime"].includes(x.type));
|
|
4829
4866
|
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, open && /* @__PURE__ */ React.createElement(DeleteModal, {
|
|
4830
4867
|
filename: vars.relativePath,
|
|
4831
4868
|
deleteFunc: async () => {
|
|
@@ -4842,9 +4879,56 @@ const CollectionListPage = () => {
|
|
|
4842
4879
|
close: () => setOpen(false)
|
|
4843
4880
|
}), /* @__PURE__ */ React.createElement(PageHeader, {
|
|
4844
4881
|
isLocalMode: (_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode
|
|
4845
|
-
}, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("
|
|
4882
|
+
}, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
4883
|
+
className: "flex flex-col gap-4"
|
|
4884
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
4846
4885
|
className: "font-sans text-2xl text-gray-700"
|
|
4847
|
-
}, collection.label ? collection.label : collection.name),
|
|
4886
|
+
}, collection.label ? collection.label : collection.name), fields.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4887
|
+
className: "flex gap-2 items-center"
|
|
4888
|
+
}, /* @__PURE__ */ React.createElement("label", {
|
|
4889
|
+
htmlFor: "sort",
|
|
4890
|
+
className: "block font-sans text-xs font-semibold text-gray-500 whitespace-normal"
|
|
4891
|
+
}, "Sort by"), /* @__PURE__ */ React.createElement(Select, {
|
|
4892
|
+
name: "sort",
|
|
4893
|
+
options: [
|
|
4894
|
+
{
|
|
4895
|
+
label: "Default",
|
|
4896
|
+
value: JSON.stringify({
|
|
4897
|
+
order: "asc",
|
|
4898
|
+
name: ""
|
|
4899
|
+
})
|
|
4900
|
+
},
|
|
4901
|
+
...fields.map((x) => [
|
|
4902
|
+
{
|
|
4903
|
+
label: x.label + " (Ascending)",
|
|
4904
|
+
value: JSON.stringify({
|
|
4905
|
+
name: x.name,
|
|
4906
|
+
order: "asc"
|
|
4907
|
+
})
|
|
4908
|
+
},
|
|
4909
|
+
{
|
|
4910
|
+
label: x.label + " (Descending)",
|
|
4911
|
+
value: JSON.stringify({
|
|
4912
|
+
name: x.name,
|
|
4913
|
+
order: "desc"
|
|
4914
|
+
})
|
|
4915
|
+
}
|
|
4916
|
+
]).flat()
|
|
4917
|
+
],
|
|
4918
|
+
input: {
|
|
4919
|
+
id: "sort",
|
|
4920
|
+
name: "sort",
|
|
4921
|
+
value: sortKey,
|
|
4922
|
+
onChange: (e) => {
|
|
4923
|
+
const val = JSON.parse(e.target.value);
|
|
4924
|
+
setEndCursor("");
|
|
4925
|
+
setPrevCursors([]);
|
|
4926
|
+
window == null ? void 0 : window.localStorage.setItem(`${LOCAL_STORAGE_KEY}.${collectionName}`, e.target.value);
|
|
4927
|
+
setSortKey(e.target.value);
|
|
4928
|
+
setSortOrder(val.order);
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
}))), !collection.templates && /* @__PURE__ */ React.createElement(Link, {
|
|
4848
4932
|
to: `new`,
|
|
4849
4933
|
className: "icon-parent inline-flex items-center font-medium focus:outline-none focus:ring-2 focus:shadow-outline text-center rounded-full justify-center transition-all duration-150 ease-out shadow text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 text-sm h-10 px-6"
|
|
4850
4934
|
}, "Create New", " ", /* @__PURE__ */ React.createElement(BiPlus, {
|
|
@@ -4928,11 +5012,11 @@ const CollectionListPage = () => {
|
|
|
4928
5012
|
}
|
|
4929
5013
|
]
|
|
4930
5014
|
})));
|
|
4931
|
-
}))),
|
|
5015
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4932
5016
|
className: "pt-3"
|
|
4933
5017
|
}, /* @__PURE__ */ React.createElement(CursorPaginator, {
|
|
4934
5018
|
variant: "white",
|
|
4935
|
-
hasNext: pageInfo == null ? void 0 : pageInfo.hasNextPage,
|
|
5019
|
+
hasNext: sortOrder === "asc" ? pageInfo == null ? void 0 : pageInfo.hasNextPage : pageInfo.hasPreviousPage,
|
|
4936
5020
|
navigateNext: () => {
|
|
4937
5021
|
const newState = [...prevCursors, endCursor];
|
|
4938
5022
|
setPrevCursors(newState);
|
|
@@ -5270,9 +5354,9 @@ const Redirect = () => {
|
|
|
5270
5354
|
return null;
|
|
5271
5355
|
};
|
|
5272
5356
|
const TinaAdmin = () => {
|
|
5273
|
-
const
|
|
5357
|
+
const isSSR2 = typeof window === "undefined";
|
|
5274
5358
|
const { edit } = useEditState();
|
|
5275
|
-
if (
|
|
5359
|
+
if (isSSR2) {
|
|
5276
5360
|
return null;
|
|
5277
5361
|
}
|
|
5278
5362
|
if (!edit) {
|