PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / admin / components / AdminPanel.js

AdminPanel.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/admin/components/AdminPanel.js

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useState, useLayoutEffect, useEffect } from 'react'
2 import { Router } from 'react-router-dom';
3
4 import { history } from '~betterdocs/utils/history';
5 import Routes from './Routes';
6
7 const AdminPanel = () => {
8 const [state, setState] = useState({
9 action: history.action,
10 location: history.location,
11 });
12
13 useLayoutEffect(() => history.listen((location, action) => {
14 setState({ action, location });
15 }), [history]);
16
17 useEffect(() => {
18 let instantAnswer = document.getElementsByClassName('betterdocs-ia');
19
20 if (instantAnswer.length === 0) {
21 return;
22 }
23
24 //related I/A settings preview
25 if( ! ( state?.location?.pathname == '/betterdocs-settings' && betterdocsAdminSettings?.values?.enable_disable ) ) { //inverse or negate the condition
26 instantAnswer[0].style.display = 'none';
27 return;
28 }
29
30 //related I/A settings preview
31 if( ! ( state?.location?.pathname == '/betterdocs-settings' && betterdocsAdminSettings?.values?.ia_enable_preview ) ) { //inverse or negate the condition
32 instantAnswer[0].style.display = 'none';
33 return;
34 }
35
36 //related I/A settings preview
37 instantAnswer[0].style.display = 'block';
38
39 }, [state]);
40
41 return (
42 <Router
43 location={state.location}
44 basename="/"
45 navigator={history}
46 navigationType={state.action}>
47 <Routes />
48 </Router>
49 )
50 }
51
52 export default AdminPanel
53