tinacms 0.0.0-d20d4ee-20250329210608 → 0.0.0-d28d795-20250427004334
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/README.md +1 -1
- package/dist/admin/components/AuthCallback.d.ts +5 -0
- package/dist/auth/authenticate.d.ts +1 -1
- package/dist/client.d.ts +1 -4
- package/dist/client.js +10 -1
- package/dist/client.mjs +10 -1
- package/dist/index.d.ts +1 -61
- package/dist/index.js +592 -402
- package/dist/index.mjs +593 -403
- package/dist/internalClient/authProvider.d.ts +2 -0
- package/dist/internalClient/index.d.ts +3 -3
- package/dist/react.d.ts +1 -34
- package/dist/rich-text/index.d.ts +1 -142
- package/dist/rich-text/prism.d.ts +1 -10
- package/dist/toolkit/components/media/media-manager.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-switcher-legacy.d.ts +1 -1
- package/dist/toolkit/plugin-branch-switcher/branch-switcher.d.ts +1 -1
- package/dist/toolkit/react-cloud-config/cloud-config-plugin.d.ts +3 -3
- package/dist/unifiedClient/index.d.ts +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -54,12 +54,12 @@ import { ELEMENT_PARAGRAPH as ELEMENT_PARAGRAPH$1 } from "@udecode/plate-paragra
|
|
|
54
54
|
import { ELEMENT_BLOCKQUOTE as ELEMENT_BLOCKQUOTE$1 } from "@udecode/plate-block-quote";
|
|
55
55
|
import { useFloatingToolbarState, offset, flip, useFloatingToolbar } from "@udecode/plate-floating";
|
|
56
56
|
import { getIntrospectionQuery, buildClientSchema, print, parse as parse$3, buildSchema } from "graphql";
|
|
57
|
-
import gql from "graphql-tag";
|
|
58
57
|
import { TinaSchema, addNamespaceToSchema, parseURL, resolveForm, normalizePath, validateSchema } from "@tinacms/schema-tools";
|
|
59
58
|
import { NAMER, resolveField } from "@tinacms/schema-tools";
|
|
59
|
+
import gql from "graphql-tag";
|
|
60
60
|
import { diff } from "@graphql-inspector/core";
|
|
61
61
|
import * as yup from "yup";
|
|
62
|
-
import { NavLink,
|
|
62
|
+
import { NavLink, useLocation, useNavigate, useParams, Link, useSearchParams, HashRouter, Routes, Route } from "react-router-dom";
|
|
63
63
|
import { stringifyMDX } from "@tinacms/mdx";
|
|
64
64
|
const ModalProvider = ({ children }) => {
|
|
65
65
|
const [modalRootContainerRef, setModalRootContainerRef] = useState(
|
|
@@ -4430,36 +4430,6 @@ function MdOutlineArrowBackIos(props) {
|
|
|
4430
4430
|
function MdOutlinePerson(props) {
|
|
4431
4431
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M12 6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2m0 10c2.7 0 5.8 1.29 6 2H6c.23-.72 3.31-2 6-2m0-12C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 10c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }, "child": [] }] })(props);
|
|
4432
4432
|
}
|
|
4433
|
-
const BranchContext = React.createContext({
|
|
4434
|
-
currentBranch: null,
|
|
4435
|
-
setCurrentBranch: (branch) => {
|
|
4436
|
-
console.warn("BranchContext not initialized");
|
|
4437
|
-
}
|
|
4438
|
-
});
|
|
4439
|
-
const BranchDataProvider = ({
|
|
4440
|
-
currentBranch,
|
|
4441
|
-
setCurrentBranch,
|
|
4442
|
-
children
|
|
4443
|
-
}) => {
|
|
4444
|
-
return /* @__PURE__ */ React.createElement(
|
|
4445
|
-
BranchContext.Provider,
|
|
4446
|
-
{
|
|
4447
|
-
value: {
|
|
4448
|
-
currentBranch,
|
|
4449
|
-
setCurrentBranch
|
|
4450
|
-
}
|
|
4451
|
-
},
|
|
4452
|
-
children
|
|
4453
|
-
);
|
|
4454
|
-
};
|
|
4455
|
-
const useBranchData = () => {
|
|
4456
|
-
const branchData = React.useContext(BranchContext);
|
|
4457
|
-
const { dispatch } = useEvent("branch:change");
|
|
4458
|
-
React.useEffect(() => {
|
|
4459
|
-
dispatch({ branchName: branchData.currentBranch });
|
|
4460
|
-
}, [branchData.currentBranch]);
|
|
4461
|
-
return branchData;
|
|
4462
|
-
};
|
|
4463
4433
|
const textFieldClasses = "shadow-inner focus:shadow-outline focus:border-blue-500 focus:outline-none block text-base placeholder:text-gray-300 px-3 py-2 text-gray-600 w-full bg-white border border-gray-200 transition-all ease-out duration-150 focus:text-gray-900 rounded-md";
|
|
4464
4434
|
const disabledClasses$1 = "opacity-50 pointer-events-none cursor-not-allowed";
|
|
4465
4435
|
const BaseTextField = React.forwardRef(({ className, disabled, ...rest }, ref) => {
|
|
@@ -8063,9 +8033,6 @@ const PasswordFieldPlugin = {
|
|
|
8063
8033
|
},
|
|
8064
8034
|
parse: parse$2
|
|
8065
8035
|
};
|
|
8066
|
-
function GrCircleQuestion(props) {
|
|
8067
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeWidth": "2", "d": "M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,15 L12,14 C12,13 12,12.5 13,12 C14,11.5 15,11 15,9.5 C15,8.5 14,7 12,7 C10,7 9,8.26413718 9,10 M12,16 L12,18" }, "child": [] }] })(props);
|
|
8068
|
-
}
|
|
8069
8036
|
function AiFillWarning(props) {
|
|
8070
8037
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 1024 1024" }, "child": [{ "tag": "path", "attr": { "d": "M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z" }, "child": [] }] })(props);
|
|
8071
8038
|
}
|
|
@@ -8084,6 +8051,39 @@ function FaSpinner(props) {
|
|
|
8084
8051
|
function FaUnlock(props) {
|
|
8085
8052
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M400 256H152V152.9c0-39.6 31.7-72.5 71.3-72.9 40-.4 72.7 32.1 72.7 72v16c0 13.3 10.7 24 24 24h32c13.3 0 24-10.7 24-24v-16C376 68 307.5-.3 223.5 0 139.5.3 72 69.5 72 153.5V256H48c-26.5 0-48 21.5-48 48v160c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z" }, "child": [] }] })(props);
|
|
8086
8053
|
}
|
|
8054
|
+
function GrCircleQuestion(props) {
|
|
8055
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeWidth": "2", "d": "M12,22 C17.5228475,22 22,17.5228475 22,12 C22,6.4771525 17.5228475,2 12,2 C6.4771525,2 2,6.4771525 2,12 C2,17.5228475 6.4771525,22 12,22 Z M12,15 L12,14 C12,13 12,12.5 13,12 C14,11.5 15,11 15,9.5 C15,8.5 14,7 12,7 C10,7 9,8.26413718 9,10 M12,16 L12,18" }, "child": [] }] })(props);
|
|
8056
|
+
}
|
|
8057
|
+
const BranchContext = React.createContext({
|
|
8058
|
+
currentBranch: null,
|
|
8059
|
+
setCurrentBranch: (branch) => {
|
|
8060
|
+
console.warn("BranchContext not initialized");
|
|
8061
|
+
}
|
|
8062
|
+
});
|
|
8063
|
+
const BranchDataProvider = ({
|
|
8064
|
+
currentBranch,
|
|
8065
|
+
setCurrentBranch,
|
|
8066
|
+
children
|
|
8067
|
+
}) => {
|
|
8068
|
+
return /* @__PURE__ */ React.createElement(
|
|
8069
|
+
BranchContext.Provider,
|
|
8070
|
+
{
|
|
8071
|
+
value: {
|
|
8072
|
+
currentBranch,
|
|
8073
|
+
setCurrentBranch
|
|
8074
|
+
}
|
|
8075
|
+
},
|
|
8076
|
+
children
|
|
8077
|
+
);
|
|
8078
|
+
};
|
|
8079
|
+
const useBranchData = () => {
|
|
8080
|
+
const branchData = React.useContext(BranchContext);
|
|
8081
|
+
const { dispatch } = useEvent("branch:change");
|
|
8082
|
+
React.useEffect(() => {
|
|
8083
|
+
dispatch({ branchName: branchData.currentBranch });
|
|
8084
|
+
}, [branchData.currentBranch]);
|
|
8085
|
+
return branchData;
|
|
8086
|
+
};
|
|
8087
8087
|
function formatBranchName$1(str) {
|
|
8088
8088
|
const pattern = /[^/\w-]+/g;
|
|
8089
8089
|
const formattedStr = str.replace(pattern, "");
|
|
@@ -8182,7 +8182,7 @@ const BranchSwitcherLegacy = ({
|
|
|
8182
8182
|
className: "transition-all duration-150 ease-out text-blue-600 hover:text-blue-400 hover:underline no-underline",
|
|
8183
8183
|
href: "https://tina.io/docs/tina-cloud/"
|
|
8184
8184
|
},
|
|
8185
|
-
"Learn more about moving to production with
|
|
8185
|
+
"Learn more about moving to production with TinaCloud."
|
|
8186
8186
|
)), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(
|
|
8187
8187
|
Button$1,
|
|
8188
8188
|
{
|
|
@@ -8418,7 +8418,7 @@ const EditoralBranchSwitcher = ({
|
|
|
8418
8418
|
className: "transition-all duration-150 ease-out text-blue-600 hover:text-blue-400 hover:underline no-underline",
|
|
8419
8419
|
href: "https://tina.io/docs/tina-cloud/"
|
|
8420
8420
|
},
|
|
8421
|
-
"Learn more about moving to production with
|
|
8421
|
+
"Learn more about moving to production with TinaCloud."
|
|
8422
8422
|
)), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement(
|
|
8423
8423
|
Button$1,
|
|
8424
8424
|
{
|
|
@@ -9450,7 +9450,7 @@ const E_BAD_ROUTE = new MediaListError({
|
|
|
9450
9450
|
});
|
|
9451
9451
|
new MediaListError({
|
|
9452
9452
|
title: "An Error Occurred",
|
|
9453
|
-
message: "Something went wrong accessing your media from
|
|
9453
|
+
message: "Something went wrong accessing your media from TinaCloud.",
|
|
9454
9454
|
docsLink: ""
|
|
9455
9455
|
// TODO
|
|
9456
9456
|
});
|
|
@@ -9980,7 +9980,7 @@ const SyncStatus = ({ cms, setEventsOpen }) => {
|
|
|
9980
9980
|
"Event Log"
|
|
9981
9981
|
));
|
|
9982
9982
|
};
|
|
9983
|
-
const version = "2.7.
|
|
9983
|
+
const version = "2.7.5";
|
|
9984
9984
|
const Nav = ({
|
|
9985
9985
|
isLocalMode,
|
|
9986
9986
|
className = "",
|
|
@@ -11043,6 +11043,93 @@ function createPlaceholder(name, _pr) {
|
|
|
11043
11043
|
);
|
|
11044
11044
|
};
|
|
11045
11045
|
}
|
|
11046
|
+
function dirname(path) {
|
|
11047
|
+
var _a, _b;
|
|
11048
|
+
const pattern = new RegExp("(?<prevDir>.*)/");
|
|
11049
|
+
return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
|
|
11050
|
+
}
|
|
11051
|
+
const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
|
|
11052
|
+
"button",
|
|
11053
|
+
{
|
|
11054
|
+
className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
|
|
11055
|
+
...props
|
|
11056
|
+
}
|
|
11057
|
+
);
|
|
11058
|
+
function Breadcrumb$1({ directory = "", setDirectory }) {
|
|
11059
|
+
directory = directory.replace(/^\/|\/$/g, "");
|
|
11060
|
+
let prevDir = dirname(directory) || "";
|
|
11061
|
+
if (prevDir === ".") {
|
|
11062
|
+
prevDir = "";
|
|
11063
|
+
}
|
|
11064
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
|
|
11065
|
+
IconButton,
|
|
11066
|
+
{
|
|
11067
|
+
variant: "ghost",
|
|
11068
|
+
className: "mr-2",
|
|
11069
|
+
onClick: () => setDirectory(prevDir)
|
|
11070
|
+
},
|
|
11071
|
+
/* @__PURE__ */ React__default.createElement(
|
|
11072
|
+
LeftArrowIcon,
|
|
11073
|
+
{
|
|
11074
|
+
className: `w-7 h-auto fill-gray-300 hover:fill-gray-900 transition duration-150 ease-out`
|
|
11075
|
+
}
|
|
11076
|
+
)
|
|
11077
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
11078
|
+
BreadcrumbButton,
|
|
11079
|
+
{
|
|
11080
|
+
onClick: () => setDirectory(""),
|
|
11081
|
+
className: directory === "" ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"
|
|
11082
|
+
},
|
|
11083
|
+
"Media"
|
|
11084
|
+
), directory && directory.split("/").map((part, index, parts) => {
|
|
11085
|
+
const currentDir = parts.slice(0, index + 1).join("/");
|
|
11086
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
11087
|
+
BreadcrumbButton,
|
|
11088
|
+
{
|
|
11089
|
+
className: "pl-1.5 " + (index + 1 === parts.length ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"),
|
|
11090
|
+
key: currentDir,
|
|
11091
|
+
onClick: () => {
|
|
11092
|
+
setDirectory(currentDir);
|
|
11093
|
+
}
|
|
11094
|
+
},
|
|
11095
|
+
part
|
|
11096
|
+
);
|
|
11097
|
+
}));
|
|
11098
|
+
}
|
|
11099
|
+
const CopyField = ({ label, description, value }) => {
|
|
11100
|
+
const [copied, setCopied] = React__default.useState(false);
|
|
11101
|
+
const [fadeOut, setFadeOut] = React__default.useState(false);
|
|
11102
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full" }, label && /* @__PURE__ */ React__default.createElement("label", { className: "w-full mb-1 block flex-1 text-sm font-bold leading-5 text-gray-700" }, label), /* @__PURE__ */ React__default.createElement(
|
|
11103
|
+
"span",
|
|
11104
|
+
{
|
|
11105
|
+
onClick: () => {
|
|
11106
|
+
if (copied === true)
|
|
11107
|
+
return;
|
|
11108
|
+
setCopied(true);
|
|
11109
|
+
setTimeout(() => {
|
|
11110
|
+
setFadeOut(true);
|
|
11111
|
+
}, 2500);
|
|
11112
|
+
setTimeout(() => {
|
|
11113
|
+
setCopied(false);
|
|
11114
|
+
setFadeOut(false);
|
|
11115
|
+
}, 3e3);
|
|
11116
|
+
navigator.clipboard.writeText(value);
|
|
11117
|
+
},
|
|
11118
|
+
className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
|
|
11119
|
+
},
|
|
11120
|
+
/* @__PURE__ */ React__default.createElement(BiCopyAlt, { className: "relative text-blue-500 shrink-0 w-5 h-auto mr-1.5 -ml-0.5 z-20" }),
|
|
11121
|
+
" ",
|
|
11122
|
+
value,
|
|
11123
|
+
" ",
|
|
11124
|
+
copied && /* @__PURE__ */ React__default.createElement(
|
|
11125
|
+
"span",
|
|
11126
|
+
{
|
|
11127
|
+
className: `${fadeOut ? `opacity-0` : `opacity-100`} text-blue-500 transition-opacity duration-500 absolute right-0 w-full h-full px-3 py-2 bg-white bg-opacity-90 flex items-center justify-center text-center tracking-wide font-medium z-10`
|
|
11128
|
+
},
|
|
11129
|
+
/* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
|
|
11130
|
+
)
|
|
11131
|
+
), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
|
|
11132
|
+
};
|
|
11046
11133
|
function ListMediaItem({ item, onClick, active }) {
|
|
11047
11134
|
let FileIcon = BiFile;
|
|
11048
11135
|
if (item.type === "dir") {
|
|
@@ -11118,59 +11205,6 @@ function GridMediaItem({ item, active, onClick }) {
|
|
|
11118
11205
|
)
|
|
11119
11206
|
);
|
|
11120
11207
|
}
|
|
11121
|
-
function dirname(path) {
|
|
11122
|
-
var _a, _b;
|
|
11123
|
-
const pattern = new RegExp("(?<prevDir>.*)/");
|
|
11124
|
-
return (_b = (_a = path.match(pattern)) == null ? void 0 : _a.groups) == null ? void 0 : _b.prevDir;
|
|
11125
|
-
}
|
|
11126
|
-
const BreadcrumbButton = ({ className = "", ...props }) => /* @__PURE__ */ React__default.createElement(
|
|
11127
|
-
"button",
|
|
11128
|
-
{
|
|
11129
|
-
className: "capitalize transition-colors duration-150 border-0 bg-transparent hover:text-blue-500 " + className,
|
|
11130
|
-
...props
|
|
11131
|
-
}
|
|
11132
|
-
);
|
|
11133
|
-
function Breadcrumb$1({ directory = "", setDirectory }) {
|
|
11134
|
-
directory = directory.replace(/^\/|\/$/g, "");
|
|
11135
|
-
let prevDir = dirname(directory) || "";
|
|
11136
|
-
if (prevDir === ".") {
|
|
11137
|
-
prevDir = "";
|
|
11138
|
-
}
|
|
11139
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex items-center text-[16px] text-gray-300" }, directory !== "" && /* @__PURE__ */ React__default.createElement(
|
|
11140
|
-
IconButton,
|
|
11141
|
-
{
|
|
11142
|
-
variant: "ghost",
|
|
11143
|
-
className: "mr-2",
|
|
11144
|
-
onClick: () => setDirectory(prevDir)
|
|
11145
|
-
},
|
|
11146
|
-
/* @__PURE__ */ React__default.createElement(
|
|
11147
|
-
LeftArrowIcon,
|
|
11148
|
-
{
|
|
11149
|
-
className: `w-7 h-auto fill-gray-300 hover:fill-gray-900 transition duration-150 ease-out`
|
|
11150
|
-
}
|
|
11151
|
-
)
|
|
11152
|
-
), /* @__PURE__ */ React__default.createElement(
|
|
11153
|
-
BreadcrumbButton,
|
|
11154
|
-
{
|
|
11155
|
-
onClick: () => setDirectory(""),
|
|
11156
|
-
className: directory === "" ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"
|
|
11157
|
-
},
|
|
11158
|
-
"Media"
|
|
11159
|
-
), directory && directory.split("/").map((part, index, parts) => {
|
|
11160
|
-
const currentDir = parts.slice(0, index + 1).join("/");
|
|
11161
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
11162
|
-
BreadcrumbButton,
|
|
11163
|
-
{
|
|
11164
|
-
className: "pl-1.5 " + (index + 1 === parts.length ? "text-gray-500 font-bold" : "text-gray-300 font-medium after:pl-1.5 after:content-['/']"),
|
|
11165
|
-
key: currentDir,
|
|
11166
|
-
onClick: () => {
|
|
11167
|
-
setDirectory(currentDir);
|
|
11168
|
-
}
|
|
11169
|
-
},
|
|
11170
|
-
part
|
|
11171
|
-
);
|
|
11172
|
-
}));
|
|
11173
|
-
}
|
|
11174
11208
|
const DeleteModal$1 = ({
|
|
11175
11209
|
close: close2,
|
|
11176
11210
|
deleteFunc,
|
|
@@ -11224,40 +11258,6 @@ const NewFolderModal = ({ onSubmit, close: close2 }) => {
|
|
|
11224
11258
|
"Create New Folder"
|
|
11225
11259
|
))));
|
|
11226
11260
|
};
|
|
11227
|
-
const CopyField = ({ label, description, value }) => {
|
|
11228
|
-
const [copied, setCopied] = React__default.useState(false);
|
|
11229
|
-
const [fadeOut, setFadeOut] = React__default.useState(false);
|
|
11230
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "w-full" }, label && /* @__PURE__ */ React__default.createElement("label", { className: "w-full mb-1 block flex-1 text-sm font-bold leading-5 text-gray-700" }, label), /* @__PURE__ */ React__default.createElement(
|
|
11231
|
-
"span",
|
|
11232
|
-
{
|
|
11233
|
-
onClick: () => {
|
|
11234
|
-
if (copied === true)
|
|
11235
|
-
return;
|
|
11236
|
-
setCopied(true);
|
|
11237
|
-
setTimeout(() => {
|
|
11238
|
-
setFadeOut(true);
|
|
11239
|
-
}, 2500);
|
|
11240
|
-
setTimeout(() => {
|
|
11241
|
-
setCopied(false);
|
|
11242
|
-
setFadeOut(false);
|
|
11243
|
-
}, 3e3);
|
|
11244
|
-
navigator.clipboard.writeText(value);
|
|
11245
|
-
},
|
|
11246
|
-
className: `shadow-inner text-base leading-5 whitespace-normal break-all px-3 py-2 text-gray-600 w-full bg-gray-50 border border-gray-200 transition-all ease-out duration-150 rounded-md relative overflow-hidden appearance-none flex items-center w-full cursor-pointer hover:bg-white hover:text-blue-500 ${copied ? `pointer-events-none` : ``}`
|
|
11247
|
-
},
|
|
11248
|
-
/* @__PURE__ */ React__default.createElement(BiCopyAlt, { className: "relative text-blue-500 shrink-0 w-5 h-auto mr-1.5 -ml-0.5 z-20" }),
|
|
11249
|
-
" ",
|
|
11250
|
-
value,
|
|
11251
|
-
" ",
|
|
11252
|
-
copied && /* @__PURE__ */ React__default.createElement(
|
|
11253
|
-
"span",
|
|
11254
|
-
{
|
|
11255
|
-
className: `${fadeOut ? `opacity-0` : `opacity-100`} text-blue-500 transition-opacity duration-500 absolute right-0 w-full h-full px-3 py-2 bg-white bg-opacity-90 flex items-center justify-center text-center tracking-wide font-medium z-10`
|
|
11256
|
-
},
|
|
11257
|
-
/* @__PURE__ */ React__default.createElement("span", null, "Copied to clipboard!")
|
|
11258
|
-
)
|
|
11259
|
-
), description && /* @__PURE__ */ React__default.createElement("p", { className: "mt-2 text-sm text-gray-500" }, description));
|
|
11260
|
-
};
|
|
11261
11261
|
const { useDropzone } = dropzone;
|
|
11262
11262
|
const join = function(...parts) {
|
|
11263
11263
|
const [first, last, slash] = [0, parts.length - 1, "/"];
|
|
@@ -11759,7 +11759,7 @@ const SyncStatusContainer = ({ children }) => {
|
|
|
11759
11759
|
target: "_blank",
|
|
11760
11760
|
href: `${cms.api.tina.appDashboardLink}/media`
|
|
11761
11761
|
},
|
|
11762
|
-
"Sync Your Media In
|
|
11762
|
+
"Sync Your Media In TinaCloud.",
|
|
11763
11763
|
/* @__PURE__ */ React__default.createElement(BiLinkExternal, { className: `w-5 h-auto flex-shrink-0` })
|
|
11764
11764
|
)
|
|
11765
11765
|
)))) : /* @__PURE__ */ React__default.createElement(SyncStatusContext.Provider, { value: { syncStatus } }, children);
|
|
@@ -30364,9 +30364,31 @@ function popupWindow(url, title, window2, w, h) {
|
|
|
30364
30364
|
}
|
|
30365
30365
|
const TINA_LOGIN_EVENT = "tinaCloudLogin";
|
|
30366
30366
|
const AUTH_TOKEN_KEY = "tinacms-auth";
|
|
30367
|
-
const
|
|
30368
|
-
|
|
30367
|
+
const generateRandomString = (length) => {
|
|
30368
|
+
const array = new Uint32Array(length);
|
|
30369
|
+
window.crypto.getRandomValues(array);
|
|
30370
|
+
return Array.from(array, (dec) => ("0" + dec.toString(16)).slice(-2)).join(
|
|
30371
|
+
""
|
|
30372
|
+
);
|
|
30373
|
+
};
|
|
30374
|
+
const generateCodeChallenge = async (codeVerifier) => {
|
|
30375
|
+
const encoder = new TextEncoder();
|
|
30376
|
+
const data = encoder.encode(codeVerifier);
|
|
30377
|
+
const digest = await window.crypto.subtle.digest("SHA-256", data);
|
|
30378
|
+
return btoa(String.fromCharCode(...new Uint8Array(digest))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
30379
|
+
};
|
|
30380
|
+
const authenticate = (clientId, frontendUrl, oauth2) => {
|
|
30381
|
+
return new Promise(async (resolve) => {
|
|
30369
30382
|
const origin = `${window.location.protocol}//${window.location.host}`;
|
|
30383
|
+
if (oauth2) {
|
|
30384
|
+
const codeVerifier = generateRandomString(32);
|
|
30385
|
+
const codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
30386
|
+
localStorage.setItem("code_verifier", codeVerifier);
|
|
30387
|
+
const redirectUri = encodeURIComponent(`${origin}/admin`);
|
|
30388
|
+
window.location.href = `${frontendUrl}/oauth-signin?redirect_uri=${redirectUri}&code_challenge=${codeChallenge}&client_id=${clientId}`;
|
|
30389
|
+
resolve(void 0);
|
|
30390
|
+
return;
|
|
30391
|
+
}
|
|
30370
30392
|
const authTab = popupWindow(
|
|
30371
30393
|
`${frontendUrl}/signin?clientId=${clientId}&origin=${origin}`,
|
|
30372
30394
|
"_blank",
|
|
@@ -30447,6 +30469,7 @@ class TinaCloudAuthProvider extends AbstractAuthProvider {
|
|
|
30447
30469
|
this.frontendUrl = frontendUrl;
|
|
30448
30470
|
this.clientId = clientId;
|
|
30449
30471
|
this.identityApiUrl = identityApiUrl;
|
|
30472
|
+
this.oauth2 = options.oauth2 || false;
|
|
30450
30473
|
switch (tokenStorage) {
|
|
30451
30474
|
case "LOCAL_STORAGE":
|
|
30452
30475
|
this.getToken = async function() {
|
|
@@ -30492,9 +30515,52 @@ class TinaCloudAuthProvider extends AbstractAuthProvider {
|
|
|
30492
30515
|
}
|
|
30493
30516
|
}
|
|
30494
30517
|
async authenticate() {
|
|
30495
|
-
const
|
|
30496
|
-
|
|
30497
|
-
|
|
30518
|
+
const params = new URLSearchParams(window.location.search);
|
|
30519
|
+
console.log({ params });
|
|
30520
|
+
const code = params.get("code");
|
|
30521
|
+
const state = params.get("state");
|
|
30522
|
+
const codeVerifier = localStorage.getItem("code_verifier");
|
|
30523
|
+
console.log({
|
|
30524
|
+
code,
|
|
30525
|
+
state,
|
|
30526
|
+
codeVerifier
|
|
30527
|
+
});
|
|
30528
|
+
if (code && state && codeVerifier) {
|
|
30529
|
+
const origin = `${window.location.protocol}//${window.location.host}`;
|
|
30530
|
+
const redirectUri = encodeURIComponent(`${origin}/admin`);
|
|
30531
|
+
const tokenUrl = `${this.identityApiUrl}/oauth2/${this.clientId}/token`;
|
|
30532
|
+
console.log("Token URL:", tokenUrl);
|
|
30533
|
+
await fetch(tokenUrl, {
|
|
30534
|
+
method: "POST",
|
|
30535
|
+
headers: {
|
|
30536
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
30537
|
+
},
|
|
30538
|
+
body: new URLSearchParams({
|
|
30539
|
+
grant_type: "authorization_code",
|
|
30540
|
+
code,
|
|
30541
|
+
redirect_uri: redirectUri,
|
|
30542
|
+
client_id: this.clientId,
|
|
30543
|
+
code_verifier: localStorage.getItem("code_verifier")
|
|
30544
|
+
})
|
|
30545
|
+
}).then((response) => response.json()).then((data) => {
|
|
30546
|
+
console.log("Token exchange response:", data);
|
|
30547
|
+
this.setToken(data);
|
|
30548
|
+
}).catch((error) => {
|
|
30549
|
+
console.error("Error during token exchange:", error);
|
|
30550
|
+
});
|
|
30551
|
+
} else {
|
|
30552
|
+
console.log("calling authenticate");
|
|
30553
|
+
const token = await authenticate(
|
|
30554
|
+
this.clientId,
|
|
30555
|
+
this.frontendUrl,
|
|
30556
|
+
this.oauth2
|
|
30557
|
+
);
|
|
30558
|
+
console.log("Token:", token);
|
|
30559
|
+
if (token) {
|
|
30560
|
+
this.setToken(token);
|
|
30561
|
+
}
|
|
30562
|
+
}
|
|
30563
|
+
return this.getToken();
|
|
30498
30564
|
}
|
|
30499
30565
|
async getUser() {
|
|
30500
30566
|
if (!this.clientId) {
|
|
@@ -30603,7 +30669,7 @@ const IndexStatusResponse = z.object({
|
|
|
30603
30669
|
});
|
|
30604
30670
|
class Client {
|
|
30605
30671
|
constructor({ tokenStorage = "MEMORY", ...options }) {
|
|
30606
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
30672
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
30607
30673
|
this.events = new EventBus();
|
|
30608
30674
|
this.protectedBranches = [];
|
|
30609
30675
|
this.usingEditorialWorkflow = false;
|
|
@@ -30684,7 +30750,8 @@ mutation addPendingDocumentMutation(
|
|
|
30684
30750
|
identityApiUrl: this.identityApiUrl,
|
|
30685
30751
|
getTokenFn: options.getTokenFn,
|
|
30686
30752
|
tokenStorage,
|
|
30687
|
-
frontendUrl: this.frontendUrl
|
|
30753
|
+
frontendUrl: this.frontendUrl,
|
|
30754
|
+
oauth2: (_w = (_v = options.schema) == null ? void 0 : _v.config) == null ? void 0 : _w.oauth2
|
|
30688
30755
|
});
|
|
30689
30756
|
}
|
|
30690
30757
|
get isLocalMode() {
|
|
@@ -30696,6 +30763,7 @@ mutation addPendingDocumentMutation(
|
|
|
30696
30763
|
setBranch(branchName) {
|
|
30697
30764
|
var _a, _b, _c, _d;
|
|
30698
30765
|
const encodedBranch = encodeURIComponent(branchName);
|
|
30766
|
+
document.cookie = `x-branch=${encodedBranch}; path=/; max-age=3600`;
|
|
30699
30767
|
this.branch = encodedBranch;
|
|
30700
30768
|
this.assetsApiUrl = ((_a = this.options.tinaioConfig) == null ? void 0 : _a.assetsApiUrlOverride) || "https://assets.tinajs.io";
|
|
30701
30769
|
this.frontendUrl = ((_b = this.options.tinaioConfig) == null ? void 0 : _b.frontendUrlOverride) || "https://app.tina.io";
|
|
@@ -30738,7 +30806,7 @@ mutation addPendingDocumentMutation(
|
|
|
30738
30806
|
branch: ${this.branch}.`;
|
|
30739
30807
|
if (this.branch !== "main") {
|
|
30740
30808
|
errorMessage = `${errorMessage}
|
|
30741
|
-
Note: This error can occur if the branch does not exist on GitHub or on
|
|
30809
|
+
Note: This error can occur if the branch does not exist on GitHub or on TinaCloud`;
|
|
30742
30810
|
}
|
|
30743
30811
|
}
|
|
30744
30812
|
throw new Error(errorMessage);
|
|
@@ -30874,7 +30942,7 @@ mutation addPendingDocumentMutation(
|
|
|
30874
30942
|
unknownCount++;
|
|
30875
30943
|
if (unknownCount > 5) {
|
|
30876
30944
|
throw new Error(
|
|
30877
|
-
"AsyncPoller: status unknown for too long, please check indexing progress the
|
|
30945
|
+
"AsyncPoller: status unknown for too long, please check indexing progress the TinaCloud dashboard"
|
|
30878
30946
|
);
|
|
30879
30947
|
}
|
|
30880
30948
|
}
|
|
@@ -31510,7 +31578,52 @@ const AuthWallInner = ({
|
|
|
31510
31578
|
const [showChildren, setShowChildren] = useState(false);
|
|
31511
31579
|
const [authProps, setAuthProps] = useState({ username: "", password: "" });
|
|
31512
31580
|
const [authenticated, setAuthenticated] = useState(false);
|
|
31581
|
+
const [code, setCode] = useState(null);
|
|
31582
|
+
const [state, setState] = useState(null);
|
|
31583
|
+
const [retrievingToken, setRetrievingToken] = useState(false);
|
|
31584
|
+
useEffect(() => {
|
|
31585
|
+
if (typeof window !== "undefined") {
|
|
31586
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
31587
|
+
setCode(queryParams.get("code"));
|
|
31588
|
+
setState(queryParams.get("state"));
|
|
31589
|
+
}
|
|
31590
|
+
}, []);
|
|
31591
|
+
useEffect(() => {
|
|
31592
|
+
const codeVerifier = localStorage.getItem("code_verifier");
|
|
31593
|
+
if (codeVerifier && code && state) {
|
|
31594
|
+
setRetrievingToken(true);
|
|
31595
|
+
const origin = `${window.location.protocol}//${window.location.host}`;
|
|
31596
|
+
const redirectUri = encodeURIComponent(`${origin}/admin`);
|
|
31597
|
+
const tokenUrl = `${client.identityApiUrl}/oauth2/${client.clientId}/token`;
|
|
31598
|
+
console.log("Token URL:", tokenUrl);
|
|
31599
|
+
fetch(tokenUrl, {
|
|
31600
|
+
method: "POST",
|
|
31601
|
+
headers: {
|
|
31602
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
31603
|
+
},
|
|
31604
|
+
body: new URLSearchParams({
|
|
31605
|
+
grant_type: "authorization_code",
|
|
31606
|
+
code,
|
|
31607
|
+
redirect_uri: redirectUri,
|
|
31608
|
+
client_id: client.clientId,
|
|
31609
|
+
code_verifier: localStorage.getItem("code_verifier")
|
|
31610
|
+
})
|
|
31611
|
+
}).then((response) => response.json()).then((data) => {
|
|
31612
|
+
console.log("Token exchange response:", data);
|
|
31613
|
+
setRetrievingToken(false);
|
|
31614
|
+
localStorage.setItem(AUTH_TOKEN_KEY, JSON.stringify(data));
|
|
31615
|
+
setAuthenticated(true);
|
|
31616
|
+
}).catch((error) => {
|
|
31617
|
+
console.error("Error during token exchange:", error);
|
|
31618
|
+
setRetrievingToken(false);
|
|
31619
|
+
});
|
|
31620
|
+
}
|
|
31621
|
+
}, [code, state]);
|
|
31513
31622
|
React__default.useEffect(() => {
|
|
31623
|
+
if (retrievingToken) {
|
|
31624
|
+
console.log("Retrieving token...");
|
|
31625
|
+
return;
|
|
31626
|
+
}
|
|
31514
31627
|
let mounted = true;
|
|
31515
31628
|
client.authProvider.isAuthenticated().then((isAuthenticated) => {
|
|
31516
31629
|
if (!mounted)
|
|
@@ -31555,7 +31668,7 @@ const AuthWallInner = ({
|
|
|
31555
31668
|
return () => {
|
|
31556
31669
|
mounted = false;
|
|
31557
31670
|
};
|
|
31558
|
-
}, [authenticated]);
|
|
31671
|
+
}, [authenticated, retrievingToken]);
|
|
31559
31672
|
const onAuthenticated = async () => {
|
|
31560
31673
|
setAuthenticated(true);
|
|
31561
31674
|
setActiveModal(null);
|
|
@@ -31585,7 +31698,7 @@ const AuthWallInner = ({
|
|
|
31585
31698
|
});
|
|
31586
31699
|
}
|
|
31587
31700
|
};
|
|
31588
|
-
let modalTitle = "
|
|
31701
|
+
let modalTitle = "TinaCloud";
|
|
31589
31702
|
if (activeModal === "authenticate" && loginStrategy === "Redirect" && !isTinaCloud) {
|
|
31590
31703
|
modalTitle = "Enter into edit mode";
|
|
31591
31704
|
} else if (activeModal === "authenticate" && loginStrategy === "UsernamePassword") {
|
|
@@ -31601,7 +31714,7 @@ const AuthWallInner = ({
|
|
|
31601
31714
|
ModalBuilder,
|
|
31602
31715
|
{
|
|
31603
31716
|
title: modalTitle,
|
|
31604
|
-
message: isTinaCloud ? "Your site uses
|
|
31717
|
+
message: isTinaCloud ? "Your site uses TinaCloud to track changes. To make edits, you must log in." : "To save edits, enter into edit mode. On save, changes will saved to the local filesystem.",
|
|
31605
31718
|
close,
|
|
31606
31719
|
actions: [
|
|
31607
31720
|
...otherModalActions,
|
|
@@ -32324,6 +32437,14 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
32324
32437
|
}
|
|
32325
32438
|
return client.request(query, { variables });
|
|
32326
32439
|
};
|
|
32440
|
+
const GetCMS = ({ children }) => {
|
|
32441
|
+
try {
|
|
32442
|
+
const cms = useCMS$1();
|
|
32443
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(cms));
|
|
32444
|
+
} catch (e) {
|
|
32445
|
+
return null;
|
|
32446
|
+
}
|
|
32447
|
+
};
|
|
32327
32448
|
const Layout = ({ children }) => {
|
|
32328
32449
|
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
32329
32450
|
"div",
|
|
@@ -32535,47 +32656,6 @@ const SidebarCloudLink = ({ config }) => {
|
|
|
32535
32656
|
}
|
|
32536
32657
|
return /* @__PURE__ */ React__default.createElement("span", { className: "text-base tracking-wide text-gray-500 hover:text-blue-600 flex items-center opacity-90 hover:opacity-100" }, /* @__PURE__ */ React__default.createElement(config.Icon, { className: "mr-2 h-6 opacity-80 w-auto" }), /* @__PURE__ */ React__default.createElement("a", { target: "_blank", href: config.link.href }, config.link.text));
|
|
32537
32658
|
};
|
|
32538
|
-
const GetCMS = ({ children }) => {
|
|
32539
|
-
try {
|
|
32540
|
-
const cms = useCMS$1();
|
|
32541
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(cms));
|
|
32542
|
-
} catch (e) {
|
|
32543
|
-
return null;
|
|
32544
|
-
}
|
|
32545
|
-
};
|
|
32546
|
-
const PageWrapper = ({ children }) => {
|
|
32547
|
-
var _a, _b;
|
|
32548
|
-
const cms = useCMS$1();
|
|
32549
|
-
const isLocalMode = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode;
|
|
32550
|
-
const [branchingEnabled, setBranchingEnabled] = React__default.useState(
|
|
32551
|
-
() => cms.flags.get("branch-switcher")
|
|
32552
|
-
);
|
|
32553
|
-
React__default.useEffect(() => {
|
|
32554
|
-
cms.events.subscribe("flag:set", ({ key, value }) => {
|
|
32555
|
-
if (key === "branch-switcher") {
|
|
32556
|
-
setBranchingEnabled(value);
|
|
32557
|
-
}
|
|
32558
|
-
});
|
|
32559
|
-
}, [cms.events]);
|
|
32560
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: "relative left-0 w-full h-full bg-gradient-to-b from-gray-50/50 to-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100" }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React__default.createElement(BranchBanner, null), children);
|
|
32561
|
-
};
|
|
32562
|
-
const PageHeader = ({
|
|
32563
|
-
isLocalMode,
|
|
32564
|
-
children
|
|
32565
|
-
}) => {
|
|
32566
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, isLocalMode && /* @__PURE__ */ React__default.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React__default.createElement(BillingWarning, null), /* @__PURE__ */ React__default.createElement("div", { className: "pt-16 xl:pt-12 px-6 xl:px-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex justify-between items-end" }, children))));
|
|
32567
|
-
};
|
|
32568
|
-
const PageBody = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-8 px-6 xl:px-12" }, children);
|
|
32569
|
-
const PageBodyNarrow = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-10 px-6 xl:px-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, children));
|
|
32570
|
-
const DashboardPage = () => {
|
|
32571
|
-
return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
|
|
32572
|
-
var _a, _b;
|
|
32573
|
-
return /* @__PURE__ */ React__default.createElement(PageWrapper, null, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(PageHeader, { isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode }, /* @__PURE__ */ React__default.createElement("h3", { className: "text-2xl font-sans text-gray-700" }, "Welcome to Tina!")), /* @__PURE__ */ React__default.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
|
|
32574
|
-
});
|
|
32575
|
-
};
|
|
32576
|
-
function RiHome2Line(props) {
|
|
32577
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M19 21H5C4.44772 21 4 20.5523 4 20V11L1 11L11.3273 1.6115C11.7087 1.26475 12.2913 1.26475 12.6727 1.6115L23 11L20 11V20C20 20.5523 19.5523 21 19 21ZM6 19H18V9.15745L12 3.7029L6 9.15745V19Z" }, "child": [] }] })(props);
|
|
32578
|
-
}
|
|
32579
32659
|
const LoadingPage = () => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
32580
32660
|
"div",
|
|
32581
32661
|
{
|
|
@@ -32685,231 +32765,33 @@ const LoadingPage = () => /* @__PURE__ */ React__default.createElement(React__de
|
|
|
32685
32765
|
)
|
|
32686
32766
|
)
|
|
32687
32767
|
));
|
|
32688
|
-
|
|
32689
|
-
|
|
32690
|
-
|
|
32691
|
-
}) => {
|
|
32692
|
-
|
|
32693
|
-
|
|
32694
|
-
const
|
|
32695
|
-
|
|
32696
|
-
|
|
32697
|
-
|
|
32698
|
-
|
|
32699
|
-
|
|
32700
|
-
|
|
32701
|
-
|
|
32702
|
-
for (const field of template.fields) {
|
|
32703
|
-
if (collectionMap[field.name]) {
|
|
32704
|
-
if (collectionMap[field.name].type !== field.type) {
|
|
32705
|
-
conflictedFields.add(field.name);
|
|
32706
|
-
}
|
|
32707
|
-
} else {
|
|
32708
|
-
collectionMap[field.name] = field;
|
|
32709
|
-
}
|
|
32710
|
-
}
|
|
32711
|
-
}
|
|
32712
|
-
for (const key in conflictedFields) {
|
|
32713
|
-
delete collectionMap[key];
|
|
32714
|
-
}
|
|
32715
|
-
for (const key in collectionMap) {
|
|
32716
|
-
if (key === sortKey) {
|
|
32717
|
-
return true;
|
|
32718
|
-
}
|
|
32719
|
-
}
|
|
32720
|
-
return false;
|
|
32721
|
-
}
|
|
32722
|
-
};
|
|
32723
|
-
const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
|
|
32724
|
-
const api = new TinaAdminApi(cms);
|
|
32725
|
-
const schema = cms.api.tina.schema;
|
|
32726
|
-
const collectionExtra = schema.getCollection(collectionName);
|
|
32727
|
-
const [collection, setCollection] = useState(void 0);
|
|
32728
|
-
const [loading, setLoading] = useState(true);
|
|
32729
|
-
const [error, setError] = useState(void 0);
|
|
32730
|
-
const [resetState, setResetSate] = useState(0);
|
|
32731
|
-
useEffect(() => {
|
|
32732
|
-
let cancelled = false;
|
|
32733
|
-
const fetchCollection = async () => {
|
|
32734
|
-
if (await api.isAuthenticated() && !folder.loading && !cancelled) {
|
|
32735
|
-
const { name, order } = JSON.parse(sortKey || "{}");
|
|
32736
|
-
const validSortKey = isValidSortKey(name, collectionExtra) ? name : void 0;
|
|
32737
|
-
try {
|
|
32738
|
-
const collection2 = await api.fetchCollection(
|
|
32739
|
-
collectionName,
|
|
32740
|
-
includeDocuments,
|
|
32741
|
-
(filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName,
|
|
32742
|
-
after,
|
|
32743
|
-
validSortKey,
|
|
32744
|
-
order,
|
|
32745
|
-
filterArgs
|
|
32746
|
-
);
|
|
32747
|
-
setCollection(collection2);
|
|
32748
|
-
} catch (error2) {
|
|
32749
|
-
cms.alerts.error(
|
|
32750
|
-
`[${error2.name}] GetCollection failed: ${error2.message}`
|
|
32751
|
-
);
|
|
32752
|
-
console.error(error2);
|
|
32753
|
-
setCollection(void 0);
|
|
32754
|
-
setError(error2);
|
|
32755
|
-
}
|
|
32756
|
-
setLoading(false);
|
|
32757
|
-
}
|
|
32758
|
-
};
|
|
32759
|
-
if (cancelled)
|
|
32760
|
-
return;
|
|
32761
|
-
setLoading(true);
|
|
32762
|
-
fetchCollection();
|
|
32763
|
-
return () => {
|
|
32764
|
-
cancelled = true;
|
|
32765
|
-
};
|
|
32766
|
-
}, [
|
|
32767
|
-
cms,
|
|
32768
|
-
collectionName,
|
|
32769
|
-
folder.loading,
|
|
32770
|
-
folder.fullyQualifiedName,
|
|
32771
|
-
resetState,
|
|
32772
|
-
after,
|
|
32773
|
-
sortKey
|
|
32774
|
-
]);
|
|
32775
|
-
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
32776
|
-
return { collection, loading, error, reFetchCollection, collectionExtra };
|
|
32777
|
-
};
|
|
32778
|
-
const useSearchCollection = (cms, collectionName, includeDocuments = true, folder, after = "", search) => {
|
|
32779
|
-
const api = new TinaAdminApi(cms);
|
|
32780
|
-
const schema = cms.api.tina.schema;
|
|
32781
|
-
const collectionExtra = schema.getCollection(collectionName);
|
|
32782
|
-
const [collection, setCollection] = useState(void 0);
|
|
32783
|
-
const [loading, setLoading] = useState(true);
|
|
32784
|
-
const [error, setError] = useState(void 0);
|
|
32785
|
-
const [resetState, setResetSate] = useState(0);
|
|
32786
|
-
useEffect(() => {
|
|
32787
|
-
let cancelled = false;
|
|
32788
|
-
const searchCollection = async () => {
|
|
32789
|
-
if (await api.isAuthenticated() && !folder.loading && !cancelled) {
|
|
32790
|
-
try {
|
|
32791
|
-
const response = await cms.api.search.query(
|
|
32792
|
-
`${search} AND _collection:${collectionName}`,
|
|
32793
|
-
{
|
|
32794
|
-
limit: 15,
|
|
32795
|
-
cursor: after
|
|
32796
|
-
}
|
|
32797
|
-
);
|
|
32798
|
-
const docs = await Promise.allSettled(
|
|
32799
|
-
response.results.map((result) => {
|
|
32800
|
-
const [collection2, relativePath2] = result._id.split(":");
|
|
32801
|
-
return api.fetchDocument(collection2, relativePath2, false);
|
|
32802
|
-
})
|
|
32803
|
-
);
|
|
32804
|
-
const edges = docs.filter((p) => {
|
|
32805
|
-
var _a;
|
|
32806
|
-
return p.status === "fulfilled" && !!((_a = p.value) == null ? void 0 : _a.document);
|
|
32807
|
-
}).map((result) => ({ node: result.value.document }));
|
|
32808
|
-
const c = await api.fetchCollection(collectionName, false, "");
|
|
32809
|
-
setCollection({
|
|
32810
|
-
format: collection.format,
|
|
32811
|
-
label: collection.label,
|
|
32812
|
-
name: collectionName,
|
|
32813
|
-
templates: collection.templates,
|
|
32814
|
-
documents: {
|
|
32815
|
-
pageInfo: {
|
|
32816
|
-
hasNextPage: !!response.nextCursor,
|
|
32817
|
-
hasPreviousPage: !!response.prevCursor,
|
|
32818
|
-
startCursor: "",
|
|
32819
|
-
endCursor: response.nextCursor || ""
|
|
32820
|
-
},
|
|
32821
|
-
edges
|
|
32822
|
-
}
|
|
32823
|
-
});
|
|
32824
|
-
} catch (error2) {
|
|
32825
|
-
cms.alerts.error(
|
|
32826
|
-
`[${error2.name}] GetCollection failed: ${error2.message}`
|
|
32827
|
-
);
|
|
32828
|
-
console.error(error2);
|
|
32829
|
-
setCollection(void 0);
|
|
32830
|
-
setError(error2);
|
|
32831
|
-
}
|
|
32832
|
-
setLoading(false);
|
|
32768
|
+
function RiHome2Line(props) {
|
|
32769
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M19 21H5C4.44772 21 4 20.5523 4 20V11L1 11L11.3273 1.6115C11.7087 1.26475 12.2913 1.26475 12.6727 1.6115L23 11L20 11V20C20 20.5523 19.5523 21 19 21ZM6 19H18V9.15745L12 3.7029L6 9.15745V19Z" }, "child": [] }] })(props);
|
|
32770
|
+
}
|
|
32771
|
+
const PageWrapper = ({ children }) => {
|
|
32772
|
+
var _a, _b;
|
|
32773
|
+
const cms = useCMS$1();
|
|
32774
|
+
const isLocalMode = (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode;
|
|
32775
|
+
const [branchingEnabled, setBranchingEnabled] = React__default.useState(
|
|
32776
|
+
() => cms.flags.get("branch-switcher")
|
|
32777
|
+
);
|
|
32778
|
+
React__default.useEffect(() => {
|
|
32779
|
+
cms.events.subscribe("flag:set", ({ key, value }) => {
|
|
32780
|
+
if (key === "branch-switcher") {
|
|
32781
|
+
setBranchingEnabled(value);
|
|
32833
32782
|
}
|
|
32834
|
-
};
|
|
32835
|
-
|
|
32836
|
-
|
|
32837
|
-
setLoading(true);
|
|
32838
|
-
searchCollection();
|
|
32839
|
-
return () => {
|
|
32840
|
-
cancelled = true;
|
|
32841
|
-
};
|
|
32842
|
-
}, [
|
|
32843
|
-
cms,
|
|
32844
|
-
collectionName,
|
|
32845
|
-
folder.loading,
|
|
32846
|
-
folder.fullyQualifiedName,
|
|
32847
|
-
resetState,
|
|
32848
|
-
after,
|
|
32849
|
-
search
|
|
32850
|
-
]);
|
|
32851
|
-
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
32852
|
-
return { collection, loading, error, reFetchCollection, collectionExtra };
|
|
32783
|
+
});
|
|
32784
|
+
}, [cms.events]);
|
|
32785
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "relative left-0 w-full h-full bg-gradient-to-b from-gray-50/50 to-gray-50 shadow-2xl overflow-y-auto transition-opacity duration-300 ease-out flex flex-col opacity-100" }, branchingEnabled && !isLocalMode && /* @__PURE__ */ React__default.createElement(BranchBanner, null), children);
|
|
32853
32786
|
};
|
|
32854
|
-
const
|
|
32855
|
-
|
|
32856
|
-
|
|
32857
|
-
folder,
|
|
32858
|
-
includeDocuments = true,
|
|
32859
|
-
startCursor,
|
|
32860
|
-
sortKey,
|
|
32861
|
-
children,
|
|
32862
|
-
filterArgs,
|
|
32863
|
-
search
|
|
32787
|
+
const PageHeader = ({
|
|
32788
|
+
isLocalMode,
|
|
32789
|
+
children
|
|
32864
32790
|
}) => {
|
|
32865
|
-
|
|
32866
|
-
const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
|
|
32867
|
-
cms,
|
|
32868
|
-
collectionName,
|
|
32869
|
-
includeDocuments,
|
|
32870
|
-
folder,
|
|
32871
|
-
startCursor || "",
|
|
32872
|
-
search
|
|
32873
|
-
) : useGetCollection(
|
|
32874
|
-
cms,
|
|
32875
|
-
collectionName,
|
|
32876
|
-
includeDocuments,
|
|
32877
|
-
folder,
|
|
32878
|
-
startCursor || "",
|
|
32879
|
-
sortKey,
|
|
32880
|
-
filterArgs
|
|
32881
|
-
) || {};
|
|
32882
|
-
useEffect(() => {
|
|
32883
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
32884
|
-
if (loading)
|
|
32885
|
-
return;
|
|
32886
|
-
const collectionDefinition = cms.api.tina.schema.getCollection(
|
|
32887
|
-
collection.name
|
|
32888
|
-
);
|
|
32889
|
-
const allowCreate = ((_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) ?? true;
|
|
32890
|
-
const allowDelete = ((_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.delete) ?? true;
|
|
32891
|
-
const collectionResponse = collection;
|
|
32892
|
-
if (!allowCreate && !allowDelete && // Check there is only one document
|
|
32893
|
-
((_f = (_e = collectionResponse.documents) == null ? void 0 : _e.edges) == null ? void 0 : _f.length) === 1 && // Check to make sure the file is not a folder
|
|
32894
|
-
((_i = (_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges[0]) == null ? void 0 : _h.node) == null ? void 0 : _i.__typename) !== "Folder") {
|
|
32895
|
-
const doc = collectionResponse.documents.edges[0].node;
|
|
32896
|
-
handleNavigate(
|
|
32897
|
-
navigate,
|
|
32898
|
-
cms,
|
|
32899
|
-
collectionResponse,
|
|
32900
|
-
collectionDefinition,
|
|
32901
|
-
doc
|
|
32902
|
-
);
|
|
32903
|
-
}
|
|
32904
|
-
}, [(collection == null ? void 0 : collection.name) || "", loading]);
|
|
32905
|
-
if (error) {
|
|
32906
|
-
return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
|
|
32907
|
-
}
|
|
32908
|
-
if (loading) {
|
|
32909
|
-
return /* @__PURE__ */ React__default.createElement(LoadingPage, null);
|
|
32910
|
-
}
|
|
32911
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
|
|
32791
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, isLocalMode && /* @__PURE__ */ React__default.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React__default.createElement(BillingWarning, null), /* @__PURE__ */ React__default.createElement("div", { className: "pt-16 xl:pt-12 px-6 xl:px-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full flex justify-between items-end" }, children))));
|
|
32912
32792
|
};
|
|
32793
|
+
const PageBody = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-8 px-6 xl:px-12" }, children);
|
|
32794
|
+
const PageBodyNarrow = ({ children }) => /* @__PURE__ */ React__default.createElement("div", { className: "py-10 px-6 xl:px-12" }, /* @__PURE__ */ React__default.createElement("div", { className: "w-full mx-auto max-w-screen-xl" }, children));
|
|
32913
32795
|
const folderRegex = /^.*\/~\/*(.*)$/;
|
|
32914
32796
|
const parentFolder = (folder) => {
|
|
32915
32797
|
return {
|
|
@@ -33787,6 +33669,231 @@ const RenameModal = ({
|
|
|
33787
33669
|
"Rename"
|
|
33788
33670
|
))));
|
|
33789
33671
|
};
|
|
33672
|
+
const FullscreenError = ({
|
|
33673
|
+
title = "Error",
|
|
33674
|
+
errorMessage = "It looks like something went wrong."
|
|
33675
|
+
}) => {
|
|
33676
|
+
return /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col justify-center items-center h-screen bg-gray-100" }, /* @__PURE__ */ React__default.createElement("div", { className: "text-red-500 text-4xl mb-6 flex items-center" }, /* @__PURE__ */ React__default.createElement(BiError, { className: "w-12 h-auto fill-current text-red-400 opacity-70 mr-1" }), " ", title), /* @__PURE__ */ React__default.createElement("p", { className: "text-gray-700 text-xl mb-8" }, errorMessage), /* @__PURE__ */ React__default.createElement(Button$1, { variant: "danger", onClick: () => window.location.reload() }, /* @__PURE__ */ React__default.createElement(BiSync, { className: "w-7 h-auto fill-current opacity-70 mr-1" }), " Reload"));
|
|
33677
|
+
};
|
|
33678
|
+
const isValidSortKey = (sortKey, collection) => {
|
|
33679
|
+
if (collection.fields) {
|
|
33680
|
+
const sortKeys = collection.fields.map((x) => x.name);
|
|
33681
|
+
return sortKeys.includes(sortKey);
|
|
33682
|
+
} else if (collection.templates) {
|
|
33683
|
+
const collectionMap = {};
|
|
33684
|
+
const conflictedFields = /* @__PURE__ */ new Set();
|
|
33685
|
+
for (const template of collection.templates) {
|
|
33686
|
+
for (const field of template.fields) {
|
|
33687
|
+
if (collectionMap[field.name]) {
|
|
33688
|
+
if (collectionMap[field.name].type !== field.type) {
|
|
33689
|
+
conflictedFields.add(field.name);
|
|
33690
|
+
}
|
|
33691
|
+
} else {
|
|
33692
|
+
collectionMap[field.name] = field;
|
|
33693
|
+
}
|
|
33694
|
+
}
|
|
33695
|
+
}
|
|
33696
|
+
for (const key in conflictedFields) {
|
|
33697
|
+
delete collectionMap[key];
|
|
33698
|
+
}
|
|
33699
|
+
for (const key in collectionMap) {
|
|
33700
|
+
if (key === sortKey) {
|
|
33701
|
+
return true;
|
|
33702
|
+
}
|
|
33703
|
+
}
|
|
33704
|
+
return false;
|
|
33705
|
+
}
|
|
33706
|
+
};
|
|
33707
|
+
const useGetCollection = (cms, collectionName, includeDocuments = true, folder, after = "", sortKey, filterArgs) => {
|
|
33708
|
+
const api = new TinaAdminApi(cms);
|
|
33709
|
+
const schema = cms.api.tina.schema;
|
|
33710
|
+
const collectionExtra = schema.getCollection(collectionName);
|
|
33711
|
+
const [collection, setCollection] = useState(void 0);
|
|
33712
|
+
const [loading, setLoading] = useState(true);
|
|
33713
|
+
const [error, setError] = useState(void 0);
|
|
33714
|
+
const [resetState, setResetSate] = useState(0);
|
|
33715
|
+
useEffect(() => {
|
|
33716
|
+
let cancelled = false;
|
|
33717
|
+
const fetchCollection = async () => {
|
|
33718
|
+
if (await api.isAuthenticated() && !folder.loading && !cancelled) {
|
|
33719
|
+
const { name, order } = JSON.parse(sortKey || "{}");
|
|
33720
|
+
const validSortKey = isValidSortKey(name, collectionExtra) ? name : void 0;
|
|
33721
|
+
try {
|
|
33722
|
+
const collection2 = await api.fetchCollection(
|
|
33723
|
+
collectionName,
|
|
33724
|
+
includeDocuments,
|
|
33725
|
+
(filterArgs == null ? void 0 : filterArgs.filterField) ? "" : folder.fullyQualifiedName,
|
|
33726
|
+
after,
|
|
33727
|
+
validSortKey,
|
|
33728
|
+
order,
|
|
33729
|
+
filterArgs
|
|
33730
|
+
);
|
|
33731
|
+
setCollection(collection2);
|
|
33732
|
+
} catch (error2) {
|
|
33733
|
+
cms.alerts.error(
|
|
33734
|
+
`[${error2.name}] GetCollection failed: ${error2.message}`
|
|
33735
|
+
);
|
|
33736
|
+
console.error(error2);
|
|
33737
|
+
setCollection(void 0);
|
|
33738
|
+
setError(error2);
|
|
33739
|
+
}
|
|
33740
|
+
setLoading(false);
|
|
33741
|
+
}
|
|
33742
|
+
};
|
|
33743
|
+
if (cancelled)
|
|
33744
|
+
return;
|
|
33745
|
+
setLoading(true);
|
|
33746
|
+
fetchCollection();
|
|
33747
|
+
return () => {
|
|
33748
|
+
cancelled = true;
|
|
33749
|
+
};
|
|
33750
|
+
}, [
|
|
33751
|
+
cms,
|
|
33752
|
+
collectionName,
|
|
33753
|
+
folder.loading,
|
|
33754
|
+
folder.fullyQualifiedName,
|
|
33755
|
+
resetState,
|
|
33756
|
+
after,
|
|
33757
|
+
sortKey
|
|
33758
|
+
]);
|
|
33759
|
+
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
33760
|
+
return { collection, loading, error, reFetchCollection, collectionExtra };
|
|
33761
|
+
};
|
|
33762
|
+
const useSearchCollection = (cms, collectionName, includeDocuments = true, folder, after = "", search) => {
|
|
33763
|
+
const api = new TinaAdminApi(cms);
|
|
33764
|
+
const schema = cms.api.tina.schema;
|
|
33765
|
+
const collectionExtra = schema.getCollection(collectionName);
|
|
33766
|
+
const [collection, setCollection] = useState(void 0);
|
|
33767
|
+
const [loading, setLoading] = useState(true);
|
|
33768
|
+
const [error, setError] = useState(void 0);
|
|
33769
|
+
const [resetState, setResetSate] = useState(0);
|
|
33770
|
+
useEffect(() => {
|
|
33771
|
+
let cancelled = false;
|
|
33772
|
+
const searchCollection = async () => {
|
|
33773
|
+
if (await api.isAuthenticated() && !folder.loading && !cancelled) {
|
|
33774
|
+
try {
|
|
33775
|
+
const response = await cms.api.search.query(
|
|
33776
|
+
`${search} AND _collection:${collectionName}`,
|
|
33777
|
+
{
|
|
33778
|
+
limit: 15,
|
|
33779
|
+
cursor: after
|
|
33780
|
+
}
|
|
33781
|
+
);
|
|
33782
|
+
const docs = await Promise.allSettled(
|
|
33783
|
+
response.results.map((result) => {
|
|
33784
|
+
const [collection2, relativePath2] = result._id.split(":");
|
|
33785
|
+
return api.fetchDocument(collection2, relativePath2, false);
|
|
33786
|
+
})
|
|
33787
|
+
);
|
|
33788
|
+
const edges = docs.filter((p) => {
|
|
33789
|
+
var _a;
|
|
33790
|
+
return p.status === "fulfilled" && !!((_a = p.value) == null ? void 0 : _a.document);
|
|
33791
|
+
}).map((result) => ({ node: result.value.document }));
|
|
33792
|
+
const c = await api.fetchCollection(collectionName, false, "");
|
|
33793
|
+
setCollection({
|
|
33794
|
+
format: collection.format,
|
|
33795
|
+
label: collection.label,
|
|
33796
|
+
name: collectionName,
|
|
33797
|
+
templates: collection.templates,
|
|
33798
|
+
documents: {
|
|
33799
|
+
pageInfo: {
|
|
33800
|
+
hasNextPage: !!response.nextCursor,
|
|
33801
|
+
hasPreviousPage: !!response.prevCursor,
|
|
33802
|
+
startCursor: "",
|
|
33803
|
+
endCursor: response.nextCursor || ""
|
|
33804
|
+
},
|
|
33805
|
+
edges
|
|
33806
|
+
}
|
|
33807
|
+
});
|
|
33808
|
+
} catch (error2) {
|
|
33809
|
+
cms.alerts.error(
|
|
33810
|
+
`[${error2.name}] GetCollection failed: ${error2.message}`
|
|
33811
|
+
);
|
|
33812
|
+
console.error(error2);
|
|
33813
|
+
setCollection(void 0);
|
|
33814
|
+
setError(error2);
|
|
33815
|
+
}
|
|
33816
|
+
setLoading(false);
|
|
33817
|
+
}
|
|
33818
|
+
};
|
|
33819
|
+
if (cancelled)
|
|
33820
|
+
return;
|
|
33821
|
+
setLoading(true);
|
|
33822
|
+
searchCollection();
|
|
33823
|
+
return () => {
|
|
33824
|
+
cancelled = true;
|
|
33825
|
+
};
|
|
33826
|
+
}, [
|
|
33827
|
+
cms,
|
|
33828
|
+
collectionName,
|
|
33829
|
+
folder.loading,
|
|
33830
|
+
folder.fullyQualifiedName,
|
|
33831
|
+
resetState,
|
|
33832
|
+
after,
|
|
33833
|
+
search
|
|
33834
|
+
]);
|
|
33835
|
+
const reFetchCollection = () => setResetSate((x) => x + 1);
|
|
33836
|
+
return { collection, loading, error, reFetchCollection, collectionExtra };
|
|
33837
|
+
};
|
|
33838
|
+
const GetCollection = ({
|
|
33839
|
+
cms,
|
|
33840
|
+
collectionName,
|
|
33841
|
+
folder,
|
|
33842
|
+
includeDocuments = true,
|
|
33843
|
+
startCursor,
|
|
33844
|
+
sortKey,
|
|
33845
|
+
children,
|
|
33846
|
+
filterArgs,
|
|
33847
|
+
search
|
|
33848
|
+
}) => {
|
|
33849
|
+
const navigate = useNavigate();
|
|
33850
|
+
const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
|
|
33851
|
+
cms,
|
|
33852
|
+
collectionName,
|
|
33853
|
+
includeDocuments,
|
|
33854
|
+
folder,
|
|
33855
|
+
startCursor || "",
|
|
33856
|
+
search
|
|
33857
|
+
) : useGetCollection(
|
|
33858
|
+
cms,
|
|
33859
|
+
collectionName,
|
|
33860
|
+
includeDocuments,
|
|
33861
|
+
folder,
|
|
33862
|
+
startCursor || "",
|
|
33863
|
+
sortKey,
|
|
33864
|
+
filterArgs
|
|
33865
|
+
) || {};
|
|
33866
|
+
useEffect(() => {
|
|
33867
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
33868
|
+
if (loading)
|
|
33869
|
+
return;
|
|
33870
|
+
const collectionDefinition = cms.api.tina.schema.getCollection(
|
|
33871
|
+
collection.name
|
|
33872
|
+
);
|
|
33873
|
+
const allowCreate = ((_b = (_a = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _a.allowedActions) == null ? void 0 : _b.create) ?? true;
|
|
33874
|
+
const allowDelete = ((_d = (_c = collectionDefinition == null ? void 0 : collectionDefinition.ui) == null ? void 0 : _c.allowedActions) == null ? void 0 : _d.delete) ?? true;
|
|
33875
|
+
const collectionResponse = collection;
|
|
33876
|
+
if (!allowCreate && !allowDelete && // Check there is only one document
|
|
33877
|
+
((_f = (_e = collectionResponse.documents) == null ? void 0 : _e.edges) == null ? void 0 : _f.length) === 1 && // Check to make sure the file is not a folder
|
|
33878
|
+
((_i = (_h = (_g = collectionResponse.documents) == null ? void 0 : _g.edges[0]) == null ? void 0 : _h.node) == null ? void 0 : _i.__typename) !== "Folder") {
|
|
33879
|
+
const doc = collectionResponse.documents.edges[0].node;
|
|
33880
|
+
handleNavigate(
|
|
33881
|
+
navigate,
|
|
33882
|
+
cms,
|
|
33883
|
+
collectionResponse,
|
|
33884
|
+
collectionDefinition,
|
|
33885
|
+
doc
|
|
33886
|
+
);
|
|
33887
|
+
}
|
|
33888
|
+
}, [(collection == null ? void 0 : collection.name) || "", loading]);
|
|
33889
|
+
if (error) {
|
|
33890
|
+
return /* @__PURE__ */ React__default.createElement(FullscreenError, null);
|
|
33891
|
+
}
|
|
33892
|
+
if (loading) {
|
|
33893
|
+
return /* @__PURE__ */ React__default.createElement(LoadingPage, null);
|
|
33894
|
+
}
|
|
33895
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children(collection, loading, reFetchCollection, collectionExtra));
|
|
33896
|
+
};
|
|
33790
33897
|
const ErrorDialog = (props) => {
|
|
33791
33898
|
return /* @__PURE__ */ React__default.createElement(
|
|
33792
33899
|
"div",
|
|
@@ -34330,6 +34437,12 @@ const RenderForm = ({
|
|
|
34330
34437
|
), /* @__PURE__ */ React__default.createElement("span", { className: "opacity-30 text-sm leading-tight whitespace-nowrap flex-0" }, "/"), /* @__PURE__ */ React__default.createElement("span", { className: "flex-1 w-full text-sm leading-tight whitespace-nowrap truncate" }, `${filename}.${collection.format}`), /* @__PURE__ */ React__default.createElement(FormStatus, { pristine: formIsPristine }))
|
|
34331
34438
|
), activeForm && /* @__PURE__ */ React__default.createElement(FormBuilder, { form: activeForm, onPristineChange: setFormIsPristine }));
|
|
34332
34439
|
};
|
|
34440
|
+
const DashboardPage = () => {
|
|
34441
|
+
return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
|
|
34442
|
+
var _a, _b;
|
|
34443
|
+
return /* @__PURE__ */ React__default.createElement(PageWrapper, null, /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(PageHeader, { isLocalMode: (_b = (_a = cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode }, /* @__PURE__ */ React__default.createElement("h3", { className: "text-2xl font-sans text-gray-700" }, "Welcome to Tina!")), /* @__PURE__ */ React__default.createElement(PageBodyNarrow, null, "This is your dashboard for editing or creating content. Select a collection on the left to begin.")));
|
|
34444
|
+
});
|
|
34445
|
+
};
|
|
34333
34446
|
const ScreenPage = () => {
|
|
34334
34447
|
const { screenName } = useParams();
|
|
34335
34448
|
return /* @__PURE__ */ React__default.createElement(GetCMS, null, (cms) => {
|
|
@@ -34348,6 +34461,71 @@ const ScreenPage = () => {
|
|
|
34348
34461
|
} })));
|
|
34349
34462
|
});
|
|
34350
34463
|
};
|
|
34464
|
+
function AuthCallback({
|
|
34465
|
+
clientId,
|
|
34466
|
+
identityApiUrl
|
|
34467
|
+
}) {
|
|
34468
|
+
console.log("AuthCallback", clientId, identityApiUrl);
|
|
34469
|
+
const [code, setCode] = React.useState(null);
|
|
34470
|
+
const [state, setState] = React.useState(null);
|
|
34471
|
+
const [tokenResponse, setTokenResponse] = React.useState(null);
|
|
34472
|
+
const [app, setApp] = React.useState(null);
|
|
34473
|
+
React.useEffect(() => {
|
|
34474
|
+
if (typeof window !== "undefined") {
|
|
34475
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
34476
|
+
setCode(queryParams.get("code"));
|
|
34477
|
+
setState(queryParams.get("state"));
|
|
34478
|
+
}
|
|
34479
|
+
}, []);
|
|
34480
|
+
React.useEffect(() => {
|
|
34481
|
+
if (code && state) {
|
|
34482
|
+
if (localStorage.getItem("code_verifier")) {
|
|
34483
|
+
const origin = `${window.location.protocol}//${window.location.host}`;
|
|
34484
|
+
const redirectUri = encodeURIComponent(
|
|
34485
|
+
`${origin}/admin#/auth/callback`
|
|
34486
|
+
);
|
|
34487
|
+
fetch(`${identityApiUrl}/oauth2/${clientId}/token`, {
|
|
34488
|
+
method: "POST",
|
|
34489
|
+
headers: {
|
|
34490
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
34491
|
+
},
|
|
34492
|
+
body: new URLSearchParams({
|
|
34493
|
+
grant_type: "authorization_code",
|
|
34494
|
+
code,
|
|
34495
|
+
redirect_uri: redirectUri,
|
|
34496
|
+
client_id: clientId || "",
|
|
34497
|
+
code_verifier: localStorage.getItem("code_verifier")
|
|
34498
|
+
})
|
|
34499
|
+
}).then((response) => response.json()).then((data) => {
|
|
34500
|
+
console.log("Token exchange response:", data);
|
|
34501
|
+
setTokenResponse(data);
|
|
34502
|
+
}).catch((error) => {
|
|
34503
|
+
console.error("Error during token exchange:", error);
|
|
34504
|
+
});
|
|
34505
|
+
}
|
|
34506
|
+
}
|
|
34507
|
+
}, [code, state]);
|
|
34508
|
+
React.useEffect(() => {
|
|
34509
|
+
localStorage.setItem(
|
|
34510
|
+
AUTH_TOKEN_KEY,
|
|
34511
|
+
JSON.stringify(tokenResponse, null, 2)
|
|
34512
|
+
);
|
|
34513
|
+
}, [tokenResponse]);
|
|
34514
|
+
React.useEffect(() => {
|
|
34515
|
+
fetch(`${identityApiUrl}/v2/apps/${clientId}`, {
|
|
34516
|
+
method: "GET",
|
|
34517
|
+
headers: {
|
|
34518
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
34519
|
+
Authorization: "Bearer " + (tokenResponse == null ? void 0 : tokenResponse.access_token)
|
|
34520
|
+
}
|
|
34521
|
+
}).then((response) => response.json()).then((data) => {
|
|
34522
|
+
setApp(data);
|
|
34523
|
+
}).catch((error) => {
|
|
34524
|
+
console.error("Error fetching apps:", error);
|
|
34525
|
+
});
|
|
34526
|
+
}, [tokenResponse]);
|
|
34527
|
+
return /* @__PURE__ */ React.createElement("div", null, code && /* @__PURE__ */ React.createElement("div", null, "Code: ", /* @__PURE__ */ React.createElement("pre", null, code), /* @__PURE__ */ React.createElement("br", null)), state && /* @__PURE__ */ React.createElement("div", null, "State: ", /* @__PURE__ */ React.createElement("pre", null, state), /* @__PURE__ */ React.createElement("br", null)), tokenResponse && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", null, "Token Response:"), /* @__PURE__ */ React.createElement("pre", null, tokenResponse.access_token), /* @__PURE__ */ React.createElement("br", null)), /* @__PURE__ */ React.createElement("div", null, app && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h2", null, "Project Name: ", app.name), /* @__PURE__ */ React.createElement("p", null, "Project ID: ", /* @__PURE__ */ React.createElement("pre", null, app.id)))));
|
|
34528
|
+
}
|
|
34351
34529
|
const IndexingPage = () => {
|
|
34352
34530
|
const cms = useCMS$1();
|
|
34353
34531
|
const tinaApi = cms.api.tina;
|
|
@@ -34412,7 +34590,7 @@ const IndexingPage = () => {
|
|
|
34412
34590
|
} catch {
|
|
34413
34591
|
cms.alerts.error("Branch indexing failed.");
|
|
34414
34592
|
setErrorMessage(
|
|
34415
|
-
'Branch indexing failed, please check the
|
|
34593
|
+
'Branch indexing failed, please check the TinaCloud dashboard for more information. To try again chick "re-index" on the branch in the dashboard.'
|
|
34416
34594
|
);
|
|
34417
34595
|
setState("error");
|
|
34418
34596
|
}
|
|
@@ -34580,7 +34758,7 @@ const CheckSchema = ({
|
|
|
34580
34758
|
);
|
|
34581
34759
|
}
|
|
34582
34760
|
}).catch((e) => {
|
|
34583
|
-
if (e.message.includes("has not been indexed by
|
|
34761
|
+
if (e.message.includes("has not been indexed by TinaCloud")) {
|
|
34584
34762
|
setSchemaMissingError(true);
|
|
34585
34763
|
} else {
|
|
34586
34764
|
cms.alerts.error(`Unexpected error checking schema: ${e}`);
|
|
@@ -34695,6 +34873,18 @@ const TinaAdmin = ({
|
|
|
34695
34873
|
path: "screens/:screenName",
|
|
34696
34874
|
element: /* @__PURE__ */ React__default.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React__default.createElement(ScreenPage, null))
|
|
34697
34875
|
}
|
|
34876
|
+
), /* @__PURE__ */ React__default.createElement(
|
|
34877
|
+
Route,
|
|
34878
|
+
{
|
|
34879
|
+
path: "auth/callback",
|
|
34880
|
+
element: /* @__PURE__ */ React__default.createElement(DefaultWrapper, { cms }, /* @__PURE__ */ React__default.createElement(
|
|
34881
|
+
AuthCallback,
|
|
34882
|
+
{
|
|
34883
|
+
clientId: tinaClient.clientId,
|
|
34884
|
+
identityApiUrl: tinaClient.identityApiUrl
|
|
34885
|
+
}
|
|
34886
|
+
))
|
|
34887
|
+
}
|
|
34698
34888
|
), /* @__PURE__ */ React__default.createElement(
|
|
34699
34889
|
Route,
|
|
34700
34890
|
{
|