Skip to content

Commit

Permalink
- OCSharePermission: add localizedDriveRoleName accessors to return j…
Browse files Browse the repository at this point in the history
…ust "native"/fallback names for a OCSharePermissionDriveRole

- OCShareRole, GAUnifiedRoleDefinition+ShareRole: add support for ocis role weights
  • Loading branch information
felix-schwarz committed Dec 20, 2024
1 parent 4a5a93f commit 98e3bdf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ - (OCShareRole *)role
role.localizedName = self.displayName;
role.localizedDescription = self.desc;

role.weight = self.libreGraphWeight;

// TODO: self.rolePermissions[0].allowedResourceActions -> integration into OCShareRolef

_role = role;
Expand Down
1 change: 1 addition & 0 deletions ownCloudSDK/Share/Permissions/OCSharePermission.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef NS_ENUM(NSInteger, OCSharePermissionDriveRole) {

// MARK: - ocis space properties
@property(readonly,nonatomic) OCSharePermissionDriveRole driveRole; //!< For ocis spaces, returns the role - or OCSharePermissionDriveRoleNone if no role is provided
@property(readonly,strong,nullable,nonatomic) NSString *localizedDriveRoleName; //!< For ocis spaces, returns a localized name for the drive role, ignoring actual roles. Returns nil for non-driverole roles
- (nullable NSString *)localizedRoleNameWithRoles:(nullable NSArray<GAUnifiedRoleDefinition *> *)roleDefinitions; //!< For ocis spaces, returns a textual representation of .driveRole - or the name of the matching role definition

// MARK: - OC10 properties
Expand Down
31 changes: 18 additions & 13 deletions ownCloudSDK/Share/Permissions/OCSharePermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,8 @@ - (OCSharePermissionDriveRole)driveRole
return (OCSharePermissionDriveRoleNone);
}

- (nullable NSString *)localizedRoleNameWithRoles:(nullable NSArray<GAUnifiedRoleDefinition *> *)roleDefinitions
- (nullable NSString *)localizedDriveRoleName
{
for (GAUnifiedRoleDefinition *roleDefinition in roleDefinitions)
{
if ([roleDefinition.identifier isEqual:_roleID] && (roleDefinition.displayName != nil)) {
return (roleDefinition.displayName);
}
}

if ([self.role.identifier isEqual:self.roleID])
{
return (self.role.localizedName);
}

switch (self.driveRole)
{
case OCSharePermissionDriveRoleManager:
Expand All @@ -131,6 +119,23 @@ - (nullable NSString *)localizedRoleNameWithRoles:(nullable NSArray<GAUnifiedRol
}
}

- (nullable NSString *)localizedRoleNameWithRoles:(nullable NSArray<GAUnifiedRoleDefinition *> *)roleDefinitions
{
for (GAUnifiedRoleDefinition *roleDefinition in roleDefinitions)
{
if ([roleDefinition.identifier isEqual:_roleID] && (roleDefinition.displayName != nil)) {
return (roleDefinition.displayName);
}
}

if ([self.role.identifier isEqual:self.roleID])
{
return (self.role.localizedName);
}

return (self.localizedDriveRoleName);
}

// MARK: - permission -> Legacy mask conversion
+ (OCSharePermissionsMask)permissionMaskForPermissions:(NSArray<OCSharePermission *> *)permissions
{
Expand Down
2 changes: 2 additions & 0 deletions ownCloudSDK/Share/Roles/OCShareRole.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
@property(assign) OCSharePermissionsMask customizablePermissions; //!< Mask of permissions the user is allowed to customize
@property(assign) OCLocationType locations; //!< Mask of OCLocationTypes this role can be used with

@property(strong,nullable) NSNumber *weight; //!< Weight for ordering

@property(strong) OCSymbolName symbolName;
@property(strong) NSString *localizedName;
@property(strong) NSString *localizedDescription;
Expand Down

0 comments on commit 98e3bdf

Please sign in to comment.