Skip to content

SITES-28486 - open inline editing of a contentfragment in the new cf editor if a feature toggle is set #2916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 7, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
var CLASS_CONTENTFRAGMENT = "cmp-contentfragment";
// name of the attribute on the content fragment storing its path
var ATTRIBUTE_PATH = "data-cmp-contentfragment-path";
// base URL of the editor
// unified shell endpoints for internal stage and for prod
var UNIFIED_SHELL_STAGE_ENDPOINT = "https://experience-stage.adobe.com/";
var UNIFIED_SHELL_PROD_ENDPOINT = "https://experience.adobe.com/";
// identifier of internal stage env
var AEM_STAGE_ENV = "cmstg";
// base URL of the old cf editor
var EDITOR_URL = "/editor.html";
// feature toggle enabling opening the cf in the new editor
var FT_USE_NEW_EDITOR = "FT_SITES-19326";

var ContentFragmentEditor = ns.util.createClass({

Expand All @@ -37,14 +44,33 @@
// get the path of the content fragment
var fragmentPath = $(editable.dom).find("." + CLASS_CONTENTFRAGMENT).attr(ATTRIBUTE_PATH);
if (fragmentPath) {
var fragmentEditUrl = EDITOR_URL + fragmentPath;
var fragment = ns.CFM.Fragments.adaptToFragment(editable.dom);
if (fragment && typeof fragment.variation !== "undefined" && fragment.variation !== "master") {
fragmentEditUrl = fragmentEditUrl + "?variation=" + fragment.variation;
var editorUrl = "";
// check if the url for the new editor should be used
if (Granite.Toggles && Granite.Toggles.isEnabled(FT_USE_NEW_EDITOR)) {
editorUrl = this.getNewEditorUrl(fragmentPath);
} else {
editorUrl = EDITOR_URL + fragmentPath;
var fragment = ns.CFM.Fragments.adaptToFragment(editable.dom);
if (fragment && typeof fragment.variation !== "undefined" && fragment.variation !== "master") {
editorUrl = editorUrl + "?variation=" + fragment.variation;
}
editorUrl = Granite.HTTP.externalize(editorUrl);
}
// open the editor in a new window
window.open(Granite.HTTP.externalize(fragmentEditUrl));
window.open(editorUrl);
}
},

getNewEditorUrl: function(fragmentPath) {
var newEditorUrl = "";
var hostNameAEM = window.location.hostname;
if (hostNameAEM.indexOf(AEM_STAGE_ENV) !== -1) {
newEditorUrl = UNIFIED_SHELL_STAGE_ENDPOINT;
} else {
newEditorUrl = UNIFIED_SHELL_PROD_ENDPOINT;
}
newEditorUrl += "?repo=" + hostNameAEM + "#/aem/cf/editor" + fragmentPath;
return newEditorUrl;
}

});
Expand Down
Loading