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 / dashboard / components / ContextMenu.js

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

138 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useState } from "react";
2 import { __ } from "@wordpress/i18n";
3 import { IconDotsHorizontal } from "~betterdocs/icons";
4 import { useDashboardContext } from "../DashboardContext";
5 import { gutenbergEditScreenUrl } from "../helpers/Helpers";
6 import { applyFilters } from "@wordpress/hooks";
7
8 const ContextMenu = (props) => {
9 const { doc, status } = props;
10
11 const { data, setData } = useDashboardContext();
12
13 const { isListMenuOpen, docId } = data;
14 const { doc_category, knowledge_base } = doc;
15
16 let nonTrashButtons = applyFilters('contextMenuListTable', {
17 'edit' : () => {
18 return <li>
19 <a
20 target="_blank"
21 href={gutenbergEditScreenUrl(doc.id)}
22 >
23 {__("Edit", "betterdocs")}
24 </a>
25 </li>
26 },
27 'quickEdit':() => {
28 return <li>
29 <a
30 href="#"
31 onClick={() =>
32 setData((state) => ({
33 ...state,
34 isOpen: true,
35 docData: doc,
36 }))
37 }
38 >
39 {__("Quick Edit", "betterdocs")}
40 </a>
41 </li>
42 },
43 'trash':() => {
44 return <li>
45 <a
46 href="#"
47 onClick={(event) => {
48 event.preventDefault();
49 setData((state) => ({
50 ...state,
51 quickAction: {
52 action: "trash",
53 docId: doc?.id,
54 },
55 }));
56 }}
57 >
58 {__("Trash", "betterdocs")}
59 </a>
60 </li>
61 },
62 'view':() => {
63 return <li>
64 <a target="_blank" href={doc.link}>
65 {__("View", "betterdocs")}
66 </a>
67 </li>
68 }
69 }, doc);
70
71 return (
72 <span className="betterdocs-dashboard-list-item-action">
73 <span
74 className="betterdocs-dashboard-list-item-action-icon"
75 onClick={() =>
76 setData((state) => ({
77 ...state,
78 isListMenuOpen: !isListMenuOpen,
79 docId: doc.id,
80 }))
81 }
82 >
83 <IconDotsHorizontal />
84 </span>
85
86 {isListMenuOpen && docId != undefined && docId == doc?.id && (
87 <ul className="betterdocs-dashboard-list-item-action-dropdown open">
88 {status != "trash" && (
89 Object.keys(nonTrashButtons)?.map((key) => {
90 return nonTrashButtons[key]();
91 })
92 )}
93 {status == 'trash' && <>
94 <li>
95 <a
96 target="_blank"
97 href="#"
98 onClick={(e) => {
99 e.preventDefault();
100 setData((state) => ({
101 ...state,
102 quickAction: {
103 action: "restore",
104 docId: doc?.id,
105 },
106 }));
107 }}
108 >
109 {__("Restore", "betterdocs")}
110 </a>
111 </li>
112 <li>
113 <a
114 target="_blank"
115 href="#"
116 onClick={(e) => {
117 e.preventDefault();
118 setData((state) => ({
119 ...state,
120 quickAction: {
121 action: "permanent-delete",
122 docId: doc?.id,
123 },
124 }));
125 }}
126 >
127 {__("Delete Permanantly", "betterdocs")}
128 </a>
129 </li>
130 </> }
131 </ul>
132 )}
133 </span>
134 );
135 };
136
137 export default ContextMenu;
138