chore: rename OrganizationRole to Role (#3387)

This commit is contained in:
Bryan Oltman
2025-11-17 16:29:44 -05:00
committed by GitHub
parent 85393c566d
commit 9ac371ab56
16 changed files with 54 additions and 58 deletions
@@ -298,11 +298,11 @@ void main() {
final expectedMemberships = [
OrganizationMembership(
organization: Organization.forTest(),
role: OrganizationRole.admin,
role: Role.admin,
),
OrganizationMembership(
organization: Organization.forTest(),
role: OrganizationRole.member,
role: Role.member,
),
];
when(
@@ -98,7 +98,7 @@ environment:
when(() => codePushClientWrapper.getOrganizationMemberships()).thenAnswer(
(_) async => [
OrganizationMembership(
role: OrganizationRole.owner,
role: Role.owner,
organization: Organization.forTest(id: organizationId),
),
],
@@ -398,7 +398,7 @@ Please make sure you are running "shorebird init" from within your Flutter proje
).thenAnswer(
(_) async => [
OrganizationMembership(
role: OrganizationRole.owner,
role: Role.owner,
organization: Organization.forTest(id: organizationId),
),
],
@@ -440,11 +440,11 @@ Please make sure you are running "shorebird init" from within your Flutter proje
).thenAnswer(
(_) async => [
OrganizationMembership(
role: OrganizationRole.owner,
role: Role.owner,
organization: org1,
),
OrganizationMembership(
role: OrganizationRole.owner,
role: Role.owner,
organization: org2,
),
],
@@ -2046,7 +2046,7 @@ void main() {
setUp(() {
membership = OrganizationMembership(
role: OrganizationRole.admin,
role: Role.admin,
organization: Organization.forTest(),
);
response = GetOrganizationsResponse(organizations: [membership]);
@@ -54,7 +54,7 @@ Map<String, dynamic> _$CreateReleaseArtifactRequestToJson(
instance.canSideload,
),
'size': CreateReleaseArtifactRequest._parseIntToString(instance.size),
if (instance.podfileLockHash case final value?) 'podfile_lock_hash': value,
'podfile_lock_hash': ?instance.podfileLockHash,
};
const _$ReleasePlatformEnumMap = {
@@ -66,5 +66,5 @@ Map<String, dynamic> _$PatchCheckMetadataToJson(PatchCheckMetadata instance) =>
'number': instance.number,
'download_url': instance.downloadUrl,
'hash': instance.hash,
if (instance.hashSignature case final value?) 'hash_signature': value,
'hash_signature': ?instance.hashSignature,
};
@@ -17,3 +17,4 @@ export 'release_artifact.dart';
export 'release_patch.dart';
export 'release_platform.dart';
export 'release_status.dart';
export 'role.dart';
@@ -4,24 +4,6 @@ import 'package:meta/meta.dart';
part 'organization.g.dart';
/// {@template organization_role}
/// A role that a user can have in an organization.
/// {@endtemplate}
enum OrganizationRole {
/// User that created the organization.
owner,
/// Users who have permissions to manage the organization.
admin,
/// Users who are part of the organization but have limited permissions.
member,
/// Users who are not part of the organization but have visibility into it via
/// app collaborator permissions.
none,
}
/// {@template organization_type}
/// Distinguishes between automatically created organizations that are limited
/// to a single user and organizations that support multiple users.
@@ -1,6 +1,6 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:shorebird_code_push_protocol/src/models/organization.dart';
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
part 'organization_membership.g.dart';
@@ -26,7 +26,7 @@ class OrganizationMembership extends Equatable {
final Organization organization;
/// The user's role in the organization.
final OrganizationRole role;
final Role role;
@override
List<Object?> get props => [organization, role];
@@ -16,10 +16,7 @@ OrganizationMembership _$OrganizationMembershipFromJson(
'organization',
(v) => Organization.fromJson(v as Map<String, dynamic>),
),
role: $checkedConvert(
'role',
(v) => $enumDecode(_$OrganizationRoleEnumMap, v),
),
role: $checkedConvert('role', (v) => $enumDecode(_$RoleEnumMap, v)),
);
return val;
});
@@ -28,12 +25,12 @@ Map<String, dynamic> _$OrganizationMembershipToJson(
OrganizationMembership instance,
) => <String, dynamic>{
'organization': instance.organization.toJson(),
'role': _$OrganizationRoleEnumMap[instance.role]!,
'role': _$RoleEnumMap[instance.role]!,
};
const _$OrganizationRoleEnumMap = {
OrganizationRole.owner: 'owner',
OrganizationRole.admin: 'admin',
OrganizationRole.member: 'member',
OrganizationRole.none: 'none',
const _$RoleEnumMap = {
Role.owner: 'owner',
Role.admin: 'admin',
Role.member: 'member',
Role.none: 'none',
};
@@ -22,5 +22,5 @@ class OrganizationUser {
final PublicUser user;
/// The role [user] has in the organization.
final OrganizationRole role;
final Role role;
}
@@ -15,10 +15,7 @@ OrganizationUser _$OrganizationUserFromJson(Map<String, dynamic> json) =>
'user',
(v) => PublicUser.fromJson(v as Map<String, dynamic>),
),
role: $checkedConvert(
'role',
(v) => $enumDecode(_$OrganizationRoleEnumMap, v),
),
role: $checkedConvert('role', (v) => $enumDecode(_$RoleEnumMap, v)),
);
return val;
});
@@ -26,12 +23,12 @@ OrganizationUser _$OrganizationUserFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> _$OrganizationUserToJson(OrganizationUser instance) =>
<String, dynamic>{
'user': instance.user.toJson(),
'role': _$OrganizationRoleEnumMap[instance.role]!,
'role': _$RoleEnumMap[instance.role]!,
};
const _$OrganizationRoleEnumMap = {
OrganizationRole.owner: 'owner',
OrganizationRole.admin: 'admin',
OrganizationRole.member: 'member',
OrganizationRole.none: 'none',
const _$RoleEnumMap = {
Role.owner: 'owner',
Role.admin: 'admin',
Role.member: 'member',
Role.none: 'none',
};
@@ -0,0 +1,19 @@
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart';
/// {@template role}
/// A role that a user can have relative to an [Organization] or [App].
/// {@endtemplate}
enum Role {
/// User that created the organization.
owner,
/// Users who have permissions to manage the organization.
admin,
/// Users who are part of the organization but have limited permissions.
member,
/// Users who are not part of the organization but have visibility into it via
/// app collaborator permissions.
none,
}
@@ -8,7 +8,7 @@ void main() {
users: [
OrganizationUser(
user: PublicUser.fromPrivateUser(PrivateUser.forTest()),
role: OrganizationRole.owner,
role: Role.owner,
),
],
);
@@ -8,7 +8,7 @@ void main() {
organizations: [
OrganizationMembership(
organization: Organization.forTest(),
role: OrganizationRole.member,
role: Role.member,
),
],
);
@@ -6,7 +6,7 @@ void main() {
test('can be (de)serialized', () {
final membership = OrganizationMembership(
organization: Organization.forTest(),
role: OrganizationRole.member,
role: Role.member,
);
expect(
OrganizationMembership.fromJson(membership.toJson()).toJson(),
@@ -24,14 +24,14 @@ void main() {
createdAt: date,
updatedAt: date,
),
role: OrganizationRole.member,
role: Role.member,
);
final otherMembership = OrganizationMembership(
organization: Organization.forTest(
createdAt: date,
updatedAt: date,
),
role: OrganizationRole.member,
role: Role.member,
);
expect(membership, equals(otherMembership));
});
@@ -44,14 +44,14 @@ void main() {
createdAt: date,
updatedAt: date,
),
role: OrganizationRole.member,
role: Role.member,
);
final otherMembership = OrganizationMembership(
organization: Organization.forTest(
createdAt: date,
updatedAt: date,
),
role: OrganizationRole.admin,
role: Role.admin,
);
expect(membership, isNot(equals(otherMembership)));
});
@@ -6,7 +6,7 @@ void main() {
test('can be (de)serialized', () {
final organizationUser = OrganizationUser(
user: PublicUser.fromPrivateUser(PrivateUser.forTest()),
role: OrganizationRole.member,
role: Role.member,
);
expect(
OrganizationUser.fromJson(organizationUser.toJson()).toJson(),