Skip to content

📈 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!

Ability to add projects & members to organisations

Blue Mouse8c32e7ef1829
diff --git a/backend/apps/cloud/src/organisation/organisation.controller.ts b/backend/apps/cloud/src/organisation/organisation.controller.ts
index 08d273dc5..98789f8ae 100644
--- a/backend/apps/cloud/src/organisation/organisation.controller.ts
+++ b/backend/apps/cloud/src/organisation/organisation.controller.ts
@@ -12,6 +12,7 @@ import {
Headers,
Get,
Query,
+ ForbiddenException,
} from '@nestjs/common'
import { ApiBearerAuth, ApiQuery, ApiResponse } from '@nestjs/swagger'
import { isEmpty as _isEmpty, find as _find } from 'lodash'
@@ -98,8 +99,23 @@ export class OrganisationController {
@Get('/:orgId')
@ApiResponse({ status: 200, type: Organisation })
@Auth([], true)
- async getOne(@Param('orgId') orgId: string): Promise<Organisation> {
- // todo: add access control
+ async getOne(
+ @Param('orgId') orgId: string,
+ @CurrentUserId() userId: string,
+ ): Promise<Organisation> {
+ this.logger.log({ orgId, userId }, 'GET /organisation/:orgId')
+
+ const canManage = await this.organisationService.canManageOrganisation(
+ orgId,
+ userId,
+ )
+
+ if (!canManage) {
+ throw new ForbiddenException(
+ 'You do not have permission to manage this organisation',
+ )
+ }
+
return this.organisationService.findOne({
where: { id: orgId },
select: {
@@ -114,8 +130,15 @@ export class OrganisationController {
email: true,
},
},
+ projects: {
+ id: true,
+ name: true,
+ admin: {
+ email: true,
+ },
+ },
},
- relations: ['members', 'members.user'],
+ relations: ['members', 'members.user', 'projects', 'projects.admin'],
})
}
diff --git a/backend/apps/cloud/src/project/dto/create-project.dto.ts b/backend/apps/cloud/src/project/dto/create-project.dto.ts
index 93a5bd8ca..5daad7d9c 100644
--- a/backend/apps/cloud/src/project/dto/create-project.dto.ts
+++ b/backend/apps/cloud/src/project/dto/create-project.dto.ts
@@ -1,7 +1,8 @@
import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty, Length } from 'class-validator'
+import { ProjectOrganisationDto } from './project-organisation.dto'
-export class CreateProjectDTO {
+export class CreateProjectDTO extends ProjectOrganisationDto {
@ApiProperty({
example: 'Your awesome project',
required: true,
@@ -16,11 +17,6 @@ export class CreateProjectDTO {
})
isCaptcha?: boolean
- @ApiProperty({
- required: false,
- })
- organisationId?: string
-
@ApiProperty({
required: false,
})
diff --git a/backend/apps/cloud/src/project/dto/project-organisation.dto.ts b/backend/apps/cloud/src/project/dto/project-organisation.dto.ts
new file mode 100644
index 000000000..4b4a2704e
--- /dev/null
+++ b/backend/apps/cloud/src/project/dto/project-organisation.dto.ts
@@ -0,0 +1,11 @@
+import { ApiProperty } from '@nestjs/swagger'
+import { IsOptional, IsString } from 'class-validator'
+
+export class ProjectOrganisationDto {
+ @ApiProperty({
+ required: false,
+ })
+ @IsString()
+ @IsOptional()
+ organisationId?: string
+}
diff --git a/backend/apps/cloud/src/project/dto/update-project.dto.ts b/backend/apps/cloud/src/project/dto/update-project.dto.ts
index 1489a5880..5a39ff1b7 100644
--- a/backend/apps/cloud/src/project/dto/update-project.dto.ts
+++ b/backend/apps/cloud/src/project/dto/update-project.dto.ts
@@ -3,10 +3,12 @@ import { IntersectionType, PartialType } from '@nestjs/mapped-types'
import { ApiProperty } from '@nestjs/swagger'
import { ProjectDTO } from './project.dto'
import { ProjectPasswordDto } from './project-password.dto'
+import { ProjectOrganisationDto } from './project-organisation.dto'
export class UpdateProjectDto extends IntersectionType(
PartialType(ProjectDTO),
ProjectPasswordDto,
+ ProjectOrganisationDto,
) {
@ApiProperty({
required: false,
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index efe9538ce..ef81f5217 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -224,6 +224,7 @@ export class ProjectController {
isLocked: !!user?.dashboardBlockReason,
isDataExists: _includes(pidsWithData, p?.id),
isErrorDataExists: _includes(pidsWithErrorData, p?.id),
+ organisationId: p?.organisation?.id,
}))
return {
@@ -979,6 +980,76 @@ export class ProjectController {
await this.projectService.removeDataFromClickhouse(pid, from, to)
}
+ @ApiBearerAuth()
+ @Post('organisation/:orgId')
+ @HttpCode(200)
+ @UseGuards(JwtAccessTokenGuard, RolesGuard)
+ @Roles(UserType.CUSTOMER, UserType.ADMIN)
+ @Auth([], true)
+ async addProject(
+ @Param('orgId') orgId: string,
+ @Body() addProjectDTO: ProjectIdDto,
+ @CurrentUserId() uid: string,
+ ) {
+ this.logger.log(
+ { uid, orgId, addProjectDTO },
+ 'POST /organisation/:orgId/project',
+ )
+
+ const organisation = await this.organisationService.findOne({
+ where: { id: orgId },
+ relations: ['members', 'projects'],
+ })
+
+ if (_isEmpty(organisation)) {
+ throw new NotFoundException(
+ `Organisation with ID ${orgId} does not exist`,
+ )
+ }
+
+ await this.organisationService.validateManageAccess(organisation, uid)
+
+ return this.projectService.addProjectToOrganisation(
+ organisation.id,
+ addProjectDTO.projectId,
+ )
+ }
+
+ @ApiBearerAuth()
+ @Delete('organisation/:orgId/:projectId')
+ @HttpCode(204)
+ @UseGuards(JwtAccessTokenGuard, RolesGuard)
+ @Roles(UserType.CUSTOMER, UserType.ADMIN)
+ @Auth([], true)
+ async removeProject(
+ @Param('orgId') orgId: string,
+ @Param('projectId') projectId: string,
+ @CurrentUserId() uid: string,
+ ) {
+ this.logger.log(
+ { uid, orgId, projectId },
+ 'DELETE /organisation/:orgId/project/:projectId',
+ )
+
+ const organisation = await this.organisationService.findOne({
+ where: { id: orgId },
+ relations: ['members', 'projects'],
+ })
+
+ if (_isEmpty(organisation)) {
+ throw new NotFoundException(
+ `Organisation with ID ${orgId} does not exist`,
+ )
+ }
+
+ await this.organisationService.validateManageAccess(organisation, uid)
+
+ await this.projectService.removeProjectFromOrganisation(
+ organisation.id,
+ projectId,
+ )
+ }
+
@Delete('/reset-filters/:pid')
@ApiResponse({ status: 200 })
@UseGuards(JwtAccessTokenGuard, RolesGuard)
@@ -1935,6 +2006,12 @@ export class ProjectController {
project.name = _trim(projectDTO.name)
}
+ if (projectDTO.organisationId) {
+ project.organisation = {
+ id: projectDTO.organisationId,
+ } as Organisation
+ }
+
if (_isBoolean(projectDTO.isPasswordProtected)) {
if (projectDTO.isPasswordProtected) {
if (projectDTO.password) {
@@ -1950,7 +2027,6 @@ export class ProjectController {
// @ts-expect-error
await this.projectService.update(id, _omit(project, ['share', 'admin']))
- // await updateProjectRedis(id, project)
await deleteProjectRedis(id)
return _omit(project, ['admin', 'passwordHash', 'share'])
diff --git a/backend/apps/cloud/src/project/project.service.ts b/backend/apps/cloud/src/project/project.service.ts
index 1dec435db..c08720947 100644
--- a/backend/apps/cloud/src/project/project.service.ts
+++ b/backend/apps/cloud/src/project/project.service.ts
@@ -89,6 +89,7 @@ import { CreateMonitorHttpRequestDTO } from './dto/create-monitor.dto'
import { MonitorEntity } from './entity/monitor.entity'
import { UpdateMonitorHttpRequestDTO } from './dto/update-monitor.dto'
import { HttpRequestOptions } from './interfaces/http-request-options.interface'
+import { Organisation } from '../organisation/entity/organisation.entity'
dayjs.extend(utc)
@@ -301,7 +302,6 @@ export class ProjectService {
private projectsRepository: Repository<Project>,
@InjectRepository(ProjectShare)
private projectShareRepository: Repository<ProjectShare>,
- private userService: UserService,
@InjectRepository(ProjectSubscriber)
private readonly projectSubscriberRepository: Repository<ProjectSubscriber>,
@InjectRepository(Funnel)
@@ -312,6 +312,7 @@ export class ProjectService {
private readonly mailerService: MailerService,
private readonly httpService: HttpService,
private readonly logger: AppLoggerService,
+ private readonly userService: UserService,
@InjectQueue('monitor') private monitorQueue: Queue,
) {}
@@ -384,7 +385,7 @@ export class ProjectService {
order: {
name: 'ASC',
},
- relations: ['share', 'share.user', 'funnels'],
+ relations: ['share', 'share.user', 'funnels', 'organisation'],
})
return new Pagination<Project>({
@@ -1619,4 +1620,43 @@ export class ProjectService {
await job.remove()
}
}
+
+ async addProjectToOrganisation(organisationId: string, projectId: string) {
+ const project = await this.findOne({
+ where: { id: projectId },
+ })
+
+ if (!project) {
+ throw new NotFoundException(`Project with ID ${projectId} not found`)
+ }
+
+ return this.update(projectId, {
+ organisation: {
+ id: organisationId,
+ } as Organisation,
+ } as Project)
+ }
+
+ async removeProjectFromOrganisation(
+ organisationId: string,
+ projectId: string,
+ ) {
+ const project = await this.findOne({
+ where: { id: projectId },
+ })
+
+ if (!project) {
+ throw new NotFoundException(`Project with ID ${projectId} not found`)
+ }
+
+ if (project.organisation?.id !== organisationId) {
+ throw new BadRequestException(
+ `Project with ID ${projectId} is not in organisation with ID ${organisationId}`,
+ )
+ }
+
+ return this.update(projectId, {
+ organisation: null,
+ } as Project)
+ }
}
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index 446612a01..f73dca5de 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -307,6 +307,24 @@ export const createOrganisation = (name: string) =>
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const addProjectToOrganisation = (organisationId: string, projectId: string) =>
+ api
+ .post(`/project/organisation/${organisationId}`, { projectId })
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
+export const removeProjectFromOrganisation = (organisationId: string, projectId: string) =>
+ api
+ .delete(`/project/organisation/${organisationId}/${projectId}`)
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
export const getSharedProjects = (take: number = 0, skip: number = 0, search?: string) =>
api
.get(`/project/shared?take=${take}&skip=${skip}&search=${search}`)
@@ -338,7 +356,7 @@ export const getProject = (pid: string, isCaptcha: boolean = false, password?: s
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
-export const createProject = (data: { name: string; isCaptcha?: boolean }) =>
+export const createProject = (data: { name: string; organisationId?: string; isCaptcha?: boolean }) =>
api
.post('/project', data)
.then((response): IProject => response.data)
diff --git a/web/app/pages/Dashboard/Dashboard.tsx b/web/app/pages/Dashboard/Dashboard.tsx
index da167693e..172944239 100644
--- a/web/app/pages/Dashboard/Dashboard.tsx
+++ b/web/app/pages/Dashboard/Dashboard.tsx
@@ -1,7 +1,6 @@
import React, { memo, useState, useEffect, useMemo } from 'react'
-import { Link, useNavigate } from '@remix-run/react'
+import { Link } from '@remix-run/react'
import { toast } from 'sonner'
-import type i18next from 'i18next'
import { ClientOnly } from 'remix-utils/client-only'
import cx from 'clsx'
import _isEmpty from 'lodash/isEmpty'
@@ -27,7 +26,7 @@ import Modal from 'ui/Modal'
import Select from 'ui/Select'
import { withAuthentication, auth } from 'hoc/protected'
import Loader from 'ui/Loader'
-import { Badge } from 'ui/Badge'
+import { Badge, BadgeProps } from 'ui/Badge'
import routes from 'utils/routes'
import { nFormatter, calculateRelativePercentage } from 'utils/generic'
import {
@@ -51,34 +50,28 @@ import { ISharedProject } from 'redux/models/ISharedProject'
import { IProject, ICaptchaProject, ILiveStats, IOverall } from 'redux/models/IProject'
import { IUser } from 'redux/models/IUser'
-interface IProjectCard {
- name?: string
- active?: boolean
+interface ProjectCardProps {
birdseye: IOverall
type: 'analytics' | 'captcha'
- t: typeof i18next.t
live?: string | number
- isPublic?: boolean
confirmed?: boolean
- id: string
sharedProjects: ISharedProject[]
setProjectsShareData: (data: Partial<ISharedProject>, id: string, shared?: boolean) => void
setUserShareData: (data: Partial<ISharedProject>, id: string) => void
shared?: boolean
captcha?: boolean
- isTransferring?: boolean
getRole?: (id: string) => string | null
- members?: number
+ project: IProject
}
-interface IMiniCard {
+interface MiniCardProps {
labelTKey: string
- t: typeof i18next.t
total?: number | string
percChange?: number
}
-const MiniCard = ({ labelTKey, t, total = 0, percChange }: IMiniCard): JSX.Element => {
+const MiniCard = ({ labelTKey, total = 0, percChange }: MiniCardProps) => {
+ const { t } = useTranslation('common')
const statsDidGrowUp = percChange ? percChange >= 0 : false
return (
@@ -114,30 +107,62 @@ const MiniCard = ({ labelTKey, t, total = 0, percChange }: IMiniCard): JSX.Eleme
}
const ProjectCard = ({
- name,
- active,
birdseye,
- t,
live = 'N/A',
- isPublic,
confirmed,
- id,
sharedProjects,
setProjectsShareData,
setUserShareData,
shared,
captcha,
- isTransferring,
type,
getRole,
- members,
-}: IProjectCard) => {
+ project,
+}: ProjectCardProps) => {
+ const { t } = useTranslation('common')
const [showInviteModal, setShowInviteModal] = useState(false)
- const role = useMemo(() => getRole && getRole(id), [getRole, id])
- const navigate = useNavigate()
+ const role = useMemo(() => getRole && getRole(project.id), [getRole, project.id])
+
+ const { id, name, public: isPublic, active, isTransferring, share, organisation } = project
+
+ const badges = useMemo(() => {
+ const list: BadgeProps[] = []
+
+ if (!active) {
+ list.push({ colour: 'red', label: t('dashboard.disabled') })
+ }
+
+ if (shared) {
+ if (confirmed) {
+ list.push({ colour: 'green', label: t('dashboard.shared') })
+ } else {
+ list.push({ colour: 'yellow', label: t('common.pending') })
+ }
+ }
+
+ if (isTransferring) {
+ list.push({ colour: 'indigo', label: t('common.transferring') })
+ }
+
+ if (isPublic) {
+ list.push({ colour: 'green', label: t('dashboard.public') })
+ }
+
+ if (organisation) {
+ list.push({ colour: 'sky', label: organisation.name })
+ }
+
+ const members = _size(share)
+
+ if (members > 0) {
+ list.push({ colour: 'slate', label: t('common.xMembers', { number: members + 1 }) })
+ }
+
+ return list
+ }, [t, active, shared, isTransferring, isPublic, organisation, confirmed, share])
const onAccept = async () => {
- // @ts-ignore
+ // @ts-expect-error
const pid: string = _find(sharedProjects, (item: ISharedProject) => item.project && item.project.id === id)?.id
try {
@@ -153,152 +178,132 @@ const ProjectCard = ({
}
}
- const onElementClick = (e: React.MouseEvent<HTMLLIElement>) => {
+ const onElementClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
if (confirmed) {
return
}
- e.stopPropagation()
e.preventDefault()
setShowInviteModal(true)
}
return (
- <div
- onClick={() => {
- navigate(_replace(type === 'analytics' ? routes.project : routes.captcha, ':id', id))
- }}
+ <Link
+ to={_replace(type === 'analytics' ? routes.project : routes.captcha, ':id', id)}
+ onClick={onElementClick}
+ className='min-h-[153.1px] cursor-pointer overflow-hidden rounded-xl border border-gray-200 bg-gray-50 hover:bg-gray-100 dark:border-slate-800/25 dark:bg-slate-800 dark:hover:bg-slate-700'
>
- <li
- onClick={onElementClick}
- className='cursor-pointer overflow-hidden rounded-xl border border-gray-200 bg-gray-50 hover:bg-gray-100 dark:border-slate-800/25 dark:bg-slate-800 dark:hover:bg-slate-700'
- >
- <div className='px-4 py-4'>
- <div className='flex items-center justify-between'>
- <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>
-
- <div className='flex items-center gap-2' onClick={(e) => e.stopPropagation()}>
- {role !== roleViewer.role && (
- <Link
- to={_replace(type === 'analytics' ? routes.project_settings : routes.captcha_settings, ':id', id)}
- aria-label={`${t('project.settings.settings')} ${name}`}
- >
- <AdjustmentsVerticalIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
- </Link>
- )}
- <a
- href={_replace(type === 'analytics' ? routes.project : routes.captcha, ':id', id)}
- aria-label='name (opens in a new tab)'
- target='_blank'
- rel='noopener noreferrer'
+ <div className='px-4 py-4'>
+ <div className='flex items-center justify-between'>
+ <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>
+
+ <div className='flex items-center gap-2' onClick={(e) => e.stopPropagation()}>
+ {role !== roleViewer.role && (
+ <Link
+ to={_replace(type === 'analytics' ? routes.project_settings : routes.captcha_settings, ':id', id)}
+ aria-label={`${t('project.settings.settings')} ${name}`}
>
- <ArrowTopRightOnSquareIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
- </a>
- </div>
- </div>
- <div className='mt-1 flex flex-shrink-0 flex-wrap gap-2'>
- {active ? (
- <Badge colour='green' label={t('dashboard.active')} />
- ) : (
- <Badge colour='red' label={t('dashboard.disabled')} />
- )}
- {shared &&
- (confirmed ? (
- <Badge colour='green' label={t('dashboard.shared')} />
- ) : (
- <Badge colour='yellow' label={t('common.pending')} />
- ))}
- {isTransferring && <Badge colour='indigo' label={t('common.transferring')} />}
- {isPublic && <Badge colour='green' label={t('dashboard.public')} />}
- {!isSelfhosted && _isNumber(members) && (
- <Badge
- colour='slate'
- label={
- members === 1
- ? t('common.oneMember')
- : t('common.xMembers', {
- number: members,
- })
- }
- />
- )}
- </div>
- <div className='mt-4 flex flex-shrink-0 gap-5'>
- {birdseye[id] && (
- <MiniCard
- labelTKey={captcha ? 'dashboard.captchaEvents' : 'dashboard.pageviews'}
- t={t}
- total={birdseye[id].current.all}
- percChange={calculateRelativePercentage(birdseye[id].previous.all, birdseye[id].current.all)}
- />
+ <AdjustmentsVerticalIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
+ </Link>
)}
- {!captcha && <MiniCard labelTKey='dashboard.liveVisitors' t={t} total={live} />}
+ <a
+ href={_replace(type === 'analytics' ? routes.project : routes.captcha, ':id', id)}
+ aria-label='name (opens in a new tab)'
+ target='_blank'
+ rel='noopener noreferrer'
+ >
+ <ArrowTopRightOnSquareIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
+ </a>
</div>
</div>
- {!confirmed && (
- <Modal
- onClose={() => {
- setShowInviteModal(false)
- }}
- onSubmit={() => {
- setShowInviteModal(false)
- onAccept()
- }}
- submitText={t('common.accept')}
- type='confirmed'
- closeText={t('common.cancel')}
- title={t('dashboard.invitationFor', { project: name })}
- message={t('dashboard.invitationDesc', { project: name })}
- isOpened={showInviteModal}
- />
- )}
- </li>
- </div>
+ <div className='mt-1 flex flex-shrink-0 flex-wrap gap-2'>
+ {badges.map((badge) => (
+ <Badge key={badge.label} {...badge} />
+ ))}
+ </div>
+ <div className='mt-4 flex flex-shrink-0 gap-5'>
+ {birdseye[id] && (
+ <MiniCard
+ labelTKey={captcha ? 'dashboard.captchaEvents' : 'dashboard.pageviews'}
+ total={birdseye[id].current.all}
+ percChange={calculateRelativePercentage(birdseye[id].previous.all, birdseye[id].current.all)}
+ />
+ )}
+ {!captcha && <MiniCard labelTKey='dashboard.liveVisitors' total={live} />}
+ </div>
+ </div>
+ {!confirmed && (
+ <Modal
+ onClose={() => {
+ setShowInviteModal(false)
+ }}
+ onSubmit={() => {
+ setShowInviteModal(false)
+ onAccept()
+ }}
+ submitText={t('common.accept')}
+ type='confirmed'
+ closeText={t('common.cancel')}
+ title={t('dashboard.invitationFor', { project: name })}
+ message={t('dashboard.invitationDesc', { project: name })}
+ isOpened={showInviteModal}
+ />
+ )}
+ </Link>
)
}
-interface INoProjects {
- t: typeof i18next.t
- onClick: () => void
+interface NoProjectsProps {
+ newProjectLink: string
+ onClick: (e: React.MouseEvent<HTMLAnchorElement>) => void
}
-interface IAddProject {
- t: typeof i18next.t
- onClick: () => void
+interface AddProjectProps {
+ newProjectLink: string
+ onClick: (e: React.MouseEvent<HTMLAnchorElement>) => void
sitesCount: number
}
-const NoProjects = ({ t, onClick }: INoProjects): JSX.Element => (
- <button
- type='button'
- onClick={onClick}
- className='relative mx-auto block max-w-lg rounded-lg border-2 border-dashed border-gray-300 p-12 text-center hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
- >
- <FolderPlusIcon className='mx-auto h-12 w-12 text-gray-400 dark:text-gray-200' />
- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50'>
- {t('dashboard.createProject')}
- </span>
- </button>
-)
-
-const AddProject = ({ t, onClick, sitesCount }: IAddProject): JSX.Element => (
- <li
- onClick={onClick}
- className={cx(
- 'group flex h-auto min-h-[153.1px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400',
- {
- 'lg:min-h-[auto]': sitesCount % 3 !== 0,
- },
- )}
- >
- <div>
- <FolderPlusIcon className='mx-auto h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400' />
- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>
- {t('dashboard.newProject')}
+const NoProjects = ({ newProjectLink, onClick }: NoProjectsProps) => {
+ const { t } = useTranslation('common')
+
+ return (
+ <Link
+ to={newProjectLink}
+ onClick={onClick}
+ className='relative mx-auto block max-w-lg rounded-lg border-2 border-dashed border-gray-300 p-12 text-center hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ <FolderPlusIcon className='mx-auto h-12 w-12 text-gray-400 dark:text-gray-200' />
+ <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50'>
+ {t('dashboard.createProject')}
</span>
- </div>
- </li>
-)
+ </Link>
+ )
+}
+
+const AddProject = ({ newProjectLink, onClick, sitesCount }: AddProjectProps) => {
+ const { t } = useTranslation('common')
+
+ return (
+ <Link
+ to={newProjectLink}
+ onClick={onClick}
+ className={cx(
+ 'group flex h-auto min-h-[153.1px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400',
+ {
+ 'lg:min-h-[auto]': sitesCount % 3 !== 0,
+ },
+ )}
+ >
+ <div>
+ <FolderPlusIcon className='mx-auto h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400' />
+ <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>
+ {t('dashboard.newProject')}
+ </span>
+ </div>
+ </Link>
+ )
+}
interface DashboardProps {
projects: IProject[]
@@ -356,8 +361,7 @@ const Dashboard = ({
const { t } = useTranslation('common')
const [isSearchActive, setIsSearchActive] = useState<boolean>(false)
const [showActivateEmailModal, setShowActivateEmailModal] = useState<boolean>(false)
- const navigate = useNavigate()
- const [activeTab, setActiveTab] = useState<string>(dashboardTabs)
+ const [activeTab, setActiveTab] = useState(dashboardTabs)
const pageAmountShared: number = Math.ceil(sharedTotal / ENTRIES_PER_PAGE_DASHBOARD)
const pageAmount: number = Math.ceil(total / ENTRIES_PER_PAGE_DASHBOARD)
const pageAmountCaptcha: number = Math.ceil(captchaTotal / ENTRIES_PER_PAGE_DASHBOARD)
@@ -365,21 +369,26 @@ const Dashboard = ({
_find([..._map(sharedProjects, (item) => ({ ...item.project, role: item.role }))], (p) => p.id === pid)?.role ||
null
// This search represents what's inside the search input
- const [search, setSearch] = useState<string>('')
- const debouncedSearch = useDebounce<string>(search, 500)
+ const [search, setSearch] = useState('')
+ const debouncedSearch = useDebounce(search, 500)
- const onNewProject = () => {
+ const onNewProject = (e: React.MouseEvent<HTMLAnchorElement>) => {
if (user.isActive || isSelfhosted) {
- if (dashboardTabs === tabForCaptchaProject) {
- navigate(routes.new_captcha)
- } else {
- navigate(routes.new_project)
- }
- } else {
- setShowActivateEmailModal(true)
+ return
}
+
+ e.preventDefault()
+ setShowActivateEmailModal(true)
}
+ const newProjectLink = useMemo(() => {
+ if (isSelfhosted) {
+ return routes.new_project
+ }
+
+ return dashboardTabs === tabForCaptchaProject ? routes.new_captcha : routes.new_project
+ }, [dashboardTabs])
+
useEffect(() => {
if (sharedTotal <= 0 && activeTab === tabForSharedProject) {
setDashboardTabs(tabForOwnedProject)
@@ -546,13 +555,14 @@ const Dashboard = ({
</div>
)}
</div>
- <span
+ <Link
+ to={newProjectLink}
onClick={onNewProject}
className='inline-flex cursor-pointer items-center justify-center rounded-md border border-transparent bg-slate-900 px-3 py-2 !pl-2 text-center text-sm font-medium leading-4 text-white shadow-sm hover:bg-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-500 focus:ring-offset-2 dark:border-gray-800 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700'
>
<FolderPlusIcon className='mr-1 h-5 w-5' />
{activeTab === tabForCaptchaProject ? t('dashboard.newCaptchaProject') : t('dashboard.newProject')}
- </span>
+ </Link>
</div>
{isSearchActive && (
<div className='mb-2 flex w-full items-center sm:hidden'>
@@ -633,135 +643,117 @@ const Dashboard = ({
{() => (
<>
{activeTab === tabForOwnedProject && (
- <div>
+ <>
{_isEmpty(_filter(projects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
+ <NoProjects newProjectLink={newProjectLink} onClick={onNewProject} />
) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
+ <div className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
{_map(
_filter(projects, ({ uiHidden }) => !uiHidden),
- ({ name, id, active, public: isPublic, isTransferring, share }) => (
+ (project) => (
<ProjectCard
- key={id}
- members={1 + _size(share)}
- id={id}
+ key={project.id}
+ project={project}
type='analytics'
- t={t}
- name={name}
- active={active}
- isPublic={isPublic}
birdseye={birdseye}
- live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
+ live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
setUserShareData={() => {}}
sharedProjects={[]}
setProjectsShareData={() => {}}
- isTransferring={isTransferring}
confirmed
/>
),
)}
<AddProject
+ newProjectLink={newProjectLink}
sitesCount={_size(_filter(projects, ({ uiHidden }) => !uiHidden))}
- t={t}
onClick={onNewProject}
/>
- </ul>
+ </div>
)}
- </div>
+ </>
)}
{activeTab === tabForCaptchaProject && (
- <div>
+ <>
{_isEmpty(_filter(captchaProjects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
+ <NoProjects newProjectLink={newProjectLink} onClick={onNewProject} />
) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
+ <div className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
{_map(
_filter(captchaProjects, ({ uiHidden }) => !uiHidden),
- ({ name, id, active, public: isPublic }) => (
+ (project) => (
<ProjectCard
- t={t}
- key={id}
- id={id}
+ key={project.id}
+ project={project as IProject}
type='captcha'
- name={name}
- captcha
- active={active}
- isPublic={isPublic}
birdseye={birdseye}
- live={_isNumber(liveStats[id]) ? liveStats[id] : 'N/A'}
+ live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
sharedProjects={[]}
setProjectsShareData={() => {}}
setUserShareData={() => {}}
+ captcha
confirmed
/>
),
)}
<AddProject
+ newProjectLink={newProjectLink}
sitesCount={_size(_filter(captchaProjects, ({ uiHidden }) => !uiHidden))}
- t={t}
onClick={onNewProject}
/>
- </ul>
+ </div>
)}
- </div>
+ </>
)}
{activeTab === tabForSharedProject && (
- <div>
+ <>
{_isEmpty(_filter(sharedProjects, ({ uiHidden }) => !uiHidden)) ? (
- <NoProjects t={t} onClick={onNewProject} />
+ <NoProjects newProjectLink={newProjectLink} onClick={onNewProject} />
) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
+ <div className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
{_map(
_filter(sharedProjects, ({ uiHidden }) => !uiHidden),
({ project, confirmed }) => {
if (_isUndefined(confirmed) || confirmed) {
return (
<ProjectCard
- t={t}
- key={`${project?.id}-confirmed`}
+ key={project.id}
+ project={project}
type='analytics'
- id={project?.id}
- name={project?.name}
- shared
getRole={getRole}
- active={project?.active}
- isPublic={project?.public}
confirmed={confirmed}
birdseye={birdseye}
live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
setUserShareData={() => {}}
sharedProjects={[]}
setProjectsShareData={() => {}}
+ shared
/>
)
}
return (
<ProjectCard
- t={t}
key={project?.id}
- id={project?.id}
type='analytics'
- name={project?.name}
shared
getRole={getRole}
- active={project?.active}
- isPublic={project?.public}
birdseye={birdseye}
confirmed={confirmed}
sharedProjects={user.sharedProjects}
setProjectsShareData={setProjectsShareData}
setUserShareData={setUserShareData}
live={_isNumber(liveStats[project.id]) ? liveStats[project.id] : 'N/A'}
+ project={project}
/>
)
},
)}
- </ul>
+ </div>
)}
- </div>
+ </>
)}
</>
)}
diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsx
index a27aeb604..dd46c093e 100644
--- a/web/app/pages/Organisations/Settings/People.tsx
+++ b/web/app/pages/Organisations/Settings/People.tsx
@@ -1,4 +1,3 @@
-import type i18next from 'i18next'
import React, { useState, useEffect, useRef } from 'react'
import { toast } from 'sonner'
import { ChevronDownIcon, CheckIcon } from '@heroicons/react/24/solid'
@@ -21,13 +20,17 @@ import { DetailedOrganisation } from 'redux/models/Organisation'
import { useSelector } from 'react-redux'
import { StateType } from 'redux/store'
-const NoPeople = ({ t }: { t: typeof i18next.t }) => (
- <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-8 px-4 text-center text-xl leading-snug'>{t('project.settings.noPeople')}</h2>
+const NoPeople = () => {
+ 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-8 px-4 text-center text-xl leading-snug'>{t('project.settings.noPeople')}</h2>
+ </div>
</div>
- </div>
-)
+ )
+}
interface UsersListProps {
members: DetailedOrganisation['members']
@@ -278,7 +281,7 @@ const People = ({ organisation }: PeopleProps): JSX.Element => {
</div>
<div>
{_isEmpty(members) ? (
- <NoPeople t={t} />
+ <NoPeople />
) : (
<div className='mt-3 flex flex-col'>
<div className='-mx-4 -my-2 overflow-x-auto sm:-mx-6 md:overflow-x-visible lg:-mx-8'>
diff --git a/web/app/pages/Organisations/Settings/Projects.tsx b/web/app/pages/Organisations/Settings/Projects.tsx
new file mode 100644
index 000000000..b4cac57a7
--- /dev/null
+++ b/web/app/pages/Organisations/Settings/Projects.tsx
@@ -0,0 +1,161 @@
+import React, { useState } from 'react'
+import { toast } from 'sonner'
+import { InformationCircleIcon, PlusIcon } from '@heroicons/react/24/outline'
+import { useTranslation } from 'react-i18next'
+import _isEmpty from 'lodash/isEmpty'
+
+import Button from 'ui/Button'
+import Modal from 'ui/Modal'
+import { DetailedOrganisation } from 'redux/models/Organisation'
+import { useSelector } from 'react-redux'
+import { StateType } from 'redux/store'
+import Tooltip from 'ui/Tooltip'
+import { removeProjectFromOrganisation } from 'api'
+
+const NoProjects = () => {
+ 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-8 px-4 text-center text-xl leading-snug'>{t('project.settings.noPeople')}</h2>
+ </div>
+ </div>
+ )
+}
+
+interface ProjectListProps {
+ projects: DetailedOrganisation['projects']
+ onRemove: (project: DetailedOrganisation['projects'][number]) => void
+}
+
+const ProjectList = ({ projects, onRemove }: ProjectListProps) => {
+ const { t } = useTranslation('common')
+ const { user } = useSelector((state: StateType) => state.auth)
+
+ return projects.map((project) => (
+ <tr key={project.id} 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'>
+ {project.name}
+ </td>
+ <td className='relative whitespace-nowrap py-4 pr-2 text-sm font-medium'>
+ <div className='flex items-center justify-end'>
+ {project.admin.email !== user.email ? (
+ <Tooltip
+ className='mr-2'
+ text={t('organisations.projectOwnedBy', { email: project.admin.email })}
+ tooltipNode={<InformationCircleIcon className='size-5 text-gray-400' />}
+ />
+ ) : null}
+
+ <Button onClick={() => onRemove(project)} danger small>
+ {t('common.remove')}
+ </Button>
+ </div>
+ </td>
+ </tr>
+ ))
+}
+
+interface ProjectsProps {
+ organisation: DetailedOrganisation
+}
+
+export const Projects = ({ organisation }: ProjectsProps): JSX.Element => {
+ const { t } = useTranslation('common')
+
+ const [showDeleteModal, setShowDeleteModal] = useState(false)
+ const [projectToRemove, setProjectToRemove] = useState<DetailedOrganisation['projects'][number] | null>(null)
+ const [removingProject, setRemovingProject] = useState(false)
+
+ const { projects } = organisation
+
+ const removeProject = async (projectId: string) => {
+ if (removingProject) {
+ return
+ }
+
+ setRemovingProject(true)
+
+ try {
+ await removeProjectFromOrganisation(organisation.id, projectId)
+ toast.success(t('apiNotifications.projectRemovedFromOrganisation'))
+ } catch (reason) {
+ console.error(`[ERROR] Error while deleting a project: ${reason}`)
+ toast.error(t('apiNotifications.projectRemoveError'))
+ } finally {
+ setProjectToRemove(null)
+ setRemovingProject(false)
+ }
+ }
+
+ return (
+ <div className='mb-6 mt-6'>
+ <div className='mb-3 flex items-center justify-between'>
+ <h3 className='mt-2 flex items-center text-lg font-bold text-gray-900 dark:text-gray-50'>
+ {t('organisations.projects')}
+ </h3>
+ <Button className='h-8 pl-2' primary regular type='button' onClick={() => {}}>
+ <>
+ <PlusIcon className='mr-1 h-5 w-5' />
+ {t('organisations.addProject')}
+ </>
+ </Button>
+ </div>
+ <div>
+ {_isEmpty(projects) ? (
+ <NoProjects />
+ ) : (
+ <div className='mt-3 flex flex-col'>
+ <div className='-mx-4 -my-2 overflow-x-auto sm:-mx-6 md:overflow-x-visible lg:-mx-8'>
+ <div className='inline-block min-w-full py-2 md:px-6 lg:px-8'>
+ <div className='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('common.name')}
+ </th>
+ <th scope='col' />
+ </tr>
+ </thead>
+ <tbody className='divide-y divide-gray-300 dark:divide-gray-600'>
+ <ProjectList
+ projects={projects}
+ onRemove={(project) => {
+ setProjectToRemove(project)
+ setShowDeleteModal(true)
+ }}
+ />
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+
+ <Modal
+ onClose={() => {
+ setShowDeleteModal(false)
+ setProjectToRemove(null)
+ }}
+ onSubmit={async () => {
+ await removeProject(projectToRemove!.id)
+ setShowDeleteModal(false)
+ }}
+ submitText={t('common.yes')}
+ closeText={t('common.no')}
+ title={t('organisations.modals.remove.title', { project: projectToRemove?.name })}
+ message={t('organisations.modals.remove.message')}
+ isOpened={showDeleteModal}
+ type='warning'
+ isLoading={removingProject}
+ />
+ </div>
+ )
+}
diff --git a/web/app/pages/Organisations/Settings/index.tsx b/web/app/pages/Organisations/Settings/index.tsx
index 05566f3f5..6742ad040 100644
--- a/web/app/pages/Organisations/Settings/index.tsx
+++ b/web/app/pages/Organisations/Settings/index.tsx
@@ -21,6 +21,7 @@ import { useRequiredParams } from 'hooks/useRequiredParams'
import { DetailedOrganisation } from 'redux/models/Organisation'
import { StateType } from 'redux/store'
import { useSelector } from 'react-redux'
+import { Projects } from './Projects'
const MAX_NAME_LENGTH = 50
@@ -173,7 +174,7 @@ const OrganisationSettings = () => {
document.title = `${t('project.settings.settings')} ${form.name} ${TITLE_SUFFIX}`
}, [form, t])
- if (isLoading || isLoading === null) {
+ if (isLoading || isLoading === null || !organisation) {
return (
<div className='flex min-h-min-footer flex-col bg-gray-50 px-4 py-6 dark:bg-slate-900 sm:px-6 lg:px-8'>
<Loader />
@@ -229,6 +230,7 @@ const OrganisationSettings = () => {
</div>
<hr className='mt-2 border-gray-200 dark:border-gray-600 sm:mt-5' />
<People organisation={organisation} />
+ <Projects organisation={organisation} />
</form>
<Modal
onClose={() => setShowDelete(false)}
diff --git a/web/app/pages/Organisations/index.tsx b/web/app/pages/Organisations/index.tsx
index c59e83674..5d4f004dc 100644
--- a/web/app/pages/Organisations/index.tsx
+++ b/web/app/pages/Organisations/index.tsx
@@ -1,7 +1,6 @@
import React, { useState, useEffect, useMemo } from 'react'
-import { Link, useNavigate } from '@remix-run/react'
+import { Link } from '@remix-run/react'
import { toast } from 'sonner'
-import type i18next from 'i18next'
import { ClientOnly } from 'remix-utils/client-only'
import cx from 'clsx'
import _isEmpty from 'lodash/isEmpty'
@@ -22,9 +21,9 @@ import { XCircleIcon } from '@heroicons/react/24/solid'
import Modal from 'ui/Modal'
import { withAuthentication, auth } from 'hoc/protected'
import Loader from 'ui/Loader'
-import { Badge } from 'ui/Badge'
+import { Badge, BadgeProps } from 'ui/Badge'
import routes from 'utils/routes'
-import { isSelfhosted, ENTRIES_PER_PAGE_DASHBOARD, roleViewer } from 'redux/constants'
+import { ENTRIES_PER_PAGE_DASHBOARD, roleViewer } from 'redux/constants'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import useDebounce from 'hooks/useDebounce'
@@ -38,7 +37,6 @@ import Input from 'ui/Input'
interface OrganisationCardProps {
name?: string
active?: boolean
- t: typeof i18next.t
isPublic?: boolean
confirmed?: boolean
id: string
@@ -66,7 +64,28 @@ const OrganisationCard = ({
const { t } = useTranslation('common')
const [showInviteModal, setShowInviteModal] = useState(false)
const role = useMemo(() => getRole && getRole(id), [getRole, id])
- const navigate = useNavigate()
+
+ const badges = useMemo(() => {
+ const list: BadgeProps[] = []
+
+ if (shared) {
+ if (confirmed) {
+ list.push({ colour: 'green', label: t('dashboard.shared') })
+ } else {
+ list.push({ colour: 'yellow', label: t('common.pending') })
+ }
+ }
+
+ if (isTransferring) {
+ list.push({ colour: 'indigo', label: t('common.transferring') })
+ }
+
+ if (_isNumber(members)) {
+ list.push({ colour: 'slate', label: t('common.xMembers', { number: members + 1 }) })
+ }
+
+ return list
+ }, [t, confirmed, shared, isTransferring, members])
const onAccept = async () => {
// @ts-ignore
@@ -85,127 +104,112 @@ const OrganisationCard = ({
}
}
- const onElementClick = (e: React.MouseEvent<HTMLLIElement>) => {
+ const onElementClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
if (confirmed) {
return
}
- e.stopPropagation()
e.preventDefault()
setShowInviteModal(true)
}
return (
- <div
- onClick={() => {
- navigate(_replace(routes.organisation, ':id', id))
- }}
+ <Link
+ to={_replace(routes.organisation, ':id', id)}
+ onClick={onElementClick}
+ className='min-h-[153.1px] cursor-pointer overflow-hidden rounded-xl border border-gray-200 bg-gray-50 hover:bg-gray-100 dark:border-slate-800/25 dark:bg-slate-800 dark:hover:bg-slate-700'
>
- <li
- onClick={onElementClick}
- className='min-h-[153.1px] cursor-pointer overflow-hidden rounded-xl border border-gray-200 bg-gray-50 hover:bg-gray-100 dark:border-slate-800/25 dark:bg-slate-800 dark:hover:bg-slate-700'
- >
- <div className='px-4 py-4'>
- <div className='flex items-center justify-between'>
- <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>
-
- <div className='flex items-center gap-2' onClick={(e) => e.stopPropagation()}>
- {role !== roleViewer.role && (
- <Link
- to={_replace(routes.organisation, ':id', id)}
- aria-label={`${t('project.settings.settings')} ${name}`}
- >
- <AdjustmentsVerticalIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
- </Link>
- )}
- </div>
- </div>
- <div className='mt-1 flex flex-shrink-0 flex-wrap gap-2'>
- {shared &&
- (confirmed ? (
- <Badge colour='green' label={t('dashboard.shared')} />
- ) : (
- <Badge colour='yellow' label={t('common.pending')} />
- ))}
- {isTransferring && <Badge colour='indigo' label={t('common.transferring')} />}
- {!isSelfhosted && _isNumber(members) && (
- <Badge
- colour='slate'
- label={
- members === 1
- ? t('common.oneMember')
- : t('common.xMembers', {
- number: members,
- })
- }
- />
+ <div className='px-4 py-4'>
+ <div className='flex items-center justify-between'>
+ <p className='truncate text-lg font-semibold text-slate-900 dark:text-gray-50'>{name}</p>
+
+ <div className='flex items-center gap-2' onClick={(e) => e.stopPropagation()}>
+ {role !== roleViewer.role && (
+ <Link
+ to={_replace(routes.organisation, ':id', id)}
+ aria-label={`${t('project.settings.settings')} ${name}`}
+ >
+ <AdjustmentsVerticalIcon className='h-6 w-6 text-gray-800 hover:text-gray-900 dark:text-slate-400 dark:hover:text-slate-500' />
+ </Link>
)}
</div>
</div>
- {!confirmed && (
- <Modal
- onClose={() => {
- setShowInviteModal(false)
- }}
- onSubmit={() => {
- setShowInviteModal(false)
- onAccept()
- }}
- submitText={t('common.accept')}
- type='confirmed'
- closeText={t('common.cancel')}
- title={t('dashboard.invitationFor', { project: name })}
- message={t('dashboard.invitationDesc', { project: name })}
- isOpened={showInviteModal}
- />
- )}
- </li>
- </div>
+ <div className='mt-1 flex flex-shrink-0 flex-wrap gap-2'>
+ {badges.map((badge) => (
+ <Badge key={badge.label} {...badge} />
+ ))}
+ </div>
+ </div>
+ {!confirmed && (
+ <Modal
+ onClose={() => {
+ setShowInviteModal(false)
+ }}
+ onSubmit={() => {
+ setShowInviteModal(false)
+ onAccept()
+ }}
+ submitText={t('common.accept')}
+ type='confirmed'
+ closeText={t('common.cancel')}
+ title={t('dashboard.invitationFor', { project: name })}
+ message={t('dashboard.invitationDesc', { project: name })}
+ isOpened={showInviteModal}
+ />
+ )}
+ </Link>
)
}
interface INoOrganisations {
- t: typeof i18next.t
onClick: () => void
}
interface IAddOrganisation {
- t: typeof i18next.t
onClick: () => void
sitesCount: number
}
-const NoOrganisations = ({ t, onClick }: INoOrganisations): JSX.Element => (
- <button
- type='button'
- onClick={onClick}
- className='relative mx-auto block max-w-lg rounded-lg border-2 border-dashed border-gray-300 p-12 text-center hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
- >
- <BuildingOffice2Icon className='mx-auto h-12 w-12 text-gray-400 dark:text-gray-200' />
- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50'>
- {t('dashboard.createProject')}
- </span>
- </button>
-)
-
-const AddOrganisation = ({ t, onClick, sitesCount }: IAddOrganisation): JSX.Element => (
- <li
- onClick={onClick}
- className={cx(
- 'group flex h-auto min-h-[153.1px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400',
- {
- 'lg:min-h-[auto]': sitesCount % 3 !== 0,
- },
- )}
- >
- <div>
- <BuildingOffice2Icon className='mx-auto h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400' />
- <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>
- {t('organisations.new')}
+const NoOrganisations = ({ onClick }: INoOrganisations) => {
+ const { t } = useTranslation('common')
+
+ return (
+ <button
+ type='button'
+ onClick={onClick}
+ className='relative mx-auto block max-w-lg rounded-lg border-2 border-dashed border-gray-300 p-12 text-center hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ <BuildingOffice2Icon className='mx-auto h-12 w-12 text-gray-400 dark:text-gray-200' />
+ <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50'>
+ {t('dashboard.createProject')}
</span>
- </div>
- </li>
-)
+ </button>
+ )
+}
+
+const AddOrganisation = ({ onClick, sitesCount }: IAddOrganisation) => {
+ const { t } = useTranslation('common')
+
+ return (
+ <button
+ type='button'
+ onClick={onClick}
+ className={cx(
+ 'group flex h-auto min-h-[153.1px] cursor-pointer items-center justify-center rounded-lg border-2 border-dashed border-gray-300 hover:border-gray-400',
+ {
+ 'lg:min-h-[auto]': sitesCount % 3 !== 0,
+ },
+ )}
+ >
+ <div>
+ <BuildingOffice2Icon className='mx-auto h-12 w-12 text-gray-400 group-hover:text-gray-500 dark:text-gray-200 group-hover:dark:text-gray-400' />
+ <span className='mt-2 block text-sm font-semibold text-gray-900 dark:text-gray-50 group-hover:dark:text-gray-400'>
+ {t('organisations.new')}
+ </span>
+ </div>
+ </button>
+ )
+}
const Organisations = () => {
const { t } = useTranslation('common')
@@ -424,9 +428,9 @@ const Organisations = () => {
{() => (
<div>
{_isEmpty(organisations) ? (
- <NoOrganisations t={t} onClick={onNewOrganisation} />
+ <NoOrganisations onClick={onNewOrganisation} />
) : (
- <ul className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
+ <div className='grid grid-cols-1 gap-x-6 gap-y-3 lg:grid-cols-3 lg:gap-y-6'>
{_map(
organisations,
// @ts-expect-error
@@ -435,7 +439,6 @@ const Organisations = () => {
key={id}
members={1 + _size(share)}
id={id}
- t={t}
name={name}
active={active}
isPublic={isPublic}
@@ -447,8 +450,8 @@ const Organisations = () => {
/>
),
)}
- <AddOrganisation sitesCount={_size(organisations)} t={t} onClick={onNewOrganisation} />
- </ul>
+ <AddOrganisation sitesCount={_size(organisations)} onClick={onNewOrganisation} />
+ </div>
)}
</div>
)}
diff --git a/web/app/pages/Project/New/index.tsx b/web/app/pages/Project/New/index.tsx
index 43794d2a7..60748d109 100644
--- a/web/app/pages/Project/New/index.tsx
+++ b/web/app/pages/Project/New/index.tsx
@@ -71,6 +71,7 @@ const NewProject = () => {
try {
await createProject({
name: data.name || DEFAULT_PROJECT_NAME,
+ organisationId: data.organisationId,
})
trackCustom('PROJECT_CREATED')
navigate(routes.dashboard)
@@ -165,7 +166,7 @@ const NewProject = () => {
keyExtractor={(item) => item.id || 'not-set'}
labelExtractor={(item) => {
if (item.id === undefined) {
- return <span className='italic text-gray-600 dark:text-gray-200'>{t('common.notSet')}</span>
+ return <span className='italic'>{t('common.notSet')}</span>
}
return item.name
diff --git a/web/app/pages/Project/Settings/People/People.tsx b/web/app/pages/Project/Settings/People/People.tsx
index 80370d3fc..9b7585c94 100644
--- a/web/app/pages/Project/Settings/People/People.tsx
+++ b/web/app/pages/Project/Settings/People/People.tsx
@@ -1,4 +1,3 @@
-import type i18next from 'i18next'
import React, { useState, useEffect, useRef } from 'react'
import { toast } from 'sonner'
import { ChevronDownIcon, CheckIcon } from '@heroicons/react/24/solid'
@@ -23,18 +22,21 @@ import useOnClickOutside from 'hooks/useOnClickOutside'
import { IProject, IShareOwnerProject } from 'redux/models/IProject'
import { IUser } from 'redux/models/IUser'
-const NoPeople = ({ t }: { t: typeof i18next.t }) => (
- <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-8 px-4 text-center text-xl leading-snug'>{t('project.settings.noPeople')}</h2>
+const NoPeople = () => {
+ 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-8 px-4 text-center text-xl leading-snug'>{t('project.settings.noPeople')}</h2>
+ </div>
</div>
- </div>
-)
+ )
+}
interface IUsersList {
data: IShareOwnerProject
onRemove: (id: string) => void
- t: typeof i18next.t
share?: IShareOwnerProject[]
setProjectShareData: (item: Partial<IProject>, id: string, shared: boolean) => void
pid: string
@@ -46,7 +48,6 @@ interface IUsersList {
const UsersList = ({
data,
onRemove,
- t,
share,
setProjectShareData,
pid,
@@ -54,6 +55,7 @@ const UsersList = ({
authedUserEmail,
isSharedProject,
}: IUsersList) => {
+ const { t } = useTranslation('common')
const [open, setOpen] = useState(false)
const [showDeleteModal, setShowDeleteModal] = useState(false)
const openRef = useRef<HTMLDivElement>(null)
@@ -319,7 +321,7 @@ const People: React.FunctionComponent<IPeopleProps> = ({
</div>
<div>
{_isEmpty(share) ? (
- <NoPeople t={t} />
+ <NoPeople />
) : (
<div className='mt-3 flex flex-col'>
<div className='-mx-4 -my-2 overflow-x-auto sm:-mx-6 md:overflow-x-visible lg:-mx-8'>
@@ -350,7 +352,6 @@ const People: React.FunctionComponent<IPeopleProps> = ({
data={user}
key={user.id}
onRemove={onRemove}
- t={t}
language={language}
share={project.share}
setProjectShareData={setProjectShareData}
diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsx
index 24e232a11..1f5534e2f 100644
--- a/web/app/pages/Project/Settings/ProjectSettings.tsx
+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx
@@ -16,7 +16,7 @@ import _filter from 'lodash/filter'
import _map from 'lodash/map'
import _toUpper from 'lodash/toUpper'
import _includes from 'lodash/includes'
-import { ExclamationTriangleIcon, TrashIcon, RocketLaunchIcon } from '@heroicons/react/24/outline'
+import { TrashIcon } from '@heroicons/react/24/outline'
import { withAuthentication, auth } from 'hoc/protected'
import {
@@ -55,6 +55,7 @@ import People from './People'
import Emails from './Emails'
import Select from 'ui/Select'
import { useRequiredParams } from 'hooks/useRequiredParams'
+import { ArrowLeftRight, RotateCcw } from 'lucide-react'
const MAX_NAME_LENGTH = 50
const MAX_ORIGINS_LENGTH = 300
@@ -352,6 +353,17 @@ const ProjectSettings = ({
] as const
}, [t])
+ const organisations = useMemo(
+ () => [
+ {
+ id: undefined,
+ name: t('common.notSet'),
+ },
+ ...(user.manageableOrganisations || []),
+ ],
+ [user.manageableOrganisations, t],
+ )
+
const sharableLink = useMemo(() => {
const origin = requestOrigin || isBrowser ? window.location.origin : 'https://swetrix.com'
@@ -698,6 +710,29 @@ const ProjectSettings = ({
label={t('project.settings.protected')}
hint={t('project.settings.protectedHint')}
/>
+ {organisations.length > 1 && (
+ <div className='mt-4'>
+ <Select
+ items={organisations}
+ keyExtractor={(item) => item.id || 'not-set'}
+ labelExtractor={(item) => {
+ if (item.id === undefined) {
+ return <span className='italic'>{t('common.notSet')}</span>
+ }
+
+ return item.name
+ }}
+ onSelect={(item) => {
+ setForm((oldForm) => ({
+ ...oldForm,
+ organisationId: item.id,
+ }))
+ }}
+ label={t('project.settings.organisation')}
+ title={organisations.find((org) => org.id === form.organisationId)?.name}
+ />
+ </div>
+ )}
<div className='mt-8 flex flex-wrap justify-center gap-2 sm:justify-between'>
<div className='flex flex-wrap items-center gap-2'>
<Button
@@ -717,7 +752,7 @@ const ProjectSettings = ({
{!isSelfhosted && (
<Button onClick={() => setShowTransfer(true)} semiDanger semiSmall>
<>
- <RocketLaunchIcon className='mr-1 h-5 w-5' />
+ <ArrowLeftRight className='mr-1 h-5 w-5' />
{t('project.settings.transfer')}
</>
</Button>
@@ -729,7 +764,7 @@ const ProjectSettings = ({
semiSmall
>
<>
- <TrashIcon className='mr-1 h-5 w-5' />
+ <RotateCcw className='mr-1 h-5 w-5' />
{t('project.settings.reset')}
</>
</Button>
@@ -740,7 +775,7 @@ const ProjectSettings = ({
semiSmall
>
<>
- <ExclamationTriangleIcon className='mr-1 h-5 w-5' />
+ <TrashIcon className='mr-1 h-5 w-5' />
{t('project.settings.delete')}
</>
</Button>
diff --git a/web/app/redux/models/IProject.ts b/web/app/redux/models/IProject.ts
index d3d6f5bd3..dbc786c6c 100644
--- a/web/app/redux/models/IProject.ts
+++ b/web/app/redux/models/IProject.ts
@@ -1,3 +1,5 @@
+import { Organisation } from './Organisation'
+
interface _IOverallPeriodStats {
all: number
unique?: number
@@ -89,6 +91,7 @@ export interface IProject {
isTransferring?: boolean
isPasswordProtected?: boolean
organisationId?: string
+ organisation?: Organisation
password?: string
isLocked: boolean
isDataExists: boolean
diff --git a/web/app/redux/models/Organisation.ts b/web/app/redux/models/Organisation.ts
index 20e4d7d0a..792da04db 100644
--- a/web/app/redux/models/Organisation.ts
+++ b/web/app/redux/models/Organisation.ts
@@ -15,4 +15,11 @@ export interface DetailedOrganisation extends Organisation {
email: string
}
}[]
+ projects: {
+ id: string
+ name: string
+ admin: {
+ email: string
+ }
+ }[]
}
diff --git a/web/app/ui/Badge.tsx b/web/app/ui/Badge.tsx
index f2bdf4765..74eb34203 100644
--- a/web/app/ui/Badge.tsx
+++ b/web/app/ui/Badge.tsx
@@ -1,13 +1,13 @@
import React from 'react'
import cx from 'clsx'
-interface IBadge {
+export interface BadgeProps {
label: string
className?: string
- colour?: 'red' | 'yellow' | 'green' | 'indigo' | 'slate'
+ colour?: 'red' | 'yellow' | 'green' | 'indigo' | 'slate' | 'sky'
}
-const Badge = ({ label, className, colour }: IBadge): JSX.Element => (
+export const Badge = ({ label, className, colour }: BadgeProps): JSX.Element => (
<span
className={cx('inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset', className, {
'bg-slate-50 text-slate-600 ring-slate-500/10 dark:bg-slate-400/10 dark:text-slate-400 dark:ring-slate-400/20':
@@ -20,10 +20,10 @@ const Badge = ({ label, className, colour }: IBadge): JSX.Element => (
colour === 'green',
'bg-red-50 text-red-700 ring-red-600/10 dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20':
colour === 'red',
+ 'bg-sky-50 text-sky-700 ring-sky-600/20 dark:bg-sky-400/10 dark:text-sky-400 dark:ring-sky-400/20':
+ colour === 'sky',
})}
>
{label}
</span>
)
-
-export { Badge }
diff --git a/web/app/ui/Chart.tsx b/web/app/ui/Chart.tsx
index 4156021b7..98cd6b46c 100644
--- a/web/app/ui/Chart.tsx
+++ b/web/app/ui/Chart.tsx
@@ -43,11 +43,7 @@ const Chart = ({ current, options }: IChart): JSX.Element => {
return destroy
})
- return (
- <div>
- <div id={current} data-testid='chart' />
- </div>
- )
+ return <div id={current} />
}
export default Chart
diff --git a/web/app/ui/Flatpicker.tsx b/web/app/ui/Flatpicker.tsx
index ecd5fcb10..bbe56da84 100644
--- a/web/app/ui/Flatpicker.tsx
+++ b/web/app/ui/Flatpicker.tsx
@@ -105,7 +105,6 @@ class FlatPicker extends React.Component<
<div className={cx('flatpicker-custom h-0', className)}>
<Flatpickr
id='calendar'
- data-testid='calendar'
value={value}
options={{
mode: 'range',
diff --git a/web/app/ui/MultiProgress.tsx b/web/app/ui/MultiProgress.tsx
index a15ecd67d..d066e3f76 100644
--- a/web/app/ui/MultiProgress.tsx
+++ b/web/app/ui/MultiProgress.tsx
@@ -2,20 +2,20 @@ import React, { memo } from 'react'
import cx from 'clsx'
import _map from 'lodash/map'
-interface IProgress {
+interface Progress {
value: number
lightColour: string
darkColour: string
}
-interface IMultiProgress {
- progress: IProgress[]
+interface MultiProgressProps {
+ progress: Progress[]
theme: 'dark' | 'light'
className?: string
}
-const MultiProgress = ({ progress, theme, className }: IMultiProgress): JSX.Element => (
- <div className='relative' data-testid='multiprogress'>
+const MultiProgress = ({ progress, theme, className }: MultiProgressProps) => (
+ <div className='relative'>
<div className={cx('flex h-5 overflow-hidden rounded bg-gray-200 text-xs dark:bg-slate-600', className)}>
{_map(progress, ({ value, lightColour, darkColour }) => (
<div
diff --git a/web/app/ui/Progress.tsx b/web/app/ui/Progress.tsx
index bcf6defda..52dbc6200 100644
--- a/web/app/ui/Progress.tsx
+++ b/web/app/ui/Progress.tsx
@@ -1,11 +1,11 @@
import React, { memo } from 'react'
-interface IProgress {
+interface ProgressProps {
now: number
}
-const Progress = ({ now }: IProgress): JSX.Element => (
- <div className='relative' data-testid='progress'>
+const Progress = ({ now }: ProgressProps) => (
+ <div className='relative'>
<div className='flex h-2 overflow-hidden rounded bg-blue-200 text-xs dark:bg-slate-600'>
<div
style={{ width: `${now}%` }}
diff --git a/web/app/ui/Tooltip.tsx b/web/app/ui/Tooltip.tsx
index 56a51f40d..d4cd88bb7 100644
--- a/web/app/ui/Tooltip.tsx
+++ b/web/app/ui/Tooltip.tsx
@@ -1,25 +1,51 @@
-import React, { memo } from 'react'
import { QuestionMarkCircleIcon } from '@heroicons/react/24/solid'
+import React, { forwardRef, memo } from 'react'
+import * as TooltipPrimitive from '@radix-ui/react-tooltip'
import cx from 'clsx'
-interface ITooltip {
+const TooltipProvider = TooltipPrimitive.Provider
+
+const TooltipRoot = TooltipPrimitive.Root
+
+const TooltipTrigger = TooltipPrimitive.Trigger
+
+const TooltipContent = forwardRef<
+ React.ElementRef<typeof TooltipPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
+>(({ className, sideOffset = 2, ...props }, ref) => (
+ <TooltipPrimitive.Portal>
+ <TooltipPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cx(
+ // Animation does not work
+ // 'transform-gpu transition-all duration-300 ease-in-out',
+ // 'data-[state=closed]:scale-90 data-[state=delayed-open]:scale-100',
+ // 'data-[state=closed]:opacity-0 data-[state=delayed-open]:opacity-100',
+ 'z-50 overflow-hidden rounded-md bg-slate-800 px-3 py-1.5 text-xs text-white ring-1 ring-slate-900/80',
+ className,
+ )}
+ {...props}
+ />
+ </TooltipPrimitive.Portal>
+))
+TooltipContent.displayName = TooltipPrimitive.Content.displayName
+
+interface TooltipProps {
text: string | number | React.ReactNode
className?: string
tooltipNode?: JSX.Element
}
-const Tooltip = ({ text, className, tooltipNode }: ITooltip): JSX.Element => (
- <div className={cx('group relative flex flex-col items-center', className)} data-testid='tooltip-wrapper'>
- {tooltipNode || (
- <QuestionMarkCircleIcon className='h-5 w-5 text-gray-700 dark:text-gray-300' data-testid='tooltip-icon' />
- )}
- <div className='absolute bottom-0 mb-6 hidden flex-col items-center group-hover:flex'>
- <span className='whitespace-no-wrap relative z-10 w-60 rounded-md bg-gray-700 p-2 text-xs leading-none text-white opacity-95 shadow-lg'>
- {text}
- </span>
- <div className='-mt-2 h-3 w-3 rotate-45 bg-gray-700 opacity-95' />
- </div>
- </div>
+const Tooltip = ({ text, className, tooltipNode }: TooltipProps) => (
+ <TooltipProvider delayDuration={200}>
+ <TooltipRoot>
+ <TooltipTrigger className={className}>
+ {tooltipNode || <QuestionMarkCircleIcon className='h-5 w-5 text-gray-700 dark:text-gray-300' />}
+ </TooltipTrigger>
+ <TooltipContent>{text}</TooltipContent>
+ </TooltipRoot>
+ </TooltipProvider>
)
export default memo(Tooltip)
diff --git a/web/package-lock.json b/web/package-lock.json
index d649254ed..c10c07719 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -10,6 +10,7 @@
"@heroicons/react": "^2.1.5",
"@icons-pack/react-simple-icons": "^10.1.0",
"@nivo/sankey": "^0.87.0",
+ "@radix-ui/react-tooltip": "^1.1.4",
"@reduxjs/toolkit": "^1.9.7",
"@remix-run/node": "^2.13.1",
"@remix-run/react": "^2.13.1",
@@ -1237,6 +1238,411 @@
"node": ">=14"
}
},
+ "node_modules/@radix-ui/primitive": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.1.0.tgz",
+ "integrity": "sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==",
+ "license": "MIT"
+ },
+ "node_modules/@radix-ui/react-arrow": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
+ "integrity": "sha512-FmlW1rCg7hBpEBwFbjHwCW6AmWLQM6g/v0Sn8XbP9NvmSZ2San1FpQeyPtufzOMSIx7Y4dzjlHoifhp+7NkZhw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.0.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-compose-refs": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.0.tgz",
+ "integrity": "sha512-b4inOtiaOnYf9KWyO3jAeeCG6FeyfY6ldiEPanbUjWd+xIk5wZeHa8yVwmrJ2vderhu/BQvzCrJI0lHd+wIiqw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-context": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.1.tgz",
+ "integrity": "sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-dismissable-layer": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.1.1.tgz",
+ "integrity": "sha512-QSxg29lfr/xcev6kSz7MAlmDnzbP1eI/Dwn3Tp1ip0KT5CUELsxkekFEMVBEoykI3oV39hKT4TKZzBNMbcTZYQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-callback-ref": "1.1.0",
+ "@radix-ui/react-use-escape-keydown": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-id": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.1.0.tgz",
+ "integrity": "sha512-EJUrI8yYh7WOjNOqpoJaf1jlFIH2LvtgAl+YcFqNCa+4hj64ZXmPkAKOFs/ukjz3byN6bdb/AVUqHkI8/uWWMA==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-popper": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.2.0.tgz",
+ "integrity": "sha512-ZnRMshKF43aBxVWPWvbj21+7TQCvhuULWJ4gNIKYpRlQt5xGRhLx66tMp8pya2UkGHTSlhpXwmjqltDYHhw7Vg==",
+ "license": "MIT",
+ "dependencies": {
+ "@floating-ui/react-dom": "^2.0.0",
+ "@radix-ui/react-arrow": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-context": "1.1.0",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-callback-ref": "1.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0",
+ "@radix-ui/react-use-rect": "1.1.0",
+ "@radix-ui/react-use-size": "1.1.0",
+ "@radix-ui/rect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-popper/node_modules/@radix-ui/react-context": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-context/-/react-context-1.1.0.tgz",
+ "integrity": "sha512-OKrckBy+sMEgYM/sMmqmErVn0kZqrHPJze+Ql3DzYsDDp0hl0L62nx/2122/Bvps1qz645jlcu2tD9lrRSdf8A==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-portal": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.2.tgz",
+ "integrity": "sha512-WeDYLGPxJb/5EGBoedyJbT0MpoULmwnIPMJMSldkuiMsBAv7N1cRdsTWZWht9vpPOiN3qyiGAtbK2is47/uMFg==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-presence": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-presence/-/react-presence-1.1.1.tgz",
+ "integrity": "sha512-IeFXVi4YS1K0wVZzXNrbaaUvIJ3qdY+/Ih4eHFhWA9SwGR9UDX7Ck8abvL57C4cv3wwMvUE0OG69Qc3NCcTe/A==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-primitive": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.0.0.tgz",
+ "integrity": "sha512-ZSpFm0/uHa8zTvKBDjLFWLo8dkr4MBsiDLz0g3gMUwqgLHz9rTaRRGYDgvZPtBJgYCBKXkS9fzmoySgr8CO6Cw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-slot": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-slot": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.1.0.tgz",
+ "integrity": "sha512-FUCf5XMfmW4dtYl69pdS4DbxKy8nj4M7SafBgPllysxmdachynNflAdp/gCsnYWNDnge6tI9onzMp5ARYc1KNw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-compose-refs": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-tooltip": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.1.4.tgz",
+ "integrity": "sha512-QpObUH/ZlpaO4YgHSaYzrLO2VuO+ZBFFgGzjMUPwtiYnAzzNNDPJeEGRrT7qNOrWm/Jr08M1vlp+vTHtnSQ0Uw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.0",
+ "@radix-ui/react-compose-refs": "1.1.0",
+ "@radix-ui/react-context": "1.1.1",
+ "@radix-ui/react-dismissable-layer": "1.1.1",
+ "@radix-ui/react-id": "1.1.0",
+ "@radix-ui/react-popper": "1.2.0",
+ "@radix-ui/react-portal": "1.1.2",
+ "@radix-ui/react-presence": "1.1.1",
+ "@radix-ui/react-primitive": "2.0.0",
+ "@radix-ui/react-slot": "1.1.0",
+ "@radix-ui/react-use-controllable-state": "1.1.0",
+ "@radix-ui/react-visually-hidden": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-callback-ref": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.0.tgz",
+ "integrity": "sha512-CasTfvsy+frcFkbXtSJ2Zu9JHpN8TYKxkgJGWbjiZhFivxaeW7rMeZt7QELGVLaYVfFMsKHjb7Ak0nMEe+2Vfw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-controllable-state": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.1.0.tgz",
+ "integrity": "sha512-MtfMVJiSr2NjzS0Aa90NPTnvTSg6C/JLCV7ma0W6+OMV78vd8OyRpID+Ng9LxzsPbLeuBnWBA1Nq30AtBIDChw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-use-callback-ref": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-escape-keydown": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.1.0.tgz",
+ "integrity": "sha512-L7vwWlR1kTTQ3oh7g1O0CBF3YCyyTj8NmhLR+phShpyA50HCfBFKVJTpshm9PzLiKmehsrQzTYTpX9HvmC9rhw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-use-callback-ref": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-layout-effect": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.0.tgz",
+ "integrity": "sha512-+FPE0rOdziWSrH9athwI1R0HDVbWlEhd+FR+aSDk4uWGmSJ9Z54sdZVDQPZAinJhJXwfT+qnj969mCsT2gfm5w==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-rect": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-rect/-/react-use-rect-1.1.0.tgz",
+ "integrity": "sha512-0Fmkebhr6PiseyZlYAOtLS+nb7jLmpqTrJyv61Pe68MKYW6OWdRE2kI70TaYY27u7H0lajqM3hSMMLFq18Z7nQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/rect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-use-size": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-use-size/-/react-use-size-1.1.0.tgz",
+ "integrity": "sha512-XW3/vWuIXHa+2Uwcc2ABSfcCledmXhhQPlGbfcRXbiUQI5Icjcg19BGCZVKKInYbvUCut/ufbbLLPFC5cbb1hw==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-use-layout-effect": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-visually-hidden": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.1.0.tgz",
+ "integrity": "sha512-N8MDZqtgCgG5S3aV60INAB475osJousYpZ4cTJ2cFbMpdHS5Y6loLTH8LPtkj2QN0x93J30HT/M3qJXM0+lyeQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.0.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/rect": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@radix-ui/rect/-/rect-1.1.0.tgz",
+ "integrity": "sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==",
+ "license": "MIT"
+ },
"node_modules/@react-aria/focus": {
"version": "3.18.4",
"license": "Apache-2.0",
@@ -2235,7 +2641,7 @@
},
"node_modules/@types/react-dom": {
"version": "18.3.1",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"@types/react": "*"
diff --git a/web/package.json b/web/package.json
index 565f8f390..8fd309481 100644
--- a/web/package.json
+++ b/web/package.json
@@ -23,6 +23,7 @@
"@heroicons/react": "^2.1.5",
"@icons-pack/react-simple-icons": "^10.1.0",
"@nivo/sankey": "^0.87.0",
+ "@radix-ui/react-tooltip": "^1.1.4",
"@reduxjs/toolkit": "^1.9.7",
"@remix-run/node": "^2.13.1",
"@remix-run/react": "^2.13.1",
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 8e4b79210..1ad8aa30a 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -49,7 +49,9 @@
"viewDeleted": "View has been deleted",
"noAIForecastAvailable": "AI forecast is not available for this project yet",
"organisationCreated": "Organisation has been created",
- "organisationCreateError": "Error occurred while creating the organisation"
+ "organisationCreateError": "Error occurred while creating the organisation",
+ "projectRemovedFromOrganisation": "The project has been removed from the organisation",
+ "projectRemoveError": "Error occurred while removing the project from the organisation"
},
"common": {
"features": "Features",
@@ -108,7 +110,8 @@
"fixIt": "Fix it",
"errorOccured": "An error occurred: {{error}}",
"name": "Name",
- "notSet": "Not set"
+ "notSet": "Not set",
+ "remove": "Remove"
},
"performance": {
"slogan": "End user <span>performance monitoring</span> to deliver fast websites.",
@@ -624,7 +627,16 @@
"name": "Viewer",
"desc": "Can only access the organisation and its projects without the ability to change any settings."
}
- }
+ },
+ "projects": "Projects",
+ "addProject": "Add project",
+ "modals": {
+ "remove": {
+ "title": "Remove {{project}}?",
+ "message": "Are you sure you want to remove this project from the organisation? Once removed, organisation members will no longer have access to this project unless they are added in the project settings."
+ }
+ },
+ "projectOwnedBy": "This project is owned by {{email}}"
},
"dashboard": {
"uptime": "Uptime",