Ejemplo n.º 1
0
 /// <summary>
 /// Returns context menu for each tree node
 /// </summary>
 /// <param name="id">Node's id.</param>
 /// <param name="queryStrings">Query strings</param>
 /// <returns>Collection of menu items</returns>
 protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
 {
     var menu = new MenuItemCollection();
     if (id == Constants.System.Root.ToInvariantString())
     {
         // WebPack node actions:       
         menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
         return menu;
     }
     else if(id == "0")
     {
         // Websites node actions:
         MenuItem createItem = new MenuItem("Create", ActionNew.Instance.Alias);
         createItem.Name = "Create";
         createItem.Icon = "add";
         menu.Items.Add(createItem);
         //menu.Items.Add<CreateChildEntity, ActionNew>(ActionNew.Instance.Alias);
         menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
         return menu;
     }
     else
     {
         // Website node actions:
         menu.Items.Add<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));                
     }
     return menu;
 }
Ejemplo n.º 2
0
 private static void AddEnableRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes objectType, UrlHelper urlHelper)
 {
     if (objectType == UmbracoObjectTypes.DocumentType || objectType == UmbracoObjectTypes.MediaType)
     {
         var menuItem = new MenuItem("enableRelations", "Enable relations");
         menuItem.LaunchDialogView(urlHelper.Content("~/App_Plugins/RelationEditor/enablerelations.html"), "Enable relations");
         eventArgs.Menu.Items.Add(menuItem);
     }
 }
        void TreeControllerBaseMenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            if (sender.TreeAlias == "content" && sender.Security.CurrentUser.UserType.Alias == "admin")
            {
                var menu = new MenuItem("moriyamaDeploy", "Deploy this");
                menu.Icon = "umb-content";

                e.Menu.Items.Add(menu);
            }
        }
Ejemplo n.º 4
0
 private void AddMenuItem(MenuRenderingEventArgs e)
 {
     var menuItem = new MenuItem("xmlEdit", "XmlEdit")
     {
         Icon = "code",
         SeperatorBefore = true,
         AdditionalData = {}
     };
     menuItem.AdditionalData.Add("actionView", "/App_Plugins/UmbracoXmlEdit/BackOffice/content/edit.html");
     e.Menu.Items.Add(menuItem);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the "Create Folder" action to the folder's menu.
 /// </summary>
 /// <param name="menu">
 /// The menu items.
 /// </param>
 public void AddCreateFolderAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/createFolder.html";
     var menuItem = new MenuItem()
     {
         Alias = "createFolder",
         Icon = "formulate-create-folder",
         Name = LocalizationHelper.GetMenuItemName("Create Folder")
     };
     menuItem.LaunchDialogView(path, "Create Folder");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 6
0
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     if (sender.TreeAlias == "content"
         && sender.Security.CurrentUser.UserType.Alias == "admin"
         && e.NodeId != "-1" && e.NodeId != "-20")
     {
         var mi = new MenuItem("pageNotFound", "404 page");
         mi.Icon = "document";
         mi.LaunchDialogView("/App_Plugins/PageNotFoundManager/Backoffice/Dialogs/dialog.html", "404 Page");
         mi.SeperatorBefore = true;
         e.Menu.Items.Insert(e.Menu.Items.Count - 1, mi);
     }
 }
Ejemplo n.º 7
0
        private static void AddEditRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes type, string alias, UrlHelper urlHelper)
        {
            var typeConfig = Configuration.Get(type, alias);

            if (!typeConfig.Enabled || !typeConfig.EnabledRelations.Any())
            {
                return;
            }
            var menuItem = new MenuItem("editRelations", "Edit relations");

            menuItem.LaunchDialogView(urlHelper.Content("~/App_Plugins/RelationEditor/editrelations.html"), "Edit relations");
            eventArgs.Menu.Items.Add(menuItem);
        }
Ejemplo n.º 8
0
        private static void AddPreviewMenuItem(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            var section = e.QueryStrings.Get("section");
            var treeType = e.QueryStrings.Get("treeType");
            var isDocumentType = section == "settings" && (treeType == "nodeTypes" || treeType == "mediaTypes");
            if (!isDocumentType || e.NodeId == "-1")
                return;

            var insertAfter = e.Menu.Items.FirstOrDefault(extItem => extItem.Alias == "exportDocumentType");

              //creates a menu action that will open /umbraco/currentSection/itemAlias.html
            var i = new MenuItem("previewModelClass", "Preview CodeGen class");
            i.AdditionalData.Add("actionRoute", "settings/codegen/codegen.preview/" + e.NodeId);
            i.Icon = "brackets";

            if (insertAfter != null)
                e.Menu.Items.Insert(e.Menu.Items.IndexOf(insertAfter) + 1, i);
            else
                e.Menu.Items.Add(i);
        }
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     var user = sender.Security.CurrentUser;
     var path = "/App_Plugins/UserGroupPermissions/Views/ApplyUserGroupPermissions.html";
     var title = "Apply User Group Permissions";
     var treeType = e.QueryStrings.Get("treeType");
     var section = e.QueryStrings.Get("section");
     var validTree = "users".InvariantEquals(treeType) && "users".InvariantEquals(section);
     var strUserId = e.NodeId ?? "";
     var userId = default(int);
     var validUserId = int.TryParse(strUserId, out userId) ? userId > 0 : false;
     var validUser = user.IsAdmin();
     if (validTree && validUserId && validUser)
     {
         var menuItem = new MenuItem("ApplyUserGroupPermissions", "Apply Group Permissions")
         {
             Icon = "vcard"
         };
         menuItem.LaunchDialogView(path, title);
         e.Menu.Items.Add(menuItem);
     }
 }
Ejemplo n.º 10
0
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            // create my menu item "Import"
            var menu = new MenuItemCollection();

            //// duplicate this section for more than one icon
            var m = new MenuItem("create", "Create");
            m.Icon = "add";
            m.NavigateToRoute("/settings/definedContent/create/" + id);
            m.AdditionalData.Add("DefinedContentParent", id == "-1" ? "" : id);
            menu.Items.Add(m);

            if (id != "-1")
            {
                menu.Items.Add<ActionDelete>("Delete", additionalData: new Dictionary<string, object> { { "id", id } });
            }
            else
            {
                menu.Items.Add<FullRefreshAction>("Full Refresh");
            }

            menu.Items.Add<ActionRefresh>("Refresh");
            return menu;
        }
Ejemplo n.º 11
0
        private void AddPurgeCacheForContentMenu(TreeControllerBase sender, MenuRenderingEventArgs args)
        {
            if(sender.TreeAlias != "content")
            {
                //We aren't dealing with the content menu
                return;
            }

            MenuItem menuItem = new MenuItem("purgeCache", "Purge Cloudflare Cache");

            menuItem.Icon = "umbracoflare-tiny";

            menuItem.LaunchDialogView("/App_Plugins/UmbracoFlare/backoffice/treeViews/PurgeCacheDialog.html", "Purge Cloudflare Cache");

            args.Menu.Items.Insert(args.Menu.Items.Count - 1, menuItem);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds the "Create Validation" action with the specified ID used
 /// as the parent for the validation that is created.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 /// <param name="entityId">
 /// The ID of the entity to create the validation under.
 /// If null, the validation will be created at the root.
 /// </param>
 public void AddCreateValidationAction(MenuItemCollection menu,
     Guid? entityId = null)
 {
     var path = "/App_Plugins/formulate/menu-actions/createValidation.html";
     var menuItem = new MenuItem()
     {
         Alias = "createValidation",
         Icon = "folder",
         Name = "Create Validation"
     };
     if (entityId.HasValue)
     {
         path = path + "?under=" + GuidHelper.GetString(entityId.Value);
     }
     menuItem.LaunchDialogView(path, "Create Validation");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Adds the "Delete Validation" action to the validation node.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 public void AddDeleteValidationAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/deleteValidation.html";
     var menuItem = new MenuItem()
     {
         Alias = "deleteValidation",
         Icon = "folder",
         Name = "Delete Validation"
     };
     menuItem.LaunchDialogView(path, "Delete Validation");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Adds the "Move" action to the menu.
 /// </summary>
 /// <param name="menu">
 /// The menu items to add the action to.
 /// </param>
 /// <param name="folder">
 /// The folder.
 /// </param>
 public void AddMoveFolderAction(MenuItemCollection menu, Folder folder)
 {
     var path = "/App_Plugins/formulate/menu-actions/moveFolder.html";
     var menuItem = new MenuItem()
     {
         Alias = "moveFolder",
         Icon = "formulate-move",
         Name = LocalizationHelper.GetMenuItemName("Move")
     };
     var titleFormat = @"Move ""{0}"" Folder";
     var title = string.Format(titleFormat, folder.Name);
     menuItem.LaunchDialogView(path, title);
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Adds the "Delete Configured Form" action to the configured form node.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 public void AddDeleteAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/deleteConfiguredForm.html";
     var menuItem = new MenuItem()
     {
         Alias = "deleteConfiguredForm",
         Icon = "formulate-delete",
         Name = LocalizationHelper.GetMenuItemName("Delete Configuration")
     };
     menuItem.LaunchDialogView(path, "Delete Configuration");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Adds the "Create Configuration" action with the specified ID used
 /// as the parent for the configured form that is created.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 /// <param name="entityId">
 /// The ID of the entity to create the configured form under.
 /// </param>
 public void AddCreateConfiguredFormAction(MenuItemCollection menu,
     Guid entityId)
 {
     var path = "/formulate/formulate/editConfiguredForm/null?under="
         + GuidHelper.GetString(entityId);
     var menuItem = new MenuItem()
     {
         Alias = "createConfiguredForm",
         Icon = "formulate-create",
         Name = LocalizationHelper.GetMenuItemName("Create Configuration")
     };
     menuItem.NavigateToRoute(path);
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 17
0
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            var menu = new MenuItemCollection();

            if (id == Constants.System.Root.ToInvariantString())
            {
                // root actions      
                if (Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
                {
                    //set default
                    menu.DefaultMenuAlias = ActionNew.Instance.Alias;

                    //Create the normal create action
                    menu.Items.Add<ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
                }
                else
                {
                    //Create a custom create action - this does not launch a dialog, it just navigates to the create screen
                    // we'll create it baesd on the ActionNew so it maintains the same icon properties, name, etc...
                    var createMenuItem = new MenuItem(ActionNew.Instance);
                    //we want to go to this route: /member/member/edit/-1?create=true
                    createMenuItem.NavigateToRoute("/member/member/edit/-1?create=true");
                    menu.Items.Add(createMenuItem);
                }
                
                menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
                return menu;
            }

            Guid guid;
            if (Guid.TryParse(id, out guid))
            {
                menu.Items.Add<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
            }
            else
            {
                menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), false);    
            }
            return menu;
        }
Ejemplo n.º 18
0
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            //check if we're rendering the local tree
            if (id == "local")
            {
                var menu = new MenuItemCollection();

                //Default Route = /App_Plugins/NuGet/backoffice/Packages/create-package.html
                //Overwriten Route = /App_Plugins/NuGet/BackOffice/Packages/partials/dialogs/create-package.html
                var createPackageMenu   = new MenuItem("create-package", "Create Package");
                createPackageMenu.Icon  = "brick"; //CSS class name without the icon- prefix - icon-brick
                createPackageMenu.NavigateToRoute("nuget/Packages/create/package");
                menu.Items.Add(createPackageMenu);

                //Default Route = /App_Plugins/NuGet/backoffice/Packages/convert-package.html
                //Overwritten Route =
                var convertPackageMenu  = new MenuItem("convert-package", "Convert Package");
                convertPackageMenu.Icon = "cloud-upload"; //CSS class name without the icon- prefix - icon-cloud-upload
                convertPackageMenu.LaunchDialogView("/App_Plugins/NuGet/BackOffice/Packages/partials/dialogs/convert-package.html", "Convert Package");
                menu.Items.Add(convertPackageMenu);

                return menu;
            }

            //if not the local-packages node (aka Local Packages node) do nothing
            return null;
        }
        // A context menu is rendering.
        void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {

            // Variables.
            var path = "/App_Plugins/UserGroupPermissions/Views/SetUserGroupPermissions.html";
            var title = "User Group Permissions";

            // Initial check (in content tree and on a node).
            IUser currentUser = sender.Security.CurrentUser;
            var showMenuItem = sender.TreeAlias == "content";
            var strNodeId = e.NodeId;
            var nodeId = default(int);
            if (showMenuItem && int.TryParse(strNodeId, out nodeId))
            {
                showMenuItem = nodeId >= 0;
            }
            else
            {
                showMenuItem = false;
            }

            // Check permissions for non-admin users.
            if (showMenuItem && !currentUser.IsAdmin())
            {
                showMenuItem = false;
                var userService = ApplicationContext.Current.Services.UserService;
                var permissions = userService.GetPermissions(currentUser, nodeId);
                var letter = MenuActions.UserGroupPermissions.Instance.Letter.ToString();
                if(permissions.Any(x => x.AssignedPermissions.InvariantContains(letter)))
                {
                    showMenuItem = true;
                }
            }

            // Add a custom menu item in the content tree.
            if (showMenuItem)
            {

                var menuItem = new MenuItem("UserGroupPermissions", "User Group Permissions")
                {
                    Icon = "vcard"
                };

                menuItem.LaunchDialogView(path, title);

                var permissionsIndex = e.Menu.Items.FindIndex(x =>
                    "Permissions".InvariantEquals(x.Name) ||
                    "Permissions".InvariantEquals(x.Alias));

                // Attempt to insert after the existing "Permissions" menu item.
                if (permissionsIndex >= 0)
                {
                    e.Menu.Items.Insert(permissionsIndex + 1, menuItem);
                }
                else
                {
                    e.Menu.Items.Add(menuItem);
                }

            }

        }
        private void AddMenuItem(MenuItemCollection menu, string name, string alias = null, string icon = null, string view = null)
        {
            var menuItem = new MenuItem { Name = name };

            if (alias != null)
            {
                menuItem.Alias = alias;
            }

            if (icon != null)
            {
                menuItem.Icon = icon;
            }

            if (view != null)
            {
                menuItem.LaunchDialogView(VIEWS_ROOT + view + ".html", name);
            }

            menu.Items.Add(menuItem);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Adds the "Create Form" action with the specified ID used
 /// as the parent for the form that is created.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 /// <param name="entityId">
 /// The ID of the entity to create the form under.
 /// If null, the form will be created at the root.
 /// </param>
 public void AddCreateFormAction(MenuItemCollection menu,
     Guid? entityId = null)
 {
     var path = "/formulate/formulate/editForm/null";
     var menuItem = new MenuItem()
     {
         Alias = "createForm",
         Icon = "formulate-create",
         Name = LocalizationHelper.GetMenuItemName("Create Form")
     };
     if (entityId.HasValue)
     {
         path = path + "?under=" + GuidHelper.GetString(entityId.Value);
     }
     menuItem.NavigateToRoute(path);
     menu.Items.Add(menuItem);
 }