PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.2.2
Presto Player v2.2.2
4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / settings / app.js
presto-player / src / admin / settings Last commit date
components 3 years ago pages 3 years ago scss 5 years ago store 5 years ago app.js 3 years ago entities.js 3 years ago index.js 3 years ago routes.js 3 years ago settings.js 4 years ago settings.scss 5 years ago util.js 5 years ago
app.js
141 lines
1 import { __ } from "@wordpress/i18n";
2 import {
3 Card,
4 Flex,
5 FlexBlock,
6 FlexItem,
7 Spinner,
8 } from "@wordpress/components";
9 import { store as noticesStore } from "@wordpress/notices";
10 import { useDispatch, useSelect } from "@wordpress/data";
11 import { store as coreStore } from "@wordpress/core-data";
12 import { useState, useEffect } from "@wordpress/element";
13
14 import { Router, Link, Route } from "@/router";
15 import { routes } from "./routes";
16
17 import SaveButton from "./components/SaveButton";
18 import Notices from "./components/Notices";
19 import useSave from "../../hooks/useSave";
20 import General from "./pages/General";
21 import Performance from "./pages/Performance";
22 import Integrations from "./pages/Integrations";
23
24 function App() {
25 const { createSuccessNotice, createErrorNotice } = useDispatch(noticesStore);
26 const [loaded, setLoaded] = useState(false);
27
28 // scroll top on history change
29 window.onhashchange = () => {
30 window.scrollTo(0, 0);
31 };
32
33 const { save } = useSave();
34
35 /**
36 * Form is submitted.
37 */
38 const onSubmit = async () => {
39 try {
40 await save();
41 createSuccessNotice(__("Settings Updated", "presto-player"), {
42 type: "snackbar",
43 });
44 } catch (e) {
45 console.error(e);
46 createErrorNotice(
47 e?.message || __("Something went wrong", "presto-player"),
48 { type: "snackbar" }
49 );
50 }
51 };
52
53 const loading = useSelect((select) => {
54 const queryArgs = ["root", "site"];
55 select(coreStore).getEntityRecords(...queryArgs);
56 return !select(coreStore)?.hasFinishedResolution?.(
57 "getEntityRecords",
58 queryArgs
59 );
60 });
61
62 useEffect(() => {
63 if (!loading) {
64 setLoaded(true);
65 }
66 }, [loading]);
67
68 if (!loaded) {
69 return (
70 <div className="presto-settings__loading">
71 <Spinner />
72 </div>
73 );
74 }
75
76 return (
77 <div className="presto-settings">
78 <Router routes={routes} defaultRoute={routes?.general?.path}>
79 <Card className="presto-settings__navigation">
80 <Flex>
81 <FlexBlock>
82 <div
83 role="tablist"
84 aria-orientation="horizontal"
85 className="components-tab-panel__tabs"
86 >
87 <Link
88 to={routes?.general?.path}
89 type="button"
90 role="tab"
91 activeClassName="is-active"
92 className="components-button components-tab-panel__tabs-item presto-player__nav-general"
93 >
94 {__("General", "presto-player")}
95 </Link>
96 <Link
97 to={routes?.integrations?.path}
98 type="button"
99 role="tab"
100 activeClassName="is-active"
101 className="components-button components-tab-panel__tabs-item presto-player__nav-integrations"
102 >
103 {__("Integrations", "presto-player")}
104 </Link>
105 <Link
106 to={routes?.performance?.path}
107 type="button"
108 role="tab"
109 activeClassName="is-active"
110 className="components-button components-tab-panel__tabs-item presto-player__nav-performance"
111 >
112 {__("Performance", "presto-player")}
113 </Link>
114 </div>
115 </FlexBlock>
116 <FlexItem>
117 <SaveButton onSave={onSubmit} style={{ marginRight: "8px" }}>
118 {__("Update Settings", "presto-player")}
119 </SaveButton>
120 </FlexItem>
121 </Flex>
122 </Card>
123
124 <Route path={routes?.general?.path}>
125 <General />
126 </Route>
127 <Route path={routes?.integrations?.path}>
128 <Integrations />
129 </Route>
130 <Route path={routes?.performance?.path}>
131 <Performance />
132 </Route>
133 </Router>
134
135 <Notices className="presto-settings-page-notices" />
136 </div>
137 );
138 }
139
140 export default App;
141