tinacms 0.57.4 → 0.59.1
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 +47 -0
- package/dist/admin/components/AuthTemplate.d.ts +17 -0
- package/dist/admin/components/Sidebar.d.ts +17 -0
- package/dist/admin/pages/LogoutPage.d.ts +14 -0
- package/dist/admin/plugins/route-mapping.d.ts +32 -0
- package/dist/client/index.d.ts +3 -2
- package/dist/edit-state.d.ts +2 -11
- package/dist/edit-state.es.js +14 -38
- package/dist/edit-state.js +29 -42
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +415 -322
- package/dist/index.js +415 -322
- package/dist/tina-cms.d.ts +1 -1
- package/dist/utils/client.d.ts +29 -0
- package/package.json +7 -24
package/dist/index.js
CHANGED
|
@@ -30,8 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
(function(global, factory) {
|
|
33
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("graphql"), require("lodash.set"), require("graphql-tag"), require("@tinacms/toolkit"), require("react"), require("styled-components"), require("yup"), require("final-form"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "graphql", "lodash.set", "graphql-tag", "@tinacms/toolkit", "react", "styled-components", "yup", "final-form", "react-router-dom", "@headlessui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
|
|
34
|
-
})(this, function(exports2, graphql, set, gql$1, toolkit, React, styled, yup, finalForm, reactRouterDom, react) {
|
|
33
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("graphql"), require("lodash.set"), require("graphql-tag"), require("@tinacms/toolkit"), require("react"), require("styled-components"), require("yup"), require("@tinacms/sharedctx"), require("final-form"), require("react-router-dom"), require("@headlessui/react")) : typeof define === "function" && define.amd ? define(["exports", "graphql", "lodash.set", "graphql-tag", "@tinacms/toolkit", "react", "styled-components", "yup", "@tinacms/sharedctx", "final-form", "react-router-dom", "@headlessui/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
|
|
34
|
+
})(this, function(exports2, graphql, set, gql$1, toolkit, React, styled, yup, sharedctx, finalForm, reactRouterDom, react) {
|
|
35
35
|
"use strict";
|
|
36
36
|
function _interopDefaultLegacy(e) {
|
|
37
37
|
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
@@ -397,6 +397,7 @@ var __objRest = (source, exclude) => {
|
|
|
397
397
|
class Client {
|
|
398
398
|
constructor(_a) {
|
|
399
399
|
var _b = _a, { tokenStorage = "MEMORY" } = _b, options = __objRest(_b, ["tokenStorage"]);
|
|
400
|
+
this.events = new toolkit.EventBus();
|
|
400
401
|
this.addPendingContent = async (props) => {
|
|
401
402
|
const mutation = `#graphql
|
|
402
403
|
mutation addPendingDocumentMutation(
|
|
@@ -437,8 +438,7 @@ mutation addPendingDocumentMutation(
|
|
|
437
438
|
};
|
|
438
439
|
this.options = options;
|
|
439
440
|
this.setBranch(options.branch);
|
|
440
|
-
this.events
|
|
441
|
-
this.events.subscribe("branch-switcher:change-branch", ({ branchName }) => {
|
|
441
|
+
this.events.subscribe("branch:change", ({ branchName }) => {
|
|
442
442
|
this.setBranch(branchName);
|
|
443
443
|
});
|
|
444
444
|
this.clientId = options.clientId;
|
|
@@ -489,8 +489,8 @@ mutation addPendingDocumentMutation(
|
|
|
489
489
|
const encodedBranch = encodeURIComponent(branchName);
|
|
490
490
|
this.frontendUrl = ((_a = this.options.tinaioConfig) == null ? void 0 : _a.frontendUrlOverride) || "https://app.tina.io";
|
|
491
491
|
this.identityApiUrl = ((_b = this.options.tinaioConfig) == null ? void 0 : _b.identityApiUrlOverride) || "https://identity.tinajs.io";
|
|
492
|
-
|
|
493
|
-
this.contentApiUrl = this.options.customContentApiUrl || `${contentApiBase}/content/${this.options.clientId}/github/${encodedBranch}`;
|
|
492
|
+
this.contentApiBase = ((_c = this.options.tinaioConfig) == null ? void 0 : _c.contentApiUrlOverride) || `https://content.tinajs.io`;
|
|
493
|
+
this.contentApiUrl = this.options.customContentApiUrl || `${this.contentApiBase}/content/${this.options.clientId}/github/${encodedBranch}`;
|
|
494
494
|
}
|
|
495
495
|
async requestWithForm(query, { variables }) {
|
|
496
496
|
const schema = await this.getSchema();
|
|
@@ -555,28 +555,24 @@ mutation addPendingDocumentMutation(
|
|
|
555
555
|
return null;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
async listBranches(
|
|
559
|
-
const url = `${this.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
return JSON.stringify(res);
|
|
565
|
-
} catch (e) {
|
|
566
|
-
console.error("There was an issue fetching the branch list.", e);
|
|
567
|
-
return null;
|
|
568
|
-
}
|
|
558
|
+
async listBranches() {
|
|
559
|
+
const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
|
|
560
|
+
const res = await this.fetchWithToken(url, {
|
|
561
|
+
method: "GET"
|
|
562
|
+
});
|
|
563
|
+
return res.json();
|
|
569
564
|
}
|
|
570
|
-
async createBranch({
|
|
571
|
-
const url = `${this.
|
|
565
|
+
async createBranch({ baseBranch, branchName }) {
|
|
566
|
+
const url = `${this.contentApiBase}/github/${this.clientId}/create_branch`;
|
|
572
567
|
try {
|
|
573
568
|
const res = await this.fetchWithToken(url, {
|
|
574
569
|
method: "POST",
|
|
575
570
|
body: {
|
|
576
|
-
owner,
|
|
577
|
-
repo,
|
|
578
571
|
baseBranch,
|
|
579
572
|
branchName
|
|
573
|
+
},
|
|
574
|
+
headers: {
|
|
575
|
+
"Content-Type": "application/json"
|
|
580
576
|
}
|
|
581
577
|
});
|
|
582
578
|
return JSON.stringify(res);
|
|
@@ -677,24 +673,6 @@ mutation addPendingDocumentMutation(
|
|
|
677
673
|
return false;
|
|
678
674
|
}
|
|
679
675
|
}
|
|
680
|
-
const LOCALSTORAGEKEY = "tina.isEditing";
|
|
681
|
-
const isSSR = typeof window === "undefined";
|
|
682
|
-
const isEditing = () => {
|
|
683
|
-
if (!isSSR) {
|
|
684
|
-
const isEdit = window.localStorage.getItem(LOCALSTORAGEKEY);
|
|
685
|
-
return isEdit && isEdit === "true";
|
|
686
|
-
}
|
|
687
|
-
return false;
|
|
688
|
-
};
|
|
689
|
-
const setEditing = (isEditing2) => {
|
|
690
|
-
if (!isSSR) {
|
|
691
|
-
window.localStorage.setItem(LOCALSTORAGEKEY, isEditing2 ? "true" : "false");
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
React__default["default"].createContext({
|
|
695
|
-
edit: isEditing(),
|
|
696
|
-
setEdit: void 0
|
|
697
|
-
});
|
|
698
676
|
function sleep(ms) {
|
|
699
677
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
700
678
|
}
|
|
@@ -740,7 +718,7 @@ mutation addPendingDocumentMutation(
|
|
|
740
718
|
...otherModalActions,
|
|
741
719
|
{
|
|
742
720
|
action: async () => {
|
|
743
|
-
setEditing(false);
|
|
721
|
+
sharedctx.setEditing(false);
|
|
744
722
|
window.location.reload();
|
|
745
723
|
},
|
|
746
724
|
name: "Close",
|
|
@@ -758,13 +736,15 @@ mutation addPendingDocumentMutation(
|
|
|
758
736
|
}), showChildren ? children : loginScreen ? loginScreen : null);
|
|
759
737
|
};
|
|
760
738
|
const TinaCloudProvider = (props) => {
|
|
739
|
+
const baseBranch = props.branch || "main";
|
|
740
|
+
const [currentBranch, setCurrentBranch] = toolkit.useLocalStorage("tinacms-current-branch", baseBranch);
|
|
761
741
|
useTinaAuthRedirect();
|
|
762
742
|
const cms = React__default["default"].useMemo(() => props.cms || new toolkit.TinaCMS({
|
|
763
743
|
enabled: true,
|
|
764
744
|
sidebar: true
|
|
765
745
|
}), [props.cms]);
|
|
766
746
|
if (!cms.api.tina) {
|
|
767
|
-
cms.
|
|
747
|
+
cms.registerApi("tina", createClient(props));
|
|
768
748
|
}
|
|
769
749
|
const setupMedia = async () => {
|
|
770
750
|
var _a;
|
|
@@ -780,47 +760,144 @@ mutation addPendingDocumentMutation(
|
|
|
780
760
|
const handleListBranches = async () => {
|
|
781
761
|
const { owner, repo } = props;
|
|
782
762
|
const branches = await cms.api.tina.listBranches({ owner, repo });
|
|
783
|
-
|
|
763
|
+
if (!Array.isArray(branches)) {
|
|
764
|
+
return [];
|
|
765
|
+
}
|
|
766
|
+
return branches;
|
|
784
767
|
};
|
|
785
768
|
const handleCreateBranch = async (data) => {
|
|
786
769
|
const newBranch = await cms.api.tina.createBranch(data);
|
|
787
770
|
return newBranch;
|
|
788
771
|
};
|
|
789
772
|
setupMedia();
|
|
790
|
-
const branchingEnabled = cms.flags.get("branch-switcher");
|
|
773
|
+
const [branchingEnabled, setBranchingEnabled] = React__default["default"].useState(() => cms.flags.get("branch-switcher"));
|
|
774
|
+
React__default["default"].useEffect(() => {
|
|
775
|
+
cms.events.subscribe("flag:set", ({ key, value }) => {
|
|
776
|
+
if (key === "branch-switcher") {
|
|
777
|
+
setBranchingEnabled(value);
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}, [cms.events]);
|
|
791
781
|
React__default["default"].useEffect(() => {
|
|
792
782
|
let branchSwitcher;
|
|
793
783
|
if (branchingEnabled) {
|
|
794
784
|
branchSwitcher = new toolkit.BranchSwitcherPlugin({
|
|
795
|
-
cms,
|
|
796
|
-
owner: props.owner,
|
|
797
|
-
repo: props.repo,
|
|
798
|
-
baseBranch: props.branch || "main",
|
|
799
|
-
currentBranch: props.branch || "main",
|
|
800
785
|
listBranches: handleListBranches,
|
|
801
|
-
createBranch: handleCreateBranch
|
|
802
|
-
setCurrentBranch: () => console.log(props.branch)
|
|
786
|
+
createBranch: handleCreateBranch
|
|
803
787
|
});
|
|
804
788
|
cms.plugins.add(branchSwitcher);
|
|
805
789
|
}
|
|
806
790
|
return () => {
|
|
807
|
-
if (
|
|
808
|
-
|
|
809
|
-
cms.plugins.remove(branchSwitcher);
|
|
810
|
-
}
|
|
791
|
+
if (branchingEnabled && branchSwitcher) {
|
|
792
|
+
cms.plugins.remove(branchSwitcher);
|
|
811
793
|
}
|
|
812
794
|
};
|
|
813
795
|
}, [branchingEnabled, props.branch]);
|
|
814
|
-
|
|
815
|
-
props.cmsCallback
|
|
816
|
-
|
|
817
|
-
|
|
796
|
+
React__default["default"].useEffect(() => {
|
|
797
|
+
if (props.cmsCallback) {
|
|
798
|
+
props.cmsCallback(cms);
|
|
799
|
+
}
|
|
800
|
+
}, []);
|
|
801
|
+
return /* @__PURE__ */ React__default["default"].createElement(toolkit.BranchDataProvider, {
|
|
802
|
+
currentBranch,
|
|
803
|
+
setCurrentBranch: (b) => {
|
|
804
|
+
setCurrentBranch(b);
|
|
805
|
+
}
|
|
806
|
+
}, /* @__PURE__ */ React__default["default"].createElement(toolkit.TinaProvider, {
|
|
818
807
|
cms
|
|
819
808
|
}, /* @__PURE__ */ React__default["default"].createElement(AuthWallInner, __spreadProps(__spreadValues({}, props), {
|
|
820
809
|
cms
|
|
821
|
-
})));
|
|
810
|
+
}))));
|
|
822
811
|
};
|
|
823
812
|
const TinaCloudAuthWall = TinaCloudProvider;
|
|
813
|
+
var DefaultContext = {
|
|
814
|
+
color: void 0,
|
|
815
|
+
size: void 0,
|
|
816
|
+
className: void 0,
|
|
817
|
+
style: void 0,
|
|
818
|
+
attr: void 0
|
|
819
|
+
};
|
|
820
|
+
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
821
|
+
var __assign = function() {
|
|
822
|
+
__assign = Object.assign || function(t) {
|
|
823
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
824
|
+
s = arguments[i];
|
|
825
|
+
for (var p in s)
|
|
826
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
827
|
+
t[p] = s[p];
|
|
828
|
+
}
|
|
829
|
+
return t;
|
|
830
|
+
};
|
|
831
|
+
return __assign.apply(this, arguments);
|
|
832
|
+
};
|
|
833
|
+
var __rest = function(s, e) {
|
|
834
|
+
var t = {};
|
|
835
|
+
for (var p in s)
|
|
836
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
837
|
+
t[p] = s[p];
|
|
838
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
839
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
840
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
841
|
+
t[p[i]] = s[p[i]];
|
|
842
|
+
}
|
|
843
|
+
return t;
|
|
844
|
+
};
|
|
845
|
+
function Tree2Element(tree) {
|
|
846
|
+
return tree && tree.map(function(node, i) {
|
|
847
|
+
return React__default["default"].createElement(node.tag, __assign({
|
|
848
|
+
key: i
|
|
849
|
+
}, node.attr), Tree2Element(node.child));
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
function GenIcon(data) {
|
|
853
|
+
return function(props) {
|
|
854
|
+
return React__default["default"].createElement(IconBase, __assign({
|
|
855
|
+
attr: __assign({}, data.attr)
|
|
856
|
+
}, props), Tree2Element(data.child));
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
function IconBase(props) {
|
|
860
|
+
var elem = function(conf) {
|
|
861
|
+
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
862
|
+
var computedSize = size || conf.size || "1em";
|
|
863
|
+
var className;
|
|
864
|
+
if (conf.className)
|
|
865
|
+
className = conf.className;
|
|
866
|
+
if (props.className)
|
|
867
|
+
className = (className ? className + " " : "") + props.className;
|
|
868
|
+
return React__default["default"].createElement("svg", __assign({
|
|
869
|
+
stroke: "currentColor",
|
|
870
|
+
fill: "currentColor",
|
|
871
|
+
strokeWidth: "0"
|
|
872
|
+
}, conf.attr, attr, svgProps, {
|
|
873
|
+
className,
|
|
874
|
+
style: __assign(__assign({
|
|
875
|
+
color: props.color || conf.color
|
|
876
|
+
}, conf.style), props.style),
|
|
877
|
+
height: computedSize,
|
|
878
|
+
width: computedSize,
|
|
879
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
880
|
+
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
881
|
+
};
|
|
882
|
+
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
883
|
+
return elem(conf);
|
|
884
|
+
}) : elem(DefaultContext);
|
|
885
|
+
}
|
|
886
|
+
function BiEdit(props) {
|
|
887
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m7 17.013 4.413-.015 9.632-9.54c.378-.378.586-.88.586-1.414s-.208-1.036-.586-1.414l-1.586-1.586c-.756-.756-2.075-.752-2.825-.003L7 12.583v4.43zM18.045 4.458l1.589 1.583-1.597 1.582-1.586-1.585 1.594-1.58zM9 13.417l6.03-5.973 1.586 1.586-6.029 5.971L9 15.006v-1.589z" } }, { "tag": "path", "attr": { "d": "M5 21h14c1.103 0 2-.897 2-2v-8.668l-2 2V19H8.158c-.026 0-.053.01-.079.01-.033 0-.066-.009-.1-.01H5V5h6.847l2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2z" } }] })(props);
|
|
888
|
+
}
|
|
889
|
+
function BiExit(props) {
|
|
890
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M19.002 3h-14c-1.103 0-2 .897-2 2v4h2V5h14v14h-14v-4h-2v4c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2V5c0-1.103-.898-2-2-2z" } }, { "tag": "path", "attr": { "d": "m11 16 5-4-5-4v3.001H3v2h8z" } }] })(props);
|
|
891
|
+
}
|
|
892
|
+
function BiLinkExternal(props) {
|
|
893
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 3 3.293 3.293-7 7 1.414 1.414 7-7L21 11V3z" } }, { "tag": "path", "attr": { "d": "M19 19H5V5h7l-2-2H5c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5l-2-2v7z" } }] })(props);
|
|
894
|
+
}
|
|
895
|
+
function BiLogIn(props) {
|
|
896
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "m13 16 5-4-5-4v3H4v2h9z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
|
|
897
|
+
}
|
|
898
|
+
function BiLogOut(props) {
|
|
899
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "d": "M16 13v-2H7V8l-5 4 5 4v-3z" } }, { "tag": "path", "attr": { "d": "M20 3h-9c-1.103 0-2 .897-2 2v4h2V5h9v14h-9v-4H9v4c0 1.103.897 2 2 2h9c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2z" } }] })(props);
|
|
900
|
+
}
|
|
824
901
|
function useGraphqlForms({
|
|
825
902
|
query,
|
|
826
903
|
variables,
|
|
@@ -834,6 +911,7 @@ mutation addPendingDocumentMutation(
|
|
|
834
911
|
const [pendingReset, setPendingReset] = React__default["default"].useState(null);
|
|
835
912
|
const [isLoading, setIsLoading] = React__default["default"].useState(true);
|
|
836
913
|
const [newUpdate, setNewUpdate] = React__default["default"].useState(null);
|
|
914
|
+
const { currentBranch } = toolkit.useBranchData();
|
|
837
915
|
const updateData = async () => {
|
|
838
916
|
var _a;
|
|
839
917
|
if (newUpdate) {
|
|
@@ -885,6 +963,7 @@ mutation addPendingDocumentMutation(
|
|
|
885
963
|
const formIds = [];
|
|
886
964
|
setIsLoading(true);
|
|
887
965
|
cms.api.tina.requestWithForm(query, { variables }).then((payload) => {
|
|
966
|
+
cms.plugins.remove(new toolkit.FormMetaPlugin({ name: "tina-admin-link" }));
|
|
888
967
|
setData(payload);
|
|
889
968
|
setInitialData(payload);
|
|
890
969
|
setIsLoading(false);
|
|
@@ -901,6 +980,32 @@ mutation addPendingDocumentMutation(
|
|
|
901
980
|
values: yup2.object().required(),
|
|
902
981
|
form: yup2.object().required()
|
|
903
982
|
}), `Unable to build form shape for fields at ${queryName}`);
|
|
983
|
+
if (cms.flags.get("tina-admin")) {
|
|
984
|
+
const TinaAdminLink = new toolkit.FormMetaPlugin({
|
|
985
|
+
name: "tina-admin-link",
|
|
986
|
+
Component: () => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
987
|
+
href: `/admin/collections/${result._internalSys.collection.name}/${result._internalSys.filename}`,
|
|
988
|
+
style: {
|
|
989
|
+
display: "flex",
|
|
990
|
+
alignItems: "center",
|
|
991
|
+
padding: "10px 20px",
|
|
992
|
+
borderTop: "1px solid var(--tina-color-grey-2)",
|
|
993
|
+
textTransform: "uppercase",
|
|
994
|
+
fontSize: "11px",
|
|
995
|
+
fontWeight: 500,
|
|
996
|
+
background: "var(--tina-color-grey-0)"
|
|
997
|
+
}
|
|
998
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLinkExternal, {
|
|
999
|
+
style: {
|
|
1000
|
+
height: "1.25em",
|
|
1001
|
+
width: "auto",
|
|
1002
|
+
opacity: "0.8",
|
|
1003
|
+
marginRight: "8px"
|
|
1004
|
+
}
|
|
1005
|
+
}), " ", "Edit in Tina Admin")
|
|
1006
|
+
});
|
|
1007
|
+
cms.plugins.add(TinaAdminLink);
|
|
1008
|
+
}
|
|
904
1009
|
const formConfig = {
|
|
905
1010
|
id: queryName,
|
|
906
1011
|
label: result.form.label,
|
|
@@ -1017,7 +1122,7 @@ mutation addPendingDocumentMutation(
|
|
|
1017
1122
|
}
|
|
1018
1123
|
});
|
|
1019
1124
|
};
|
|
1020
|
-
}, [queryString, JSON.stringify(variables)]);
|
|
1125
|
+
}, [queryString, JSON.stringify(variables), currentBranch]);
|
|
1021
1126
|
return [data, isLoading];
|
|
1022
1127
|
}
|
|
1023
1128
|
const transformDocumentIntoMutationRequestPayload = (document2, instructions) => {
|
|
@@ -1076,9 +1181,9 @@ mutation addPendingDocumentMutation(
|
|
|
1076
1181
|
cms.forms.add(form);
|
|
1077
1182
|
return form;
|
|
1078
1183
|
};
|
|
1079
|
-
const createGlobalForm = (formConfig) => {
|
|
1184
|
+
const createGlobalForm = (formConfig, options) => {
|
|
1080
1185
|
const form = new toolkit.Form(formConfig);
|
|
1081
|
-
cms.plugins.add(new toolkit.GlobalFormPlugin(form));
|
|
1186
|
+
cms.plugins.add(new toolkit.GlobalFormPlugin(form, options == null ? void 0 : options.icon, options == null ? void 0 : options.layout));
|
|
1082
1187
|
return form;
|
|
1083
1188
|
};
|
|
1084
1189
|
return { createForm, createGlobalForm };
|
|
@@ -1490,87 +1595,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1490
1595
|
}
|
|
1491
1596
|
return client.request(query, { variables });
|
|
1492
1597
|
};
|
|
1493
|
-
function gql(strings) {
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
color: void 0,
|
|
1498
|
-
size: void 0,
|
|
1499
|
-
className: void 0,
|
|
1500
|
-
style: void 0,
|
|
1501
|
-
attr: void 0
|
|
1502
|
-
};
|
|
1503
|
-
var IconContext = React__default["default"].createContext && React__default["default"].createContext(DefaultContext);
|
|
1504
|
-
var __assign = function() {
|
|
1505
|
-
__assign = Object.assign || function(t) {
|
|
1506
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1507
|
-
s = arguments[i];
|
|
1508
|
-
for (var p in s)
|
|
1509
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1510
|
-
t[p] = s[p];
|
|
1511
|
-
}
|
|
1512
|
-
return t;
|
|
1513
|
-
};
|
|
1514
|
-
return __assign.apply(this, arguments);
|
|
1515
|
-
};
|
|
1516
|
-
var __rest = function(s, e) {
|
|
1517
|
-
var t = {};
|
|
1518
|
-
for (var p in s)
|
|
1519
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
1520
|
-
t[p] = s[p];
|
|
1521
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
1522
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1523
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
1524
|
-
t[p[i]] = s[p[i]];
|
|
1525
|
-
}
|
|
1526
|
-
return t;
|
|
1527
|
-
};
|
|
1528
|
-
function Tree2Element(tree) {
|
|
1529
|
-
return tree && tree.map(function(node, i) {
|
|
1530
|
-
return React__default["default"].createElement(node.tag, __assign({
|
|
1531
|
-
key: i
|
|
1532
|
-
}, node.attr), Tree2Element(node.child));
|
|
1598
|
+
function gql(strings, ...args) {
|
|
1599
|
+
let str = "";
|
|
1600
|
+
strings.forEach((string, i) => {
|
|
1601
|
+
str += string + (args[i] || "");
|
|
1533
1602
|
});
|
|
1534
|
-
|
|
1535
|
-
function GenIcon(data) {
|
|
1536
|
-
return function(props) {
|
|
1537
|
-
return React__default["default"].createElement(IconBase, __assign({
|
|
1538
|
-
attr: __assign({}, data.attr)
|
|
1539
|
-
}, props), Tree2Element(data.child));
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
function IconBase(props) {
|
|
1543
|
-
var elem = function(conf) {
|
|
1544
|
-
var attr = props.attr, size = props.size, title = props.title, svgProps = __rest(props, ["attr", "size", "title"]);
|
|
1545
|
-
var computedSize = size || conf.size || "1em";
|
|
1546
|
-
var className;
|
|
1547
|
-
if (conf.className)
|
|
1548
|
-
className = conf.className;
|
|
1549
|
-
if (props.className)
|
|
1550
|
-
className = (className ? className + " " : "") + props.className;
|
|
1551
|
-
return React__default["default"].createElement("svg", __assign({
|
|
1552
|
-
stroke: "currentColor",
|
|
1553
|
-
fill: "currentColor",
|
|
1554
|
-
strokeWidth: "0"
|
|
1555
|
-
}, conf.attr, attr, svgProps, {
|
|
1556
|
-
className,
|
|
1557
|
-
style: __assign(__assign({
|
|
1558
|
-
color: props.color || conf.color
|
|
1559
|
-
}, conf.style), props.style),
|
|
1560
|
-
height: computedSize,
|
|
1561
|
-
width: computedSize,
|
|
1562
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
1563
|
-
}), title && React__default["default"].createElement("title", null, title), props.children);
|
|
1564
|
-
};
|
|
1565
|
-
return IconContext !== void 0 ? React__default["default"].createElement(IconContext.Consumer, null, function(conf) {
|
|
1566
|
-
return elem(conf);
|
|
1567
|
-
}) : elem(DefaultContext);
|
|
1568
|
-
}
|
|
1569
|
-
function ImFilesEmpty(props) {
|
|
1570
|
-
return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" } }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" } }] })(props);
|
|
1571
|
-
}
|
|
1572
|
-
function VscOpenPreview(props) {
|
|
1573
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
|
|
1603
|
+
return str;
|
|
1574
1604
|
}
|
|
1575
1605
|
const Layout = ({ children }) => {
|
|
1576
1606
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -1586,14 +1616,12 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1586
1616
|
}
|
|
1587
1617
|
}, children);
|
|
1588
1618
|
};
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
1619
|
+
function ImFilesEmpty(props) {
|
|
1620
|
+
return GenIcon({ "tag": "svg", "attr": { "version": "1.1", "viewBox": "0 0 16 16" }, "child": [{ "tag": "path", "attr": { "d": "M14.341 5.579c-0.347-0.473-0.831-1.027-1.362-1.558s-1.085-1.015-1.558-1.362c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.689 0.561 1.25 1.25 1.25h9.5c0.689 0 1.25-0.561 1.25-1.25v-7.75c0-0.224-0.068-0.615-0.659-1.421zM12.271 4.729c0.48 0.48 0.856 0.912 1.134 1.271h-2.406v-2.405c0.359 0.278 0.792 0.654 1.271 1.134v0zM14 14.75c0 0.136-0.114 0.25-0.25 0.25h-9.5c-0.136 0-0.25-0.114-0.25-0.25v-11.5c0-0.135 0.114-0.25 0.25-0.25 0 0 5.749-0 5.75 0v3.5c0 0.276 0.224 0.5 0.5 0.5h3.5v7.75z" } }, { "tag": "path", "attr": { "d": "M9.421 0.659c-0.806-0.591-1.197-0.659-1.421-0.659h-5.75c-0.689 0-1.25 0.561-1.25 1.25v11.5c0 0.604 0.43 1.109 1 1.225v-12.725c0-0.135 0.115-0.25 0.25-0.25h7.607c-0.151-0.124-0.297-0.238-0.437-0.341z" } }] })(props);
|
|
1621
|
+
}
|
|
1622
|
+
function VscOpenPreview(props) {
|
|
1623
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 16 16", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "clipRule": "evenodd", "d": "M3 1h11l1 1v5.3a3.21 3.21 0 0 0-1-.3V2H9v10.88L7.88 14H3l-1-1V2l1-1zm0 12h5V2H3v11zm10.379-4.998a2.53 2.53 0 0 0-1.19.348h-.03a2.51 2.51 0 0 0-.799 3.53L9 14.23l.71.71 2.35-2.36c.325.22.7.358 1.09.4a2.47 2.47 0 0 0 1.14-.13 2.51 2.51 0 0 0 1-.63 2.46 2.46 0 0 0 .58-1 2.63 2.63 0 0 0 .07-1.15 2.53 2.53 0 0 0-1.35-1.81 2.53 2.53 0 0 0-1.211-.258zm.24 3.992a1.5 1.5 0 0 1-.979-.244 1.55 1.55 0 0 1-.56-.68 1.49 1.49 0 0 1-.08-.86 1.49 1.49 0 0 1 1.18-1.18 1.49 1.49 0 0 1 .86.08c.276.117.512.311.68.56a1.5 1.5 0 0 1-1.1 2.324z" } }] })(props);
|
|
1624
|
+
}
|
|
1597
1625
|
const useGetCollections = (cms) => {
|
|
1598
1626
|
const [collections, setCollections] = React.useState([]);
|
|
1599
1627
|
React.useEffect(() => {
|
|
@@ -1611,23 +1639,97 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1611
1639
|
return null;
|
|
1612
1640
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(collections));
|
|
1613
1641
|
};
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1642
|
+
const Sidebar = ({ cms }) => {
|
|
1643
|
+
const { setEdit } = sharedctx.useEditState();
|
|
1644
|
+
const logout2 = () => setEdit(false);
|
|
1645
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCollections, {
|
|
1646
|
+
cms
|
|
1647
|
+
}, (collections) => /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1648
|
+
className: "flex flex-col w-80 lg:w-96 flex-shrink-0 bg-gradient-to-b from-white to-gray-50 border-r border-gray-200"
|
|
1649
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1650
|
+
className: "border-b border-gray-200"
|
|
1651
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu, {
|
|
1652
|
+
as: "div",
|
|
1653
|
+
className: "relative block"
|
|
1654
|
+
}, ({ open }) => /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Button, {
|
|
1655
|
+
className: `group w-full px-6 py-4 flex justify-between items-center transition-colors duration-150 ease-out ${open ? `bg-gray-50` : `bg-transparent`}`
|
|
1656
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1657
|
+
className: "text-left inline-flex items-center text-2xl tracking-wide text-gray-800 flex-1 gap-1 opacity-80 group-hover:opacity-100 transition-opacity duration-150 ease-out"
|
|
1658
|
+
}, /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1659
|
+
viewBox: "0 0 32 32",
|
|
1660
|
+
fill: "#EC4815",
|
|
1661
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1662
|
+
className: "w-10 h-auto -ml-1"
|
|
1663
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1664
|
+
d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z"
|
|
1665
|
+
}), /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1666
|
+
d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z"
|
|
1667
|
+
})), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin")), /* @__PURE__ */ React__default["default"].createElement("svg", {
|
|
1668
|
+
width: "20",
|
|
1669
|
+
height: "20",
|
|
1670
|
+
viewBox: "0 0 20 20",
|
|
1671
|
+
fill: "none",
|
|
1672
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1673
|
+
className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
|
|
1674
|
+
}, /* @__PURE__ */ React__default["default"].createElement("g", {
|
|
1675
|
+
opacity: "0.3"
|
|
1676
|
+
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1677
|
+
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
1678
|
+
fill: "currentColor"
|
|
1679
|
+
})))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1680
|
+
className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
|
|
1681
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
|
|
1682
|
+
enter: "transition duration-150 ease-out",
|
|
1683
|
+
enterFrom: "transform opacity-0 -translate-y-2",
|
|
1684
|
+
enterTo: "transform opacity-100 translate-y-0",
|
|
1685
|
+
leave: "transition duration-75 ease-in",
|
|
1686
|
+
leaveFrom: "transform opacity-100 translate-y-0",
|
|
1687
|
+
leaveTo: "transform opacity-0 -translate-y-2"
|
|
1688
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
|
|
1689
|
+
className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
|
|
1690
|
+
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1691
|
+
className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
|
|
1692
|
+
href: "/"
|
|
1693
|
+
}, /* @__PURE__ */ React__default["default"].createElement(VscOpenPreview, {
|
|
1694
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
1695
|
+
}), " ", "View Website")), /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
1696
|
+
className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
|
|
1697
|
+
onClick: () => logout2()
|
|
1698
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiExit, {
|
|
1699
|
+
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
1700
|
+
}), " ", "Log out")))))))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1701
|
+
className: "px-6 py-7 flex-1"
|
|
1702
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h4", {
|
|
1703
|
+
className: "uppercase font-bold text-sm mb-3"
|
|
1704
|
+
}, "Collections"), /* @__PURE__ */ React__default["default"].createElement("ul", {
|
|
1705
|
+
className: "flex flex-col gap-4"
|
|
1706
|
+
}, collections.map((collection) => {
|
|
1707
|
+
return /* @__PURE__ */ React__default["default"].createElement("li", {
|
|
1708
|
+
key: `${collection.name}-link`
|
|
1709
|
+
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
|
|
1710
|
+
className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
|
|
1711
|
+
activeClassName: "text-blue-600",
|
|
1712
|
+
to: `/admin/collections/${collection.name}`
|
|
1713
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ImFilesEmpty, {
|
|
1714
|
+
className: "mr-2 h-6 opacity-80 w-auto"
|
|
1715
|
+
}), " ", collection.label));
|
|
1716
|
+
})))));
|
|
1717
|
+
};
|
|
1718
|
+
const GetCMS = ({ children }) => {
|
|
1719
|
+
try {
|
|
1720
|
+
const cms = toolkit.useCMS();
|
|
1721
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(cms));
|
|
1722
|
+
} catch (e) {
|
|
1723
|
+
return null;
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1623
1726
|
function MdOutlineArrowBack(props) {
|
|
1624
1727
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" } }, { "tag": "path", "attr": { "d": "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" } }] })(props);
|
|
1625
1728
|
}
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
}
|
|
1630
|
-
const LoginPage = () => {
|
|
1729
|
+
const AuthTemplate = ({
|
|
1730
|
+
message,
|
|
1731
|
+
children
|
|
1732
|
+
}) => {
|
|
1631
1733
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1632
1734
|
className: "h-screen w-full bg-gradient-to-b from-blue-900 to-gray-900 flex items-center justify-center px-4 py-6"
|
|
1633
1735
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -1645,12 +1747,19 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1645
1747
|
d: "M18.6466 14.5553C19.9018 13.5141 20.458 7.36086 21.0014 5.14903C21.5447 2.9372 23.7919 3.04938 23.7919 3.04938C23.7919 3.04938 23.2085 4.06764 23.4464 4.82751C23.6844 5.58738 25.3145 6.26662 25.3145 6.26662L24.9629 7.19622C24.9629 7.19622 24.2288 7.10204 23.7919 7.9785C23.355 8.85496 24.3392 17.4442 24.3392 17.4442C24.3392 17.4442 21.4469 22.7275 21.4469 24.9206C21.4469 27.1136 22.4819 28.9515 22.4819 28.9515H21.0296C21.0296 28.9515 18.899 26.4086 18.462 25.1378C18.0251 23.8669 18.1998 22.596 18.1998 22.596C18.1998 22.596 15.8839 22.4646 13.8303 22.596C11.7767 22.7275 10.4072 24.498 10.16 25.4884C9.91287 26.4787 9.81048 28.9515 9.81048 28.9515H8.66211C7.96315 26.7882 7.40803 26.0129 7.70918 24.9206C8.54334 21.8949 8.37949 20.1788 8.18635 19.4145C7.99321 18.6501 6.68552 17.983 6.68552 17.983C7.32609 16.6741 7.97996 16.0452 10.7926 15.9796C13.6052 15.914 17.3915 15.5965 18.6466 14.5553Z"
|
|
1646
1748
|
}), /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
1647
1749
|
d: "M11.1268 24.7939C11.1268 24.7939 11.4236 27.5481 13.0001 28.9516H14.3511C13.0001 27.4166 12.8527 23.4155 12.8527 23.4155C12.1656 23.6399 11.3045 24.3846 11.1268 24.7939Z"
|
|
1648
|
-
})), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin"))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1750
|
+
})), /* @__PURE__ */ React__default["default"].createElement("span", null, "Tina Admin"))), message && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1649
1751
|
className: "px-5 py-4 "
|
|
1650
1752
|
}, /* @__PURE__ */ React__default["default"].createElement("p", {
|
|
1651
1753
|
className: "text-base font-sans leading-normal"
|
|
1652
|
-
},
|
|
1754
|
+
}, message)), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1653
1755
|
className: "px-5 py-4 flex gap-4 w-full justify-between"
|
|
1756
|
+
}, children)));
|
|
1757
|
+
};
|
|
1758
|
+
const LoginPage = () => {
|
|
1759
|
+
const { setEdit } = sharedctx.useEditState();
|
|
1760
|
+
const login = () => setEdit(true);
|
|
1761
|
+
return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, {
|
|
1762
|
+
message: "Please log in to Tina Cloud to access your content."
|
|
1654
1763
|
}, /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1655
1764
|
href: "/",
|
|
1656
1765
|
className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
|
|
@@ -1663,7 +1772,26 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1663
1772
|
style: { background: "#0084FF" }
|
|
1664
1773
|
}, /* @__PURE__ */ React__default["default"].createElement(BiLogIn, {
|
|
1665
1774
|
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1666
|
-
}), " Log in"))
|
|
1775
|
+
}), " Log in"));
|
|
1776
|
+
};
|
|
1777
|
+
const logout = () => {
|
|
1778
|
+
sharedctx.setEditing(false);
|
|
1779
|
+
window.location.href = "/";
|
|
1780
|
+
};
|
|
1781
|
+
const LogoutPage = () => {
|
|
1782
|
+
return /* @__PURE__ */ React__default["default"].createElement(AuthTemplate, null, /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1783
|
+
href: "/",
|
|
1784
|
+
className: "flex-1 text-center inline-flex justify-center items-center px-8 py-3 shadow-sm text-sm leading-4 font-medium rounded-full text-gray-600 border border-gray-150 hover:opacity-80 hover:bg-gray-50 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out"
|
|
1785
|
+
}, /* @__PURE__ */ React__default["default"].createElement(MdOutlineArrowBack, {
|
|
1786
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1787
|
+
}), " Back to site"), /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
1788
|
+
type: "submit",
|
|
1789
|
+
onClick: () => logout(),
|
|
1790
|
+
className: "flex-1 justify-center text-center inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1791
|
+
style: { background: "#0084FF" }
|
|
1792
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLogOut, {
|
|
1793
|
+
className: "w-6 h-auto mr-1.5 opacity-80"
|
|
1794
|
+
}), " Log out"));
|
|
1667
1795
|
};
|
|
1668
1796
|
const DashboardPage = () => {
|
|
1669
1797
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
@@ -1772,60 +1900,73 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1772
1900
|
const CollectionListPage = () => {
|
|
1773
1901
|
const location2 = reactRouterDom.useLocation();
|
|
1774
1902
|
const { collectionName } = reactRouterDom.useParams();
|
|
1775
|
-
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) =>
|
|
1776
|
-
cms
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1903
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
|
|
1904
|
+
const plugins = cms.plugins.all("tina-admin");
|
|
1905
|
+
const routeMapping = plugins.find(({ name }) => name === "route-mapping");
|
|
1906
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCollection, {
|
|
1907
|
+
cms,
|
|
1908
|
+
collectionName,
|
|
1909
|
+
includeDocuments: true
|
|
1910
|
+
}, (collection) => {
|
|
1911
|
+
const totalCount = collection.documents.totalCount;
|
|
1912
|
+
const documents = collection.documents.edges;
|
|
1913
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1914
|
+
className: "px-6 py-14 h-screen overflow-y-auto flex justify-center"
|
|
1915
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1916
|
+
className: "max-w-screen-md w-full"
|
|
1917
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1918
|
+
className: "w-full flex justify-between items-end"
|
|
1919
|
+
}, /* @__PURE__ */ React__default["default"].createElement("h3", {
|
|
1920
|
+
className: "text-3xl"
|
|
1921
|
+
}, collection.label), !collection.templates && /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1922
|
+
to: `${location2.pathname}/new`,
|
|
1923
|
+
className: "inline-flex items-center px-8 py-3 shadow-sm border border-transparent text-sm leading-4 font-medium rounded-full text-white hover:opacity-80 focus:outline-none focus:shadow-outline-blue transition duration-150 ease-out",
|
|
1924
|
+
style: { background: "#0084FF" }
|
|
1925
|
+
}, "Create New"), collection.templates && /* @__PURE__ */ React__default["default"].createElement(TemplateMenu, {
|
|
1926
|
+
templates: collection.templates
|
|
1927
|
+
})), totalCount > 0 && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
1928
|
+
className: "mt-8 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"
|
|
1929
|
+
}, /* @__PURE__ */ React__default["default"].createElement("table", {
|
|
1930
|
+
className: "min-w-full"
|
|
1931
|
+
}, /* @__PURE__ */ React__default["default"].createElement("tbody", {
|
|
1932
|
+
className: "bg-white divide-y divide-gray-150"
|
|
1933
|
+
}, documents.map((document2) => {
|
|
1934
|
+
const livesiteRoute = routeMapping ? routeMapping.mapper(collection, document2.node) : void 0;
|
|
1935
|
+
return /* @__PURE__ */ React__default["default"].createElement("tr", {
|
|
1936
|
+
key: document2.node.sys.relativePath
|
|
1937
|
+
}, /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1938
|
+
className: "px-5 py-3 whitespace-nowrap"
|
|
1939
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1940
|
+
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1941
|
+
}, "Filename"), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1942
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1943
|
+
className: "h-5 leading-5 block"
|
|
1944
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1945
|
+
className: "leading-5 font-medium text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-700"
|
|
1946
|
+
}, document2.node.sys.filename), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1947
|
+
className: "leading-5 text-base font-medium text-gray-300"
|
|
1948
|
+
}, document2.node.sys.extension))), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1949
|
+
className: "px-5 py-3 whitespace-nowrap"
|
|
1950
|
+
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1951
|
+
className: "block text-xs mb-0.5 text-gray-400 uppercase"
|
|
1952
|
+
}, "Template"), /* @__PURE__ */ React__default["default"].createElement("span", {
|
|
1953
|
+
className: "h-5 block leading-5 font-regular text-base overflow-ellipsis overflow-hidden whitespace-nowrap text-gray-500"
|
|
1954
|
+
}, document2.node.sys.template)), /* @__PURE__ */ React__default["default"].createElement("td", {
|
|
1955
|
+
className: "px-5 py-3 whitespace-nowrap flex gap-3 items-center justify-end"
|
|
1956
|
+
}, livesiteRoute && /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
1957
|
+
href: livesiteRoute,
|
|
1958
|
+
className: "flex gap-1.5 items-center px-4 py-1.5 rounded-full transition-all ease-out duration-150 text-gray-500 hover:text-blue-500"
|
|
1959
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiLinkExternal, {
|
|
1960
|
+
className: "inline-block h-5 w-auto opacity-70"
|
|
1961
|
+
}), " ", "View"), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Link, {
|
|
1962
|
+
to: `${location2.pathname}/${document2.node.sys.filename}`,
|
|
1963
|
+
className: "flex gap-1.5 items-center px-4 py-1.5 rounded-full border border-gray-150 transition-all ease-out duration-150 text-gray-700 hover:bg-gray-50 hover:text-blue-500"
|
|
1964
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BiEdit, {
|
|
1965
|
+
className: "inline-block h-5 w-auto opacity-70"
|
|
1966
|
+
}), " ", "Edit")));
|
|
1967
|
+
}))))));
|
|
1968
|
+
});
|
|
1969
|
+
});
|
|
1829
1970
|
};
|
|
1830
1971
|
const useGetDocumentFields = (cms, collectionName, templateName) => {
|
|
1831
1972
|
const [info, setInfo] = React.useState({
|
|
@@ -1880,13 +2021,15 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1880
2021
|
includeCollection,
|
|
1881
2022
|
includeTemplate
|
|
1882
2023
|
});
|
|
1883
|
-
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
1884
|
-
createDocument(
|
|
2024
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
2025
|
+
createDocument(
|
|
2026
|
+
collection: $collection,
|
|
1885
2027
|
relativePath: $relativePath,
|
|
1886
2028
|
params: $params
|
|
1887
2029
|
){__typename}
|
|
1888
2030
|
}`, {
|
|
1889
2031
|
variables: {
|
|
2032
|
+
collection: collection.name,
|
|
1890
2033
|
relativePath,
|
|
1891
2034
|
params
|
|
1892
2035
|
}
|
|
@@ -1960,19 +2103,21 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1960
2103
|
}
|
|
1961
2104
|
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, children(document2));
|
|
1962
2105
|
};
|
|
1963
|
-
const updateDocument = async (cms, relativePath, mutationInfo, values) => {
|
|
2106
|
+
const updateDocument = async (cms, relativePath, collection, mutationInfo, values) => {
|
|
1964
2107
|
const { includeCollection, includeTemplate } = mutationInfo;
|
|
1965
2108
|
const params = transformDocumentIntoMutationRequestPayload(values, {
|
|
1966
2109
|
includeCollection,
|
|
1967
2110
|
includeTemplate
|
|
1968
2111
|
});
|
|
1969
|
-
await cms.api.tina.request(`mutation($relativePath: String!, $params: DocumentMutation!) {
|
|
2112
|
+
await cms.api.tina.request(`mutation($collection: String!, $relativePath: String!, $params: DocumentMutation!) {
|
|
1970
2113
|
updateDocument(
|
|
2114
|
+
collection: $collection,
|
|
1971
2115
|
relativePath: $relativePath,
|
|
1972
2116
|
params: $params
|
|
1973
2117
|
){__typename}
|
|
1974
2118
|
}`, {
|
|
1975
2119
|
variables: {
|
|
2120
|
+
collection: collection.name,
|
|
1976
2121
|
relativePath,
|
|
1977
2122
|
params
|
|
1978
2123
|
}
|
|
@@ -1997,7 +2142,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
1997
2142
|
fields: document2.form.fields,
|
|
1998
2143
|
initialValues: document2.values,
|
|
1999
2144
|
onSubmit: async (values) => {
|
|
2000
|
-
await updateDocument(cms, relativePath, mutationInfo, values);
|
|
2145
|
+
await updateDocument(cms, relativePath, collection, mutationInfo, values);
|
|
2001
2146
|
history.push(`/admin/collections/${collection.name}`);
|
|
2002
2147
|
}
|
|
2003
2148
|
});
|
|
@@ -2014,8 +2159,8 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2014
2159
|
};
|
|
2015
2160
|
const useEmbedTailwind = () => {
|
|
2016
2161
|
React.useEffect(() => {
|
|
2017
|
-
const
|
|
2018
|
-
if (!
|
|
2162
|
+
const isSSR = typeof window === "undefined";
|
|
2163
|
+
if (!isSSR) {
|
|
2019
2164
|
const head = document.head;
|
|
2020
2165
|
const link = document.createElement("link");
|
|
2021
2166
|
link.id = "tina-admin-stylesheet";
|
|
@@ -2026,111 +2171,59 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
2026
2171
|
}
|
|
2027
2172
|
}, []);
|
|
2028
2173
|
};
|
|
2029
|
-
const logout = () => {
|
|
2030
|
-
setEditing(false);
|
|
2031
|
-
window.location.reload();
|
|
2032
|
-
};
|
|
2033
2174
|
const TinaAdmin = () => {
|
|
2034
2175
|
useEmbedTailwind();
|
|
2035
|
-
const
|
|
2036
|
-
if (
|
|
2176
|
+
const isSSR = typeof window === "undefined";
|
|
2177
|
+
if (isSSR) {
|
|
2037
2178
|
return null;
|
|
2038
2179
|
}
|
|
2039
|
-
const
|
|
2040
|
-
if (!
|
|
2180
|
+
const { edit } = sharedctx.useEditState();
|
|
2181
|
+
if (!edit) {
|
|
2041
2182
|
return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(LoginPage, null));
|
|
2042
2183
|
}
|
|
2043
|
-
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) =>
|
|
2044
|
-
cms
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
className: `flex-0 inline-block opacity-50 group-hover:opacity-80 transition-all duration-300 ease-in-out transform ${open ? `rotate-90 opacity-100` : `rotate-0`}`
|
|
2074
|
-
}, /* @__PURE__ */ React__default["default"].createElement("g", {
|
|
2075
|
-
opacity: "0.3"
|
|
2076
|
-
}, /* @__PURE__ */ React__default["default"].createElement("path", {
|
|
2077
|
-
d: "M7.91675 13.8086L9.16675 15.0586L14.2253 10L9.16675 4.9414L7.91675 6.1914L11.7253 10L7.91675 13.8086Z",
|
|
2078
|
-
fill: "currentColor"
|
|
2079
|
-
})))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2080
|
-
className: "transform translate-y-full absolute bottom-3 right-5 w-2/3 z-50"
|
|
2081
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react.Transition, {
|
|
2082
|
-
enter: "transition duration-150 ease-out",
|
|
2083
|
-
enterFrom: "transform opacity-0 -translate-y-2",
|
|
2084
|
-
enterTo: "transform opacity-100 translate-y-0",
|
|
2085
|
-
leave: "transition duration-75 ease-in",
|
|
2086
|
-
leaveFrom: "transform opacity-100 translate-y-0",
|
|
2087
|
-
leaveTo: "transform opacity-0 -translate-y-2"
|
|
2088
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Items, {
|
|
2089
|
-
className: "w-full py-1 bg-white border border-gray-150 rounded-lg shadow-lg"
|
|
2090
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("a", {
|
|
2091
|
-
className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
|
|
2092
|
-
href: "/"
|
|
2093
|
-
}, /* @__PURE__ */ React__default["default"].createElement(VscOpenPreview, {
|
|
2094
|
-
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2095
|
-
}), " ", "View Website")), /* @__PURE__ */ React__default["default"].createElement(react.Menu.Item, null, ({ active }) => /* @__PURE__ */ React__default["default"].createElement("button", {
|
|
2096
|
-
className: `w-full text-lg px-4 py-2 tracking-wide flex items-center opacity-80 text-gray-600 ${active && "text-gray-800 opacity-100"}`,
|
|
2097
|
-
onClick: () => logout()
|
|
2098
|
-
}, /* @__PURE__ */ React__default["default"].createElement(BiExit, {
|
|
2099
|
-
className: "w-6 h-auto mr-1.5 text-blue-400"
|
|
2100
|
-
}), " ", "Log out")))))))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2101
|
-
className: "px-6 py-7 flex-1"
|
|
2102
|
-
}, /* @__PURE__ */ React__default["default"].createElement("h4", {
|
|
2103
|
-
className: "uppercase font-bold text-sm mb-3"
|
|
2104
|
-
}, "Collections"), /* @__PURE__ */ React__default["default"].createElement("ul", {
|
|
2105
|
-
className: "flex flex-col gap-4"
|
|
2106
|
-
}, collections.map((collection) => {
|
|
2107
|
-
return /* @__PURE__ */ React__default["default"].createElement("li", {
|
|
2108
|
-
key: `${collection.name}-link`
|
|
2109
|
-
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.NavLink, {
|
|
2110
|
-
className: `text-lg tracking-wide hover:text-blue-600 flex items-center opacity-90 hover:opacity-100`,
|
|
2111
|
-
activeClassName: "text-blue-600",
|
|
2112
|
-
to: `/admin/collections/${collection.name}`
|
|
2113
|
-
}, /* @__PURE__ */ React__default["default"].createElement(ImFilesEmpty, {
|
|
2114
|
-
className: "mr-2 h-6 opacity-80 w-auto"
|
|
2115
|
-
}), " ", collection.label));
|
|
2116
|
-
})))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2117
|
-
className: "flex-1"
|
|
2118
|
-
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2119
|
-
path: `/admin/collections/:collectionName/new`
|
|
2120
|
-
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2121
|
-
path: `/admin/collections/:collectionName/:templateName/new`
|
|
2122
|
-
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2123
|
-
path: `/admin/collections/:collectionName/:filename`
|
|
2124
|
-
}, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2125
|
-
path: `/admin/collections/:collectionName`
|
|
2126
|
-
}, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2127
|
-
path: `/admin`
|
|
2128
|
-
}, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))))));
|
|
2184
|
+
return /* @__PURE__ */ React__default["default"].createElement(GetCMS, null, (cms) => {
|
|
2185
|
+
const isTinaAdminEnabled = cms.flags.get("tina-admin");
|
|
2186
|
+
if (isTinaAdminEnabled) {
|
|
2187
|
+
return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2188
|
+
className: "flex items-stretch h-screen overflow-hidden"
|
|
2189
|
+
}, /* @__PURE__ */ React__default["default"].createElement(Sidebar, {
|
|
2190
|
+
cms
|
|
2191
|
+
}), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
2192
|
+
className: "flex-1"
|
|
2193
|
+
}, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2194
|
+
path: `/admin/collections/:collectionName/new`
|
|
2195
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2196
|
+
path: `/admin/collections/:collectionName/:templateName/new`
|
|
2197
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionCreatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2198
|
+
path: `/admin/collections/:collectionName/:filename`
|
|
2199
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionUpdatePage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2200
|
+
path: `/admin/collections/:collectionName`
|
|
2201
|
+
}, /* @__PURE__ */ React__default["default"].createElement(CollectionListPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2202
|
+
path: `/admin`
|
|
2203
|
+
}, /* @__PURE__ */ React__default["default"].createElement(DashboardPage, null)))))));
|
|
2204
|
+
} else {
|
|
2205
|
+
return /* @__PURE__ */ React__default["default"].createElement(Layout, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.BrowserRouter, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Switch, null, /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2206
|
+
path: [`/admin/logout`, `/admin/exit`, `/admin/exit-admin`]
|
|
2207
|
+
}, /* @__PURE__ */ React__default["default"].createElement(LogoutPage, null)), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
2208
|
+
path: `/admin`
|
|
2209
|
+
}, () => {
|
|
2210
|
+
window.location.href = "/";
|
|
2211
|
+
}))));
|
|
2212
|
+
}
|
|
2213
|
+
});
|
|
2129
2214
|
};
|
|
2215
|
+
class RouteMappingPlugin {
|
|
2216
|
+
constructor(mapper) {
|
|
2217
|
+
this.__type = "tina-admin";
|
|
2218
|
+
this.name = "route-mapping";
|
|
2219
|
+
this.mapper = mapper;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2130
2222
|
exports2.AuthWallInner = AuthWallInner;
|
|
2131
2223
|
exports2.Client = Client;
|
|
2132
2224
|
exports2.DEFAULT_LOCAL_TINA_GQL_SERVER_URL = DEFAULT_LOCAL_TINA_GQL_SERVER_URL;
|
|
2133
2225
|
exports2.LocalClient = LocalClient;
|
|
2226
|
+
exports2.RouteMappingPlugin = RouteMappingPlugin;
|
|
2134
2227
|
exports2.TinaAdmin = TinaAdmin;
|
|
2135
2228
|
exports2.TinaCMSProvider2 = TinaCMSProvider2;
|
|
2136
2229
|
exports2.TinaCloudAuthWall = TinaCloudAuthWall;
|