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 / utils / proAlert.js

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

161 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __, sprintf } from "@wordpress/i18n";
2 import { isObject } from "quickbuilder";
3 import Swal from "sweetalert2";
4
5 // Pro upgrade target for the Settings pro-teaser / license modals. Kept in sync
6 // with the analytics teaser's upgradeUrl() fallback (ProTeaser.js).
7 const UPGRADE_URL = "https://betterdocs.co/dashboard-upgrade-to-pro";
8
9 export const SweetAlert = (args = {}) => {
10 return Swal.mixin({
11 target: args?.target ?? "#betterdocsQuickBuilder",
12 html: args?.html,
13 title: args?.title ?? __("Title Goes Here: title", "betterdocs"),
14 text: args?.text ?? __("Text Goes Here: text", "betterdocs"),
15 icon: args?.icon ?? (args?.type || "success"),
16 timer: args?.timer ?? null,
17 ...args,
18 });
19 };
20 const proAlert = (html = null) => {
21 const tabKey = document.querySelector('li.wprf-tab-nav-item.wprf-active-nav')?.getAttribute('data-key');
22
23 let title = __('Upgrade to BetterDocs PRO', 'betterdocs');
24 let description = __('To access this feature, simply upgrade to BetterDocs PRO for premium access.', 'betterdocs');
25
26
27 if (tabKey === 'tab-ai-chatbot') {
28 title = __('Upgrade To BetterDocs PRO & Get BetterDocs AI Chatbot Addon', 'betterdocs');
29 description = __('To access this feature, simply upgrade to BetterDocs PRO, get the BetterDocs AI chatbot Addon, and activate the license keys.', 'betterdocs');
30 }
31
32 let htmlObject = {};
33 let closeButtonHtml = `<svg class="betterdocs-close-button" xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">
34 <path d="M1.69687 14L0.296875 12.6L5.89687 7L0.296875 1.4L1.69687 0L7.29688 5.6L12.8969 0L14.2969 1.4L8.69688 7L14.2969 12.6L12.8969 14L7.29688 8.4L1.69687 14Z" fill="#475467"/>
35 </svg>`;
36 if (html === null) {
37 html = sprintf(
38 '<div class="icon">' +
39 '<i class="btd-icon btd-crown"></i>' +
40 '</div>' +
41 '<h3 class="title">%s</h3>' +
42 '<p class="description">%s</p>' +
43 '<div class="features">' +
44 '<h5 class="feature-title">%s</h5>' +
45 '<ul class="feature-list">' +
46 '<li class="list-item">%s</li>' +
47 '<li class="list-item">%s</li>' +
48 '<li class="list-item">%s</li>' +
49 '<li class="list-item">%s</li>' +
50 '<li class="list-item">%s</li>' +
51 '<li class="list-item">%s</li>' +
52 '<li class="list-item">%s</li>' +
53 '<li class="list-item">%s</li>' +
54 '</ul>' +
55 '</div>' +
56 '<div class="footer">' +
57 '<a href="%s" target="_blank">%s</a>' +
58 '</div>',
59 title,
60 description,
61 __("Here’s what’s inside BetterDocs Pro.", "betterdocs"),
62 __("Multiple Knowledge Bases", "betterdocs"),
63 __("Internal Knowledge Base", "betterdocs"),
64 __("Instant Answer", "betterdocs"),
65 __("Git Sync", "betterdocs"),
66 __("Insightful Analytics Report", "betterdocs"),
67 __("User Role Management", "betterdocs"),
68 __("Glossaries & Encyclopedia", "betterdocs"),
69 __("AI-Powered Chatbot", "betterdocs"),
70 UPGRADE_URL,
71 __("Upgrade Now", "betterdocs")
72 );
73 }
74 if (isObject(html)) {
75 htmlObject = html;
76 html = html.message || html.html;
77 }
78 let alertOptions = {
79 showConfirmButton: false,
80 showDenyButton: false,
81 icon: false,
82 type: "warning",
83 title: false,
84 showCloseButton: true,
85 closeButtonHtml: closeButtonHtml,
86 customClass: {
87 container: "betterdocs-pro-alert-container",
88 popup: "betterdocs-pro-alert-popup",
89 closeButton: "betterdocs-pro-alert-close-button",
90 htmlContainer: "betterdocs-pro-alert-html",
91 },
92 ...htmlObject,
93 html,
94 };
95 return SweetAlert(alertOptions);
96 };
97
98 export const licenseInactiveAlert = (html = null) => {
99 let htmlObject = {};
100 let closeButtonHtml = `<svg class="betterdocs-close-button" xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">
101 <path d="M1.69687 14L0.296875 12.6L5.89687 7L0.296875 1.4L1.69687 0L7.29688 5.6L12.8969 0L14.2969 1.4L8.69688 7L14.2969 12.6L12.8969 14L7.29688 8.4L1.69687 14Z" fill="#475467"/>
102 </svg>`;
103 if (html === null) {
104 html = sprintf(
105 '<div class="icon">' +
106 '<i class="btd-icon btd-crown"></i>' +
107 '</div>' +
108 '<h3 class="title">%s</h3>' +
109 '<p class="description">%s</p>' +
110 '<div class="features">' +
111 '<h5 class="feature-title">%s</h5>' +
112 '<ul class="feature-list">' +
113 '<li class="list-item">%s</li>' +
114 '<li class="list-item">%s</li>' +
115 '<li class="list-item">%s</li>' +
116 '<li class="list-item">%s</li>' +
117 '<li class="list-item">%s</li>' +
118 '<li class="list-item">%s</li>' +
119 '</ul>' +
120 '</div>' +
121 '<div class="footer">' +
122 '<a href="%s" target="_blank">%s</a>' +
123 '</div>',
124 __("License Not Activated", "betterdocs"),
125 __("To access this feature, simply upgrade to BetterDocs PRO for premium access.", "betterdocs"),
126 __("Here’s what’s inside BetterDocs Pro.", "betterdocs"),
127 __("Multiple Knowledge Bases", "betterdocs"),
128 __("Internal Knowledge Base", "betterdocs"),
129 __("Instant Answer", "betterdocs"),
130 __("Advanced Live Search", "betterdocs"),
131 __("Insightful Analytics Report", "betterdocs"),
132 __("User Role Management", "betterdocs"),
133 UPGRADE_URL,
134 __("Upgrade Now", "betterdocs")
135 );
136 }
137 if (isObject(html)) {
138 htmlObject = html;
139 html = html.message || html.html;
140 }
141 let alertOptions = {
142 showConfirmButton: false,
143 showDenyButton: false,
144 icon: false,
145 title: false,
146 showCloseButton: true,
147 closeButtonHtml: closeButtonHtml,
148 customClass: {
149 container: "betterdocs-pro-alert-container",
150 popup: "betterdocs-pro-alert-popup",
151 closeButton: "betterdocs-pro-alert-close-button",
152 htmlContainer: "betterdocs-pro-alert-html",
153 },
154 ...htmlObject,
155 html,
156 };
157 return SweetAlert(alertOptions);
158 };
159
160 export default proAlert;
161