/// <summary> /// Checks if the menu requested is for the recycle bin and renders that, otherwise renders the result of PerformGetMenuForNode /// </summary> /// <param name="id"></param> /// <param name="queryStrings"></param> /// <returns></returns> protected sealed override ActionResult <MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings) { if (RecycleBinId.ToInvariantString() == id) { // get the default assigned permissions for this user var deleteAllowed = false; var deleteAction = _actionCollection.FirstOrDefault(y => y.Letter == ActionDelete.ActionLetter); if (deleteAction != null) { var perms = _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.GetPermissions(Constants.System.RecycleBinContentString, _userService); deleteAllowed = perms.FirstOrDefault(x => x.Contains(deleteAction.Letter)) != null; } var menu = MenuItemCollectionFactory.Create(); // only add empty recycle bin if the current user is allowed to delete by default if (deleteAllowed) { menu.Items.Add(new MenuItem("emptyrecyclebin", LocalizedTextService) { Icon = "trash", OpensDialog = true }); menu.Items.Add(new RefreshNode(LocalizedTextService, true)); } return(menu); } return(PerformGetMenuForNode(id, queryStrings)); }
protected virtual MenuItemCollection GetMenuForFile(string path, FormCollection queryStrings) { var menu = MenuItemCollectionFactory.Create(); // if it's not a directory then we only allow to delete the item menu.Items.Add <ActionDelete>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); return(menu); }
protected override MenuItemCollection GetMenuForFolder(string path, FormCollection queryStrings) { var menu = MenuItemCollectionFactory.Create(); //refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return(menu); }
protected virtual MenuItemCollection GetMenuForRootNode(FormCollection queryStrings) { var menu = MenuItemCollectionFactory.Create(); //set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; //create action menu.Items.Add <ActionNew>(LocalizedTextService, opensDialog: true); //refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return(menu); }
protected virtual MenuItemCollection GetMenuForFolder(string path, FormCollection queryStrings) { var menu = MenuItemCollectionFactory.Create(); //set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; //create action menu.Items.Add <ActionNew>(LocalizedTextService, opensDialog: true); var hasChildren = FileSystem is not null && (FileSystem.GetFiles(path).Any() || FileSystem.GetDirectories(path).Any()); //We can only delete folders if it doesn't have any children (folders or files) if (hasChildren == false) { //delete action menu.Items.Add <ActionDelete>(LocalizedTextService, true, opensDialog: true); } //refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return(menu); }
protected override ActionResult <MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings) { //if root node no need to visit the filesystem so lets just create the menu and return it if (id == Constants.System.RootString) { return(GetMenuForRootNode(queryStrings)); } var menu = MenuItemCollectionFactory.Create(); var path = string.IsNullOrEmpty(id) == false && id != Constants.System.RootString ? WebUtility.UrlDecode(id).TrimStart("/") : ""; var isFile = FileSystem?.FileExists(path) ?? false; var isDirectory = FileSystem?.DirectoryExists(path) ?? false; if (isDirectory) { return(GetMenuForFolder(path, queryStrings)); } return(isFile ? GetMenuForFile(path, queryStrings) : menu); }
protected override ActionResult <MenuItemCollection> PerformGetMenuForNode(string id, FormCollection queryStrings) { MenuItemCollection menu = MenuItemCollectionFactory.Create(); //set the default menu.DefaultMenuAlias = ActionNew.ActionAlias; if (id == Constants.System.RootString) { // if the user's start node is not the root then the only menu item to display is refresh if (UserStartNodes.Contains(Constants.System.Root) == false) { menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); return(menu); } // root actions menu.Items.Add <ActionNew>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionSort>(LocalizedTextService, hasSeparator: true, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); return(menu); } if (int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var iid) == false) { return(NotFound()); } IEntitySlim?item = _entityService.Get(iid, UmbracoObjectTypes.Media); if (item == null) { return(NotFound()); } //if the user has no path access for this node, all they can do is refresh if (!_backofficeSecurityAccessor.BackOfficeSecurity?.CurrentUser?.HasMediaPathAccess(item, _entityService, _appCaches) ?? false) { menu.Items.Add(new RefreshNode(LocalizedTextService, true)); return(menu); } //if the media item is in the recycle bin, we don't have a default menu and we need to show a limited menu if (item.Path.Split(Constants.CharArrays.Comma, StringSplitOptions.RemoveEmptyEntries) .Contains(RecycleBinId.ToInvariantString())) { menu.Items.Add <ActionRestore>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionMove>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionDelete>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); menu.DefaultMenuAlias = null; } else { //return a normal node menu: menu.Items.Add <ActionNew>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionMove>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionDelete>(LocalizedTextService, opensDialog: true, useLegacyIcon: false); menu.Items.Add <ActionSort>(LocalizedTextService, useLegacyIcon: false); menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); //set the default to create menu.DefaultMenuAlias = ActionNew.ActionAlias; } return(menu); }
protected override MenuItemCollection GetMenuForFile(string path, FormCollection queryStrings) { var menu = MenuItemCollectionFactory.Create(); return(menu); }