diff --git a/packages/console/src/pages/TenantSettings/TenantMembers/EditMemberModal/index.tsx b/packages/console/src/pages/TenantSettings/TenantMembers/EditMemberModal/index.tsx index 1e23f6640..ba4f42a72 100644 --- a/packages/console/src/pages/TenantSettings/TenantMembers/EditMemberModal/index.tsx +++ b/packages/console/src/pages/TenantSettings/TenantMembers/EditMemberModal/index.tsx @@ -24,13 +24,13 @@ function EditMemberModal({ user, isOpen, onClose }: Props) { const { currentTenantId } = useContext(TenantsContext); const [isLoading, setIsLoading] = useState(false); - const [role, setRole] = useState(TenantRole.Member); + const [role, setRole] = useState(TenantRole.Collaborator); const cloudApi = useAuthedCloudApi(); const roleOptions: Array> = useMemo( () => [ { value: TenantRole.Admin, title: t('admin') }, - { value: TenantRole.Member, title: t('member') }, + { value: TenantRole.Collaborator, title: t('collaborator') }, ], [t] ); @@ -38,10 +38,11 @@ function EditMemberModal({ user, isOpen, onClose }: Props) { const onSubmit = async () => { setIsLoading(true); try { - await cloudApi.put(`/api/tenants/:tenantId/members/:userId/roles`, { - params: { tenantId: currentTenantId, userId: user.id }, - body: { roleName: role }, - }); + // TODO: @charles Uncomment later once the Cloud APIs are updated + // await cloudApi.put(`/api/tenants/:tenantId/members/:userId/roles`, { + // params: { tenantId: currentTenantId, userId: user.id }, + // body: { roleName: role }, + // }); onClose(); } finally { setIsLoading(false); diff --git a/packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx b/packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx index 69db6b052..1f679905d 100644 --- a/packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx +++ b/packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/index.tsx @@ -42,7 +42,7 @@ function InviteMemberModal({ isOpen, onClose }: Props) { const formMethods = useForm({ defaultValues: { emails: [], - role: TenantRole.Member, + role: TenantRole.Collaborator, }, }); @@ -56,7 +56,7 @@ function InviteMemberModal({ isOpen, onClose }: Props) { const roleOptions: Array> = useMemo( () => [ { value: TenantRole.Admin, title: t('admin') }, - { value: TenantRole.Member, title: t('member') }, + { value: TenantRole.Collaborator, title: t('collaborator') }, ], [t] ); @@ -77,14 +77,15 @@ function InviteMemberModal({ isOpen, onClose }: Props) { return; } - await Promise.all( - emails.map(async (email) => - cloudApi.post('/api/tenants/:tenantId/invitations', { - params: { tenantId: currentTenantId }, - body: { invitee: email.value, roleName: role }, - }) - ) - ); + // TODO: @charles Uncomment later once the Cloud APIs are updated + // await Promise.all( + // emails.map(async (email) => + // cloudApi.post('/api/tenants/:tenantId/invitations', { + // params: { tenantId: currentTenantId }, + // body: { invitee: email.value, roleName: role }, + // }) + // ) + // ); toast.success(t('messages.invitation_sent')); onClose(true); } finally { diff --git a/packages/phrases/src/locales/de/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/de/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/de/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/de/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/en/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/en/translation/admin-console/tenant-members.ts index c4bdafe91..ed0e392b0 100644 --- a/packages/phrases/src/locales/en/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/en/translation/admin-console/tenant-members.ts @@ -1,11 +1,13 @@ const tenant_members = { members: 'Members', + collaborators: 'Collaborators', invitations: 'Invitations', invite_members: 'Invite members', user: 'User', roles: 'Roles', admin: 'Admin', member: 'Member', + collaborator: 'Collaborator', invitation_status: 'Invitation status', invitation_sent: 'Invitation sent', expiration_date: 'Expiration date', diff --git a/packages/phrases/src/locales/es/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/es/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/es/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/es/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/fr/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/fr/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/fr/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/fr/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/it/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/it/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/it/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/it/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/ja/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/ja/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/ja/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/ja/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/ko/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/ko/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/ko/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/ko/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/pl-pl/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/pl-pl/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/pl-pl/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/pl-pl/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/pt-br/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/pt-br/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/pt-br/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/pt-br/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/pt-pt/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/pt-pt/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/pt-pt/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/pt-pt/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/ru/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/ru/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/ru/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/ru/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/tr-tr/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/tr-tr/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/tr-tr/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/tr-tr/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/zh-cn/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/zh-cn/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/zh-cn/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/zh-cn/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/zh-hk/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/zh-hk/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/zh-hk/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/zh-hk/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/phrases/src/locales/zh-tw/translation/admin-console/tenant-members.ts b/packages/phrases/src/locales/zh-tw/translation/admin-console/tenant-members.ts index 0b64b99cd..c4390e2f4 100644 --- a/packages/phrases/src/locales/zh-tw/translation/admin-console/tenant-members.ts +++ b/packages/phrases/src/locales/zh-tw/translation/admin-console/tenant-members.ts @@ -2,6 +2,8 @@ const tenant_members = { /** UNTRANSLATED */ members: 'Members', /** UNTRANSLATED */ + collaborators: 'Collaborators', + /** UNTRANSLATED */ invitations: 'Invitations', /** UNTRANSLATED */ invite_members: 'Invite members', @@ -14,6 +16,8 @@ const tenant_members = { /** UNTRANSLATED */ member: 'Member', /** UNTRANSLATED */ + collaborator: 'Collaborator', + /** UNTRANSLATED */ invitation_status: 'Invitation status', /** UNTRANSLATED */ invitation_sent: 'Invitation sent', diff --git a/packages/schemas/alterations/next-1712041436-rename-organization-member-role-to-collaborator.ts b/packages/schemas/alterations/next-1712041436-rename-organization-member-role-to-collaborator.ts new file mode 100644 index 000000000..524943cfa --- /dev/null +++ b/packages/schemas/alterations/next-1712041436-rename-organization-member-role-to-collaborator.ts @@ -0,0 +1,28 @@ +import { sql } from '@silverhand/slonik'; + +import type { AlterationScript } from '../lib/types/alteration.js'; + +const alteration: AlterationScript = { + up: async (pool) => { + await pool.query(sql` + update organization_roles + set id = 'collaborator', name = 'collaborator', description = 'Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings.' + where tenant_id = 'admin' and id = 'member'; + update organization_role_scope_relations + set organization_role_id = 'collaborator' + where tenant_id = 'admin' and organization_role_id = 'member'; + `); + }, + down: async (pool) => { + await pool.query(sql` + update organization_roles + set id = 'member', name = 'member', description = 'Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings.' + where tenant_id = 'admin' and id = 'collaborator'; + update organization_role_scope_relations + set organization_role_id = 'member' + where tenant_id = 'admin' and organization_role_id = 'collaborator'; + `); + }, +}; + +export default alteration; diff --git a/packages/schemas/src/types/tenant-organization.ts b/packages/schemas/src/types/tenant-organization.ts index ce2d1ba26..beaf4524a 100644 --- a/packages/schemas/src/types/tenant-organization.ts +++ b/packages/schemas/src/types/tenant-organization.ts @@ -124,14 +124,14 @@ const tenantScopeDescriptions: Readonly> = Object.fr export enum TenantRole { /** Admin of the tenant, who has all permissions. */ Admin = 'admin', - /** Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings. */ - Member = 'member', + /** Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings. */ + Collaborator = 'collaborator', } const tenantRoleDescriptions: Readonly> = Object.freeze({ [TenantRole.Admin]: 'Admin of the tenant, who has all permissions.', - [TenantRole.Member]: - 'Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings.', + [TenantRole.Collaborator]: + 'Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings.', }); /** @@ -139,14 +139,14 @@ const tenantRoleDescriptions: Readonly> = Object.free * * @example * ```ts - * const role = TenantRole.Member; // 'member' + * const role = TenantRole.Collaborator; // 'collaborator' * const roleData = getTenantRole(role); * * expect(roleData).toEqual({ * tenantId: 'admin', - * id: 'member', - * name: 'member', - * description: 'Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings.', + * id: 'collaborator', + * name: 'collaborator', + * description: 'Collaborator of the tenant, who has permissions to operate the tenant data, but not the tenant settings.', * }); * ``` * @@ -167,7 +167,7 @@ export const getTenantRole = (role: TenantRole): Readonly => export const tenantRoleScopes: Readonly>> = Object.freeze({ [TenantRole.Admin]: allTenantScopes, - [TenantRole.Member]: [ + [TenantRole.Collaborator]: [ TenantScope.ReadData, TenantScope.WriteData, TenantScope.DeleteData,