📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added i18n and other improvements
Blue Mouse86d7dbdc3de0
diff --git a/public/locales/en.json b/public/locales/en.jsonindex 9463401e8..ef92ea21a 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -33,7 +33,13 @@"yes": "Yes","no": "No","is": "is",- "isNot": "is not"+ "isNot": "is not",+ "invite": "Invite",+ "pending": "Pending",+ "accept": "Accept",+ "reject": "Reject",+ "delete": "Delete",+ "quit": "Quit"},"main": {"ukrSupport": "Support the Ukrainian army to fight Russian invasion.",@@ -197,7 +203,16 @@"confTimeout": "An email has already been sent, check your mailbox or try again in a few minutes","confSent": "An account confirmation link has been sent to your email","noConfLeft": "Unfortunately, you've ran out of your email confirmation requests.\nPlease make sure you are able to receive e-mails and check your SPAM folder again for messages.\nYou may try to use a different email address or contact our customer support service.",- "timezoneDesc": "This will be the time zone in which the data is displayed. It's only used for visualization.\nNo data will be modified based on this setting."+ "timezoneDesc": "This will be the time zone in which the data is displayed. It's only used for visualization.\nNo data will be modified based on this setting.",+ "quitProject": "Are you sure you want to quit this project?",+ "quitProjectTitle": "Quit {{project}}?",+ "shared": "Shared projects",+ "sharedTable": {+ "project": "Project",+ "role": "Role",+ "joinedOn": "Joined on"+ },+ "noSharedProjects": "Nobody is sharing a project with you yet."},"dashboard": {"newProject": "New project",@@ -210,6 +225,7 @@"createProject": "Create a new project here to start using our service","active": "Active","public": "Public",+ "shared": "Shared","disabled": "Disabled","pageviews": "Pageviews","unique": "Unique views",@@ -217,7 +233,9 @@"inc": "Increased by","dec": "Descreased by","liveVisitors": "Live visitors",- "bounceRate": "Bounce rate"+ "bounceRate": "Bounce rate",+ "invitationFor": "Invitation for {{project}}",+ "invitationDesc": "You have been invited to join the project {{project}}.\nYou can either accept the invitation here or reject it in your account settings."},"docs": {"titles": {@@ -323,7 +341,31 @@"createHint": "*you will be able to set up your project more thoroughly after you have created it","delete": "Delete project","qDelete": "Delete the project?",- "deleteHint": "By pressing 'Delete project' you understand, that this action is irreversible.\nThe project and all the data related to it will be deleted from our servers."+ "deleteHint": "By pressing 'Delete project' you understand, that this action is irreversible.\nThe project and all the data related to it will be deleted from our servers.",+ "noPeople": "No people have been added to this project yet.",+ "removeMember": "Remove member",+ "removeConfirm": "Are you sure you want to stop sharing your project with this user?",+ "removeUser": "Remove {{user}}?",+ "people": "People",+ "inviteCoworkers": "Invite your coworkers",+ "invite": "Invite a user",+ "inviteTo": "Invite a user to {{project}}",+ "inviteDesc": "Enter an email address and a role of the person you want to share your project with.\nWe shall contact them over email to offer the access to the project.",+ "inviteExpity": "The invitation will expire in {{amount}} hours.",+ "role": "Role",+ "roles": {+ "admin": {+ "name": "Administrator",+ "desc": "Can manage the project's settings, add/remove members, and invite new users.",+ "shortDesc": "Can manage the project"+ },+ "viewer": {+ "name": "Viewer",+ "desc": "Has a read-only access to the project.",+ "shortDesc": "Can only view the project"+ }+ },+ "errorNoRole": "Please select a role."}},"billing": {diff --git a/src/pages/Dashboard/Dashboard.container.jsx b/src/pages/Dashboard/Dashboard.container.jsxindex 6642f00e8..08b1ab06a 100644--- a/src/pages/Dashboard/Dashboard.container.jsx+++ b/src/pages/Dashboard/Dashboard.container.jsx@@ -15,12 +15,6 @@ const mapDispatchToProps = (dispatch) => ({deleteProjectFailed: (message) => {dispatch(errorsActions.deleteProjectFailed(message))},- removeProject: (projectId) => {- dispatch(UIActions.removeProject(projectId))- },- removeShareProject: (id) => {- dispatch(authActions.deleteShareProject(id))- },setProjectsShareData: (data, id) => {dispatch(UIActions.setProjectsShareData(data, id))},diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsxindex c9d68a0bb..2dbf8dcad 100644--- a/src/pages/Dashboard/Dashboard.jsx+++ b/src/pages/Dashboard/Dashboard.jsx@@ -18,33 +18,20 @@ import Modal from 'ui/Modal'import { withAuthentication, auth } from 'hoc/protected'import Title from 'components/Title'import Loader from 'ui/Loader'-import { ActivePin, InactivePin } from 'ui/Pin'+import { ActivePin, InactivePin, WarningPin } from 'ui/Pin'import PulsatingCircle from 'ui/icons/PulsatingCircle'import routes from 'routes'import { isSelfhosted } from 'redux/constants'import EventsRunningOutBanner from 'components/EventsRunningOutBanner'-import { deleteShareProject, acceptShareProject } from 'api'+import { acceptShareProject } from 'api'const ProjectCart = ({- name, created, active, overall, t, language, live, isPublic, confirmed, id, deleteProjectFailed, sharedProjects, removeProject, removeShareProject, setProjectsShareData, setUserShareData, shared,+ name, created, active, overall, t, language, live, isPublic, confirmed, id, deleteProjectFailed, sharedProjects, setProjectsShareData, setUserShareData, shared,}) => {const statsDidGrowUp = overall?.percChange >= 0const [showInviteModal, setShowInviteModal] = useState(false)- const deleteProject = async () => {- const pid = _find(sharedProjects, item => item.project.id === id).id-- await deleteShareProject(pid)- .then((results) => {- removeProject(id)- removeShareProject(pid)- })- .catch((err) => {- deleteProjectFailed(err)- })- }-const onAccept = async () => {const pid = _find(sharedProjects, item => item.project.id === id).id@@ -60,7 +47,7 @@ const ProjectCart = ({return (<li>- <div onClick={() => { return confirmed === false ? setShowInviteModal(true) : () => {} }} className='block cursor-pointer hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-800 dark:border-gray-700'>+ <div onClick={() => !confirmed && setShowInviteModal(true)} className='block cursor-pointer hover:bg-gray-50 dark:bg-gray-700 dark:hover:bg-gray-800 dark:border-gray-700'><div className='px-4 py-4 sm:px-6'><div className='flex items-center justify-between'><p className='text-lg font-medium text-indigo-600 dark:text-gray-50 truncate'>@@ -69,10 +56,10 @@ const ProjectCart = ({<div className='ml-2 flex-shrink-0 flex'>{shared && (- confirmed === false ? (- <InactivePin className='mr-2' label='Panding' />+ confirmed ? (+ <ActivePin className='mr-2' label={t('dashboard.shared')} />) : (- <ActivePin className='mr-2' label='Shared' />+ <WarningPin className='mr-2' label={t('common.pending')} />))}@@ -150,13 +137,13 @@ const ProjectCart = ({{!confirmed && (<Modal- onClose={() => { setShowInviteModal(false); deleteProject() }}+ onClose={() => { setShowInviteModal(false) }}onSubmit={() => { setShowInviteModal(false); onAccept() }}- submitText='Accept & Continue'+ submitText={t('common.accept')}type='confirmed'- closeText='Reject'- title={`Invitanion for ${name}`}- message='You have been invited to join this project. Do you want to accept?'+ closeText={t('common.cancel')}+ title={t('dashboard.invitationFor', { project: name })}+ message={t('dashboard.invitationDesc', { project: name })}isOpened={showInviteModal}/>)@@ -177,7 +164,7 @@ const NoProjects = ({ t }) => ()const Dashboard = ({- projects, isLoading, error, user, deleteProjectFailed, removeProject, removeShareProject, setProjectsShareData, setUserShareData,+ projects, isLoading, error, user, deleteProjectFailed, setProjectsShareData, setUserShareData,}) => {const { t, i18n: { language } } = useTranslation('common')const [showActivateEmailModal, setShowActivateEmailModal] = useState(false)@@ -245,11 +232,9 @@ const Dashboard = ({shared={shared}active={active}isPublic={isPublic}- removeProject={removeProject}overall={overall}confirmed={confirmed}sharedProjects={user.sharedProjects}- removeShareProject={removeShareProject}setProjectsShareData={setProjectsShareData}setUserShareData={setUserShareData}live={_isNumber(live) ? live : 'N/A'}@@ -307,20 +292,13 @@ Dashboard.propTypes = {user: PropTypes.object.isRequired,isLoading: PropTypes.bool.isRequired,error: PropTypes.string,- deleteProjectFailed: PropTypes.func,- removeProject: PropTypes.func,- removeShareProject: PropTypes.func,- setProjectsShareData: PropTypes.func,- setUserShareData: PropTypes.func,+ deleteProjectFailed: PropTypes.func.isRequired,+ setProjectsShareData: PropTypes.func.isRequired,+ setUserShareData: PropTypes.func.isRequired,}Dashboard.defaultProps = {error: '',- removeProject: () => {},- deleteProjectFailed: (e) => console.log(e),- removeShareProject: () => {},- setProjectsShareData: () => {},- setUserShareData: () => {},}export default memo(withAuthentication(Dashboard, auth.authenticated))diff --git a/src/pages/Project/Settings/People/People.jsx b/src/pages/Project/Settings/People/People.jsxindex 7b7011d86..b34777cbc 100644--- a/src/pages/Project/Settings/People/People.jsx+++ b/src/pages/Project/Settings/People/People.jsx@@ -1,33 +1,37 @@import React, { useState, useEffect, useRef } from 'react'-import Button from 'ui/Button'import { ChevronDownIcon, CheckIcon } from '@heroicons/react/solid'import { TrashIcon } from '@heroicons/react/outline'-import { ActivePin } from 'ui/Pin'-import Modal from 'ui/Modal'import { useTranslation } from 'react-i18next'-import Input from 'ui/Input'-import { isValidEmail } from 'utils/validator'+import cx from 'clsx'+import PropTypes from 'prop-types'import _keys from 'lodash/keys'import _isEmpty from 'lodash/isEmpty'-import cx from 'clsx'+import _filter from 'lodash/filter'import _map from 'lodash/map'+import { deleteShareProjectUsers, shareProject, changeShareRole } from 'api'-import _filter from 'lodash/filter'-import PropTypes from 'prop-types'-import { roles, roleViewer, roleAdmin } from 'redux/constants'+import { isValidEmail } from 'utils/validator'+import Input from 'ui/Input'+import { WarningPin } from 'ui/Pin'+import Button from 'ui/Button'+import Beta from 'ui/Beta'+import Modal from 'ui/Modal'+import {+ roles, roleViewer, roleAdmin, INVITATION_EXPIRES_IN,+} from 'redux/constants'import useOnClickOutside from 'hooks/useOnClickOutside'-const NoEvents = () => (+const NoEvents = ({ t }) => (<div className='flex flex-col py-6 sm:px-6 lg:px-8'><div className='max-w-7xl w-full mx-auto text-gray-900 dark:text-gray-50'><h2 className='text-2xl mb-8 text-center leading-snug'>- No people have been added to this project yet.+ {t('project.settings.noPeople')}</h2></div></div>)-const UsersList = ({ data, onRemove }) => {+const UsersList = ({ data, onRemove, t }) => {const [open, setOpen] = useState(false)const [showDeleteModal, setShowDeleteModal] = useState(false)const openRef = useRef()@@ -53,65 +57,65 @@ const UsersList = ({ data, onRemove }) => {</p><div className={cx('relative', { 'flex items-center': !data.confirmed })}>{- !data.confirmed ? (- <>- <ActivePin- label='Pannding'- className='inline-flex items-center shadow-sm px-2.5 py-0.5 mr-3'- />- <Button- type='button'- className='bg-white text-indigo-600 border border-transparent rounded-md text-base font-medium hover:bg-indigo-50 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600'- small- onClick={() => { setShowDeleteModal(true) }}- >- <TrashIcon className='h-4 w-4' />- </Button>- </>- ) : (- <>- <button- onClick={() => { setOpen(!open) }}- type='button'- className='inline-flex items-center shadow-sm pl-2 pr-1 py-0.5 border border-gray-200 dark:border-gray-500 text-sm leading-5 font-medium rounded-full bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800'- >- { data.role }- <ChevronDownIcon- style={{ transform: open ? 'rotate(180deg)' : '' }}- className='w-4 h-4 pt-px ml-0.5'- />- </button>- {open && (- <ul ref={openRef} className='origin-top-right absolute z-10 right-0 mt-2 w-72 rounded-md shadow-lg overflow-hidden bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700 focus:outline-none'>- {_map(roles, ({ name, role, description }) => (- <li onClick={() => changeRole(role)} className='p-4 hover:bg-indigo-600 group cursor-pointer flex justify-between items-center' key={role}>- <div>- <p className='font-bold text-gray-700 dark:text-gray-200 group-hover:text-gray-200'>- {name}- </p>- <p className='mt-1 text-sm text-gray-500 group-hover:text-gray-200'>- {description}- </p>- </div>- { data.role === role && (- <span className='text-indigo-600 group-hover:text-gray-200'>- <CheckIcon className='w-7 h-7 pt-px ml-1' />- </span>- )}- </li>- ))}- <li onClick={() => { setOpen(false); setShowDeleteModal(true) }} className='p-4 hover:bg-gray-900 group cursor-pointer flex justify-between items-center'>- <div>- <p className='font-bold text-red-600 group-hover:text-red-600'>- Remove member- </p>- </div>- </li>- </ul>- )}- </>- )- }+ !data.confirmed ? (+ <>+ <WarningPin+ label={t('common.pending')}+ className='inline-flex items-center shadow-sm px-2.5 py-0.5 mr-3'+ />+ <Button+ type='button'+ className='bg-white text-indigo-600 border border-transparent rounded-md text-base font-medium hover:bg-indigo-50 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600'+ small+ onClick={() => { setShowDeleteModal(true) }}+ >+ <TrashIcon className='h-4 w-4' />+ </Button>+ </>+ ) : (+ <>+ <button+ onClick={() => { setOpen(!open) }}+ type='button'+ className='inline-flex items-center shadow-sm pl-2 pr-1 py-0.5 border border-gray-200 dark:border-gray-500 text-sm leading-5 font-medium rounded-full bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800'+ >+ {t(`project.settings.roles.${data.role}.name`)}+ <ChevronDownIcon+ style={{ transform: open ? 'rotate(180deg)' : '' }}+ className='w-4 h-4 pt-px ml-0.5'+ />+ </button>+ {open && (+ <ul ref={openRef} className='origin-top-right absolute z-10 right-0 mt-2 w-72 rounded-md shadow-lg overflow-hidden bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700 focus:outline-none'>+ {_map(roles, (role) => (+ <li onClick={() => changeRole(role)} className='p-4 hover:bg-indigo-600 group cursor-pointer flex justify-between items-center' key={role}>+ <div>+ <p className='font-bold text-gray-700 dark:text-gray-200 group-hover:text-gray-200'>+ {t(`project.settings.roles.${role}.name`)}+ </p>+ <p className='mt-1 text-sm text-gray-500 group-hover:text-gray-200'>+ {t(`project.settings.roles.${role}.shortDesc`)}+ </p>+ </div>+ {data.role === role && (+ <span className='text-indigo-600 group-hover:text-gray-200'>+ <CheckIcon className='w-7 h-7 pt-px ml-1' />+ </span>+ )}+ </li>+ ))}+ <li onClick={() => { setOpen(false); setShowDeleteModal(true) }} className='p-4 hover:bg-gray-300 dark:hover:bg-gray-700 group cursor-pointer flex justify-between items-center'>+ <div>+ <p className='font-bold text-red-600 dark:text-red-500'>+ {t('project.settings.removeMember')}+ </p>+ </div>+ </li>+ </ul>+ )}+ </>+ )+ }</div></div><Modal@@ -122,11 +126,11 @@ const UsersList = ({ data, onRemove }) => {setShowDeleteModal(false)onRemove(data.id)}}- submitText='Yes'+ submitText={t('common.yes')}type='confirmed'- closeText='No'- title={`Delete user: ${data.id}?`}- message='Are you sure you want to delete this user?'+ closeText={t('common.no')}+ title={t('project.settings.removeUser', { user: data.user?.email })}+ message={t('project.settings.removeConfirm')}isOpened={showDeleteModal}/></li>@@ -140,7 +144,7 @@ UsersList.propTypes = {}UsersList.defaultProps = {- onRemove: () => {},+ onRemove: () => { },}const People = ({@@ -164,8 +168,8 @@ const People = ({allErrors.email = t('auth.common.badEmailError')}- if (form.role === '') {- allErrors.role = 'Please select a role.'+ if (_isEmpty(form.role)) {+ allErrors.role = t('project.settings.errorNoRole')}const valid = _isEmpty(_keys(allErrors))@@ -191,9 +195,10 @@ const People = ({const onSubmit = () => {setShowModal(false)- setForm({ email: '', role: '' })setErrors({})setValidated(false)+ // a timeout is needed to prevent the flicker of data fields in the modal when closing+ setTimeout(() => setForm({ email: '', role: '' }), 300)shareProject(id, { email: form.email, role: form.role }).then((results) => {setProjectShare(results.share, id)@@ -216,7 +221,8 @@ const People = ({const closeModal = () => {setShowModal(false)- setForm({ email: '', role: '' })+ // a timeout is needed to prevent the flicker of data fields in the modal when closing+ setTimeout(() => setForm({ email: '', role: '' }), 300)setErrors({})}@@ -235,11 +241,12 @@ const People = ({<div className='mt-6 mb-6'><div className='flex justify-between items-center mb-3'><div>- <h3 className='mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>- People+ <h3 className='flex items-center mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>+ {t('project.settings.people')}+ <Beta className='ml-10' /></h3><p className='text-sm text-gray-500 dark:text-gray-400'>- Invite your coworkers+ {t('project.settings.inviteCoworkers')}</p></div><Button@@ -249,16 +256,16 @@ const People = ({type='button'onClick={() => setShowModal(true)}>- Add Users+ {t('project.settings.invite')}</Button></div><div>{_isEmpty(share) ? (- <NoEvents />+ <NoEvents t={t} />) : (<ul className='divide-y divide-gray-200 dark:divide-gray-700'>- {_map(share, user => (<UsersList data={user} key={user.id} onRemove={onRemove} />))}+ {_map(share, user => (<UsersList data={user} key={user.id} onRemove={onRemove} t={t} />))}</ul>)}@@ -266,22 +273,18 @@ const People = ({<ModalonClose={closeModal}onSubmit={handleSubmit}- submitText='Add'- closeText={t('common.no')}+ submitText={t('common.invite')}+ closeText={t('common.cancel')}message={(<div><h2 className='text-xl font-bold text-gray-700 dark:text-gray-200'>- Invite member to- {' '}- {name}+ {t('project.settings.inviteTo', { project: name })}</h2><p className='mt-2 text-base text-gray-700 dark:text-gray-200'>- Enter the email address and role of the person you want to invite.- We will contact them over email to offer them access to ads- analytics.+ {t('project.settings.inviteDesc')}</p><p className='mt-2 text-base text-gray-700 dark:text-gray-200'>- The invitation will expire in 48 hours+ {t('project.settings.inviteExpity', { amount: INVITATION_EXPIRES_IN })}</p><Inputname='email'@@ -296,7 +299,9 @@ const People = ({/><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'>Role</label>+ <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 bg-white rounded-md -space-y-px dark:bg-gray-800', { 'border-red-300 border': errors.role })}>{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}<label className={cx('dark:border-gray-500 rounded-tl-md rounded-tr-md relative border p-4 flex cursor-pointer border-gray-200', { 'bg-indigo-50 border-indigo-200 dark:bg-indigo-500 dark:border-indigo-800 z-10': form.role === roleAdmin.role, 'border-gray-200': form.role !== roleAdmin.role })}>@@ -310,10 +315,10 @@ const People = ({/><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 })}>- Admin+ {t('project.settings.roles.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 })}>- Can view stats, change site settings and invite other members+ {t('project.settings.roles.admin.desc')}</span></div></label>@@ -329,10 +334,10 @@ const People = ({/><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 })}>- Viewer+ {t('project.settings.roles.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 })}>- Can view stats but cannot access settings or invite members+ {t('project.settings.roles.viewer.desc')}</span></div></label>@@ -357,8 +362,8 @@ People.propTypes = {}People.defaultProps = {- updateProjectFailed: () => {},- setProjectShare: () => {},+ updateProjectFailed: () => { },+ setProjectShare: () => { },}export default Peoplediff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsxindex edc2917d6..791ea06f6 100644--- a/src/pages/Project/Settings/ProjectSettings.jsx+++ b/src/pages/Project/Settings/ProjectSettings.jsx@@ -4,6 +4,7 @@ import React, {} from 'react'import { useLocation, useHistory, useParams } from 'react-router-dom'import { useTranslation } from 'react-i18next'+import cx from 'clsx'import _isEmpty from 'lodash/isEmpty'import _size from 'lodash/size'import _replace from 'lodash/replace'@@ -174,7 +175,11 @@ const ProjectSettings = ({return (<Title title={title}>- <div className='min-h-min-footer bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8 mb-10'>+ <div+ className={cx('min-h-min-footer bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8', {+ 'pb-40': isSettings,+ })}+ ><form className='max-w-7xl w-full mx-auto' onSubmit={handleSubmit}><h2 className='mt-2 text-3xl font-extrabold text-gray-900 dark:text-gray-50'>{title}@@ -235,18 +240,27 @@ const ProjectSettings = ({label={t('project.settings.public')}hint={t('project.settings.publicHint')}/>-+ <div className='flex justify-between mt-8'>+ <div>+ <Button className='mr-2 border-indigo-100 dark:text-gray-50 dark:border-gray-800 dark:border-gray-700 dark:bg-gray-700 dark:hover:bg-gray-600' onClick={onCancel} secondary regular>+ {t('common.cancel')}+ </Button>+ <Button type='submit' loading={projectSaving} primary regular>+ {t('common.save')}+ </Button>+ </div>+ {!project.shared && (+ <Button onClick={() => !projectDeleting && setShowDelete(true)} loading={projectDeleting} danger large>+ {t('project.settings.delete')}+ </Button>+ )}+ </div><hr className='mt-5' />-{!project.shared && (- <>- <People project={project} />- <hr className='mt-5' />- </>+ <People project={project} />)}-</>) : (<p className='text-gray-500 dark:text-gray-300 italic mt-2 text-sm'>@@ -254,7 +268,7 @@ const ProjectSettings = ({</p>)}- <div className='flex justify-between mt-4'>+ {!isSettings && (<div><Button className='mr-2 border-indigo-100 dark:text-gray-50 dark:border-gray-800 dark:border-gray-700 dark:bg-gray-700 dark:hover:bg-gray-600' onClick={onCancel} secondary regular>{t('common.cancel')}@@ -263,14 +277,8 @@ const ProjectSettings = ({{t('common.save')}</Button></div>- {(isSettings && !project.shared) && (- <Button onClick={() => !projectDeleting && setShowDelete(true)} loading={projectDeleting} danger large>- {t('project.settings.delete')}- </Button>- )}- </div>+ )}</form>-<ModalonClose={() => setShowDelete(false)}onSubmit={onDelete}diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsxindex 8c1986517..bcf22a584 100644--- a/src/pages/UserSettings/UserSettings.container.jsx+++ b/src/pages/UserSettings/UserSettings.container.jsx@@ -23,7 +23,7 @@ import UserSettings from './UserSettings'dayjs.extend(utc)const UserSettingsContainer = () => {- const { t } = useTranslation('common')+ const { t, i18n: { language } } = useTranslation('common')const dispatch = useDispatch()const history = useHistory()@@ -119,6 +119,7 @@ const UserSettingsContainer = () => {return (<UserSettingst={t}+ language={language}onDelete={onDelete}onExport={onExport}removeProject={removeProject}diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsxindex 256e6d4d3..97f4496a4 100644--- a/src/pages/UserSettings/UserSettings.jsx+++ b/src/pages/UserSettings/UserSettings.jsx@@ -9,6 +9,7 @@ import _map from 'lodash/map'import _keys from 'lodash/keys'import { MailIcon } from '@heroicons/react/outline'import PropTypes from 'prop-types'+import dayjs from 'dayjs'import { reportFrequencies, DEFAULT_TIMEZONE } from 'redux/constants'import Title from 'components/Title'@@ -25,7 +26,7 @@ import {import { deleteShareProject, acceptShareProject } from 'api'const ProjectList = ({- item, t, deleteProjectFailed, removeShareProject, removeProject, setProjectsShareData, setUserShareData,+ item, t, deleteProjectFailed, removeShareProject, removeProject, setProjectsShareData, setUserShareData, language,}) => {const [showDeleteModal, setShowDeleteModal] = useState(false)@@ -57,26 +58,27 @@ const ProjectList = ({{item.project.name}</td><td className='whitespace-nowrap px-3 py-4 text-sm text-gray-900 dark:text-white'>- {item.role}+ {t(`project.settings.roles.${item.role}.name`)}+ </td>+ <td className='whitespace-nowrap px-3 py-4 text-sm text-gray-900 dark:text-white'>+ {language === 'en'+ ? dayjs(item.created).locale(language).format('MMMM D, YYYY')+ : dayjs(item.created).locale(language).format('D MMMM, YYYY')}</td><td className='relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6'>{item.confirmed === false ? (<><Button className='mr-2' onClick={() => setShowDeleteModal(true)} primary small>- Reject+ {t('common.reject')}</Button><Button onClick={() => onAccept()} primary small>- Accept+ {t('common.accept')}</Button></>) : (- <button- type='button'- className='text-indigo-600 hover:text-indigo-900'- onClick={() => setShowDeleteModal(true)}- >- Delete- </button>+ <Button onClick={() => setShowDeleteModal(true)} danger small>+ {t('common.quit')}+ </Button>)}<ModalonClose={() => {@@ -89,8 +91,8 @@ const ProjectList = ({submitText={t('common.yes')}type='confirmed'closeText={t('common.no')}- title={`Delete ${item.id}?`}- message='Are you sure you want to delete this project?'+ title={t('profileSettings.quitProjectTitle', { project: item.project.name })}+ message={t('profileSettings.quitProject')}isOpened={showDeleteModal}/></td>@@ -111,18 +113,19 @@ ProjectList.defaultProps = {deleteProjectFailed: (e) => console.log(e),}-const NoSharedProjectss = () => (+const NoSharedProjects = ({ t }) => (<div className='flex flex-col py-6 sm:px-6 lg:px-8'><div className='max-w-7xl w-full mx-auto text-gray-900 dark:text-gray-50'><h2 className='text-2xl mb-4 text-center leading-snug'>- You have no shared projects.+ {t('profileSettings.noSharedProjects')}</h2></div></div>)const UserSettings = ({- onDelete, onExport, onSubmit, onEmailConfirm, onDeleteProjectCache, t, deleteProjectFailed, removeProject, removeShareProject, setUserShareData, setProjectsShareData,+ onDelete, onExport, onSubmit, onEmailConfirm, onDeleteProjectCache, t, deleteProjectFailed,+ removeProject, removeShareProject, setUserShareData, setProjectsShareData, language,}) => {const { user } = useSelector(state => state.auth)@@ -304,11 +307,12 @@ const UserSettings = ({</Button><hr className='mt-5' />- <h3 className='mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>- Projects+ <h3 className='flex items-center mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>+ {t('profileSettings.shared')}+ <Beta className='ml-10' /></h3><div>- { !_isEmpty(user.sharedProjects) ? (+ {!_isEmpty(user.sharedProjects) ? (<div className='mt-3 flex flex-col'><div className='-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8'><div className='inline-block min-w-full py-2 align-middle md:px-6 lg:px-8'>@@ -317,31 +321,33 @@ const UserSettings = ({<thead><tr className='dark:bg-gray-700'><th scope='col' className='py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-white'>- Name projects+ {t('profileSettings.sharedTable.project')}</th><th scope='col' className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'>- Role+ {t('profileSettings.sharedTable.role')}</th>- <th scope='col' className='relative py-3.5 pl-3 pr-4 sm:pr-6 dark:text-white'>- <span className='sr-only'>delete</span>+ <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' className='relative py-3.5 pl-3 pr-4 sm:pr-6' /></tr></thead><tbody className='divide-y divide-gray-300 dark:divide-gray-600'>{- _map(user.sharedProjects, (item) => (- <ProjectList- key={item.id}- item={item}- t={t}- deleteProjectFailed={deleteProjectFailed}- removeProject={removeProject}- removeShareProject={removeShareProject}- setUserShareData={setUserShareData}- setProjectsShareData={setProjectsShareData}- />- ))- }+ _map(user.sharedProjects, (item) => (+ <ProjectList+ key={item.id}+ item={item}+ language={language}+ t={t}+ deleteProjectFailed={deleteProjectFailed}+ removeProject={removeProject}+ removeShareProject={removeShareProject}+ setUserShareData={setUserShareData}+ setProjectsShareData={setProjectsShareData}+ />+ ))+ }</tbody></table></div>@@ -349,8 +355,8 @@ const UserSettings = ({</div></div>) : (- <NoSharedProjectss />- ) }+ <NoSharedProjects t={t} />+ )}</div><hr className='mt-5' />{!user.isActive && (@@ -423,6 +429,7 @@ UserSettings.propTypes = {removeShareProject: PropTypes.func.isRequired,setUserShareData: PropTypes.func.isRequired,setProjectsShareData: PropTypes.func.isRequired,+ language: PropTypes.string.isRequired,}UserSettings.defaultProps = {diff --git a/src/redux/constants/index.js b/src/redux/constants/index.jsindex 51890c204..4f5376be5 100644--- a/src/redux/constants/index.js+++ b/src/redux/constants/index.js@@ -150,18 +150,7 @@ export const paddleLanguageMapping = {el: 'en',}-export const roles = [- {- name: 'Admin',- role: 'admin',- description: 'Can manage the project',- },- {- name: 'Viewer',- role: 'viewer',- description: 'Can view the project',- },-]+export const roles = ['admin', 'viewer']export const roleViewer = {name: 'Viewer',@@ -174,3 +163,5 @@ export const roleAdmin = {role: 'admin',description: 'Can manage the project',}++export const INVITATION_EXPIRES_IN = 48 // hours