PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / admin / src / components / MenuHeader.jsx

MenuHeader.jsx in Tableberg – Simple Gutenberg Table Block 1.1.5, at admin/src/components/MenuHeader.jsx

106 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useMemo, useEffect } from "react";
2 import { __ } from "@wordpress/i18n";
3 import RightContainerItem from "./RightContainerItem";
4 import Navigation from "./Navigation";
5 import { routeObjects } from "../inc/routes";
6 import AssetProvider from "./AssetProvider";
7 import ButtonLink from "./ButtonLink";
8
9 /**
10 * Settings menu header element.
11 *
12 * @return {JSX.Element} component
13 */
14 function MenuHeader({ currentRoutePath, setCurrentRoutePath }) {
15 useEffect(() => {
16 const url = new URL(window.location.href);
17 url.searchParams.set("route", currentRoutePath);
18 window.history.pushState(null, null, url.href);
19 }, [currentRoutePath]);
20
21 const routeObjectsMinus404 = useMemo(() => {
22 return routeObjects.slice(0, routeObjects.length - 1);
23 }, []);
24 const logoUrl = tablebergAdminMenuData?.assets.logo;
25
26 /**
27 * Rollback plugin version.
28 *
29 * @param {Function} dispatch store action dispatch function
30 * @param {Function} getState store state selection function
31 * @return {Function} action function
32 */
33 const rollbackToVersion = version => {
34 const { url, action, nonce } = versionData.ajax.versionRollback;
35
36 const formData = new FormData();
37 formData.append("action", action);
38 formData.append("nonce", nonce);
39 formData.append("version", version);
40
41 return fetch(url, {
42 method: "POST",
43 body: formData,
44 })
45 .then(resp => {
46 return resp.json();
47 })
48 .then(data => {
49 if (data.error) {
50 throw new Error(data.error);
51 }
52
53 return data;
54 });
55 };
56 return (
57 <div className={"header-wrapper"}>
58 <div className={"menu-header"}>
59 <div className={"left-container"}>
60 <div className={"logo-container"}>
61 <img alt={"plugin logo"} src={logoUrl} />
62 <div className={"tableberg-plugin-logo-text"}>
63 Tableberg
64 </div>
65 </div>
66 </div>
67 <div className={"tableberg-menu-navigation-wrapper"}>
68 <Navigation
69 routes={routeObjectsMinus404}
70 currentRoutePath={currentRoutePath}
71 setRoute={setCurrentRoutePath}
72 />
73 </div>
74 <div className={"right-container"}>
75 {!tablebergAdminMenuData.misc.pro_status && (
76 <RightContainerItem>
77 <AssetProvider assetIds={["proBuyUrl"]}>
78 {({ proBuyUrl }) => (
79 <ButtonLink
80 url={proBuyUrl}
81 title="Upgrade to PRO"
82 />
83 )}
84 </AssetProvider>
85 </RightContainerItem>
86 )}
87 </div>
88 </div>
89 <div className={"dropdown-navigation"}>
90 <div className={"dropdown-drawer"}>
91 <Navigation
92 routes={routeObjectsMinus404}
93 currentRoutePath={currentRoutePath}
94 setRoute={setCurrentRoutePath}
95 />
96 </div>
97 </div>
98 </div>
99 );
100 }
101
102 /**
103 * @module MenuHeader
104 */
105 export default MenuHeader;
106