tinacms 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/api.d.ts +1 -1
- package/dist/admin/components/GetCollections.d.ts +1 -4
- package/dist/admin/pages/LogoutPage.d.ts +1 -0
- package/dist/index.es.js +64 -39
- package/dist/index.js +62 -37
- package/dist/internalClient/index.d.ts +9 -3
- package/dist/rich-text/index.d.ts +3 -0
- package/dist/rich-text/index.es.js +9 -0
- package/dist/rich-text/index.js +9 -0
- package/package.json +3 -3
package/dist/admin/api.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class TinaAdminApi {
|
|
|
20
20
|
schema: TinaSchema;
|
|
21
21
|
constructor(cms: TinaCMS);
|
|
22
22
|
isAuthenticated(): Promise<boolean>;
|
|
23
|
-
fetchCollections():
|
|
23
|
+
fetchCollections(): import("@tinacms/schema-tools").TinaCloudCollection<true>[];
|
|
24
24
|
deleteDocument({ collection, relativePath, }: {
|
|
25
25
|
collection: string;
|
|
26
26
|
relativePath: string;
|
|
@@ -10,12 +10,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
10
10
|
See the License for the specific language governing permissions and
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
|
-
import type { Collection } from '../types';
|
|
14
13
|
import type { TinaCMS } from '@tinacms/toolkit';
|
|
15
14
|
export declare const useGetCollections: (cms: TinaCMS) => {
|
|
16
|
-
collections:
|
|
17
|
-
loading: boolean;
|
|
18
|
-
error: Error;
|
|
15
|
+
collections: import("@tinacms/schema-tools").TinaCloudCollection<true>[];
|
|
19
16
|
};
|
|
20
17
|
declare const GetCollections: ({ cms, children }: {
|
|
21
18
|
cms: TinaCMS;
|
|
@@ -10,5 +10,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
10
10
|
See the License for the specific language governing permissions and
|
|
11
11
|
limitations under the License.
|
|
12
12
|
*/
|
|
13
|
+
export declare const LogoutRedirect: () => JSX.Element;
|
|
13
14
|
declare const LogoutPage: () => JSX.Element;
|
|
14
15
|
export default LogoutPage;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, Select, OverflowMenu, CursorPaginator, PopupModal, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
1
|
+
import { useCMS, Form, GlobalFormPlugin, EventBus, Modal, ModalPopup, ModalHeader, ModalBody, ModalActions, Button, LoadingDots, useLocalStorage, TinaCMS, BranchSwitcherPlugin, BranchDataProvider, TinaProvider, TinaMediaStore, DummyMediaStore, Nav, LocalWarning, BillingWarning, Select, OverflowMenu, CursorPaginator, PopupModal, wrapFieldsWithMeta, FormStatus, FormBuilder } from "@tinacms/toolkit";
|
|
2
2
|
export * from "@tinacms/toolkit";
|
|
3
3
|
export { MdxFieldPluginExtendible } from "@tinacms/toolkit";
|
|
4
4
|
import * as G from "graphql";
|
|
@@ -12,7 +12,7 @@ import gql$1 from "graphql-tag";
|
|
|
12
12
|
import * as yup from "yup";
|
|
13
13
|
import { setEditing, TinaDataContext, EditContext, useEditState } from "@tinacms/sharedctx";
|
|
14
14
|
import UrlPattern from "url-pattern";
|
|
15
|
-
import { NavLink, useNavigate, useParams, useLocation, Link, HashRouter, Routes, Route } from "react-router-dom";
|
|
15
|
+
import { NavLink, useSearchParams, useNavigate, useParams, useLocation, Link, HashRouter, Routes, Route } from "react-router-dom";
|
|
16
16
|
import { Transition, Menu } from "@headlessui/react";
|
|
17
17
|
import { useWindowWidth } from "@react-hook/window-size";
|
|
18
18
|
function popupWindow(url, title, window2, w, h) {
|
|
@@ -2117,7 +2117,7 @@ const parseRefForBranchName = (ref) => {
|
|
|
2117
2117
|
};
|
|
2118
2118
|
class Client {
|
|
2119
2119
|
constructor({ tokenStorage = "MEMORY", ...options }) {
|
|
2120
|
-
var _a, _b, _c, _d;
|
|
2120
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2121
2121
|
this.events = new EventBus();
|
|
2122
2122
|
this.addPendingContent = async (props) => {
|
|
2123
2123
|
const mutation = `#graphql
|
|
@@ -2166,6 +2166,7 @@ mutation addPendingDocumentMutation(
|
|
|
2166
2166
|
return parse(data.getOptimizedQuery);
|
|
2167
2167
|
};
|
|
2168
2168
|
this.onLogin = (_d = (_c = (_b = (_a = options.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.onLogin;
|
|
2169
|
+
this.onLogout = (_h = (_g = (_f = (_e = options.schema) == null ? void 0 : _e.config) == null ? void 0 : _f.admin) == null ? void 0 : _g.auth) == null ? void 0 : _h.onLogout;
|
|
2169
2170
|
if (options.schema) {
|
|
2170
2171
|
const enrichedSchema = new TinaSchema({
|
|
2171
2172
|
version: { fullVersion: "", major: "", minor: "", patch: "" },
|
|
@@ -2354,7 +2355,7 @@ mutation addPendingDocumentMutation(
|
|
|
2354
2355
|
async isAuthenticated() {
|
|
2355
2356
|
return !!await this.getUser();
|
|
2356
2357
|
}
|
|
2357
|
-
async
|
|
2358
|
+
async logout() {
|
|
2358
2359
|
this.setToken(null);
|
|
2359
2360
|
}
|
|
2360
2361
|
async authenticate() {
|
|
@@ -2392,6 +2393,30 @@ mutation addPendingDocumentMutation(
|
|
|
2392
2393
|
return null;
|
|
2393
2394
|
}
|
|
2394
2395
|
}
|
|
2396
|
+
async getBillingState() {
|
|
2397
|
+
if (!this.clientId) {
|
|
2398
|
+
return null;
|
|
2399
|
+
}
|
|
2400
|
+
const url = `${this.identityApiUrl}/v2/apps/${this.clientId}/billing/state`;
|
|
2401
|
+
try {
|
|
2402
|
+
const res = await this.fetchWithToken(url, {
|
|
2403
|
+
method: "GET"
|
|
2404
|
+
});
|
|
2405
|
+
const val = await res.json();
|
|
2406
|
+
if (!res.status.toString().startsWith("2")) {
|
|
2407
|
+
console.error(val.error);
|
|
2408
|
+
return null;
|
|
2409
|
+
}
|
|
2410
|
+
return {
|
|
2411
|
+
clientId: val.clientId || this.clientId,
|
|
2412
|
+
delinquencyDate: val.delinquencyDate,
|
|
2413
|
+
billingState: val.billingState
|
|
2414
|
+
};
|
|
2415
|
+
} catch (e) {
|
|
2416
|
+
console.error(e);
|
|
2417
|
+
return null;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2395
2420
|
async listBranches() {
|
|
2396
2421
|
const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
|
|
2397
2422
|
const res = await this.fetchWithToken(url, {
|
|
@@ -2434,7 +2459,7 @@ class LocalClient extends Client {
|
|
|
2434
2459
|
get isLocalMode() {
|
|
2435
2460
|
return true;
|
|
2436
2461
|
}
|
|
2437
|
-
async
|
|
2462
|
+
async logout() {
|
|
2438
2463
|
localStorage.removeItem(LOCAL_CLIENT_KEY);
|
|
2439
2464
|
}
|
|
2440
2465
|
async authenticate() {
|
|
@@ -2502,14 +2527,8 @@ class TinaAdminApi {
|
|
|
2502
2527
|
async isAuthenticated() {
|
|
2503
2528
|
return await this.api.isAuthenticated();
|
|
2504
2529
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
const collections = this.schema.getCollections();
|
|
2508
|
-
return collections;
|
|
2509
|
-
} catch (e) {
|
|
2510
|
-
console.error(`[TinaAdminAPI] Unable to fetchCollections(): ${e.message}`);
|
|
2511
|
-
return [];
|
|
2512
|
-
}
|
|
2530
|
+
fetchCollections() {
|
|
2531
|
+
return this.schema.getCollections();
|
|
2513
2532
|
}
|
|
2514
2533
|
async deleteDocument({
|
|
2515
2534
|
collection,
|
|
@@ -4498,28 +4517,7 @@ function ImFilesEmpty(props) {
|
|
|
4498
4517
|
}
|
|
4499
4518
|
const useGetCollections = (cms) => {
|
|
4500
4519
|
const api = new TinaAdminApi(cms);
|
|
4501
|
-
|
|
4502
|
-
const [loading, setLoading] = useState(true);
|
|
4503
|
-
const [error, setError] = useState(void 0);
|
|
4504
|
-
useEffect(() => {
|
|
4505
|
-
const fetchCollections = async () => {
|
|
4506
|
-
if (await api.isAuthenticated()) {
|
|
4507
|
-
try {
|
|
4508
|
-
const collections2 = await api.fetchCollections();
|
|
4509
|
-
setCollections(collections2);
|
|
4510
|
-
} catch (error2) {
|
|
4511
|
-
console.error(error2);
|
|
4512
|
-
setCollections([]);
|
|
4513
|
-
setError(error2);
|
|
4514
|
-
throw new Error(`[${error2.name}] GetCollections failed: ${error2.message}`);
|
|
4515
|
-
}
|
|
4516
|
-
setLoading(false);
|
|
4517
|
-
}
|
|
4518
|
-
};
|
|
4519
|
-
setLoading(true);
|
|
4520
|
-
fetchCollections();
|
|
4521
|
-
}, [cms]);
|
|
4522
|
-
return { collections, loading, error };
|
|
4520
|
+
return { collections: api.fetchCollections() };
|
|
4523
4521
|
};
|
|
4524
4522
|
function IoMdClose(props) {
|
|
4525
4523
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z" } }] })(props);
|
|
@@ -4748,6 +4746,28 @@ const LoginPage = () => {
|
|
|
4748
4746
|
className: "w-6 h-auto mr-2 opacity-80"
|
|
4749
4747
|
}), " Edit With Tina")));
|
|
4750
4748
|
};
|
|
4749
|
+
const LogoutRedirect = () => {
|
|
4750
|
+
const cms = useCMS();
|
|
4751
|
+
const { setEdit } = useEditState();
|
|
4752
|
+
const [searchParams] = useSearchParams();
|
|
4753
|
+
const slug = searchParams.get("slug") || "/";
|
|
4754
|
+
const logout2 = async () => {
|
|
4755
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4756
|
+
if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
|
|
4757
|
+
await cms.api.tina.logout();
|
|
4758
|
+
if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
|
|
4759
|
+
await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
setEdit(false);
|
|
4763
|
+
};
|
|
4764
|
+
useEffect(() => {
|
|
4765
|
+
logout2().then(() => {
|
|
4766
|
+
window.location.href = slug;
|
|
4767
|
+
});
|
|
4768
|
+
}, []);
|
|
4769
|
+
return /* @__PURE__ */ React.createElement("div", null, "Redirecting to ", slug, " ...");
|
|
4770
|
+
};
|
|
4751
4771
|
const logout = () => {
|
|
4752
4772
|
setEditing(false);
|
|
4753
4773
|
window.location.href = "/";
|
|
@@ -4784,7 +4804,7 @@ const PageWrapper = ({
|
|
|
4784
4804
|
const PageHeader = ({
|
|
4785
4805
|
isLocalMode,
|
|
4786
4806
|
children
|
|
4787
|
-
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), /* @__PURE__ */ React.createElement("div", {
|
|
4807
|
+
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, isLocalMode && /* @__PURE__ */ React.createElement(LocalWarning, null), !isLocalMode && /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
|
|
4788
4808
|
className: "bg-white pb-4 pt-16 border-b border-gray-200 px-12"
|
|
4789
4809
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4790
4810
|
className: "w-full mx-auto max-w-screen-xl"
|
|
@@ -5403,7 +5423,7 @@ const RenderForm$1 = ({ cms, collection, templateName, mutationInfo }) => {
|
|
|
5403
5423
|
const windowWidth = useWindowWidth();
|
|
5404
5424
|
const renderNavToggle = windowWidth < navBreakpoint + 1;
|
|
5405
5425
|
const headerPadding = renderNavToggle ? "px-20" : "px-6";
|
|
5406
|
-
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode)
|
|
5426
|
+
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React.createElement(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
|
|
5407
5427
|
className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
|
|
5408
5428
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
5409
5429
|
className: "max-w-form mx-auto"
|
|
@@ -5551,7 +5571,7 @@ const RenderForm = ({
|
|
|
5551
5571
|
const windowWidth = useWindowWidth();
|
|
5552
5572
|
const renderNavToggle = windowWidth < navBreakpoint + 1;
|
|
5553
5573
|
const headerPadding = renderNavToggle ? "px-20" : "px-6";
|
|
5554
|
-
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode)
|
|
5574
|
+
return /* @__PURE__ */ React.createElement(PageWrapper, null, /* @__PURE__ */ React.createElement(React.Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React.createElement(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), /* @__PURE__ */ React.createElement("div", {
|
|
5555
5575
|
className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
|
|
5556
5576
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
5557
5577
|
className: "max-w-form mx-auto"
|
|
@@ -5584,7 +5604,7 @@ const ScreenPage = () => {
|
|
|
5584
5604
|
const selectedScreen = screens.find(({ name }) => slugify(name) === screenName);
|
|
5585
5605
|
return /* @__PURE__ */ React.createElement("div", {
|
|
5586
5606
|
className: "relative w-full h-full flex flex-col items-stretch justify-between"
|
|
5587
|
-
}, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode)
|
|
5607
|
+
}, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React.createElement(LocalWarning, null) : /* @__PURE__ */ React.createElement(BillingWarning, null), renderNavToggle && /* @__PURE__ */ React.createElement("div", {
|
|
5588
5608
|
className: `py-5 border-b border-gray-200 bg-white pl-18`
|
|
5589
5609
|
}, selectedScreen.name), /* @__PURE__ */ React.createElement("div", {
|
|
5590
5610
|
className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between"
|
|
@@ -5711,6 +5731,11 @@ const TinaAdmin = ({
|
|
|
5711
5731
|
element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
|
|
5712
5732
|
cms
|
|
5713
5733
|
}, /* @__PURE__ */ React.createElement(ScreenPage, null))
|
|
5734
|
+
}), /* @__PURE__ */ React.createElement(Route, {
|
|
5735
|
+
path: "logout",
|
|
5736
|
+
element: /* @__PURE__ */ React.createElement(DefaultWrapper, {
|
|
5737
|
+
cms
|
|
5738
|
+
}, /* @__PURE__ */ React.createElement(LogoutRedirect, null))
|
|
5714
5739
|
}), /* @__PURE__ */ React.createElement(Route, {
|
|
5715
5740
|
path: "/",
|
|
5716
5741
|
element: /* @__PURE__ */ React.createElement(MaybeRedirectToPreview, {
|
package/dist/index.js
CHANGED
|
@@ -2133,7 +2133,7 @@
|
|
|
2133
2133
|
};
|
|
2134
2134
|
class Client {
|
|
2135
2135
|
constructor({ tokenStorage = "MEMORY", ...options }) {
|
|
2136
|
-
var _a, _b, _c, _d;
|
|
2136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2137
2137
|
this.events = new toolkit.EventBus();
|
|
2138
2138
|
this.addPendingContent = async (props) => {
|
|
2139
2139
|
const mutation = `#graphql
|
|
@@ -2182,6 +2182,7 @@ mutation addPendingDocumentMutation(
|
|
|
2182
2182
|
return G.parse(data.getOptimizedQuery);
|
|
2183
2183
|
};
|
|
2184
2184
|
this.onLogin = (_d = (_c = (_b = (_a = options.schema) == null ? void 0 : _a.config) == null ? void 0 : _b.admin) == null ? void 0 : _c.auth) == null ? void 0 : _d.onLogin;
|
|
2185
|
+
this.onLogout = (_h = (_g = (_f = (_e = options.schema) == null ? void 0 : _e.config) == null ? void 0 : _f.admin) == null ? void 0 : _g.auth) == null ? void 0 : _h.onLogout;
|
|
2185
2186
|
if (options.schema) {
|
|
2186
2187
|
const enrichedSchema = new schemaTools.TinaSchema({
|
|
2187
2188
|
version: { fullVersion: "", major: "", minor: "", patch: "" },
|
|
@@ -2370,7 +2371,7 @@ mutation addPendingDocumentMutation(
|
|
|
2370
2371
|
async isAuthenticated() {
|
|
2371
2372
|
return !!await this.getUser();
|
|
2372
2373
|
}
|
|
2373
|
-
async
|
|
2374
|
+
async logout() {
|
|
2374
2375
|
this.setToken(null);
|
|
2375
2376
|
}
|
|
2376
2377
|
async authenticate() {
|
|
@@ -2408,6 +2409,30 @@ mutation addPendingDocumentMutation(
|
|
|
2408
2409
|
return null;
|
|
2409
2410
|
}
|
|
2410
2411
|
}
|
|
2412
|
+
async getBillingState() {
|
|
2413
|
+
if (!this.clientId) {
|
|
2414
|
+
return null;
|
|
2415
|
+
}
|
|
2416
|
+
const url = `${this.identityApiUrl}/v2/apps/${this.clientId}/billing/state`;
|
|
2417
|
+
try {
|
|
2418
|
+
const res = await this.fetchWithToken(url, {
|
|
2419
|
+
method: "GET"
|
|
2420
|
+
});
|
|
2421
|
+
const val = await res.json();
|
|
2422
|
+
if (!res.status.toString().startsWith("2")) {
|
|
2423
|
+
console.error(val.error);
|
|
2424
|
+
return null;
|
|
2425
|
+
}
|
|
2426
|
+
return {
|
|
2427
|
+
clientId: val.clientId || this.clientId,
|
|
2428
|
+
delinquencyDate: val.delinquencyDate,
|
|
2429
|
+
billingState: val.billingState
|
|
2430
|
+
};
|
|
2431
|
+
} catch (e) {
|
|
2432
|
+
console.error(e);
|
|
2433
|
+
return null;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2411
2436
|
async listBranches() {
|
|
2412
2437
|
const url = `${this.contentApiBase}/github/${this.clientId}/list_branches`;
|
|
2413
2438
|
const res = await this.fetchWithToken(url, {
|
|
@@ -2450,7 +2475,7 @@ mutation addPendingDocumentMutation(
|
|
|
2450
2475
|
get isLocalMode() {
|
|
2451
2476
|
return true;
|
|
2452
2477
|
}
|
|
2453
|
-
async
|
|
2478
|
+
async logout() {
|
|
2454
2479
|
localStorage.removeItem(LOCAL_CLIENT_KEY);
|
|
2455
2480
|
}
|
|
2456
2481
|
async authenticate() {
|
|
@@ -2518,14 +2543,8 @@ mutation addPendingDocumentMutation(
|
|
|
2518
2543
|
async isAuthenticated() {
|
|
2519
2544
|
return await this.api.isAuthenticated();
|
|
2520
2545
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
const collections = this.schema.getCollections();
|
|
2524
|
-
return collections;
|
|
2525
|
-
} catch (e) {
|
|
2526
|
-
console.error(`[TinaAdminAPI] Unable to fetchCollections(): ${e.message}`);
|
|
2527
|
-
return [];
|
|
2528
|
-
}
|
|
2546
|
+
fetchCollections() {
|
|
2547
|
+
return this.schema.getCollections();
|
|
2529
2548
|
}
|
|
2530
2549
|
async deleteDocument({
|
|
2531
2550
|
collection,
|
|
@@ -4514,28 +4533,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4514
4533
|
}
|
|
4515
4534
|
const useGetCollections = (cms) => {
|
|
4516
4535
|
const api = new TinaAdminApi(cms);
|
|
4517
|
-
|
|
4518
|
-
const [loading, setLoading] = React.useState(true);
|
|
4519
|
-
const [error, setError] = React.useState(void 0);
|
|
4520
|
-
React.useEffect(() => {
|
|
4521
|
-
const fetchCollections = async () => {
|
|
4522
|
-
if (await api.isAuthenticated()) {
|
|
4523
|
-
try {
|
|
4524
|
-
const collections2 = await api.fetchCollections();
|
|
4525
|
-
setCollections(collections2);
|
|
4526
|
-
} catch (error2) {
|
|
4527
|
-
console.error(error2);
|
|
4528
|
-
setCollections([]);
|
|
4529
|
-
setError(error2);
|
|
4530
|
-
throw new Error(`[${error2.name}] GetCollections failed: ${error2.message}`);
|
|
4531
|
-
}
|
|
4532
|
-
setLoading(false);
|
|
4533
|
-
}
|
|
4534
|
-
};
|
|
4535
|
-
setLoading(true);
|
|
4536
|
-
fetchCollections();
|
|
4537
|
-
}, [cms]);
|
|
4538
|
-
return { collections, loading, error };
|
|
4536
|
+
return { collections: api.fetchCollections() };
|
|
4539
4537
|
};
|
|
4540
4538
|
function IoMdClose(props) {
|
|
4541
4539
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M405 136.798L375.202 107 256 226.202 136.798 107 107 136.798 226.202 256 107 375.202 136.798 405 256 285.798 375.202 405 405 375.202 285.798 256z" } }] })(props);
|
|
@@ -4764,6 +4762,28 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4764
4762
|
className: "w-6 h-auto mr-2 opacity-80"
|
|
4765
4763
|
}), " Edit With Tina")));
|
|
4766
4764
|
};
|
|
4765
|
+
const LogoutRedirect = () => {
|
|
4766
|
+
const cms = toolkit.useCMS();
|
|
4767
|
+
const { setEdit } = sharedctx.useEditState();
|
|
4768
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
4769
|
+
const slug = searchParams.get("slug") || "/";
|
|
4770
|
+
const logout2 = async () => {
|
|
4771
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4772
|
+
if ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.logout) {
|
|
4773
|
+
await cms.api.tina.logout();
|
|
4774
|
+
if ((_d = (_c = cms == null ? void 0 : cms.api) == null ? void 0 : _c.tina) == null ? void 0 : _d.onLogout) {
|
|
4775
|
+
await ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.onLogout());
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
setEdit(false);
|
|
4779
|
+
};
|
|
4780
|
+
React.useEffect(() => {
|
|
4781
|
+
logout2().then(() => {
|
|
4782
|
+
window.location.href = slug;
|
|
4783
|
+
});
|
|
4784
|
+
}, []);
|
|
4785
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", null, "Redirecting to ", slug, " ...");
|
|
4786
|
+
};
|
|
4767
4787
|
const logout = () => {
|
|
4768
4788
|
sharedctx.setEditing(false);
|
|
4769
4789
|
window.location.href = "/";
|
|
@@ -4800,7 +4820,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
4800
4820
|
const PageHeader = ({
|
|
4801
4821
|
isLocalMode,
|
|
4802
4822
|
children
|
|
4803
|
-
}) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
4823
|
+
}) => /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null), !isLocalMode && /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
4804
4824
|
className: "bg-white pb-4 pt-16 border-b border-gray-200 px-12"
|
|
4805
4825
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
4806
4826
|
className: "w-full mx-auto max-w-screen-xl"
|
|
@@ -5419,7 +5439,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5419
5439
|
const windowWidth = windowSize.useWindowWidth();
|
|
5420
5440
|
const renderNavToggle = windowWidth < navBreakpoint + 1;
|
|
5421
5441
|
const headerPadding = renderNavToggle ? "px-20" : "px-6";
|
|
5422
|
-
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode)
|
|
5442
|
+
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_f = (_e = cms == null ? void 0 : cms.api) == null ? void 0 : _e.tina) == null ? void 0 : _f.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5423
5443
|
className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
|
|
5424
5444
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5425
5445
|
className: "max-w-form mx-auto"
|
|
@@ -5567,7 +5587,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5567
5587
|
const windowWidth = windowSize.useWindowWidth();
|
|
5568
5588
|
const renderNavToggle = windowWidth < navBreakpoint + 1;
|
|
5569
5589
|
const headerPadding = renderNavToggle ? "px-20" : "px-6";
|
|
5570
|
-
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode)
|
|
5590
|
+
return /* @__PURE__ */ React__default["default"].createElement(PageWrapper, null, /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5571
5591
|
className: `py-4 border-b border-gray-200 bg-white ${headerPadding}`
|
|
5572
5592
|
}, /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5573
5593
|
className: "max-w-form mx-auto"
|
|
@@ -5600,7 +5620,7 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5600
5620
|
const selectedScreen = screens.find(({ name }) => slugify(name) === screenName);
|
|
5601
5621
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5602
5622
|
className: "relative w-full h-full flex flex-col items-stretch justify-between"
|
|
5603
|
-
}, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode)
|
|
5623
|
+
}, ((_b = (_a = cms == null ? void 0 : cms.api) == null ? void 0 : _a.tina) == null ? void 0 : _b.isLocalMode) ? /* @__PURE__ */ React__default["default"].createElement(toolkit.LocalWarning, null) : /* @__PURE__ */ React__default["default"].createElement(toolkit.BillingWarning, null), renderNavToggle && /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5604
5624
|
className: `py-5 border-b border-gray-200 bg-white pl-18`
|
|
5605
5625
|
}, selectedScreen.name), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
5606
5626
|
className: "flex-1 overflow-y-auto relative flex flex-col items-stretch justify-between"
|
|
@@ -5727,6 +5747,11 @@ This will work when developing locally but NOT when deployed to production.
|
|
|
5727
5747
|
element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
|
|
5728
5748
|
cms
|
|
5729
5749
|
}, /* @__PURE__ */ React__default["default"].createElement(ScreenPage, null))
|
|
5750
|
+
}), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
5751
|
+
path: "logout",
|
|
5752
|
+
element: /* @__PURE__ */ React__default["default"].createElement(DefaultWrapper, {
|
|
5753
|
+
cms
|
|
5754
|
+
}, /* @__PURE__ */ React__default["default"].createElement(LogoutRedirect, null))
|
|
5730
5755
|
}), /* @__PURE__ */ React__default["default"].createElement(reactRouterDom.Route, {
|
|
5731
5756
|
path: "/",
|
|
5732
5757
|
element: /* @__PURE__ */ React__default["default"].createElement(MaybeRedirectToPreview, {
|
|
@@ -35,7 +35,8 @@ interface ServerOptions {
|
|
|
35
35
|
tokenStorage?: 'MEMORY' | 'LOCAL_STORAGE' | 'CUSTOM';
|
|
36
36
|
}
|
|
37
37
|
export declare class Client {
|
|
38
|
-
onLogin
|
|
38
|
+
onLogin?: OnLoginFunc;
|
|
39
|
+
onLogout?: () => Promise<void>;
|
|
39
40
|
frontendUrl: string;
|
|
40
41
|
contentApiUrl: string;
|
|
41
42
|
identityApiUrl: string;
|
|
@@ -112,7 +113,7 @@ export declare class Client {
|
|
|
112
113
|
getRefreshedToken(tokens: string): Promise<TokenObject>;
|
|
113
114
|
isAuthorized(): Promise<boolean>;
|
|
114
115
|
isAuthenticated(): Promise<boolean>;
|
|
115
|
-
|
|
116
|
+
logout(): Promise<void>;
|
|
116
117
|
authenticate(): Promise<TokenObject>;
|
|
117
118
|
/**
|
|
118
119
|
* Wraps the normal fetch function with same API but adds the authorization header token.
|
|
@@ -125,6 +126,11 @@ export declare class Client {
|
|
|
125
126
|
*/
|
|
126
127
|
fetchWithToken(input: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
127
128
|
getUser(): Promise<any>;
|
|
129
|
+
getBillingState(): Promise<{
|
|
130
|
+
clientId: string;
|
|
131
|
+
delinquencyDate: number;
|
|
132
|
+
billingState: 'current' | 'late' | 'delinquent';
|
|
133
|
+
}>;
|
|
128
134
|
listBranches(): Promise<any>;
|
|
129
135
|
createBranch({ baseBranch, branchName }: BranchData): Promise<string>;
|
|
130
136
|
}
|
|
@@ -135,7 +141,7 @@ export declare class LocalClient extends Client {
|
|
|
135
141
|
schema?: TinaCloudSchema<false>;
|
|
136
142
|
} & Omit<ServerOptions, 'clientId' | 'branch'>);
|
|
137
143
|
get isLocalMode(): boolean;
|
|
138
|
-
|
|
144
|
+
logout(): Promise<void>;
|
|
139
145
|
authenticate(): Promise<{
|
|
140
146
|
access_token: string;
|
|
141
147
|
id_token: string;
|
|
@@ -121,6 +121,15 @@ const Node = ({ components, child }) => {
|
|
|
121
121
|
})
|
|
122
122
|
});
|
|
123
123
|
case "lic":
|
|
124
|
+
if (components.lic) {
|
|
125
|
+
const Component2 = components.lic;
|
|
126
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
127
|
+
...props
|
|
128
|
+
}, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
129
|
+
components,
|
|
130
|
+
content: children
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
124
133
|
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(TinaMarkdown, {
|
|
125
134
|
components,
|
|
126
135
|
content: child.children
|
package/dist/rich-text/index.js
CHANGED
|
@@ -128,6 +128,15 @@
|
|
|
128
128
|
})
|
|
129
129
|
});
|
|
130
130
|
case "lic":
|
|
131
|
+
if (components.lic) {
|
|
132
|
+
const Component2 = components.lic;
|
|
133
|
+
return /* @__PURE__ */ React__default["default"].createElement(Component2, {
|
|
134
|
+
...props
|
|
135
|
+
}, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
136
|
+
components,
|
|
137
|
+
content: children
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
131
140
|
return /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(TinaMarkdown, {
|
|
132
141
|
components,
|
|
133
142
|
content: child.children
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinacms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "./dist/index.es.js",
|
|
6
6
|
"exports": {
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@headlessui/react": "^1.5.0",
|
|
56
56
|
"@heroicons/react": "^1.0.4",
|
|
57
57
|
"@react-hook/window-size": "^3.0.7",
|
|
58
|
-
"@tinacms/schema-tools": "1.0
|
|
58
|
+
"@tinacms/schema-tools": "1.1.0",
|
|
59
59
|
"@tinacms/sharedctx": "1.0.0",
|
|
60
|
-
"@tinacms/toolkit": "1.
|
|
60
|
+
"@tinacms/toolkit": "1.2.0",
|
|
61
61
|
"crypto-js": "^4.0.0",
|
|
62
62
|
"encoding": "0.1.13",
|
|
63
63
|
"fetch-ponyfill": "^7.1.0",
|