Skip to content

Commit 6c5440b

Browse files
committed
feat: show dialog when subscribe button is clicked
1 parent 1b04d80 commit 6c5440b

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@ define(function (require, exports, module) {
155155
editor.focus();
156156
});
157157

158+
function _showProFeatureDialog() {
159+
const dialog = Dialogs.showModalDialog(
160+
DefaultDialogs.DIALOG_ID_INFO,
161+
Strings.LIVE_PREVIEW_PRO_FEATURE_TITLE,
162+
Strings.LIVE_PREVIEW_PRO_FEATURE_MESSAGE,
163+
[
164+
{
165+
className: Dialogs.DIALOG_BTN_CLASS_NORMAL,
166+
id: Dialogs.DIALOG_BTN_CANCEL,
167+
text: Strings.CANCEL
168+
},
169+
{
170+
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
171+
id: "subscribe",
172+
text: Strings.LIVE_PREVIEW_PRO_SUBSCRIBE
173+
}
174+
]
175+
);
176+
177+
dialog.done(function (buttonId) {
178+
if (buttonId === "subscribe") {
179+
// TODO: write the implementation here...@abose
180+
console.log("the subscribe button got clicked");
181+
}
182+
});
183+
184+
return dialog;
185+
}
158186

159187
// this function is to check if the live highlight feature is enabled or not
160188
function _isLiveHighlightEnabled() {
@@ -266,7 +294,7 @@ define(function (require, exports, module) {
266294
const crownIcon = !isEditFeaturesActive ? ' <span style="color: #FBB03B; border: 1px solid #FBB03B; padding: 2px 4px; border-radius: 10px; font-size: 9px; margin-left: 12px;"><i class="fas fa-crown"></i> Pro</span>' : '';
267295
return {
268296
html: `${checkmark}${item}${crownIcon}`,
269-
enabled: isEditFeaturesActive
297+
enabled: true
270298
};
271299
} else if (item === Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON) {
272300
const isHoverMode = PreferencesManager.get(PREFERENCE_PROJECT_ELEMENT_HIGHLIGHT) !== "click";
@@ -305,7 +333,13 @@ define(function (require, exports, module) {
305333
} else if (index === 1) {
306334
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "highlight");
307335
} else if (index === 2) {
308-
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "edit");
336+
if (!isEditFeaturesActive) {
337+
// when the feature is not active we need to show a dialog to the user asking
338+
// them to subscribe to pro
339+
_showProFeatureDialog();
340+
} else {
341+
PreferencesManager.set(PREFERENCE_LIVE_PREVIEW_MODE, "edit");
342+
}
309343
} else if (item === Strings.LIVE_PREVIEW_EDIT_HIGHLIGHT_ON) {
310344
// Don't allow edit highlight toggle if edit features are not active
311345
if (!isEditFeaturesActive) {

src/nls/root/strings.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ define({
195195
"LIVE_PREVIEW_MODE_EDIT": "Edit Mode",
196196
"LIVE_PREVIEW_EDIT_HIGHLIGHT_ON": "Edit Highlights on Hover",
197197
"LIVE_PREVIEW_MODE_PREFERENCE": "{0} shows only the webpage, {1} connects the webpage to your code - click on elements to jump to their code and vice versa, {2} provides highlighting along with advanced element manipulation",
198+
"LIVE_PREVIEW_PRO_FEATURE_TITLE": "Pro Feature",
199+
"LIVE_PREVIEW_PRO_FEATURE_MESSAGE": "This is a Pro feature. Subscribe to Phoenix Pro to keep using this feature.",
200+
"LIVE_PREVIEW_PRO_SUBSCRIBE": "Subscribe",
198201

199202
"LIVE_DEV_DETACHED_REPLACED_WITH_DEVTOOLS": "Live Preview was canceled because the browser's developer tools were opened",
200203
"LIVE_DEV_DETACHED_TARGET_CLOSED": "Live Preview was canceled because the page was closed in the browser",

0 commit comments

Comments
 (0)