<commit_before>﻿namespace formulate.deploy.Events
{

    // Namespaces.
    using app.Entities;
    using app.Resolvers;
    using System;
    using Umbraco.Core;
    using Umbraco.Web.Models.Trees;
    using Umbraco.Web.Trees;


    /// <summary>
    /// Handles application startup events.
    /// </summary>
    internal class AppStart : ApplicationEventHandler
    {

        #region Overridden Methods

        /// <summary>
        /// Application is starting.
        /// </summary>
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            TreeControllerBase.MenuRendering += Handle_RenderContextMenu;
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Handles rendering of the context menu.
        /// </summary>
        private void Handle_RenderContextMenu(TreeControllerBase sender, MenuRenderingEventArgs e)
        {

            // Variables.
            var alias = sender.TreeAlias;
            var items = e.Menu.Items;
            var nodeId = e.NodeId;
            var guid = default(Guid);


            // Is this a Formulate context menu?
            if (!"formulate".InvariantEquals(alias))
            {
                return;
            }


            // Is this a GUID (the root has "-1")?
            if (Guid.TryParse(nodeId, out guid))
            {

                // Variables.
                var persistence = EntityPersistence.Current.Manager;
                var entity = persistence.Retrieve(guid);
                var strGuid = guid.ToString("N");


                // Is this a non-root entity (e.g., a form, validation, folder, etc.)?
                if (entity != null && entity.GetType() != typeof(EntityRoot))
                {

                    // Add the "Store to Umbraco Cloud" menu item.
                    var path = "/formulate/formulate/storeEntityToCloud/null";
                    var menuItem = new MenuItem()
                    {
                        Alias = "storeEntityToCloud",
                        Icon = "cloud-upload",
                        Name = "Store to Umbraco Cloud",
                        SeperatorBefore = true
                    };
                    path = path + "?entityGuid=" + strGuid;
                    menuItem.NavigateToRoute(path);
                    items.Add(menuItem);


                    // Add the "Remove from Cloud" menu item.
                    path = "/formulate/formulate/removeEntityFromCloud/null";
                    menuItem = new MenuItem()
                    {
                        Alias = "removeEntityFromCloud",
                        Icon = "rain",
                        Name = "Remove from Cloud"
                    };
                    path = path + "?entityGuid=" + strGuid;
                    menuItem.NavigateToRoute(path);
                    items.Add(menuItem);

                }

            }

        }

        #endregion

    }

}<commit_msg>Fixed the menu items for the Umbraco Cloud interactions.<commit_after>﻿namespace formulate.deploy.Events
{

    // Namespaces.
    using app.Entities;
    using app.Resolvers;
    using System;
    using Umbraco.Core;
    using Umbraco.Web.Models.Trees;
    using Umbraco.Web.Trees;


    /// <summary>
    /// Handles application startup events.
    /// </summary>
    internal class AppStart : ApplicationEventHandler
    {

        #region Overridden Methods

        /// <summary>
        /// Application is starting.
        /// </summary>
        protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            TreeControllerBase.MenuRendering += Handle_RenderContextMenu;
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Handles rendering of the context menu.
        /// </summary>
        private void Handle_RenderContextMenu(TreeControllerBase sender, MenuRenderingEventArgs e)
        {

            // Variables.
            var alias = sender.TreeAlias;
            var items = e.Menu.Items;
            var nodeId = e.NodeId;
            var guid = default(Guid);


            // Is this a Formulate context menu?
            if (!"formulate".InvariantEquals(alias))
            {
                return;
            }


            // Is this a GUID (the root has "-1")?
            if (Guid.TryParse(nodeId, out guid))
            {

                // Variables.
                var persistence = EntityPersistence.Current.Manager;
                var entity = persistence.Retrieve(guid);
                var strGuid = guid.ToString("N");


                // Is this a non-root entity (e.g., a form, validation, folder, etc.)?
                if (entity != null && entity.GetType() != typeof(EntityRoot))
                {

                    // Add the "Store to Umbraco Cloud" menu item.
                    var path = "/App_Plugins/formulate/menu-actions/storeEntityToCloud.html";
                    var menuItem = new MenuItem()
                    {
                        Alias = "storeEntityToCloud",
                        Icon = "cloud-upload",
                        Name = "Store to Umbraco Cloud",
                        SeperatorBefore = true
                    };
                    path = path + "?entityGuid=" + strGuid;
                    menuItem.LaunchDialogView(path, "Store to Umbraco Cloud");
                    items.Add(menuItem);


                    // Add the "Remove from Cloud" menu item.
                    path = "/App_Plugins/formulate/menu-actions/removeEntityFromCloud.html";
                    menuItem = new MenuItem()
                    {
                        Alias = "removeEntityFromCloud",
                        Icon = "rain",
                        Name = "Remove from Cloud"
                    };
                    path = path + "?entityGuid=" + strGuid;
                    menuItem.LaunchDialogView(path, "Remove from Umbraco Cloud");
                    items.Add(menuItem);

                }

            }

        }

        #endregion

    }

}
{'fraction_non_alphanumeric': 0.09197809278350516, 'fraction_numerical': 0.00032216494845360824, 'mean_word_length': 1.2962278106508875, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '2258615', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1441, 'n_words': 374}