Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/01/18 15:14:44 (6 years ago)
Author:
jzenisek
Message:

#2839: fixed several bugs:

  • renamed tab "Slaves" to "Resources"
  • fixed bugs in job manager > resource selector reported by fholzinger
  • adapted client-side handling of disabled resource ancestors
  • adapted parentship check in HiveAdminClient
  • adapted seting of enabled state of controls for project details, project resources
  • introduced "inactive" tag in ProjectsView
Location:
trunk/HeuristicLab.Clients.Hive/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r16117 r16202  
    2626using System.Collections.Generic;
    2727using System.Linq;
     28using HeuristicLab.Clients.Access;
    2829
    2930namespace HeuristicLab.Clients.Hive {
     
    438439    }
    439440
     441    public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) {
     442      var missingParentIds = availableResources
     443        .Where(x => x.ParentResourceId.HasValue)
     444        .SelectMany(x => resourceAncestors[x.Id]).Distinct()
     445        .Where(x => !availableResources.Select(y => y.Id).Contains(x));
     446
     447      return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id));
     448    }
     449
    440450    public bool CheckAccessToAdminAreaGranted() {
    441451      if(projects != null) {
     
    478488
    479489      if(projectAncestors.ContainsKey(pro.Id)) {
    480         return GetAvailableProjectAncestors(pro.Id).Where(x => x.OwnerUserId == userId).Any();
     490        return GetAvailableProjectAncestors(pro.Id).Any(x => x.OwnerUserId == userId);
     491      }
     492
     493      if (pro.ParentProjectId != null && pro.ParentProjectId != Guid.Empty) {
     494        var parent = projects.FirstOrDefault(x => x.Id == pro.ParentProjectId.Value);
     495        if (parent != null)
     496          return parent.OwnerUserId == userId || GetAvailableProjectAncestors(parent.Id).Any(x => x.OwnerUserId == userId);
    481497      }
    482498
     
    491507      // ... or the new parent is not stored yet
    492508      // ... or there is not parental change
    493       if (child == null
    494         || (parent != null && parent.Id == Guid.Empty)
    495         || (parent != null && parent.Id == child.ParentProjectId)) {
     509      if (child == null
     510          || (parent != null && parent.Id == Guid.Empty)
     511          || (parent != null && parent.Id == child.ParentProjectId)) {
     512        changePossible = false;
     513      } else if (parent == null && !IsAdmin()) {
     514        // ... if parent is null, but user is no admin (only admins are allowed to create root projects)
     515        changePossible = false;
     516      } else if (parent != null && (!IsAdmin() && parent.OwnerUserId != UserInformation.Instance.User.Id && !CheckOwnershipOfParentProject(parent, UserInformation.Instance.User.Id))) {
     517        // ... if the user is no admin nor owner of the new parent or grand..grandparents
    496518        changePossible = false;
    497519      } else if(parent != null && projectDescendants.ContainsKey(child.Id)) {
     
    525547      return changePossible;
    526548    }
     549
     550    private bool IsAdmin() {
     551      return HiveRoles.CheckAdminUserPermissions();
     552    }
    527553    #endregion
    528554  }
  • trunk/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r16117 r16202  
    324324      return resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id));
    325325    }
     326
     327    public IEnumerable<Resource> GetDisabledResourceAncestors(IEnumerable<Resource> availableResources) {
     328      var missingParentIds = availableResources
     329        .Where(x => x.ParentResourceId.HasValue)
     330        .SelectMany(x => resourceAncestors[x.Id]).Distinct()
     331        .Where(x => !availableResources.Select(y => y.Id).Contains(x));
     332
     333      return resources.OfType<SlaveGroup>().Union(disabledParentResources).Where(x => missingParentIds.Contains(x.Id));
     334    }
    326335    #endregion
    327336
Note: See TracChangeset for help on using the changeset viewer.