Skip to content

Commit 77d3de1

Browse files
committed
feat: deprecated extensions like emment installed we show a dialog once that its deprecated
1 parent 23e23cd commit 77d3de1

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<div class="deprecated-extensions-dialog modal">
2+
<div class="modal-header">
3+
<h1 class="dialog-title">{{Strings.DEPRECATED_EXTENSIONS_TITLE}}</h1>
4+
</div>
5+
<div class="modal-body">
6+
<p class="dialog-message">{{Strings.DEPRECATED_EXTENSIONS_MESSAGE}}</p>
7+
8+
<div class="deprecated-extensions-list" style="margin-top: 16px;">
9+
{{#extensions}}
10+
<div class="deprecated-extension-item" style="margin-bottom: 12px; padding: 12px; border: 1px solid var(--border-color, #ddd); border-radius: 4px;">
11+
<div class="extension-info" style="margin-bottom: 6px;">
12+
<i class="fa fa-exclamation-triangle" style="color: #f5a623; margin-right: 8px;"></i>
13+
<strong>{{id}}</strong>
14+
</div>
15+
<div class="extension-alternative" style="margin-left: 24px;">
16+
<a href="{{docUrl}}" target="_blank" rel="noopener">
17+
{{Strings.DEPRECATED_EXTENSIONS_LEARN_MORE}}
18+
<i class="fa fa-external-link" style="margin-left: 4px; font-size: 11px;"></i>
19+
</a>
20+
</div>
21+
</div>
22+
{{/extensions}}
23+
</div>
24+
</div>
25+
<div class="modal-footer">
26+
<button class="dialog-button btn primary" data-button-id="ok">{{Strings.OK}}</button>
27+
</div>
28+
</div>

src/nls/root/strings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,10 @@ define({
17231723
"LICENSE_ACTIVATE_FAIL_APPLY": "'Failed to apply license to device'",
17241724
"LICENSE_ENTER_KEY": "Please enter a license key",
17251725
"LICENSE_REAPPLY_TO_DEVICE": "Already activated? Reapply system-wide",
1726+
// Deprecated Extensions Dialog
1727+
"DEPRECATED_EXTENSIONS_TITLE": "Deprecated Extensions Detected",
1728+
"DEPRECATED_EXTENSIONS_MESSAGE": "The following installed extensions are now natively supported by Phoenix and can be safely removed:",
1729+
"DEPRECATED_EXTENSIONS_LEARN_MORE": "Learn more about the native feature",
17261730
// AI CONTROL
17271731
"AI_LOGIN_DIALOG_TITLE": "Sign In to Use AI Edits",
17281732
"AI_LOGIN_DIALOG_MESSAGE": "Please log in to use AI-powered edits",

src/utils/ExtensionLoader.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,19 @@ define(function (require, exports, module) {
5454
UrlParams = require("utils/UrlParams").UrlParams,
5555
NodeUtils = require("utils/NodeUtils"),
5656
PathUtils = require("thirdparty/path-utils/path-utils"),
57-
DefaultExtensions = JSON.parse(require("text!extensions/default/DefaultExtensions.json"));
57+
DefaultExtensions = JSON.parse(require("text!extensions/default/DefaultExtensions.json")),
58+
Dialogs = require("widgets/Dialogs"),
59+
PreferencesManager = require("preferences/PreferencesManager"),
60+
Mustache = require("thirdparty/mustache/mustache"),
61+
Strings = require("strings"),
62+
DeprecatedExtensionsTemplate = require("text!htmlContent/deprecated-extensions-dialog.html");
5863

5964
// takedown/dont load extensions that are compromised at app start - start
6065
const EXTENSION_TAKEDOWN_LOCALSTORAGE_KEY = "PH_EXTENSION_TAKEDOWN_LIST";
6166

67+
// deprecated extensions dialog state key
68+
const STATE_DEPRECATED_EXTENSIONS_DIALOG_SHOWN = "deprecatedExtensionsDialogShown";
69+
6270
function _getTakedownListLS() {
6371
try{
6472
let list = localStorage.getItem(EXTENSION_TAKEDOWN_LOCALSTORAGE_KEY);
@@ -1018,6 +1026,8 @@ define(function (require, exports, module) {
10181026

10191027
promise.always(function () {
10201028
_init = true;
1029+
// Check for deprecated extensions after all extensions have loaded
1030+
_checkAndShowDeprecatedExtensionsDialog();
10211031
});
10221032

10231033
return promise;
@@ -1032,6 +1042,55 @@ define(function (require, exports, module) {
10321042
return takedownExtensionList.has(extensionID);
10331043
}
10341044

1045+
/**
1046+
* Check if any deprecated extensions are installed and show a dialog once
1047+
* @private
1048+
*/
1049+
function _checkAndShowDeprecatedExtensionsDialog() {
1050+
// Check if we've already shown the dialog
1051+
const dialogShown = PreferencesManager.stateManager.get(STATE_DEPRECATED_EXTENSIONS_DIALOG_SHOWN);
1052+
if (dialogShown) {
1053+
return;
1054+
}
1055+
1056+
// Get deprecated extensions config
1057+
const deprecatedExtensionsConfig = DefaultExtensions.deprecatedExtensions;
1058+
if (!deprecatedExtensionsConfig || !deprecatedExtensionsConfig.extensionIDsAndDocs) {
1059+
return;
1060+
}
1061+
1062+
const deprecatedExtensionIDs = deprecatedExtensionsConfig.extensionIDsAndDocs;
1063+
1064+
// Check which deprecated extensions are loaded
1065+
const deprecatedExtensionsFound = [];
1066+
for (const extensionID of loadedExtensionIDs) {
1067+
if (deprecatedExtensionIDs[extensionID]) {
1068+
deprecatedExtensionsFound.push({
1069+
id: extensionID,
1070+
docUrl: deprecatedExtensionIDs[extensionID]
1071+
});
1072+
}
1073+
}
1074+
1075+
// If no deprecated extensions found, mark dialog as shown and return
1076+
if (deprecatedExtensionsFound.length === 0) {
1077+
PreferencesManager.stateManager.set(STATE_DEPRECATED_EXTENSIONS_DIALOG_SHOWN, true);
1078+
return;
1079+
}
1080+
1081+
// Show the dialog
1082+
const templateVars = {
1083+
extensions: deprecatedExtensionsFound,
1084+
Strings: Strings
1085+
};
1086+
1087+
const $template = $(Mustache.render(DeprecatedExtensionsTemplate, templateVars));
1088+
Dialogs.showModalDialogUsingTemplate($template);
1089+
1090+
// Mark dialog as shown
1091+
PreferencesManager.stateManager.set(STATE_DEPRECATED_EXTENSIONS_DIALOG_SHOWN, true);
1092+
}
1093+
10351094

10361095
EventDispatcher.makeEventDispatcher(exports);
10371096

0 commit comments

Comments
 (0)