📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
List organisations user belongs to
Blue Mouse100f4ff5e77f
diff --git a/backend/apps/cloud/src/auth/auth.controller.ts b/backend/apps/cloud/src/auth/auth.controller.tsindex 039657955..1eca6594d 100644--- a/backend/apps/cloud/src/auth/auth.controller.ts+++ b/backend/apps/cloud/src/auth/auth.controller.ts@@ -142,7 +142,7 @@ export class AuthController {await checkRateLimit(ip, 'login', 10, 1800)- let user = await this.authService.validateUser(body.email, body.password)+ let user = await this.authService.getBasicUser(body.email, body.password)if (!user) {throw new ConflictException(i18n.t('auth.invalidCredentials'))@@ -159,7 +159,13 @@ export class AuthController {// @ts-expect-erroruser = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])} else {- user = await this.authService.getSharedProjectsForUser(user)+ const [sharedProjects, organisationMemberships] = await Promise.all([+ this.authService.getSharedProjectsForUser(user.id),+ this.authService.getOrganisationsForUser(user.id),+ ])++ user.sharedProjects = sharedProjects+ user.organisationMemberships = organisationMemberships}return {@@ -257,7 +263,7 @@ export class AuthController {throw new UnauthorizedException()}- const isPasswordValid = await this.authService.validateUser(+ const isPasswordValid = await this.authService.getBasicUser(user.email,body.oldPassword,)@@ -320,7 +326,7 @@ export class AuthController {throw new UnauthorizedException()}- const isPasswordValid = await this.authService.validateUser(+ const isPasswordValid = await this.authService.getBasicUser(user.email,body.password,)diff --git a/backend/apps/cloud/src/auth/auth.module.ts b/backend/apps/cloud/src/auth/auth.module.tsindex ce4477b9c..a9fed335a 100644--- a/backend/apps/cloud/src/auth/auth.module.ts+++ b/backend/apps/cloud/src/auth/auth.module.ts@@ -15,6 +15,7 @@ import {JwtRefreshTokenStrategy,} from './strategies'import { Message } from '../integrations/telegram/entities/message.entity'+import { OrganisationModule } from '../organisation/organisation.module'@Module({imports: [@@ -26,6 +27,7 @@ import { Message } from '../integrations/telegram/entities/message.entity'ActionTokensModule,ProjectModule,TypeOrmModule.forFeature([Message]),+ OrganisationModule,],controllers: [AuthController],providers: [diff --git a/backend/apps/cloud/src/auth/auth.service.ts b/backend/apps/cloud/src/auth/auth.service.tsindex 4dafeccbd..86e7440a9 100644--- a/backend/apps/cloud/src/auth/auth.service.ts+++ b/backend/apps/cloud/src/auth/auth.service.ts@@ -47,6 +47,7 @@ import { TelegramService } from '../integrations/telegram/telegram.service'import { SSOProviders } from './dtos'import { UserGoogleDTO } from '../user/dto/user-google.dto'import { UserGithubDTO } from '../user/dto/user-github.dto'+import { OrganisationService } from '../organisation/organisation.service'const REDIS_SSO_SESSION_TIMEOUT = 60 * 5 // 5 minutesconst getSSORedisKey = (uuid: string) => `${REDIS_SSO_UUID}:${uuid}`@@ -77,6 +78,7 @@ export class AuthService {private readonly jwtService: JwtService,private readonly projectService: ProjectService,private readonly telegramService: TelegramService,+ private readonly organisationService: OrganisationService,) {this.oauth2Client = new Auth.OAuth2Client(this.configService.get('GOOGLE_OAUTH2_CLIENT_ID'),@@ -180,7 +182,7 @@ export class AuthService {)}- public async validateUser(+ public async getBasicUser(email: string,password: string,): Promise<User | null> {@@ -201,17 +203,32 @@ export class AuthService {return null}- public async getSharedProjectsForUser(user: User): Promise<User> {- const sharedProjects = await this.projectService.findShare({+ async getSharedProjectsForUser(userId: string) {+ return this.projectService.findShare({where: {- user: { id: user.id },+ user: { id: userId },},relations: ['project'],})+ }- user.sharedProjects = sharedProjects-- return user+ async getOrganisationsForUser(userId: string) {+ return this.organisationService.findMemberships({+ where: {+ user: { id: userId },+ },+ relations: ['organisation'],+ select: {+ id: true,+ role: true,+ confirmed: true,+ created: true,+ organisation: {+ id: true,+ name: true,+ },+ },+ })}private async comparePassword(@@ -496,7 +513,13 @@ export class AuthService {// @ts-expect-erroruser = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])} else {- user = await this.getSharedProjectsForUser(user)+ const [sharedProjects, organisationMemberships] = await Promise.all([+ this.getSharedProjectsForUser(user.id),+ this.getOrganisationsForUser(user.id),+ ])++ user.sharedProjects = sharedProjects+ user.organisationMemberships = organisationMemberships}return {@@ -948,7 +971,13 @@ export class AuthService {// @ts-expect-erroruser = _pick(user, ['isTwoFactorAuthenticationEnabled', 'email'])} else {- user = await this.getSharedProjectsForUser(user)+ const [sharedProjects, organisationMemberships] = await Promise.all([+ this.getSharedProjectsForUser(user.id),+ this.getOrganisationsForUser(user.id),+ ])++ user.sharedProjects = sharedProjects+ user.organisationMemberships = organisationMemberships}return {diff --git a/backend/apps/cloud/src/organisation/organisation.controller.ts b/backend/apps/cloud/src/organisation/organisation.controller.tsindex e9bb8d556..295c6eb51 100644--- a/backend/apps/cloud/src/organisation/organisation.controller.ts+++ b/backend/apps/cloud/src/organisation/organisation.controller.ts@@ -16,7 +16,7 @@ import {} from '@nestjs/common'import { ApiBearerAuth, ApiQuery, ApiResponse } from '@nestjs/swagger'import { isEmpty as _isEmpty, find as _find, trim as _trim } from 'lodash'-import { FindOptionsWhere, ILike, In } from 'typeorm'+import { FindOptionsWhere, ILike } from 'typeorm'import { JwtAccessTokenGuard } from '../auth/guards/jwt-access-token.guard'import { RolesGuard } from '../auth/guards/roles.guard'@@ -75,7 +75,6 @@ export class OrganisationController {where = {members: {user: { id: userId },- role: In([OrganisationRole.owner, OrganisationRole.admin]),},name: ILike(`%${search}%`),}@@ -83,7 +82,6 @@ export class OrganisationController {where = {members: {user: { id: userId },- role: In([OrganisationRole.owner, OrganisationRole.admin]),},}}@@ -165,6 +163,7 @@ export class OrganisationController {role: OrganisationRole.owner,user,organisation,+ confirmed: true,})return organisationdiff --git a/backend/apps/cloud/src/organisation/organisation.service.ts b/backend/apps/cloud/src/organisation/organisation.service.tsindex 16bb8536d..7316641b1 100644--- a/backend/apps/cloud/src/organisation/organisation.service.ts+++ b/backend/apps/cloud/src/organisation/organisation.service.ts@@ -24,7 +24,7 @@ export class OrganisationService {private membershipRepository: Repository<OrganisationMember>,) {}- async create(data: Partial<Organisation>): Promise<Organisation> {+ async create(data: Partial<Organisation>) {const org = this.organisationRepository.create(data)return this.organisationRepository.save(org)}@@ -33,43 +33,37 @@ export class OrganisationService {return this.organisationRepository.update(id, data)}- async findOne(options: FindOneOptions<Organisation>): Promise<Organisation> {+ async findOne(options: FindOneOptions<Organisation>) {return this.organisationRepository.findOne(options)}- async find(options: FindManyOptions<Organisation>): Promise<Organisation[]> {+ async find(options: FindManyOptions<Organisation>) {return this.organisationRepository.find(options)}- async createMembership(- data: Partial<OrganisationMember>,- ): Promise<OrganisationMember> {+ async findMemberships(options: FindManyOptions<OrganisationMember>) {+ return this.membershipRepository.find(options)+ }++ async createMembership(data: Partial<OrganisationMember>) {const membership = this.membershipRepository.create(data)return this.membershipRepository.save(membership)}- async findOneMembership(- options: FindOneOptions<OrganisationMember>,- ): Promise<OrganisationMember> {+ async findOneMembership(options: FindOneOptions<OrganisationMember>) {return this.membershipRepository.findOne(options)}- async updateMembership(- id: string,- data: Partial<OrganisationMember>,- ): Promise<OrganisationMember> {+ async updateMembership(id: string, data: Partial<OrganisationMember>) {await this.membershipRepository.update(id, data)return this.findOneMembership({ where: { id } })}- async deleteMembership(id: string): Promise<void> {+ async deleteMembership(id: string) {await this.membershipRepository.delete(id)}- async validateManageAccess(- organisation: Organisation,- userId: string,- ): Promise<void> {+ async validateManageAccess(organisation: Organisation, userId: string) {const membership = _find(organisation.members,member => member.user?.id === userId,@@ -82,10 +76,7 @@ export class OrganisationService {}}- async canManageOrganisation(- organisationId: string,- userId: string,- ): Promise<boolean> {+ async canManageOrganisation(organisationId: string, userId: string) {const organisation = await this.findOne({where: { id: organisationId },relations: ['members', 'members.user'],@@ -122,7 +113,7 @@ export class OrganisationService {async paginate(options: PaginationOptionsInterface,where?: FindOptionsWhere<Organisation> | FindOptionsWhere<Organisation>[],- ): Promise<Pagination<Organisation>> {+ ) {const [results, total] = await this.organisationRepository.findAndCount({take: options.take || 100,skip: options.skip || 0,@@ -130,7 +121,21 @@ export class OrganisationService {order: {name: 'ASC',},- relations: ['members'],+ relations: ['members', 'members.user'],+ select: {+ id: true,+ name: true,+ members: {+ id: true,+ role: true,+ confirmed: true,+ created: true,+ user: {+ id: true,+ email: true,+ },+ },+ },})return new Pagination<Organisation>({diff --git a/backend/apps/cloud/src/user/user.controller.ts b/backend/apps/cloud/src/user/user.controller.tsindex 5e0cb689a..100c5fc19 100644--- a/backend/apps/cloud/src/user/user.controller.ts+++ b/backend/apps/cloud/src/user/user.controller.ts@@ -76,7 +76,6 @@ import {} from '../common/utils'import { IUsageInfo, IMetaInfo } from './interfaces'import { ReportFrequency } from '../project/enums'-import { Organisation } from '../organisation/entity/organisation.entity'dayjs.extend(utc)@@ -104,26 +103,16 @@ export class UserController {async me(@CurrentUserId() uid: string) {this.logger.log({ uid }, 'GET /user/me')- const [sharedProjects, manageableOrganisations, user] = await Promise.all([- this.projectService.findShare({- where: {- user: {- id: uid,- },- },- relations: ['project'],- }),- this.userService.getManageableOrganisations(uid),+ const [sharedProjects, organisationMemberships, user] = await Promise.all([+ this.authService.getSharedProjectsForUser(uid),+ this.authService.getOrganisationsForUser(uid),this.userService.findOne({ where: { id: uid } }),])- const sanitizedUser = this.userService.omitSensitiveData(- user,- ) as Partial<User> & {- manageableOrganisations: Organisation[]- }+ const sanitizedUser = this.userService.omitSensitiveData(user)+sanitizedUser.sharedProjects = sharedProjects- sanitizedUser.manageableOrganisations = manageableOrganisations+ sanitizedUser.organisationMemberships = organisationMembershipsreturn sanitizedUser}diff --git a/backend/apps/cloud/src/user/user.service.ts b/backend/apps/cloud/src/user/user.service.tsindex 0140841aa..16b9025d4 100644--- a/backend/apps/cloud/src/user/user.service.ts+++ b/backend/apps/cloud/src/user/user.service.ts@@ -41,7 +41,6 @@ import { UserGithubDTO } from './dto/user-github.dto'import { EMAIL_ACTION_ENCRYPTION_KEY } from '../common/constants'import { ReportFrequency } from '../project/enums'import { OrganisationService } from '../organisation/organisation.service'-import { OrganisationRole } from '../organisation/entity/organisation-member.entity'dayjs.extend(utc)@@ -138,18 +137,6 @@ export class UserService {return this.usersRepository.update({ id }, update)}- async getManageableOrganisations(userId: string) {- return this.organisationService.find({- where: {- members: {- user: { id: userId },- role: In([OrganisationRole.owner, OrganisationRole.admin]),- },- },- select: ['id', 'name'],- })- }-async updateByEmail(email: string,update: Record<string, unknown>,diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsxindex 7cf980f07..c368db8d9 100644--- a/web/app/pages/Organisations/Settings/People.tsx+++ b/web/app/pages/Organisations/Settings/People.tsx@@ -50,15 +50,12 @@ const UsersList = ({ members, onRemove }: UsersListProps) => {useOnClickOutside(openRef, () => setRoleEditDropdownId(null))const changeRole = async (memberId: string, newRole: Role) => {- console.log('changeRole', memberId, newRole)-try {await changeOrganisationRole(memberId, newRole)-toast.success(t('apiNotifications.roleUpdated'))} catch (reason) {console.error(`[ERROR] Error while updating user's role: ${reason}`)- toast.error(t('apiNotifications.roleUpdateError'))+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.roleUpdateError'))}setRoleEditDropdownId(null)@@ -259,7 +256,7 @@ const People = ({ organisation, reloadOrganisation }: PeopleProps): JSX.Elementtoast.success(t('apiNotifications.orgUserRemoved'))} catch (reason) {console.error(`[ERROR] Error while removing user from the organisation: ${reason}`)- toast.error(t('apiNotifications.orgUserRemoveError'))+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.orgUserRemoveError'))} finally {setIsDeleting(false)}diff --git a/web/app/pages/Project/New/index.tsx b/web/app/pages/Project/New/index.tsxindex de6cc21f0..9b1081fd6 100644--- a/web/app/pages/Project/New/index.tsx+++ b/web/app/pages/Project/New/index.tsx@@ -49,9 +49,11 @@ const NewProject = () => {id: undefined,name: t('common.notSet'),},- ...(user.manageableOrganisations || []),+ ...(user.organisationMemberships || [])+ .filter((om) => om.confirmed && (om.role === 'admin' || om.role === 'owner'))+ .map((om) => om.organisation),],- [user.manageableOrganisations, t],+ [user.organisationMemberships, t],)useEffect(() => {diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsxindex ab67a1508..5a9923ba9 100644--- a/web/app/pages/Project/Settings/ProjectSettings.tsx+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx@@ -318,9 +318,11 @@ const ProjectSettings = () => {id: undefined,name: t('common.notSet'),},- ...(user.manageableOrganisations || []),+ ...(user.organisationMemberships || [])+ .filter((om) => om.confirmed && (om.role === 'admin' || om.role === 'owner'))+ .map((om) => om.organisation),],- [user.manageableOrganisations, t],+ [user.organisationMemberships, t],)const sharableLink = useMemo(() => {diff --git a/web/app/pages/UserSettings/UserSettings.container.tsx b/web/app/pages/UserSettings/UserSettings.container.tsxindex 10b6163e7..84c1bff4e 100644--- a/web/app/pages/UserSettings/UserSettings.container.tsx+++ b/web/app/pages/UserSettings/UserSettings.container.tsx@@ -11,6 +11,7 @@ import { ISharedProject } from 'redux/models/ISharedProject'import { removeRefreshToken } from 'utils/refreshToken'import { removeAccessToken } from 'utils/accessToken'import UserSettings from './UserSettings'+import { IProject } from 'redux/models/IProject'const mapStateToProps = (state: StateType) => {return {@@ -70,7 +71,7 @@ const mapDispatchToProps = (dispatch: AppDispatch) => ({removeShareProject: (id: string) => {dispatch(authActions.deleteShareProject(id))},- setProjectsShareData: (data: Partial<ISharedProject>, id: string) => {+ setProjectsShareData: (data: Partial<IProject>, id: string) => {dispatch(UIActions.setProjectsShareData({data,diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsxindex 23f8d8349..32716df66 100644--- a/web/app/pages/UserSettings/UserSettings.tsx+++ b/web/app/pages/UserSettings/UserSettings.tsx@@ -38,7 +38,6 @@ import {isSelfhosted,} from 'redux/constants'import { IUser } from 'redux/models/IUser'-import { ISharedProject } from 'redux/models/ISharedProject'import { withAuthentication, auth } from 'hoc/protected'import Input from 'ui/Input'import Button from 'ui/Button'@@ -66,6 +65,9 @@ import Integrations from './components/Integrations'import Socialisations from './components/Socialisations'import Referral from './components/Referral'import NoSharedProjects from './components/NoSharedProjects'+import { IProject } from 'redux/models/IProject'+import Organisations from './components/Organisations'+import NoOrganisations from './components/NoOrganisations'dayjs.extend(utc)@@ -123,8 +125,8 @@ interface IProps {onDeleteProjectCache: () => voidremoveProject: (id: string) => voidremoveShareProject: (id: string) => void- setUserShareData: (data: Partial<ISharedProject>, id: string) => void- setProjectsShareData: (data: Partial<ISharedProject>, id: string) => void+ setUserShareData: (data: Partial<IProject>, id: string) => void+ setProjectsShareData: (data: Partial<IProject>, id: string) => voidupdateUserData: (data: Partial<IUser>) => voidupdateUserProfileAsync: (data: IUser, successMessage: string, callback?: (isSuccess: boolean) => void) => voidsetAPIKey: (key: string | null) => void@@ -745,9 +747,67 @@ const UserSettings = ({</div></div>) : (- <NoSharedProjects t={t} />+ <NoSharedProjects />)}</div>++ {/* Organisations setting */}+ <hr className='mt-5 border-gray-200 dark:border-gray-600' />+ <h3 className='mt-2 flex items-center text-lg font-bold text-gray-900 dark:text-gray-50'>+ {t('profileSettings.organisations')}+ </h3>+ <div>+ {!_isEmpty(user.organisationMemberships) ? (+ <div className='mt-3 flex flex-col'>+ <div className='-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8'>+ <div className='inline-block min-w-full py-2 align-middle md:px-6 lg:px-8'>+ <div className='overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg'>+ <table className='min-w-full divide-y divide-gray-300 dark:divide-gray-600'>+ <thead>+ <tr className='dark:bg-slate-800'>+ <th+ scope='col'+ className='py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 dark:text-white sm:pl-6'+ >+ {t('profileSettings.organisationsTable.organisation')}+ </th>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'+ >+ {t('profileSettings.organisationsTable.role')}+ </th>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'+ >+ {t('profileSettings.organisationsTable.joinedOn')}+ </th>+ <th scope='col' className='relative py-3.5 pl-3 pr-4 sm:pr-6' />+ </tr>+ </thead>+ <tbody className='divide-y divide-gray-300 dark:divide-gray-600'>+ {_map(user.organisationMemberships, (membership) => (+ <Organisations+ key={membership.id}+ membership={membership}+ removeProject={removeProject}+ removeShareProject={removeShareProject}+ setUserShareData={setUserShareData}+ setProjectsShareData={setProjectsShareData}+ />+ ))}+ </tbody>+ </table>+ </div>+ </div>+ </div>+ </div>+ ) : (+ <NoOrganisations />+ )}+ </div>+<hr className='mt-5 border-gray-200 dark:border-gray-600' />{!user.isActive && (<divdiff --git a/web/app/pages/UserSettings/components/NoOrganisations.tsx b/web/app/pages/UserSettings/components/NoOrganisations.tsxnew file mode 100644index 000000000..85322082d--- /dev/null+++ b/web/app/pages/UserSettings/components/NoOrganisations.tsx@@ -0,0 +1,16 @@+import React from 'react'+import { useTranslation } from 'react-i18next'++const NoOrganisations = () => {+ const { t } = useTranslation('common')++ return (+ <div className='flex flex-col py-6 sm:px-6 lg:px-8'>+ <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>+ <h2 className='mb-4 text-center text-2xl leading-snug'>{t('profileSettings.noOrganisations')}</h2>+ </div>+ </div>+ )+}++export default NoOrganisationsdiff --git a/web/app/pages/UserSettings/components/NoSharedProjects.tsx b/web/app/pages/UserSettings/components/NoSharedProjects.tsxindex fa0b0ab90..c80d497ef 100644--- a/web/app/pages/UserSettings/components/NoSharedProjects.tsx+++ b/web/app/pages/UserSettings/components/NoSharedProjects.tsx@@ -1,12 +1,16 @@import React from 'react'-import type i18next from 'i18next'+import { useTranslation } from 'react-i18next'-const NoSharedProjects = ({ t }: { t: typeof i18next.t }): JSX.Element => (- <div className='flex flex-col py-6 sm:px-6 lg:px-8'>- <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>- <h2 className='mb-4 text-center text-2xl leading-snug'>{t('profileSettings.noSharedProjects')}</h2>+const NoSharedProjects = () => {+ const { t } = useTranslation('common')++ return (+ <div className='flex flex-col py-6 sm:px-6 lg:px-8'>+ <div className='mx-auto w-full max-w-7xl text-gray-900 dark:text-gray-50'>+ <h2 className='mb-4 text-center text-2xl leading-snug'>{t('profileSettings.noSharedProjects')}</h2>+ </div></div>- </div>-)+ )+}export default NoSharedProjectsdiff --git a/web/app/pages/UserSettings/components/Organisations.tsx b/web/app/pages/UserSettings/components/Organisations.tsxnew file mode 100644index 000000000..9b5138b3d--- /dev/null+++ b/web/app/pages/UserSettings/components/Organisations.tsx@@ -0,0 +1,107 @@+import React, { memo, useState } from 'react'+import dayjs from 'dayjs'+import { toast } from 'sonner'+import { useTranslation } from 'react-i18next'++import Button from 'ui/Button'+import Modal from 'ui/Modal'+// import { deleteShareProject, acceptShareProject } from 'api'+import { IProject } from 'redux/models/IProject'+import { OrganisationMembership } from 'redux/models/Organisation'++interface OrganisationsProps {+ membership: OrganisationMembership+ removeShareProject: (id: string) => void+ removeProject: (id: string) => void+ setProjectsShareData: (data: Partial<IProject>, id: string) => void+ setUserShareData: (data: Partial<IProject>, id: string) => void+}++const Organisations = ({+ membership,+ removeShareProject,+ removeProject,+ setProjectsShareData,+ setUserShareData,+}: OrganisationsProps) => {+ const {+ t,+ i18n: { language },+ } = useTranslation('common')++ const [showDeleteModal, setShowDeleteModal] = useState(false)+ const { organisation, confirmed, id, role, created } = membership++ const deleteProject = async (pid: string) => {+ try {+ // await deleteShareProject(pid)+ // removeShareProject(pid)+ // removeProject(project.id)+ toast.success(t('apiNotifications.quitOrganisation'))+ } catch (reason) {+ console.error(`[ERROR] Error while quitting project: ${reason}`)+ toast.error(t('apiNotifications.quitOrganisationError'))+ }+ }++ const onAccept = async () => {+ try {+ // await acceptShareProject(id)+ // setProjectsShareData({ isAccessConfirmed: true }, project.id)+ // setUserShareData({ isAccessConfirmed: true }, id)+ toast.success(t('apiNotifications.acceptInvitation'))+ } catch (reason) {+ console.error(`[ERROR] Error while accepting project invitation: ${reason}`)+ toast.error(t('apiNotifications.acceptInvitationError'))+ }+ }++ return (+ <tr className='dark:bg-slate-800'>+ <td className='whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 dark:text-white sm:pl-6'>+ {organisation.name}+ </td>+ <td className='whitespace-nowrap px-3 py-4 text-sm text-gray-900 dark:text-white'>+ {t(`project.settings.roles.${role}.name`)}+ </td>+ <td className='whitespace-nowrap px-3 py-4 text-sm text-gray-900 dark:text-white'>+ {language === 'en'+ ? dayjs(created).locale(language).format('MMMM D, YYYY')+ : dayjs(created).locale(language).format('D MMMM, YYYY')}+ </td>+ <td className='relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6'>+ {confirmed ? (+ <Button onClick={() => setShowDeleteModal(true)} danger small>+ {t('common.quit')}+ </Button>+ ) : (+ <>+ <Button className='mr-2' onClick={() => setShowDeleteModal(true)} primary small>+ {t('common.reject')}+ </Button>+ <Button onClick={() => onAccept()} primary small>+ {t('common.accept')}+ </Button>+ </>+ )}+ <Modal+ onClose={() => {+ setShowDeleteModal(false)+ }}+ onSubmit={() => {+ setShowDeleteModal(false)+ deleteProject(id)+ }}+ submitText={t('common.yes')}+ type='confirmed'+ closeText={t('common.no')}+ title={t('profileSettings.quitEntity', { entity: organisation.name })}+ message={t('profileSettings.quitOrganisation')}+ isOpened={showDeleteModal}+ />+ </td>+ </tr>+ )+}++export default memo(Organisations)diff --git a/web/app/pages/UserSettings/components/ProjectList.tsx b/web/app/pages/UserSettings/components/ProjectList.tsxindex ae04b81cb..08981a222 100644--- a/web/app/pages/UserSettings/components/ProjectList.tsx+++ b/web/app/pages/UserSettings/components/ProjectList.tsx@@ -48,10 +48,10 @@ const ProjectList = ({try {await acceptShareProject(id)setProjectsShareData({ isAccessConfirmed: true }, project.id)- setUserShareData({ confirmed: true }, id)+ setUserShareData({ isAccessConfirmed: true }, id)toast.success(t('apiNotifications.acceptInvitation'))- } catch (e) {- console.error(`[ERROR] Error while accepting project invitation: ${e}`)+ } catch (reason) {+ console.error(`[ERROR] Error while accepting project invitation: ${reason}`)toast.error(t('apiNotifications.acceptInvitationError'))}}@@ -95,7 +95,7 @@ const ProjectList = ({submitText={t('common.yes')}type='confirmed'closeText={t('common.no')}- title={t('profileSettings.quitProjectTitle', { project: project.name })}+ title={t('profileSettings.quitEntity', { entity: project.name })}message={t('profileSettings.quitProject')}isOpened={showDeleteModal}/>diff --git a/web/app/redux/constants/index.ts b/web/app/redux/constants/index.tsindex ccac4e39d..f9364d886 100644--- a/web/app/redux/constants/index.ts+++ b/web/app/redux/constants/index.ts@@ -479,7 +479,7 @@ export const paddleLanguageMapping: IStringObject = {// Increase this counter every time some major change is done within localisation files// This will prevent cached version or raw locale strings being displayed in production-export const I18N_CACHE_BREAKER = 9+export const I18N_CACHE_BREAKER = 10// dashboard && projectsdiff --git a/web/app/redux/models/IUser.ts b/web/app/redux/models/IUser.tsindex 581350d7e..04bd1dc31 100644--- a/web/app/redux/models/IUser.ts+++ b/web/app/redux/models/IUser.ts@@ -1,4 +1,5 @@import { ISharedProject } from './ISharedProject'+import { OrganisationMembership } from './Organisation'export enum DashboardBlockReason {'exceeding_plan_limits' = 'exceeding_plan_limits',@@ -66,8 +67,5 @@ export interface IUser {planExceedContactedAt: DatedashboardBlockReason: DashboardBlockReasonisAccountBillingSuspended: boolean- manageableOrganisations?: {- id: string- name: string- }[]+ organisationMemberships: OrganisationMembership[]}diff --git a/web/app/redux/models/Organisation.ts b/web/app/redux/models/Organisation.tsindex 4267a8af7..009b0b080 100644--- a/web/app/redux/models/Organisation.ts+++ b/web/app/redux/models/Organisation.ts@@ -25,3 +25,11 @@ export interface DetailedOrganisation extends Organisation {}}[]}++export interface OrganisationMembership {+ id: string+ role: Role+ confirmed: boolean+ created: string+ organisation: Organisation+}diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex b32ae7d96..ca12ff27a 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -18,6 +18,8 @@"quitProjectError": "Error occurred while quitting the project","payoutInfoError": "Something went wrong whilst requesting payouts information","quitProject": "You have quit the project",+ "quitOrganisation": "You have quit the organisation",+ "quitOrganisationError": "Error occurred while quitting the organisation","acceptInvitationError": "Error occurred while accepting the project invitation","acceptInvitation": "The project invitation has been accepted","subscriptionUpdated": "Your subscription has been updated",@@ -507,14 +509,22 @@"noConfLeft": "Unfortunately, you've ran out of your email confirmation requests.\nPlease make sure you are able to receive e-mails and check your SPAM folder again for messages.\nYou may try to use a different email address or contact our customer support service.","timezoneDesc": "This will be the time zone in which the data is displayed. It's only used for visualization.\nNo data will be modified based on this setting.","quitProject": "Are you sure you want to quit this project?",- "quitProjectTitle": "Quit {{project}}?",+ "quitOrganisation": "Are you sure you want to quit this organisation?",+ "quitEntity": "Quit {{entity}}?","shared": "Shared projects","receiveLoginNotifications": "Receive login notifications",+ "organisations": "Organisations",+ "organisationsTable": {+ "organisation": "Organisation",+ "role": "Role",+ "joinedOn": "Joined on"+ },"sharedTable": {"project": "Project","role": "Role","joinedOn": "Joined on"},+ "noOrganisations": "You are not a member of any organisation yet.","noSharedProjects": "Nobody is sharing a project with you yet.","2fa": "Two-factor authentication (2FA)","2faEnable": "Enable 2FA to make your account more secure.",