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!

Update organisation settings text copy

Blue Mouse967687c55325
diff --git a/web/app/pages/Organisations/Settings/People.tsx b/web/app/pages/Organisations/Settings/People.tsx
index d6844060d..2d27de655 100644
--- a/web/app/pages/Organisations/Settings/People.tsx
+++ b/web/app/pages/Organisations/Settings/People.tsx
@@ -165,7 +165,7 @@ const UsersList = ({ members, onRemove, fetcher }: UsersListProps) => {
<Text
as='p'
size='sm'
- colour='muted'
+ colour='secondary'
className='mt-0.5'
>
{t(`organisations.role.${itRole}.desc`)}
@@ -389,7 +389,7 @@ const People = ({ organisation }: PeopleProps) => {
<Text as='h3' size='lg' weight='bold' className='mt-2'>
{t('project.settings.people')}
</Text>
- <Text as='p' size='sm' colour='muted'>
+ <Text as='p' size='sm' colour='secondary'>
{t('project.settings.inviteCoworkers')}
</Text>
</div>
diff --git a/web/app/pages/Organisations/Settings/Projects.tsx b/web/app/pages/Organisations/Settings/Projects.tsx
index acf1ccc10..d500b0103 100644
--- a/web/app/pages/Organisations/Settings/Projects.tsx
+++ b/web/app/pages/Organisations/Settings/Projects.tsx
@@ -367,6 +367,7 @@ export const Projects = ({ organisation }: ProjectsProps) => {
setCurrentPage(1)
}}
value={search}
+ className='mb-2'
classes={{ input: 'h-8 py-1.5' }}
leadingIcon={<MagnifyingGlassIcon className='size-4' />}
placeholder={t('project.search')}
diff --git a/web/app/pages/Organisations/Settings/index.tsx b/web/app/pages/Organisations/Settings/index.tsx
index 22fa5f370..01fca0908 100644
--- a/web/app/pages/Organisations/Settings/index.tsx
+++ b/web/app/pages/Organisations/Settings/index.tsx
@@ -7,11 +7,10 @@ import {
CaretLeftIcon,
FolderSimpleIcon,
SlidersHorizontalIcon,
- TrashIcon,
UserCircleIcon,
WarningOctagonIcon,
} from '@phosphor-icons/react'
-import React, { useState, useEffect, useMemo } from 'react'
+import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from '~/ui/Link'
import {
@@ -19,7 +18,6 @@ import {
useFetcher,
useLoaderData,
useSearchParams,
- useRevalidator,
} from 'react-router'
import { toast } from 'sonner'
@@ -42,10 +40,71 @@ import routes from '~/utils/routes'
import NotificationChannels from '~/components/NotificationChannels/NotificationChannels'
+import SettingsSidebar, {
+ SettingsTabConfig,
+ SettingsTabGroup,
+} from '../../Project/Settings/SettingsSidebar'
import People from './People'
import { Projects } from './Projects'
const MAX_NAME_LENGTH = 50
+const AUTOSAVE_DEBOUNCE_MS = 700
+
+type OrganisationForm = Pick<DetailedOrganisation, 'name'>
+
+const ORGANISATION_TEXT_AUTOSAVE_TOASTS = {
+ name: 'apiNotifications.orgSettingsUpdated',
+} as const
+
+type OrganisationTextAutosaveField =
+ keyof typeof ORGANISATION_TEXT_AUTOSAVE_TOASTS
+
+const isOrganisationTextAutosaveField = (
+ field: string,
+): field is OrganisationTextAutosaveField =>
+ Object.prototype.hasOwnProperty.call(ORGANISATION_TEXT_AUTOSAVE_TOASTS, field)
+
+const getFormFromOrganisation = (
+ organisation: DetailedOrganisation | null,
+): OrganisationForm => ({
+ name: organisation?.name || '',
+})
+
+const normaliseOrganisationAutosaveValue = (value: unknown) =>
+ JSON.stringify(value ?? null)
+
+const buildOrganisationAutosaveFormData = (
+ updates: Partial<OrganisationForm>,
+) => {
+ const formData = new FormData()
+ formData.set('intent', 'update-organisation')
+
+ if (updates.name !== undefined) {
+ formData.set('name', updates.name)
+ }
+
+ return formData
+}
+
+interface DangerActionProps {
+ title: string
+ description: string
+ action: React.ReactNode
+}
+
+const DangerAction = ({ title, description, action }: DangerActionProps) => (
+ <div className='flex flex-col items-start gap-4 py-5 sm:flex-row sm:items-center sm:justify-between'>
+ <div>
+ <Text as='h4' size='sm' weight='medium'>
+ {title}
+ </Text>
+ <Text as='p' size='sm' colour='secondary' className='mt-1'>
+ {description}
+ </Text>
+ </div>
+ <div className='shrink-0'>{action}</div>
+ </div>
+)
type SettingsTab = 'general' | 'people' | 'projects' | 'channels' | 'danger'
@@ -54,7 +113,7 @@ const OrganisationSettings = () => {
const loaderData = useLoaderData<OrganisationLoaderData>()
const navigate = useNavigate()
const fetcher = useFetcher<OrganisationSettingsActionData>()
- const revalidator = useRevalidator()
+ const autosaveFetcher = useFetcher<OrganisationSettingsActionData>()
const [searchParams, setSearchParams] = useSearchParams()
const { user } = useAuth()
@@ -65,27 +124,42 @@ const OrganisationSettings = () => {
}>({})
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [showDelete, setShowDelete] = useState(false)
- const [isFormDirty, setIsFormDirty] = useState(false)
const shouldHandleFetcherData =
useDeduplicateFetcherResponse<OrganisationSettingsActionData>()
const organisation = loaderData?.organisation || null
const error = loaderData?.error
-
- const [form, setForm] = useState<Pick<DetailedOrganisation, 'name'>>(() => ({
- name: organisation?.name || '',
- }))
+ const lastSavedForm = useRef<OrganisationForm>(
+ getFormFromOrganisation(organisation),
+ )
+ const lastHandledAutosaveData = useRef<OrganisationSettingsActionData | null>(
+ null,
+ )
+ const activeAutosave = useRef<{
+ updates: Partial<OrganisationForm>
+ toastKey: string
+ } | null>(null)
+ const pendingAutosave = useRef<{
+ updates: Partial<OrganisationForm>
+ toastKey: string
+ } | null>(null)
+ const autosaveTimeout = useRef<ReturnType<typeof setTimeout> | null>(null)
+
+ const [form, setForm] = useState<OrganisationForm>(() =>
+ getFormFromOrganisation(organisation),
+ )
useEffect(() => {
- if (organisation && !isFormDirty) {
- // eslint-disable-next-line
- setForm({ name: organisation.name || '' })
+ if (!organisation) return
+
+ const nextForm = getFormFromOrganisation(organisation)
+ lastSavedForm.current = nextForm
+
+ if (!activeAutosave.current && !pendingAutosave.current) {
+ setForm(nextForm)
}
- }, [organisation, isFormDirty])
+ }, [organisation])
- const isSaving =
- fetcher.state === 'submitting' &&
- fetcher.formData?.get('intent') === 'update-organisation'
const isDeleting =
fetcher.state === 'submitting' &&
fetcher.formData?.get('intent') === 'delete-organisation'
@@ -97,29 +171,16 @@ const OrganisationSettings = () => {
if (fetcher.data?.success) {
const { intent } = fetcher.data
- if (intent === 'update-organisation') {
- toast.success(t('apiNotifications.orgSettingsUpdated'))
- // eslint-disable-next-line
- setIsFormDirty(false)
- revalidator.revalidate()
- } else if (intent === 'delete-organisation') {
+ if (intent === 'delete-organisation') {
toast.success(t('apiNotifications.organisationDeleted'))
setShowDelete(false)
navigate(routes.organisations)
- } else if (
- intent === 'invite-member' ||
- intent === 'remove-member' ||
- intent === 'update-member-role' ||
- intent === 'add-project' ||
- intent === 'remove-project'
- ) {
- revalidator.revalidate()
}
} else if (fetcher.data?.error) {
toast.error(fetcher.data.error)
setShowDelete(false)
}
- }, [fetcher.data, t, navigate, revalidator, shouldHandleFetcherData])
+ }, [fetcher.data, t, navigate, shouldHandleFetcherData])
const isOrganisationOwner = useMemo(() => {
if (!organisation) {
@@ -131,7 +192,7 @@ const OrganisationSettings = () => {
return owner?.user?.email === user?.email
}, [organisation, user])
- const tabs = useMemo(
+ const tabs = useMemo<SettingsTabConfig<SettingsTab>[]>(
() =>
[
{
@@ -174,10 +235,26 @@ const OrganisationSettings = () => {
iconColor: 'text-red-500',
visible: isOrganisationOwner,
},
- ].filter((tab) => tab.visible),
+ ].filter((tab) => tab.visible) as SettingsTabConfig<SettingsTab>[],
[t, isOrganisationOwner],
)
+ const sidebarGroups = useMemo<SettingsTabGroup<SettingsTab>[]>(
+ () => [
+ {
+ id: 'general',
+ label: t('project.settings.sidebarGroups.general'),
+ tabIds: ['general', 'people', 'projects'],
+ },
+ {
+ id: 'notifications',
+ label: t('project.settings.sidebarGroups.notifications'),
+ tabIds: ['channels'],
+ },
+ ],
+ [t],
+ )
+
const activeTab = useMemo<SettingsTab>(() => {
const tab = searchParams.get('tab') as SettingsTab
const allowed = new Set(tabs.map((t) => t.id as SettingsTab))
@@ -199,15 +276,6 @@ const OrganisationSettings = () => {
return (tabs.find((tab) => tab.id === activeTab)?.label as string) || ''
}, [tabs, activeTab])
- const onSubmit = (formData: Pick<DetailedOrganisation, 'name'>) => {
- if (fetcher.state === 'submitting') return
-
- const fd = new FormData()
- fd.set('intent', 'update-organisation')
- fd.set('name', formData.name)
- fetcher.submit(fd, { method: 'post' })
- }
-
const onDelete = () => {
if (fetcher.state === 'submitting') return
@@ -216,45 +284,232 @@ const OrganisationSettings = () => {
fetcher.submit(fd, { method: 'post' })
}
- const validate = () => {
- const allErrors: {
- name?: string
- origins?: string
- ipBlacklist?: string
- password?: string
- } = {}
+ const getValidationErrors = useCallback(
+ (data: OrganisationForm) => {
+ const allErrors: {
+ name?: string
+ } = {}
- if (_isEmpty(form.name)) {
- allErrors.name = t('project.settings.noNameError')
- }
+ if (_isEmpty(data.name)) {
+ allErrors.name = t('project.settings.noNameError')
+ }
+
+ if (_size(data.name) > MAX_NAME_LENGTH) {
+ allErrors.name = t('project.settings.pxCharsError', {
+ amount: MAX_NAME_LENGTH,
+ })
+ }
+
+ return allErrors
+ },
+ [t],
+ )
- if (_size(form.name) > MAX_NAME_LENGTH) {
- allErrors.name = t('project.settings.pxCharsError', {
- amount: MAX_NAME_LENGTH,
+ const hasOrganisationAutosaveChange = useCallback(
+ (updates: Partial<OrganisationForm>) => {
+ const baseline = activeAutosave.current
+ ? {
+ ...lastSavedForm.current,
+ ...activeAutosave.current.updates,
+ }
+ : lastSavedForm.current
+
+ return Object.entries(updates).some(([field, value]) => {
+ return (
+ normaliseOrganisationAutosaveValue(
+ baseline[field as keyof OrganisationForm],
+ ) !== normaliseOrganisationAutosaveValue(value)
+ )
})
+ },
+ [],
+ )
+
+ const clearPendingAutosave = useCallback(() => {
+ pendingAutosave.current = null
+
+ if (autosaveTimeout.current) {
+ clearTimeout(autosaveTimeout.current)
+ autosaveTimeout.current = null
}
+ }, [])
+
+ const flushOrganisationAutosave = useCallback(() => {
+ if (autosaveTimeout.current) {
+ clearTimeout(autosaveTimeout.current)
+ autosaveTimeout.current = null
+ }
+
+ const autosave = pendingAutosave.current
+ if (autosaveFetcher.state !== 'idle' || !autosave) return
+
+ activeAutosave.current = autosave
+ pendingAutosave.current = null
+
+ autosaveFetcher.submit(
+ buildOrganisationAutosaveFormData(autosave.updates),
+ {
+ method: 'post',
+ },
+ )
+ }, [autosaveFetcher])
+
+ const queueOrganisationAutosave = useCallback(
+ (
+ updates: Partial<OrganisationForm>,
+ toastKey = 'apiNotifications.orgSettingsUpdated',
+ immediate = false,
+ ) => {
+ const nextForm = { ...form, ...updates }
+ const allErrors = getValidationErrors(nextForm)
+ const hasUpdatedFieldError = Object.keys(updates).some(
+ (field) => allErrors[field as keyof typeof allErrors],
+ )
+
+ setErrors(allErrors)
+
+ if (hasUpdatedFieldError) {
+ setBeenSubmitted(true)
+ clearPendingAutosave()
+ return
+ }
+
+ if (!hasOrganisationAutosaveChange(updates)) {
+ clearPendingAutosave()
+ return
+ }
+
+ pendingAutosave.current = {
+ updates: {
+ ...pendingAutosave.current?.updates,
+ ...updates,
+ },
+ toastKey,
+ }
+
+ if (autosaveTimeout.current) {
+ clearTimeout(autosaveTimeout.current)
+ autosaveTimeout.current = null
+ }
+ if (immediate) {
+ flushOrganisationAutosave()
+ return
+ }
+
+ autosaveTimeout.current = setTimeout(
+ flushOrganisationAutosave,
+ AUTOSAVE_DEBOUNCE_MS,
+ )
+ },
+ [
+ clearPendingAutosave,
+ flushOrganisationAutosave,
+ form,
+ getValidationErrors,
+ hasOrganisationAutosaveChange,
+ ],
+ )
+
+ const validate = useCallback(() => {
+ const allErrors = getValidationErrors(form)
const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
- }
+ }, [form, getValidationErrors])
+
+ useEffect(() => {
+ return () => {
+ if (autosaveTimeout.current) {
+ clearTimeout(autosaveTimeout.current)
+ }
+ }
+ }, [])
+
+ useEffect(() => {
+ if (
+ autosaveFetcher.state === 'idle' &&
+ pendingAutosave.current &&
+ lastHandledAutosaveData.current === autosaveFetcher.data
+ ) {
+ flushOrganisationAutosave()
+ }
+ }, [autosaveFetcher.data, autosaveFetcher.state, flushOrganisationAutosave])
+
+ useEffect(() => {
+ if (autosaveFetcher.state !== 'idle' || !autosaveFetcher.data) return
+ if (lastHandledAutosaveData.current === autosaveFetcher.data) return
+ lastHandledAutosaveData.current = autosaveFetcher.data
+
+ if (autosaveFetcher.data.success) {
+ const autosave = activeAutosave.current
+
+ if (autosave) {
+ lastSavedForm.current = {
+ ...lastSavedForm.current,
+ ...autosave.updates,
+ }
+ toast.success(t(autosave.toastKey))
+ }
+
+ activeAutosave.current = null
+ if (pendingAutosave.current) {
+ flushOrganisationAutosave()
+ }
+ return
+ }
+
+ activeAutosave.current = null
+
+ if (autosaveFetcher.data.fieldErrors) {
+ setErrors(autosaveFetcher.data.fieldErrors)
+ setBeenSubmitted(true)
+ } else if (autosaveFetcher.data.error) {
+ toast.error(autosaveFetcher.data.error)
+ }
+
+ if (pendingAutosave.current) {
+ flushOrganisationAutosave()
+ }
+ }, [
+ autosaveFetcher.data,
+ autosaveFetcher.state,
+ flushOrganisationAutosave,
+ t,
+ ])
- /* eslint-disable react-hooks/set-state-in-effect */
useEffect(() => {
validate()
- }, [form]) // eslint-disable-line react-hooks/exhaustive-deps
- /* eslint-enable react-hooks/set-state-in-effect */
+ }, [validate])
const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {
const { target } = event
const value = target.type === 'checkbox' ? target.checked : target.value
- setIsFormDirty(true)
setForm((oldForm) => ({
...oldForm,
[target.name]: value,
}))
+
+ if (isOrganisationTextAutosaveField(target.name)) {
+ queueOrganisationAutosave(
+ { [target.name]: value } as Partial<OrganisationForm>,
+ ORGANISATION_TEXT_AUTOSAVE_TOASTS[target.name],
+ )
+ }
+ }
+
+ const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {
+ const { name, value } = event.currentTarget
+
+ if (!isOrganisationTextAutosaveField(name)) return
+
+ queueOrganisationAutosave(
+ { [name]: value } as Partial<OrganisationForm>,
+ ORGANISATION_TEXT_AUTOSAVE_TOASTS[name],
+ true,
+ )
}
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
@@ -263,7 +518,7 @@ const OrganisationSettings = () => {
setBeenSubmitted(true)
if (validated) {
- onSubmit(form)
+ flushOrganisationAutosave()
}
}
@@ -325,7 +580,12 @@ const OrganisationSettings = () => {
labelExtractor={(item) => item.label}
iconExtractor={(item) => {
const Icon = item.icon
- return <Icon className='h-4 w-4' />
+ return (
+ <Icon
+ className={cx('h-4 w-4', item.iconColor)}
+ weight='duotone'
+ />
+ )
}}
onSelect={(item: any) =>
setActiveTab(item.id as typeof activeTab)
@@ -334,38 +594,13 @@ const OrganisationSettings = () => {
/>
</div>
<aside className='hidden w-56 shrink-0 md:block'>
- <nav className='flex flex-col space-y-0.5' aria-label='Sidebar'>
- {tabs.map((tab) => {
- const isCurrent = tab.id === activeTab
- const Icon = tab.icon
-
- return (
- <button
- key={tab.id}
- type='button'
- onClick={() => setActiveTab(tab.id as typeof activeTab)}
- className={cx(
- 'group flex items-center rounded-md px-3 py-2 text-left text-sm text-gray-900 transition-colors',
- {
- 'bg-gray-200 font-semibold dark:bg-slate-900 dark:text-gray-50':
- isCurrent,
- 'hover:bg-gray-200 dark:text-gray-200 dark:hover:bg-slate-900 dark:hover:text-gray-50':
- !isCurrent,
- },
- )}
- aria-current={isCurrent ? 'page' : undefined}
- >
- <Icon
- className={cx('mr-2 size-4 shrink-0 transition-colors', {
- 'text-gray-900 dark:text-gray-50': isCurrent,
- 'text-gray-600 dark:text-gray-300': !isCurrent,
- })}
- />
- <span className='truncate'>{tab.label}</span>
- </button>
- )
- })}
- </nav>
+ <SettingsSidebar
+ tabs={tabs}
+ activeTab={activeTab}
+ onTabChange={(tabId) => setActiveTab(tabId)}
+ groups={sidebarGroups}
+ storageKey='organisation-settings-sidebar-groups'
+ />
</aside>
<section className='flex-1'>
{activeTab === 'general' && activeTabConfig ? (
@@ -378,28 +613,14 @@ const OrganisationSettings = () => {
/>
<Input
name='name'
- label={t('common.name')}
+ label={t('organisations.name')}
+ hint={t('organisations.nameHint')}
value={form.name}
className='mt-2'
onChange={handleInput}
+ onBlur={handleInputBlur}
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
- variant='secondary'
- className='border-indigo-100 dark:border-slate-700/50 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-800'
- as={Link}
- // @ts-expect-error
- to={routes.organisations}
- >
- {t('common.cancel')}
- </Button>
- <Button type='submit' loading={isSaving}>
- {t('common.save')}
- </Button>
- </div>
- </div>
</form>
) : null}
{activeTab === 'people' && activeTabConfig ? (
@@ -453,23 +674,27 @@ const OrganisationSettings = () => {
description={activeTabConfig.description}
iconColorClass={activeTabConfig.iconColor}
/>
- <div className='rounded-lg border border-gray-200 p-5 dark:border-slate-800'>
- <Text as='h3' size='lg' weight='semibold'>
- {t('organisations.delete')}
- </Text>
- <Text as='p' size='sm' colour='muted' className='mt-2'>
- {t('organisations.modals.delete.message')}
+ <section>
+ <Text as='h3' size='lg' weight='bold'>
+ {t('project.settings.destructiveActions')}
</Text>
- <Button
- variant='danger'
- className='mt-4'
- onClick={() => setShowDelete(true)}
- disabled={isDeleting}
- >
- <TrashIcon className='mr-1 h-5 w-5' />
- {t('organisations.delete')}
- </Button>
- </div>
+ <div className='mt-2 divide-y divide-gray-200 dark:divide-gray-800'>
+ <DangerAction
+ title={t('organisations.delete')}
+ description={t('organisations.modals.delete.message')}
+ action={
+ <Button
+ variant='danger'
+ type='button'
+ onClick={() => !isDeleting && setShowDelete(true)}
+ loading={isDeleting}
+ >
+ {t('organisations.delete')}
+ </Button>
+ }
+ />
+ </div>
+ </section>
</>
) : null}
</section>
diff --git a/web/app/pages/Project/Settings/People/People.tsx b/web/app/pages/Project/Settings/People/People.tsx
index d951888af..767c6c114 100644
--- a/web/app/pages/Project/Settings/People/People.tsx
+++ b/web/app/pages/Project/Settings/People/People.tsx
@@ -181,7 +181,7 @@ const TableUserRow = ({
<Text
as='p'
size='sm'
- colour='muted'
+ colour='secondary'
className='mt-0.5'
>
{t(`project.settings.roles.${itRole}.shortDesc`)}
@@ -388,7 +388,12 @@ const People = ({ project }: PeopleProps) => {
<Text as='h3' size='lg' weight='bold'>
{t('project.settings.people')}
</Text>
- <Text as='p' size='sm' colour='muted' className='mt-1 max-w-prose'>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='mt-1 max-w-prose'
+ >
{t('project.settings.inviteCoworkers')}
</Text>
</div>
diff --git a/web/app/pages/Project/Settings/SettingsSidebar.tsx b/web/app/pages/Project/Settings/SettingsSidebar.tsx
index 7d5d4a443..2e0e31fc3 100644
--- a/web/app/pages/Project/Settings/SettingsSidebar.tsx
+++ b/web/app/pages/Project/Settings/SettingsSidebar.tsx
@@ -6,31 +6,38 @@ import { useTranslation } from 'react-i18next'
import { Text } from '~/ui/Text'
import { cn } from '~/utils/generic'
-const SIDEBAR_GROUPS_KEY = 'project-settings-sidebar-groups'
+const DEFAULT_SIDEBAR_GROUPS_KEY = 'project-settings-sidebar-groups'
-const getGroupExpandedState = (groupId: string): boolean => {
+const getGroupExpandedState = (
+ storageKey: string,
+ groupId: string,
+): boolean => {
if (typeof window === 'undefined') return true
try {
- const stored = localStorage.getItem(SIDEBAR_GROUPS_KEY)
+ const stored = localStorage.getItem(storageKey)
if (stored) {
const states = JSON.parse(stored)
return states[groupId] !== false
}
} catch {
- // Ignore parse errors
+ return true
}
return true
}
-const setGroupExpandedState = (groupId: string, isExpanded: boolean) => {
+const setGroupExpandedState = (
+ storageKey: string,
+ groupId: string,
+ isExpanded: boolean,
+) => {
if (typeof window === 'undefined') return
try {
- const stored = localStorage.getItem(SIDEBAR_GROUPS_KEY)
+ const stored = localStorage.getItem(storageKey)
const states = stored ? JSON.parse(stored) : {}
states[groupId] = isExpanded
- localStorage.setItem(SIDEBAR_GROUPS_KEY, JSON.stringify(states))
+ localStorage.setItem(storageKey, JSON.stringify(states))
} catch {
- // Ignore errors
+ return
}
}
@@ -43,7 +50,7 @@ export interface SettingsTabConfig<TabId extends string = string> {
visible: boolean
}
-interface SettingsTabGroup<TabId extends string = string> {
+export interface SettingsTabGroup<TabId extends string = string> {
id: string
label: string
tabIds: TabId[]
@@ -53,6 +60,8 @@ interface SettingsSidebarProps<TabId extends string> {
tabs: SettingsTabConfig<TabId>[]
activeTab: TabId
onTabChange: (tabId: TabId) => void
+ groups?: SettingsTabGroup<TabId>[]
+ storageKey?: string
}
const TabButton = <TabId extends string>({
@@ -96,11 +105,13 @@ const CollapsibleGroup = <TabId extends string>({
tabs,
activeTab,
onTabChange,
+ storageKey,
}: {
group: SettingsTabGroup<TabId>
tabs: SettingsTabConfig<TabId>[]
activeTab: TabId
onTabChange: (tabId: TabId) => void
+ storageKey: string
}) => {
const [isExpanded, setIsExpanded] = useState(true)
@@ -112,16 +123,16 @@ const CollapsibleGroup = <TabId extends string>({
const prevHasActiveTab = useRef(hasActiveTab)
useEffect(() => {
- setIsExpanded(getGroupExpandedState(group.id))
- }, [group.id])
+ setIsExpanded(getGroupExpandedState(storageKey, group.id))
+ }, [group.id, storageKey])
useEffect(() => {
if (hasActiveTab && !prevHasActiveTab.current && !isExpanded) {
setIsExpanded(true)
- setGroupExpandedState(group.id, true)
+ setGroupExpandedState(storageKey, group.id, true)
}
prevHasActiveTab.current = hasActiveTab
- }, [hasActiveTab, group.id]) // eslint-disable-line react-hooks/exhaustive-deps
+ }, [hasActiveTab, group.id, storageKey]) // eslint-disable-line react-hooks/exhaustive-deps
return (
<div className='mb-1'>
@@ -130,7 +141,7 @@ const CollapsibleGroup = <TabId extends string>({
onClick={() => {
const newValue = !isExpanded
setIsExpanded(newValue)
- setGroupExpandedState(group.id, newValue)
+ setGroupExpandedState(storageKey, group.id, newValue)
}}
className='group flex w-full items-center justify-between rounded-md px-2 py-1.5 text-left transition-colors hover:bg-gray-100 dark:hover:bg-slate-900/60'
>
@@ -182,10 +193,12 @@ const SettingsSidebar = <TabId extends string>({
tabs,
activeTab,
onTabChange,
+ groups,
+ storageKey = DEFAULT_SIDEBAR_GROUPS_KEY,
}: SettingsSidebarProps<TabId>) => {
const { t } = useTranslation('common')
- const groupsConfig = useMemo<SettingsTabGroup<TabId>[]>(
+ const defaultGroupsConfig = useMemo<SettingsTabGroup<TabId>[]>(
() => [
{
id: 'general',
@@ -216,13 +229,15 @@ const SettingsSidebar = <TabId extends string>({
[t],
)
+ const groupsConfig = groups || defaultGroupsConfig
+
const visibleTabsById = useMemo(() => {
const map = new Map<TabId, SettingsTabConfig<TabId>>()
tabs.forEach((tab) => map.set(tab.id, tab))
return map
}, [tabs])
- const groups = useMemo(
+ const sidebarGroups = useMemo(
() =>
groupsConfig
.map((group) => ({
@@ -250,13 +265,14 @@ const SettingsSidebar = <TabId extends string>({
return (
<nav className='flex flex-col' aria-label='Sidebar'>
- {_map(groups, (group) => (
+ {_map(sidebarGroups, (group) => (
<CollapsibleGroup
key={group.id}
group={group}
tabs={group.tabs}
activeTab={activeTab}
onTabChange={onTabChange}
+ storageKey={storageKey}
/>
))}
diff --git a/web/app/pages/UserSettings/UserSettings.tsx b/web/app/pages/UserSettings/UserSettings.tsx
index a5aaa6338..ff87683d2 100644
--- a/web/app/pages/UserSettings/UserSettings.tsx
+++ b/web/app/pages/UserSettings/UserSettings.tsx
@@ -1012,10 +1012,7 @@ const UserSettings = () => {
>
{user?.apiKey ? (
<>
- <Alert
- variant='warning'
- className='mb-3'
- >
+ <Alert variant='warning' className='mb-3'>
{t('profileSettings.apiKeyWarning')}
</Alert>
<div className='max-w-md'>
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index f44d6d2a7..7370504b7 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1002,69 +1002,71 @@
}
},
"alertsSettings": {
- "alertCreated": "The alert has been created",
- "alertUpdated": "The alert has been updated",
- "alertDeleted": "The alert has been deleted"
+ "alertCreated": "Alert created",
+ "alertUpdated": "Alert updated",
+ "alertDeleted": "Alert deleted"
},
"organisations": {
"create": "Create organisation",
"organisations": "Organisations",
"backToList": "Back to organisations",
"noOrganisations": "No organisations yet",
- "createOrganisation": "You haven't created or joined any organisations yet. Get started by creating your first organisation.",
+ "createOrganisation": "Create your first organisation to share projects and manage team access.",
"new": "New organisation",
+ "name": "Organisation name",
+ "nameHint": "Shown to members. You can change it later.",
"settings": {
"tabs": {
"general": "General",
- "generalDesc": "Update organisation name and basic details.",
+ "generalDesc": "Update the organisation name and basic settings.",
"people": "People",
- "peopleDesc": "Manage members and their roles.",
+ "peopleDesc": "Invite members and manage their roles.",
"projects": "Projects",
- "projectsDesc": "Add or remove projects for this organisation.",
+ "projectsDesc": "Choose which projects belong to this organisation.",
"channels": "Notification channels",
- "channelsDesc": "Channels visible to every member of this organisation.",
+ "channelsDesc": "Manage channels available to all organisation members.",
"danger": "Danger zone",
- "dangerDesc": "Irreversible actions for this organisation."
+ "dangerDesc": "Delete this organisation or make other permanent changes."
}
},
"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."
+ "title": "Invite user to {{organisation}}",
+ "desc": "Enter the email address of a Swetrix user and choose their role. The invite expires in {{expiresIn}} hours."
},
- "peopleEmptyTitle": "No organisation members yet",
- "peopleEmptyDescription": "Invite teammates to give them access to this organisation and the projects linked to it.",
+ "peopleEmptyTitle": "No members yet",
+ "peopleEmptyDescription": "Invite teammates to give them access to this organisation and its linked projects.",
"role": {
"owner": {
"name": "Owner",
- "desc": "Can manage the organisation and its members, as well as manage the projects within the organisation."
+ "desc": "Can manage the organisation, members, roles, and all linked projects."
},
"admin": {
"name": "Admin",
- "desc": "Can manage the organisation and its members, as well as manage the projects within the organisation."
+ "desc": "Can manage the organisation, members, roles, and all linked projects."
},
"viewer": {
"name": "Viewer",
- "desc": "Can only access the organisation and its projects without the ability to change any settings."
+ "desc": "Can view the organisation and its linked projects, but cannot change settings."
}
},
"projects": "Projects",
"addProject": "Add project",
- "noProjectsFound": "No projects found within this organisation",
+ "noProjectsFound": "No projects in this organisation",
"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."
+ "message": "This removes the project from the organisation. The project and its data will not be deleted. Organisation members will lose access unless they are added in the project settings."
},
"addProject": {
"title": "Add project to {{organisation}}",
- "message": "Select the project you want to add to the organisation. It will be available to all members of the organisation, and the organisation admins will be able to manage the project settings."
+ "message": "Choose a project to add. All organisation members will get access, and organisation admins can manage its project settings."
},
"delete": {
"title": "Delete {{organisation}}?",
- "message": "Are you sure you want to delete this organisation?\nAll the data related to the organisation will be deleted from our servers. This action is irreversible."
+ "message": "This deletes the organisation and all organisation-related data from our servers. Linked project access through this organisation will be removed. This cannot be undone."
}
},
- "projectOwnedBy": "This project is owned by {{email}}",
+ "projectOwnedBy": "Owned by {{email}}",
"delete": "Delete organisation"
},
"dashboard": {
@@ -2440,7 +2442,6 @@
"public": "Public dashboard",
"enabledHint": "Turn this off to stop collecting new analytics data. Existing data and project settings will stay available.",
"publicHint": "If enabled, anyone on the Internet would be able to see this project's dashboard.\nOnly the project administrator can edit the settings.",
- "createHint": "*you will be able to set up your project more thoroughly after you have created it",
"delete": "Delete project",
"reset": "Reset project",
"qDelete": "Delete the project?",