Skip to content

Commit 3951a31

Browse files
committed
Your commit message
1 parent 7c69c25 commit 3951a31

File tree

15 files changed

+96
-95
lines changed

15 files changed

+96
-95
lines changed
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
const PREFERENCE_PANE_IDS = [
2-
'general',
3-
'account',
4-
'security',
5-
'home-server',
6-
'vaults',
7-
'appearance',
8-
'backups',
9-
'listed',
10-
'plugins',
11-
'shortcuts',
12-
'accessibility',
13-
'get-free-month',
14-
'help-feedback',
15-
'whats-new',
16-
] as const
17-
18-
export type PreferencePaneId = (typeof PREFERENCE_PANE_IDS)[number]
1+
export enum PreferencePaneId {
2+
General = 'general',
3+
Account = 'account',
4+
Security = 'security',
5+
HomeServer = 'home-server',
6+
Vaults = 'vaults',
7+
Appearance = 'appearance',
8+
Backups = 'backups',
9+
Listed = 'listed',
10+
Plugins = 'plugins',
11+
Shortcuts = 'shortcuts',
12+
Accessibility = 'accessibility',
13+
GetFreeMonth = 'get-free-month',
14+
HelpFeedback = 'help-feedback',
15+
WhatsNew = 'whats-new',
16+
}

packages/services/src/Domain/Status/StatusService.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ import { PreferencePaneId } from '../Preferences/PreferenceId'
77

88
export class StatusService extends AbstractService<StatusServiceEvent, string> implements StatusServiceInterface {
99
private preferencesBubbleCounts: Record<PreferencePaneId, number> = {
10-
general: 0,
11-
account: 0,
12-
security: 0,
13-
'home-server': 0,
14-
vaults: 0,
15-
appearance: 0,
16-
backups: 0,
17-
listed: 0,
18-
shortcuts: 0,
19-
plugins: 0,
20-
accessibility: 0,
21-
'get-free-month': 0,
22-
'help-feedback': 0,
23-
'whats-new': 0,
10+
[PreferencePaneId.General]: 0,
11+
[PreferencePaneId.Account]: 0,
12+
[PreferencePaneId.Security]: 0,
13+
[PreferencePaneId.HomeServer]: 0,
14+
[PreferencePaneId.Vaults]: 0,
15+
[PreferencePaneId.Appearance]: 0,
16+
[PreferencePaneId.Backups]: 0,
17+
[PreferencePaneId.Listed]: 0,
18+
[PreferencePaneId.Shortcuts]: 0,
19+
[PreferencePaneId.Plugins]: 0,
20+
[PreferencePaneId.Accessibility]: 0,
21+
[PreferencePaneId.GetFreeMonth]: 0,
22+
[PreferencePaneId.HelpFeedback]: 0,
23+
[PreferencePaneId.WhatsNew]: 0,
2424
}
2525

2626
getPreferencesBubbleCount(preferencePaneId: PreferencePaneId): number {

packages/services/src/Domain/VaultInvite/VaultInviteService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { StatusServiceInterface } from '../Status/StatusServiceInterface'
4141
import { ApplicationEvent } from '../Event/ApplicationEvent'
4242
import { WebSocketsServiceEvent } from '../Api/WebSocketsServiceEvent'
4343
import { NotificationServiceEvent, NotificationServiceEventPayload } from '../UserEvent/NotificationServiceEvent'
44+
import { PreferencePaneId } from '@standardnotes/snjs'
4445

4546
export class VaultInviteService
4647
extends AbstractService<VaultInviteServiceEvent>
@@ -101,7 +102,7 @@ export class VaultInviteService
101102
}
102103

103104
updatePendingInviteCount() {
104-
this.status.setPreferencesBubbleCount('vaults', Object.keys(this.pendingInvites).length)
105+
this.status.setPreferencesBubbleCount(PreferencePaneId.Vaults, Object.keys(this.pendingInvites).length)
105106
}
106107

107108
addPendingInvite(invite: InviteRecord): void {

packages/web/src/javascripts/Components/AccountMenu/GeneralAccountMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { observer } from 'mobx-react-lite'
22
import Icon from '@/Components/Icon/Icon'
3-
import { SyncQueueStrategy } from '@standardnotes/snjs'
3+
import { PreferencePaneId, SyncQueueStrategy } from '@standardnotes/snjs'
44
import { STRING_GENERIC_SYNC_ERROR } from '@/Constants/Strings'
55
import { useCallback, useMemo, useState, FunctionComponent } from 'react'
66
import { AccountMenuPane } from './AccountMenuPane'
@@ -57,13 +57,13 @@ const GeneralAccountMenu: FunctionComponent<Props> = ({ setMenuPane, closeMenu,
5757

5858
const openPreferences = useCallback(() => {
5959
application.accountMenuController.closeAccountMenu()
60-
application.preferencesController.setCurrentPane('account')
60+
application.preferencesController.setCurrentPane(PreferencePaneId.Account)
6161
application.preferencesController.openPreferences()
6262
}, [application])
6363

6464
const openHelp = useCallback(() => {
6565
application.accountMenuController.closeAccountMenu()
66-
application.preferencesController.setCurrentPane('help-feedback')
66+
application.preferencesController.setCurrentPane(PreferencePaneId.HelpFeedback)
6767
application.preferencesController.openPreferences()
6868
}, [application])
6969

packages/web/src/javascripts/Components/ChangeEditor/ChangeEditorMenu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
SNNote,
1414
ContentType,
1515
LocalPrefKey,
16+
PreferencePaneId,
1617
} from '@standardnotes/snjs'
1718
import { FunctionComponent, useCallback, useEffect, useState } from 'react'
1819
import { EditorMenuGroup } from '@/Components/NotesOptions/EditorMenuGroup'
@@ -247,7 +248,7 @@ const ChangeEditorMenu: FunctionComponent<ChangeEditorMenuProps> = ({
247248
}
248249

249250
const managePlugins = useCallback(() => {
250-
application.openPreferences('plugins')
251+
application.openPreferences(PreferencePaneId.Plugins)
251252
}, [application])
252253

253254
return (

packages/web/src/javascripts/Components/Dropdown/Dropdown.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { classNames } from '@standardnotes/snjs'
44
import { Select, SelectItem, SelectLabel, SelectPopover, SelectStoreProps, useSelectStore } from '@ariakit/react'
55
import { KeyboardKey } from '@standardnotes/ui-services'
66

7-
type DropdownProps = {
7+
type DropdownProps<T extends string> = {
88
label: string
9-
items: DropdownItem[]
10-
value: string
11-
onChange: (value: string) => void
9+
items: DropdownItem<T>[]
10+
value: T
11+
onChange: (value: T) => void
1212
disabled?: boolean
1313
classNameOverride?: {
1414
wrapper?: string
@@ -20,7 +20,7 @@ type DropdownProps = {
2020
showLabel?: boolean
2121
}
2222

23-
const Dropdown = ({
23+
const Dropdown = <T extends string>({
2424
label,
2525
value,
2626
onChange,
@@ -30,7 +30,7 @@ const Dropdown = ({
3030
classNameOverride = {},
3131
popoverPlacement,
3232
showLabel,
33-
}: DropdownProps) => {
33+
}: DropdownProps<T>) => {
3434
const select = useSelectStore({
3535
value,
3636
setValue: onChange,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { IconType } from '@standardnotes/snjs'
22

3-
export type DropdownItem = {
3+
export type DropdownItem<T extends string> = {
44
icon?: IconType
55
iconClassName?: string
66
label: string
7-
value: string
7+
value: T
88
disabled?: boolean
99
}

packages/web/src/javascripts/Components/FileContextMenu/FileContextMenuBackupOption.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FunctionComponent, useCallback, useEffect, useState } from 'react'
22
import MenuItem from '../Menu/MenuItem'
33
import { useApplication } from '../ApplicationProvider'
4-
import { FileBackupRecord, FileItem } from '@standardnotes/snjs'
4+
import { FileBackupRecord, FileItem, PreferencePaneId } from '@standardnotes/snjs'
55
import { dateToStringStyle1 } from '@/Utils/DateUtils'
66
import { MenuItemIconSize } from '@/Constants/TailwindClassNames'
77
import MenuSection from '../Menu/MenuSection'
@@ -31,7 +31,7 @@ export const FileContextMenuBackupOption: FunctionComponent<{ file: FileItem }>
3131
}, [backupInfo, application])
3232

3333
const configureFileBackups = useCallback(() => {
34-
application.openPreferences('backups')
34+
application.openPreferences(PreferencePaneId.Backups)
3535
}, [application])
3636

3737
if (!application.fileBackups) {

packages/web/src/javascripts/Components/Footer/Footer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
StatusServiceEvent,
1010
HttpErrorResponseBody,
1111
getErrorMessageFromErrorResponseBody,
12+
PreferencePaneId,
1213
} from '@standardnotes/snjs'
1314
import {
1415
STRING_NEW_UPDATE_READY,
@@ -343,7 +344,7 @@ class Footer extends AbstractComponent<Props, State> {
343344

344345
openPreferences = (openWhatsNew: boolean) => {
345346
if (openWhatsNew) {
346-
this.application.preferencesController.setCurrentPane('whats-new')
347+
this.application.preferencesController.setCurrentPane(PreferencePaneId.WhatsNew)
347348
}
348349
this.application.preferencesController.openPreferences()
349350
}
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1+
import { PreferencePaneId } from '@/__mocks__/@standardnotes/snjs'
12
import { PreferencesMenuItem } from './PreferencesMenuItem'
23

34
export const PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
4-
{ id: 'whats-new', label: "What's New", icon: 'asterisk', order: 0 },
5-
{ id: 'account', label: 'Account', icon: 'user', order: 1 },
6-
{ id: 'general', label: 'General', icon: 'settings', order: 3 },
7-
{ id: 'security', label: 'Security', icon: 'security', order: 4 },
8-
{ id: 'backups', label: 'Backups', icon: 'restore', order: 5 },
9-
{ id: 'appearance', label: 'Appearance', icon: 'themes', order: 6 },
10-
{ id: 'listed', label: 'Listed', icon: 'listed', order: 7 },
11-
{ id: 'shortcuts', label: 'Shortcuts', icon: 'keyboard', order: 8 },
12-
{ id: 'plugins', label: 'Plugins', icon: 'dashboard', order: 8 },
13-
{ id: 'accessibility', label: 'Accessibility', icon: 'accessibility', order: 9 },
14-
{ id: 'get-free-month', label: 'Get a free month', icon: 'star', order: 10 },
15-
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help', order: 11 },
5+
{ id: PreferencePaneId.WhatsNew, label: "What's New", icon: 'asterisk', order: 0 },
6+
{ id: PreferencePaneId.Account, label: 'Account', icon: 'user', order: 1 },
7+
{ id: PreferencePaneId.General, label: 'General', icon: 'settings', order: 3 },
8+
{ id: PreferencePaneId.Security, label: 'Security', icon: 'security', order: 4 },
9+
{ id: PreferencePaneId.Backups, label: 'Backups', icon: 'restore', order: 5 },
10+
{ id: PreferencePaneId.Appearance, label: 'Appearance', icon: 'themes', order: 6 },
11+
{ id: PreferencePaneId.Listed, label: 'Listed', icon: 'listed', order: 7 },
12+
{ id: PreferencePaneId.Shortcuts, label: 'Shortcuts', icon: 'keyboard', order: 8 },
13+
{ id: PreferencePaneId.Plugins, label: 'Plugins', icon: 'dashboard', order: 8 },
14+
{ id: PreferencePaneId.Accessibility, label: 'Accessibility', icon: 'accessibility', order: 9 },
15+
{ id: PreferencePaneId.GetFreeMonth, label: 'Get a free month', icon: 'star', order: 10 },
16+
{ id: PreferencePaneId.HelpFeedback, label: 'Help & feedback', icon: 'help', order: 11 },
1617
]
1718

1819
export const READY_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
19-
{ id: 'whats-new', label: "What's New", icon: 'asterisk', order: 0 },
20-
{ id: 'account', label: 'Account', icon: 'user', order: 1 },
21-
{ id: 'general', label: 'General', icon: 'settings', order: 3 },
22-
{ id: 'security', label: 'Security', icon: 'security', order: 4 },
23-
{ id: 'backups', label: 'Backups', icon: 'restore', order: 5 },
24-
{ id: 'appearance', label: 'Appearance', icon: 'themes', order: 6 },
25-
{ id: 'listed', label: 'Listed', icon: 'listed', order: 7 },
26-
{ id: 'plugins', label: 'Plugins', icon: 'dashboard', order: 8 },
27-
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help', order: 11 },
20+
{ id: PreferencePaneId.WhatsNew, label: "What's New", icon: 'asterisk', order: 0 },
21+
{ id: PreferencePaneId.Account, label: 'Account', icon: 'user', order: 1 },
22+
{ id: PreferencePaneId.General, label: 'General', icon: 'settings', order: 3 },
23+
{ id: PreferencePaneId.Security, label: 'Security', icon: 'security', order: 4 },
24+
{ id: PreferencePaneId.Backups, label: 'Backups', icon: 'restore', order: 5 },
25+
{ id: PreferencePaneId.Appearance, label: 'Appearance', icon: 'themes', order: 6 },
26+
{ id: PreferencePaneId.Listed, label: 'Listed', icon: 'listed', order: 7 },
27+
{ id: PreferencePaneId.Plugins, label: 'Plugins', icon: 'dashboard', order: 8 },
28+
{ id: PreferencePaneId.HelpFeedback, label: 'Help & feedback', icon: 'help', order: 11 },
2829
]

0 commit comments

Comments
 (0)