<commit_before>(function ($, ns, channel, window, undefined) {

    var actionDef = {
        icon: 'coral-Icon--globe',
        text: Granite.I18n.get('Configure Shared Content'),
        handler: function (editable, param, target) { // will be called on click
        	var originalDialogSrc = editable.config.dialogSrc;
        	var originalDialog = editable.config.dialog;
        	
        	var dialogSrcArray = editable.config.dialogSrc.split(".html");
        	var langRootRegexp = /^(\/content\/([^/]+\/)+([a-zA-Z]{2}([_-][a-zA-Z]{2})?))(|\/.*)$/g;
        	var match = langRootRegexp.exec(dialogSrcArray[1]);
        	
        	var siteWideDialogSrc = dialogSrcArray[0].replace("_cq_dialog", "_cq_dialogsitewide") +
						        	".html" +
						        	match[1] +
						        	"/jcr:content/sitewideprops/" +
						        	editable.type;
        	
        	editable.config.dialogSrc = siteWideDialogSrc;
        	editable.config.dialog = editable.config.dialog.replace("cq:dialog", "cq:dialogsitewide");
        	
        	ns.edit.actions.doConfigure(editable);
        	
        	//set the dialog and dialogSrc back to the original values so normal edit dialog continues to work
        	editable.config.dialogSrc = originalDialogSrc;
        	editable.config.dialog = originalDialog;
        	
            // do not close toolbar
            return false;
        },
        /*
         * In the event that we need to restrict this to specific components or something, we would potentially
         * do that in this "condition" function. If we don't, we , we would do that here. Otherwise, leave it out!
         */
//        condition: function(editable) {
//            //restrict to just a specific component, otherwise it will show up on all components.
//            var result = editable.type === "fmmp-base/components/content/[path to component here]";
//            return result;
//        },
        isNonMulti: true
    };

    // we listen to the messaging channel
    // to figure out when a layer got activated
    channel.on('cq-layer-activated', function (ev) {
        // we continue if the user switched to the Edit layer
        if (ev.layer === 'Edit') {
            // we use the editable toolbar and register an additional action
            ns.EditorFrame.editableToolbar.registerAction('COMMON-CONTENT', actionDef);
        }
    });
<commit_msg>Updated to restrict to add the globe icon to the toolbar, only when a standard dialog exists<commit_after>(function ($, ns, channel, window, undefined) {

    var actionDef = {
        icon: 'coral-Icon--globe',
        text: Granite.I18n.get('Configure Shared Content'),
        handler: function (editable, param, target) { // will be called on click
        	var originalDialogSrc = editable.config.dialogSrc;
        	var originalDialog = editable.config.dialog;
        	
        	var dialogSrcArray = editable.config.dialogSrc.split(".html");
        	var langRootRegexp = /^(\/content\/([^/]+\/)+([a-zA-Z]{2}([_-][a-zA-Z]{2})?))(|\/.*)$/g;
        	var match = langRootRegexp.exec(dialogSrcArray[1]);
        	
        	var siteWideDialogSrc = dialogSrcArray[0].replace("_cq_dialog", "_cq_dialogsitewide") +
						        	".html" +
						        	match[1] +
						        	"/jcr:content/sitewideprops/" +
						        	editable.type;
        	
        	editable.config.dialogSrc = siteWideDialogSrc;
        	editable.config.dialog = editable.config.dialog.replace("cq:dialog", "cq:dialogsitewide");
        	
        	ns.edit.actions.doConfigure(editable);
        	
        	//set the dialog and dialogSrc back to the original values so normal edit dialog continues to work
        	editable.config.dialogSrc = originalDialogSrc;
        	editable.config.dialog = originalDialog;
        	
            // do not close toolbar
            return false;
        },
        /*
         * In the event that we need to restrict this to specific components or something, we would potentially
         * do that in this "condition" function. If we don't, we , we would do that here. Otherwise, leave it out!
         */
        //Restrict to users with correct permissions and if the dialog exists
        condition: function(editable) {
        	var canModify = ns.page.info.permissions && ns.page.info.permissions.modify;
            return !!editable.config.dialog && canModify;
        },
        isNonMulti: true
    };

    // we listen to the messaging channel
    // to figure out when a layer got activated
    channel.on('cq-layer-activated', function (ev) {
        // we continue if the user switched to the Edit layer
        if (ev.layer === 'Edit') {
            // we use the editable toolbar and register an additional action
            ns.EditorFrame.editableToolbar.registerAction('COMMON-CONTENT', actionDef);
        }
    });

{'fraction_non_alphanumeric': 0.11198347107438017, 'fraction_numerical': 0.002892561983471074, 'mean_word_length': 2.1333333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6547095', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1345, 'n_words': 379}