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!

feat: organisation settings

Blue Mousebe9854e1099b
diff --git a/backend/apps/cloud/src/organisation/organisation.controller.ts b/backend/apps/cloud/src/organisation/organisation.controller.ts
index ab28215b6..4a3e3aad2 100644
--- a/backend/apps/cloud/src/organisation/organisation.controller.ts
+++ b/backend/apps/cloud/src/organisation/organisation.controller.ts
@@ -92,6 +92,17 @@ export class OrganisationController {
return paginated
}
+ @ApiBearerAuth()
+ @Get('/:orgId')
+ @ApiResponse({ status: 200, type: Organisation })
+ @Auth([], true)
+ async getOne(@Param('orgId') orgId: string): Promise<Organisation> {
+ return this.organisationService.findOne({
+ where: { id: orgId },
+ relations: ['members'],
+ })
+ }
+
@ApiBearerAuth()
@Post('/')
@UseGuards(JwtAccessTokenGuard, RolesGuard)
diff --git a/backend/apps/cloud/src/organisation/organisation.service.ts b/backend/apps/cloud/src/organisation/organisation.service.ts
index b0afbf620..339b8927d 100644
--- a/backend/apps/cloud/src/organisation/organisation.service.ts
+++ b/backend/apps/cloud/src/organisation/organisation.service.ts
@@ -1,6 +1,6 @@
import { Injectable, ForbiddenException } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
-import { FindOptionsWhere, Repository } from 'typeorm'
+import { FindOneOptions, FindOptionsWhere, Repository } from 'typeorm'
import { find as _find } from 'lodash'
import { Organisation } from './entity/organisation.entity'
@@ -24,7 +24,7 @@ export class OrganisationService {
return this.organisationRepository.save(org)
}
- async findOne(options: any): Promise<Organisation> {
+ async findOne(options: FindOneOptions<Organisation>): Promise<Organisation> {
return this.organisationRepository.findOne(options)
}
@@ -35,7 +35,9 @@ export class OrganisationService {
return this.membershipRepository.save(membership)
}
- async findOneMembership(options: any): Promise<OrganisationMember> {
+ async findOneMembership(
+ options: FindOneOptions<OrganisationMember>,
+ ): Promise<OrganisationMember> {
return this.membershipRepository.findOne(options)
}
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index dd0bf6116..446612a01 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -289,6 +289,15 @@ export const getOrganisations = (take: number = 0, skip: number = 0, search?: st
throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
})
+export const getOrganisation = (id: string) =>
+ api
+ .get(`/organisation/${id}`)
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message
+ })
+
export const createOrganisation = (name: string) =>
api
.post('/organisation', { name })
diff --git a/web/app/components/Header/index.tsx b/web/app/components/Header/index.tsx
index 3742e8e99..35421005b 100644
--- a/web/app/components/Header/index.tsx
+++ b/web/app/components/Header/index.tsx
@@ -445,6 +445,18 @@ const ProfileMenu = ({
</Link>
)}
</MenuItem>
+ <MenuItem>
+ {({ active }) => (
+ <Link
+ to={routes.organisations}
+ className={cx('block px-4 py-2 text-sm text-gray-700 dark:text-gray-50', {
+ 'bg-gray-100 dark:bg-slate-800': active,
+ })}
+ >
+ {t('organisations.organisations')}
+ </Link>
+ )}
+ </MenuItem>
<MenuItem>
{({ active }) => (
<p
@@ -1137,6 +1149,13 @@ const Header: React.FC<IHeader> = ({ ssrTheme, authenticated, refPage, transpare
>
{t('common.accountSettings')}
</Link>
+ <Link
+ to={routes.organisations}
+ onClick={() => setMobileMenuOpen(false)}
+ className='-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-300/50 dark:text-gray-50 dark:hover:bg-slate-700/80'
+ >
+ {t('organisations.organisations')}
+ </Link>
<span
className='-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-300/50 dark:text-gray-50 dark:hover:bg-slate-700/80'
onClick={logoutHandler}
diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsx
new file mode 100644
index 000000000..dc4ebffa1
--- /dev/null
+++ b/web/app/pages/Organisations/Settings/People.tsx
@@ -0,0 +1,472 @@
+import type i18next from 'i18next'
+import React, { useState, useEffect, useRef } from 'react'
+import { toast } from 'sonner'
+import { ChevronDownIcon, CheckIcon } from '@heroicons/react/24/solid'
+import { TrashIcon, UserPlusIcon, CurrencyDollarIcon } from '@heroicons/react/24/outline'
+import { useTranslation } from 'react-i18next'
+import cx from 'clsx'
+import dayjs from 'dayjs'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
+import _map from 'lodash/map'
+
+import { shareProject, changeShareRole } from 'api'
+import { isValidEmail } from 'utils/validator'
+import Input from 'ui/Input'
+import { Badge } from 'ui/Badge'
+import Button from 'ui/Button'
+import Modal from 'ui/Modal'
+import { roles, roleViewer, roleAdmin, INVITATION_EXPIRES_IN } from 'redux/constants'
+import useOnClickOutside from 'hooks/useOnClickOutside'
+import { IProject, IShareOwnerProject } from 'redux/models/IProject'
+import { Organisation } from 'redux/models/Organisation'
+
+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>
+ </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
+ language: string
+ authedUserEmail: string | undefined
+ isSharedProject: boolean
+}
+
+const UsersList = ({
+ data,
+ onRemove,
+ t,
+ share,
+ setProjectShareData,
+ pid,
+ language,
+ authedUserEmail,
+ isSharedProject,
+}: IUsersList) => {
+ const [open, setOpen] = useState(false)
+ const [showDeleteModal, setShowDeleteModal] = useState(false)
+ const openRef = useRef<HTMLDivElement>(null)
+ useOnClickOutside(openRef, () => setOpen(false))
+ const { id, created, confirmed, role, user } = data || {}
+
+ const changeRole = async (newRole: string) => {
+ try {
+ const results = await changeShareRole(id, { role: newRole })
+ const newShared: IShareOwnerProject[] = _map(share, (itShare) => {
+ if (itShare.id === results.id) {
+ return { ...results, user: itShare.user, role: newRole }
+ }
+ return itShare
+ })
+ setProjectShareData({ share: newShared }, pid, isSharedProject)
+ toast.success(t('apiNotifications.roleUpdated'))
+ } catch (reason) {
+ console.error(`[ERROR] Error while updating user's role: ${reason}`)
+ toast.error(t('apiNotifications.roleUpdateError'))
+ }
+
+ setOpen(false)
+ }
+
+ 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'>
+ {user.email}
+ </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 pr-2 text-right text-sm font-medium'>
+ {confirmed ? (
+ <div ref={openRef}>
+ <button
+ onClick={() => setOpen(!open)}
+ type='button'
+ disabled={user.email === authedUserEmail}
+ className='inline-flex items-center rounded-full border border-gray-200 bg-white py-0.5 pl-2 pr-1 text-sm font-medium leading-5 text-gray-700 shadow-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-80 dark:border-gray-600 dark:bg-slate-800 dark:text-gray-200 dark:hover:bg-gray-600'
+ >
+ {t(`project.settings.roles.${role}.name`)}
+ <ChevronDownIcon style={{ transform: open ? 'rotate(180deg)' : '' }} className='ml-0.5 h-4 w-4 pt-px' />
+ </button>
+ {open && (
+ <ul className='absolute right-0 z-10 mt-2 w-72 origin-top-right divide-y divide-gray-200 rounded-md bg-white text-left shadow-lg focus:outline-none dark:divide-gray-700 dark:bg-slate-900'>
+ {_map(roles, (itRole) => (
+ <li
+ onClick={() => changeRole(itRole)}
+ className='group flex cursor-pointer items-center justify-between p-4 hover:bg-indigo-600'
+ key={itRole}
+ >
+ <div>
+ <p className='font-bold text-gray-700 group-hover:text-gray-200 dark:text-gray-200'>
+ {t(`project.settings.roles.${itRole}.name`)}
+ </p>
+ <p className='mt-1 text-sm text-gray-500 group-hover:text-gray-200'>
+ {t(`project.settings.roles.${itRole}.shortDesc`)}
+ </p>
+ </div>
+ {role === itRole && (
+ <span className='text-indigo-600 group-hover:text-gray-200'>
+ <CheckIcon className='ml-1 h-7 w-7 pt-px' />
+ </span>
+ )}
+ </li>
+ ))}
+ <li
+ onClick={() => {
+ setOpen(false)
+ setShowDeleteModal(true)
+ }}
+ className='group flex cursor-pointer items-center justify-between p-4 hover:bg-gray-200 dark:hover:bg-gray-700'
+ >
+ <div>
+ <p className='font-bold text-red-600 dark:text-red-500'>{t('project.settings.removeMember')}</p>
+ </div>
+ </li>
+ </ul>
+ )}
+ </div>
+ ) : (
+ <div className='flex items-center justify-end'>
+ <Badge colour='yellow' className='mr-3' label={t('common.pending')} />
+ <Button
+ type='button'
+ className='rounded-md bg-white text-base font-medium text-indigo-700 hover:bg-indigo-50 dark:border-gray-600 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700'
+ small
+ onClick={() => setShowDeleteModal(true)}
+ >
+ <TrashIcon className='h-4 w-4' />
+ </Button>
+ </div>
+ )}
+ </td>
+ <td>
+ <Modal
+ onClose={() => {
+ setShowDeleteModal(false)
+ }}
+ onSubmit={() => {
+ setShowDeleteModal(false)
+ onRemove(id)
+ }}
+ submitText={t('common.yes')}
+ type='confirmed'
+ closeText={t('common.no')}
+ title={t('project.settings.removeUser', { user: user.email })}
+ message={t('project.settings.removeConfirm')}
+ isOpened={showDeleteModal}
+ />
+ </td>
+ </tr>
+ )
+}
+
+interface PeopleProps {
+ organisation: Organisation
+}
+
+const People = ({ organisation }: PeopleProps): JSX.Element => {
+ const [showModal, setShowModal] = useState(false)
+ const { t } = useTranslation('common')
+ const [form, setForm] = useState({
+ email: '',
+ role: '',
+ })
+ const [beenSubmitted, setBeenSubmitted] = useState(false)
+ const [errors, setErrors] = useState<{
+ email?: string
+ role?: string
+ }>({})
+ const [validated, setValidated] = useState(false)
+
+ const { id, name, members } = organisation
+
+ const validate = () => {
+ const allErrors: {
+ email?: string
+ role?: string
+ } = {}
+
+ if (!isValidEmail(form.email)) {
+ allErrors.email = t('auth.common.badEmailError')
+ }
+
+ if (_isEmpty(form.role)) {
+ allErrors.role = t('project.settings.errorNoRole')
+ }
+
+ const valid = _isEmpty(_keys(allErrors))
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
+ useEffect(() => {
+ if (showModal) {
+ validate()
+ }
+ }, [form]) // eslint-disable-line
+
+ const handleInput = ({ target }: React.ChangeEvent<HTMLInputElement>) => {
+ const value = target.type === 'checkbox' ? target.checked : target.value
+
+ setForm((oldForm) => ({
+ ...oldForm,
+ [target.name]: value,
+ }))
+ }
+
+ const onSubmit = async () => {
+ setShowModal(false)
+ setErrors({})
+ setValidated(false)
+
+ try {
+ // todo
+ toast.success(t('apiNotifications.userInvited'))
+ } catch (reason) {
+ console.error(`[ERROR] Error while inviting a user: ${reason}`)
+ toast.error(typeof reason === 'string' ? reason : t('apiNotifications.userInviteError'))
+ }
+
+ // a timeout is needed to prevent the flicker of data fields in the modal when closing
+ setTimeout(() => setForm({ email: '', role: '' }), 300)
+ }
+
+ const handleSubmit = (e: React.MouseEvent<HTMLButtonElement>) => {
+ e.preventDefault()
+ e.stopPropagation()
+
+ setBeenSubmitted(true)
+ if (validated) {
+ onSubmit()
+ } else {
+ validate()
+ }
+ }
+
+ const closeModal = () => {
+ setShowModal(false)
+ // a timeout is needed to prevent the flicker of data fields in the modal when closing
+ setTimeout(() => setForm({ email: '', role: '' }), 300)
+ setErrors({})
+ }
+
+ const onRemove = async (userId: string) => {
+ try {
+ // todo
+ toast.success(t('apiNotifications.userRemoved'))
+ } catch (reason) {
+ console.error(`[ERROR] Error while deleting a user: ${reason}`)
+ toast.error(t('apiNotifications.userRemoveError'))
+ }
+ }
+
+ return (
+ <div className='mb-6 mt-6'>
+ <div className='mb-3 flex items-center justify-between'>
+ <div>
+ <h3 className='mt-2 flex items-center text-lg font-bold text-gray-900 dark:text-gray-50'>
+ {t('project.settings.people')}
+ </h3>
+ <p className='text-sm text-gray-500 dark:text-gray-400'>{t('project.settings.inviteCoworkers')}</p>
+ </div>
+ <Button className='h-8 pl-2' primary regular type='button' onClick={() => setShowModal(true)}>
+ <>
+ <UserPlusIcon className='mr-1 h-5 w-5' />
+ {t('project.settings.invite')}
+ </>
+ </Button>
+ </div>
+ <div>
+ {_isEmpty(members) ? (
+ <NoPeople t={t} />
+ ) : (
+ <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('auth.common.email')}
+ </th>
+ <th
+ scope='col'
+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'
+ >
+ {t('profileSettings.sharedTable.joinedOn')}
+ </th>
+ <th scope='col' />
+ <th scope='col' />
+ </tr>
+ </thead>
+ <tbody className='divide-y divide-gray-300 dark:divide-gray-600'>
+ {/* {_map(members, (user) => (
+ <UsersList
+ data={user}
+ key={user.id}
+ onRemove={onRemove}
+ t={t}
+ language={language}
+ pid={id}
+ />
+ ))} */}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ <Modal
+ onClose={closeModal}
+ customButtons={
+ <button
+ type='button'
+ className='inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 sm:ml-3 sm:w-auto sm:text-sm'
+ onClick={handleSubmit}
+ >
+ {t('common.invite')}
+ </button>
+ }
+ closeText={t('common.cancel')}
+ message={
+ <div>
+ <h2 className='text-xl font-bold text-gray-700 dark:text-gray-200'>
+ {t('organisations.invite.title', {
+ organisation: name,
+ })}
+ </h2>
+ <p className='mt-2 text-base text-gray-700 dark:text-gray-200'>
+ {t('organisations.invite.desc', {
+ expiresIn: INVITATION_EXPIRES_IN,
+ })}
+ </p>
+ <Input
+ name='email'
+ type='email'
+ label={t('auth.common.email')}
+ value={form.email}
+ placeholder='[email protected]'
+ className='mt-4'
+ onChange={handleInput}
+ error={beenSubmitted && errors.email}
+ />
+ <fieldset className='mt-4'>
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
+ <label className='block text-sm font-medium text-gray-700 dark:text-gray-300' htmlFor='role'>
+ {t('project.settings.role')}
+ </label>
+ <div
+ className={cx('mt-1 -space-y-px rounded-md bg-white dark:bg-slate-900', {
+ 'border border-red-300': errors.role,
+ })}
+ >
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
+ <label
+ className={cx(
+ 'relative flex cursor-pointer rounded-tl-md rounded-tr-md border border-gray-200 p-4 dark:border-slate-600',
+ {
+ 'z-10 border-indigo-200 bg-indigo-50 dark:border-indigo-800/40 dark:bg-indigo-600/40':
+ form.role === roleAdmin.role,
+ 'border-gray-200': form.role !== roleAdmin.role,
+ },
+ )}
+ >
+ <input
+ name='role'
+ className='h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-500'
+ id='role_admin'
+ type='radio'
+ value='admin'
+ onChange={handleInput}
+ />
+ <div className='ml-3 flex flex-col'>
+ <span
+ className={cx('block text-sm font-medium', {
+ 'text-indigo-900 dark:text-white': form.role === roleAdmin.role,
+ 'text-gray-700 dark:text-gray-200': form.role !== roleAdmin.role,
+ })}
+ >
+ {t('organisations.role.admin.name')}
+ </span>
+ <span
+ className={cx('block text-sm', {
+ 'text-indigo-700 dark:text-gray-100': form.role === roleAdmin.role,
+ 'text-gray-700 dark:text-gray-200': form.role !== roleAdmin.role,
+ })}
+ >
+ {t('organisations.role.admin.desc')}
+ </span>
+ </div>
+ </label>
+ {/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
+ <label
+ className={cx(
+ 'relative flex cursor-pointer rounded-bl-md rounded-br-md border border-gray-200 p-4 dark:border-gray-500',
+ {
+ 'z-10 border-indigo-200 bg-indigo-50 dark:border-indigo-800/40 dark:bg-indigo-600/40':
+ form.role === roleViewer.role,
+ 'border-gray-200': form.role !== roleViewer.role,
+ },
+ )}
+ >
+ <input
+ name='role'
+ className='h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-500'
+ id='role_viewer'
+ type='radio'
+ value='viewer'
+ onChange={handleInput}
+ />
+ <div className='ml-3 flex flex-col'>
+ <span
+ className={cx('block text-sm font-medium', {
+ 'text-indigo-900 dark:text-white': form.role === roleViewer.role,
+ 'text-gray-700 dark:text-gray-200': form.role !== roleViewer.role,
+ })}
+ >
+ {t('organisations.role.viewer.name')}
+ </span>
+ <span
+ className={cx('block text-sm', {
+ 'text-indigo-700 dark:text-gray-100': form.role === roleViewer.role,
+ 'text-gray-700 dark:text-gray-200': form.role !== roleViewer.role,
+ })}
+ >
+ {t('organisations.role.viewer.desc')}
+ </span>
+ </div>
+ </label>
+ </div>
+ {errors.role && (
+ <p className='mt-2 text-sm text-red-600 dark:text-red-500' id='email-error'>
+ {errors.role}
+ </p>
+ )}
+ </fieldset>
+ </div>
+ }
+ isOpened={showModal}
+ />
+ </div>
+ )
+}
+
+export default People
diff --git a/web/app/pages/Organisations/Settings/TransferProject/TransferProjectConfirm.tsx b/web/app/pages/Organisations/Settings/TransferProject/TransferProjectConfirm.tsx
new file mode 100644
index 000000000..540ec3ff1
--- /dev/null
+++ b/web/app/pages/Organisations/Settings/TransferProject/TransferProjectConfirm.tsx
@@ -0,0 +1,107 @@
+import React, { useState, useEffect, memo } from 'react'
+import { Link } from '@remix-run/react'
+import { useTranslation } from 'react-i18next'
+import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'
+
+import Loader from 'ui/Loader'
+
+import { confirmTransferProject } from 'api'
+import routes from 'utils/routes'
+
+const TransferProjectConfirm = (): JSX.Element => {
+ const { t } = useTranslation('common')
+ const [loading, setLoading] = useState<boolean>(true)
+ const [error, setError] = useState<string>('')
+
+ const handleConfirm = async (token: string) => {
+ try {
+ await confirmTransferProject(token)
+ } catch (e) {
+ setError(t('apiNotifications.invalidToken'))
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useEffect(() => {
+ setLoading(true)
+ const query = new URLSearchParams(window.location.search)
+ const token = query.get('token')
+
+ if (!token) {
+ setError(t('apiNotifications.invalidToken'))
+ setLoading(false)
+ return
+ }
+
+ handleConfirm(token)
+ }, []) // eslint-disable-line
+
+ if (loading) {
+ return (
+ <div className='min-h-page bg-gray-50 dark:bg-slate-900'>
+ <Loader />
+ </div>
+ )
+ }
+
+ if (error) {
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <XCircleIcon className='h-12 w-12 text-red-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {error}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ <Link
+ to={routes.contact}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-100 px-4 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700 dark:focus:ring-gray-50'
+ >
+ {t('notFoundPage.support')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+ }
+
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <CheckCircleIcon className='h-12 w-12 text-green-500 dark:text-green-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {t('apiNotifications.acceptInvitation')}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+}
+
+export default memo(TransferProjectConfirm)
diff --git a/web/app/pages/Organisations/Settings/TransferProject/TransferProjectReject.tsx b/web/app/pages/Organisations/Settings/TransferProject/TransferProjectReject.tsx
new file mode 100644
index 000000000..244927135
--- /dev/null
+++ b/web/app/pages/Organisations/Settings/TransferProject/TransferProjectReject.tsx
@@ -0,0 +1,107 @@
+import React, { useState, useEffect, memo } from 'react'
+import { Link } from '@remix-run/react'
+import { useTranslation } from 'react-i18next'
+import { XCircleIcon, InformationCircleIcon } from '@heroicons/react/24/solid'
+
+import Loader from 'ui/Loader'
+
+import { rejectTransferProject } from 'api'
+import routes from 'utils/routes'
+
+const TransferProjectReject = (): JSX.Element => {
+ const { t } = useTranslation('common')
+ const [loading, setLoading] = useState<boolean>(true)
+ const [error, setError] = useState<string>('')
+
+ const handleConfirm = async (token: string) => {
+ try {
+ await rejectTransferProject(token)
+ } catch (e) {
+ setError(t('apiNotifications.invalidToken'))
+ } finally {
+ setLoading(false)
+ }
+ }
+
+ useEffect(() => {
+ setLoading(true)
+ const query = new URLSearchParams(window.location.search)
+ const token = query.get('token')
+
+ if (!token) {
+ setError(t('apiNotifications.invalidToken'))
+ setLoading(false)
+ return
+ }
+
+ handleConfirm(token)
+ }, []) // eslint-disable-line
+
+ if (loading) {
+ return (
+ <div className='min-h-page bg-gray-50 dark:bg-slate-900'>
+ <Loader />
+ </div>
+ )
+ }
+
+ if (error) {
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <XCircleIcon className='h-12 w-12 text-red-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {error}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ <Link
+ to={routes.contact}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-100 px-4 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700 dark:focus:ring-gray-50'
+ >
+ {t('notFoundPage.support')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+ }
+
+ return (
+ <div className='min-h-page bg-gray-50 px-4 py-16 dark:bg-slate-900 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8'>
+ <div className='mx-auto max-w-max'>
+ <main className='sm:flex'>
+ <InformationCircleIcon className='h-12 w-12 text-yellow-400' aria-hidden='true' />
+ <div className='sm:ml-6'>
+ <div className='max-w-prose sm:border-l sm:border-gray-200 sm:pl-6'>
+ <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>
+ {t('apiNotifications.transferProjectReject')}
+ </h1>
+ </div>
+ <div className='mt-8 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6'>
+ <Link
+ to={routes.dashboard}
+ className='inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2'
+ >
+ {t('common.dashboard')}
+ </Link>
+ </div>
+ </div>
+ </main>
+ </div>
+ </div>
+ )
+}
+
+export default memo(TransferProjectReject)
diff --git a/web/app/pages/Organisations/Settings/index.tsx b/web/app/pages/Organisations/Settings/index.tsx
new file mode 100644
index 000000000..3d28e99dd
--- /dev/null
+++ b/web/app/pages/Organisations/Settings/index.tsx
@@ -0,0 +1,276 @@
+import React, { useState, useEffect, memo } from 'react'
+import { toast } from 'sonner'
+import { useNavigate } from '@remix-run/react'
+import { useTranslation } from 'react-i18next'
+import _isEmpty from 'lodash/isEmpty'
+import _size from 'lodash/size'
+import _replace from 'lodash/replace'
+import _keys from 'lodash/keys'
+
+import { withAuthentication, auth } from 'hoc/protected'
+import { TITLE_SUFFIX } from 'redux/constants'
+import { transferProject, getOrganisation } from 'api'
+import Input from 'ui/Input'
+import Button from 'ui/Button'
+import Loader from 'ui/Loader'
+import Modal from 'ui/Modal'
+import routes from 'utils/routes'
+
+import People from './People'
+import { useRequiredParams } from 'hooks/useRequiredParams'
+import { Organisation } from 'redux/models/Organisation'
+import { StateType } from 'redux/store'
+import { useSelector } from 'react-redux'
+
+const MAX_NAME_LENGTH = 50
+
+const DEFAULT_PROJECT_NAME = 'Untitled Project'
+
+const OrganisationSettings = () => {
+ const { t } = useTranslation('common')
+ const { id } = useRequiredParams<{ id: string }>()
+ const navigate = useNavigate()
+
+ const { loading: authLoading } = useSelector((state: StateType) => state.auth)
+
+ const [validated, setValidated] = useState(false)
+ const [errors, setErrors] = useState<{
+ name?: string
+ }>({})
+ const [beenSubmitted, setBeenSubmitted] = useState(false)
+ const [showDelete, setShowDelete] = useState(false)
+ const [isDeleting, setIsDeleting] = useState(false)
+ const [isSaving, setIsSaving] = useState(false)
+ const [showTransfer, setShowTransfer] = useState(false)
+ const [transferEmail, setTransferEmail] = useState('')
+
+ const [isLoading, setIsLoading] = useState<boolean | null>(null)
+ const [error, setError] = useState<string | null>(null)
+
+ const [organisation, setOrganisation] = useState<Organisation | null>(null)
+ const [form, setForm] = useState<Pick<Organisation, 'name'>>({
+ name: '',
+ })
+
+ const loadOrganisation = async (organisationId: string) => {
+ if (isLoading) {
+ return
+ }
+ setIsLoading(true)
+
+ try {
+ const result = await getOrganisation(organisationId)
+ setOrganisation(result)
+ setForm({
+ name: result.name,
+ })
+ } catch (reason: any) {
+ setError(reason)
+ } finally {
+ setIsLoading(false)
+ }
+ }
+
+ useEffect(() => {
+ if (authLoading) {
+ return
+ }
+
+ loadOrganisation(id)
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [authLoading, id])
+
+ const onSubmit = async (form: any) => {}
+
+ const onDelete = async () => {
+ setShowDelete(false)
+
+ if (!isDeleting) {
+ setIsDeleting(true)
+ try {
+ toast.success(t('project.settings.deleted'))
+
+ // todo
+
+ navigate(routes.organisations)
+ } catch (reason: any) {
+ toast.error(reason)
+ } finally {
+ setIsDeleting(false)
+ }
+ }
+ }
+
+ const validate = () => {
+ const allErrors: {
+ name?: string
+ origins?: string
+ ipBlacklist?: string
+ password?: string
+ } = {}
+
+ if (_isEmpty(form.name)) {
+ allErrors.name = t('project.settings.noNameError')
+ }
+
+ if (_size(form.name) > MAX_NAME_LENGTH) {
+ allErrors.name = t('project.settings.pxCharsError', { amount: MAX_NAME_LENGTH })
+ }
+
+ const valid = _isEmpty(_keys(allErrors))
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
+ useEffect(() => {
+ validate()
+ }, [form]) // eslint-disable-line
+
+ const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {
+ const { target } = event
+ const value = target.type === 'checkbox' ? target.checked : target.value
+
+ setForm((oldForm) => ({
+ ...oldForm,
+ [target.name]: value,
+ }))
+ }
+
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
+ e.preventDefault()
+ e.stopPropagation()
+ setBeenSubmitted(true)
+
+ if (validated) {
+ onSubmit(form)
+ }
+ }
+
+ const onCancel = () => {
+ navigate(_replace(routes.project, ':id', id))
+ }
+
+ const onTransfer = async () => {
+ await transferProject(id, transferEmail)
+ .then(() => {
+ toast.success(t('apiNotifications.transferRequestSent'))
+ navigate(routes.dashboard)
+ })
+ .catch((reason) => {
+ toast.error(reason)
+ })
+ .finally(() => {
+ setShowTransfer(false)
+ setTransferEmail('')
+ })
+ }
+
+ const title = `${t('project.settings.settings')} ${form.name}`
+
+ useEffect(() => {
+ document.title = `${t('project.settings.settings')} ${form.name} ${TITLE_SUFFIX}`
+ }, [form, t])
+
+ if (isLoading || isLoading === null) {
+ 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 />
+ </div>
+ )
+ }
+
+ return (
+ <div className='flex min-h-min-footer flex-col bg-gray-50 px-4 py-6 pb-40 dark:bg-slate-900 sm:px-6 lg:px-8'>
+ <form className='mx-auto w-full max-w-7xl' onSubmit={handleSubmit}>
+ <h2 className='mt-2 text-3xl font-bold text-gray-900 dark:text-gray-50'>{title}</h2>
+ <h3 className='mt-4 text-lg font-bold text-gray-900 dark:text-gray-50'>{t('profileSettings.general')}</h3>
+ <Input
+ name='name'
+ label={t('common.name')}
+ value={form.name}
+ className='mt-2'
+ onChange={handleInput}
+ error={beenSubmitted ? errors.name : null}
+ />
+ <div className='mt-8 flex flex-wrap justify-center gap-2 sm:justify-between'>
+ <div className='flex flex-wrap items-center gap-2'>
+ <Button
+ className='border-indigo-100 dark:border-slate-700/50 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700'
+ onClick={onCancel}
+ secondary
+ regular
+ >
+ {t('common.cancel')}
+ </Button>
+ <Button type='submit' loading={isSaving} primary regular>
+ {t('common.save')}
+ </Button>
+ </div>
+ {/* {!project?.shared && (
+ <div className='flex flex-wrap justify-center gap-2'>
+ {!isSelfhosted && (
+ <Button onClick={() => setShowTransfer(true)} semiDanger semiSmall>
+ <>
+ <RocketLaunchIcon className='mr-1 h-5 w-5' />
+ {t('project.settings.transfer')}
+ </>
+ </Button>
+ )}
+ <Button onClick={() => !isDeleting && setShowDelete(true)} loading={isDeleting} danger semiSmall>
+ <>
+ <ExclamationTriangleIcon className='mr-1 h-5 w-5' />
+ {t('project.settings.delete')}
+ </>
+ </Button>
+ </div>
+ )} */}
+ </div>
+ <hr className='mt-2 border-gray-200 dark:border-gray-600 sm:mt-5' />
+ <People organisation={organisation} />
+ </form>
+ <Modal
+ onClose={() => setShowDelete(false)}
+ onSubmit={onDelete}
+ submitText={t('project.settings.delete')}
+ closeText={t('common.close')}
+ title={t('project.settings.qDelete')}
+ message={t('project.settings.deleteHint')}
+ submitType='danger'
+ type='error'
+ isOpened={showDelete}
+ />
+ <Modal
+ onClose={() => {
+ setShowTransfer(false)
+ }}
+ submitText={t('project.settings.transfer')}
+ closeText={t('common.cancel')}
+ message={
+ <div>
+ <h2 className='text-xl font-bold text-gray-700 dark:text-gray-200'>{t('project.settings.transferTo')}</h2>
+ <p className='mt-2 text-base text-gray-700 dark:text-gray-200'>
+ {t('project.settings.transferHint', {
+ name: form.name || DEFAULT_PROJECT_NAME,
+ })}
+ </p>
+ <Input
+ name='email'
+ type='email'
+ label={t('project.settings.transfereeEmail')}
+ value={transferEmail}
+ placeholder='[email protected]'
+ className='mt-4'
+ onChange={(e) => setTransferEmail(e.target.value)}
+ />
+ </div>
+ }
+ isOpened={showTransfer}
+ onSubmit={onTransfer}
+ />
+ </div>
+ )
+}
+
+export default memo(withAuthentication(OrganisationSettings, auth.authenticated))
diff --git a/web/app/pages/Organisations/index.tsx b/web/app/pages/Organisations/index.tsx
index 1b74ce083..c59e83674 100644
--- a/web/app/pages/Organisations/index.tsx
+++ b/web/app/pages/Organisations/index.tsx
@@ -12,11 +12,10 @@ import _map from 'lodash/map'
import _find from 'lodash/find'
import { useTranslation } from 'react-i18next'
import {
- FolderPlusIcon,
AdjustmentsVerticalIcon,
- ArrowTopRightOnSquareIcon,
MagnifyingGlassIcon,
XMarkIcon,
+ BuildingOffice2Icon,
} from '@heroicons/react/24/outline'
import { XCircleIcon } from '@heroicons/react/24/solid'
@@ -27,7 +26,6 @@ import { Badge } from 'ui/Badge'
import routes from 'utils/routes'
import { isSelfhosted, ENTRIES_PER_PAGE_DASHBOARD, roleViewer } from 'redux/constants'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
-import DashboardLockedBanner from 'components/DashboardLockedBanner'
import useDebounce from 'hooks/useDebounce'
import { acceptShareProject, createOrganisation, getOrganisations } from 'api'
@@ -40,7 +38,6 @@ import Input from 'ui/Input'
interface OrganisationCardProps {
name?: string
active?: boolean
- type: 'analytics' | 'captcha'
t: typeof i18next.t
isPublic?: boolean
confirmed?: boolean
@@ -49,7 +46,6 @@ interface OrganisationCardProps {
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
@@ -57,8 +53,6 @@ interface OrganisationCardProps {
const OrganisationCard = ({
name,
- active,
- isPublic,
confirmed,
id,
sharedProjects,
@@ -66,7 +60,6 @@ const OrganisationCard = ({
setUserShareData,
shared,
isTransferring,
- type,
getRole,
members,
}: OrganisationCardProps) => {
@@ -105,12 +98,12 @@ const OrganisationCard = ({
return (
<div
onClick={() => {
- navigate(_replace(type === 'analytics' ? routes.project : routes.captcha, ':id', id))
+ navigate(_replace(routes.organisation, ':id', id))
}}
>
<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'
+ 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'>
@@ -119,28 +112,15 @@ const OrganisationCard = ({
<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)}
+ 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>
)}
- <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>
<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')} />
@@ -148,7 +128,6 @@ const OrganisationCard = ({
<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'
@@ -202,7 +181,7 @@ const NoOrganisations = ({ t, onClick }: INoOrganisations): JSX.Element => (
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' />
+ <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>
@@ -220,23 +199,22 @@ const AddOrganisation = ({ t, onClick, sitesCount }: IAddOrganisation): JSX.Elem
)}
>
<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' />
+ <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('dashboard.newProject')}
+ {t('organisations.new')}
</span>
</div>
</li>
)
-// @ts-expect-error
-const Organisations = ({ total }): JSX.Element => {
+const Organisations = () => {
const { t } = useTranslation('common')
const [isSearchActive, setIsSearchActive] = useState(false)
const [showActivateEmailModal, setShowActivateEmailModal] = useState(false)
- const pageAmount = Math.ceil(total / ENTRIES_PER_PAGE_DASHBOARD)
const [search, setSearch] = useState<string>('')
const debouncedSearch = useDebounce<string>(search, 500)
const [organisations, setOrganisations] = useState<Organisation[]>([])
+ const [paginationTotal, setPaginationTotal] = useState(0)
const [page, setPage] = useState(1)
const [newOrganisationModalOpen, setNewOrganisationModalOpen] = useState(false)
@@ -248,6 +226,8 @@ const Organisations = ({ total }): JSX.Element => {
const [error, setError] = useState<string | null>(null)
const [newOrganisationError, setNewOrganisationError] = useState<string | null>(null)
+ const pageAmount = Math.ceil(paginationTotal / ENTRIES_PER_PAGE_DASHBOARD)
+
const onNewOrganisation = () => {
setNewOrganisationModalOpen(true)
}
@@ -268,6 +248,7 @@ const Organisations = ({ total }): JSX.Element => {
debouncedSearch,
)
setOrganisations(result.results)
+ setPaginationTotal(result.total)
toast.success(t('organisations.organisationCreated'))
@@ -299,6 +280,7 @@ const Organisations = ({ total }): JSX.Element => {
try {
const result = await getOrganisations(take, skip, search)
setOrganisations(result.results)
+ setPaginationTotal(result.total)
} catch (reason: any) {
setError(reason)
} finally {
@@ -353,13 +335,10 @@ const Organisations = ({ total }): JSX.Element => {
setSearch(e.target.value)
}
- console.log('orgs:', organisations)
-
return (
<>
<div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
<EventsRunningOutBanner />
- <DashboardLockedBanner />
<div className='flex flex-col px-4 py-6 sm:px-6 lg:px-8'>
<div className='mx-auto w-full max-w-7xl'>
<div className='mb-6 flex justify-between'>
@@ -407,8 +386,8 @@ const Organisations = ({ total }): JSX.Element => {
onClick={onNewOrganisation}
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' />
- {t('dashboard.newProject')}
+ <BuildingOffice2Icon className='mr-1 h-5 w-5' />
+ {t('organisations.new')}
</span>
</div>
{isSearchActive && (
@@ -456,7 +435,6 @@ const Organisations = ({ total }): JSX.Element => {
key={id}
members={1 + _size(share)}
id={id}
- type='analytics'
t={t}
name={name}
active={active}
@@ -477,7 +455,13 @@ const Organisations = ({ total }): JSX.Element => {
</ClientOnly>
)}
{pageAmount > 1 && (
- <Pagination className='mt-2' page={page} pageAmount={pageAmount} setPage={setPage} total={total} />
+ <Pagination
+ className='mt-2'
+ page={page}
+ pageAmount={pageAmount}
+ setPage={setPage}
+ total={paginationTotal}
+ />
)}
</div>
</div>
diff --git a/web/app/pages/Project/Settings/ProjectSettings.tsx b/web/app/pages/Project/Settings/ProjectSettings.tsx
index 99ddf9e49..9e395c67c 100644
--- a/web/app/pages/Project/Settings/ProjectSettings.tsx
+++ b/web/app/pages/Project/Settings/ProjectSettings.tsx
@@ -19,7 +19,13 @@ import _includes from 'lodash/includes'
import { ExclamationTriangleIcon, TrashIcon, RocketLaunchIcon } from '@heroicons/react/24/outline'
import { withAuthentication, auth } from 'hoc/protected'
-import { isSelfhosted, TITLE_SUFFIX, ENTRIES_PER_PAGE_DASHBOARD, FILTERS_PANELS_ORDER } from 'redux/constants'
+import {
+ isSelfhosted,
+ TITLE_SUFFIX,
+ ENTRIES_PER_PAGE_DASHBOARD,
+ FILTERS_PANELS_ORDER,
+ isBrowser,
+} from 'redux/constants'
import { IProject } from 'redux/models/IProject'
import { IUser } from 'redux/models/IUser'
import { IProjectForShared, ISharedProject } from 'redux/models/ISharedProject'
@@ -49,7 +55,6 @@ import People from './People'
import Emails from './Emails'
import Select from 'ui/Select'
import { useRequiredParams } from 'hooks/useRequiredParams'
-import { isBrowser } from 'framer-motion'
const MAX_NAME_LENGTH = 50
const MAX_ORIGINS_LENGTH = 300
diff --git a/web/app/routes/organisations.$id.tsx b/web/app/routes/organisations.$id.tsx
new file mode 100644
index 000000000..a8fb11ddd
--- /dev/null
+++ b/web/app/routes/organisations.$id.tsx
@@ -0,0 +1,20 @@
+import { redirect } from '@remix-run/node'
+import type { SitemapFunction } from 'remix-sitemap'
+import OrganisationSettings from 'pages/Organisations/Settings'
+import { isSelfhosted } from 'redux/constants'
+
+export const sitemap: SitemapFunction = () => ({
+ exclude: true,
+})
+
+export async function loader() {
+ if (isSelfhosted) {
+ return redirect('/login', 302)
+ }
+
+ return null
+}
+
+export default function Index() {
+ return <OrganisationSettings />
+}
diff --git a/web/app/utils/routes.ts b/web/app/utils/routes.ts
index 823bb68f0..da8784a7b 100644
--- a/web/app/utils/routes.ts
+++ b/web/app/utils/routes.ts
@@ -42,6 +42,8 @@ const routes = Object.freeze({
forMarketers: '/for-marketers',
forStartups: '/for-startups',
forSmallBusinesses: '/for-small-businesses',
+ organisations: '/organisations',
+ organisation: '/organisations/:id',
})
export default routes
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index daa90f544..2310b4581 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -603,7 +603,23 @@
"alertDeleted": "The alert has been deleted"
},
"organisations": {
- "create": "Create organisation"
+ "create": "Create organisation",
+ "organisations": "Organisations",
+ "new": "New organisation",
+ "invite": {
+ "title": "Invite a user to {{organisation}}",
+ "desc": "Enter an email address and a role of the person registered on Swetrix that you want to invite to the organisation. The invitation will expire in {{expiresIn}} hours."
+ },
+ "role": {
+ "admin": {
+ "name": "Admin",
+ "desc": "Can manage the organisation and its members, as well as manage the projects within the organisation."
+ },
+ "viewer": {
+ "name": "Viewer",
+ "desc": "Can only access the organisation and its projects without the ability to change any settings."
+ }
+ }
},
"dashboard": {
"uptime": "Uptime",