fix: make display options copy type-agnostic (#1054)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { WebApplication } from '@/UIModels/Application'
|
import { WebApplication } from '@/UIModels/Application'
|
||||||
import { CollectionSort, CollectionSortProperty, PrefKey } from '@standardnotes/snjs'
|
import { CollectionSort, CollectionSortProperty, PrefKey, SystemViewId } from '@standardnotes/snjs'
|
||||||
import { observer } from 'mobx-react-lite'
|
import { observer } from 'mobx-react-lite'
|
||||||
import { FunctionComponent, useCallback, useState } from 'react'
|
import { FunctionComponent, useCallback, useState } from 'react'
|
||||||
import Icon from '@/Components/Icon/Icon'
|
import Icon from '@/Components/Icon/Icon'
|
||||||
@@ -7,18 +7,21 @@ import Menu from '@/Components/Menu/Menu'
|
|||||||
import MenuItem from '@/Components/Menu/MenuItem'
|
import MenuItem from '@/Components/Menu/MenuItem'
|
||||||
import MenuItemSeparator from '@/Components/Menu/MenuItemSeparator'
|
import MenuItemSeparator from '@/Components/Menu/MenuItemSeparator'
|
||||||
import { MenuItemType } from '@/Components/Menu/MenuItemType'
|
import { MenuItemType } from '@/Components/Menu/MenuItemType'
|
||||||
|
import { AppState } from '@/UIModels/AppState'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
|
appState: AppState
|
||||||
closeOnBlur: (event: { relatedTarget: EventTarget | null }) => void
|
closeOnBlur: (event: { relatedTarget: EventTarget | null }) => void
|
||||||
closeDisplayOptionsMenu: () => void
|
closeDisplayOptionsMenu: () => void
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
const ContentListOptionsMenu: FunctionComponent<Props> = ({
|
||||||
closeDisplayOptionsMenu,
|
closeDisplayOptionsMenu,
|
||||||
closeOnBlur,
|
closeOnBlur,
|
||||||
application,
|
application,
|
||||||
|
appState,
|
||||||
isOpen,
|
isOpen,
|
||||||
}) => {
|
}) => {
|
||||||
const [sortBy, setSortBy] = useState(() => application.getPreference(PrefKey.SortNotesBy, CollectionSort.CreatedAt))
|
const [sortBy, setSortBy] = useState(() => application.getPreference(PrefKey.SortNotesBy, CollectionSort.CreatedAt))
|
||||||
@@ -171,15 +174,17 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItemSeparator />
|
<MenuItemSeparator />
|
||||||
<div className="px-3 py-1 text-xs font-semibold color-text uppercase">View</div>
|
<div className="px-3 py-1 text-xs font-semibold color-text uppercase">View</div>
|
||||||
<MenuItem
|
{appState.tags.selectedUuid !== SystemViewId.Files && (
|
||||||
type={MenuItemType.SwitchButton}
|
<MenuItem
|
||||||
className="py-1 hover:bg-contrast focus:bg-info-backdrop"
|
type={MenuItemType.SwitchButton}
|
||||||
checked={!hidePreview}
|
className="py-1 hover:bg-contrast focus:bg-info-backdrop"
|
||||||
onChange={toggleHidePreview}
|
checked={!hidePreview}
|
||||||
onBlur={closeOnBlur}
|
onChange={toggleHidePreview}
|
||||||
>
|
onBlur={closeOnBlur}
|
||||||
<div className="flex flex-col max-w-3/4">Show note preview</div>
|
>
|
||||||
</MenuItem>
|
<div className="flex flex-col max-w-3/4">Show note preview</div>
|
||||||
|
</MenuItem>
|
||||||
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
type={MenuItemType.SwitchButton}
|
type={MenuItemType.SwitchButton}
|
||||||
className="py-1 hover:bg-contrast focus:bg-info-backdrop"
|
className="py-1 hover:bg-contrast focus:bg-info-backdrop"
|
||||||
@@ -205,7 +210,7 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
onChange={toggleEditorIcon}
|
onChange={toggleEditorIcon}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
Show editor icon
|
Show icon
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<div className="h-1px my-2 bg-border"></div>
|
<div className="h-1px my-2 bg-border"></div>
|
||||||
<div className="px-3 py-1 text-xs font-semibold color-text uppercase">Other</div>
|
<div className="px-3 py-1 text-xs font-semibold color-text uppercase">Other</div>
|
||||||
@@ -216,7 +221,7 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
onChange={toggleHidePinned}
|
onChange={toggleHidePinned}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
Show pinned notes
|
Show pinned
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
type={MenuItemType.SwitchButton}
|
type={MenuItemType.SwitchButton}
|
||||||
@@ -225,7 +230,7 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
onChange={toggleHideProtected}
|
onChange={toggleHideProtected}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
Show protected notes
|
Show protected
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
type={MenuItemType.SwitchButton}
|
type={MenuItemType.SwitchButton}
|
||||||
@@ -234,7 +239,7 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
onChange={toggleShowArchived}
|
onChange={toggleShowArchived}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
Show archived notes
|
Show archived
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
type={MenuItemType.SwitchButton}
|
type={MenuItemType.SwitchButton}
|
||||||
@@ -243,10 +248,10 @@ const NotesListOptionsMenu: FunctionComponent<Props> = ({
|
|||||||
onChange={toggleShowTrashed}
|
onChange={toggleShowTrashed}
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
Show trashed notes
|
Show trashed
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default observer(NotesListOptionsMenu)
|
export default observer(ContentListOptionsMenu)
|
||||||
@@ -15,12 +15,12 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import ContentList from '@/Components/ContentListView/ContentList'
|
import ContentList from '@/Components/ContentListView/ContentList'
|
||||||
import NotesListOptionsMenu from '@/Components/ContentListView/NotesListOptionsMenu'
|
|
||||||
import NoAccountWarningWrapper from '@/Components/NoAccountWarning/NoAccountWarning'
|
import NoAccountWarningWrapper from '@/Components/NoAccountWarning/NoAccountWarning'
|
||||||
import SearchOptions from '@/Components/SearchOptions/SearchOptions'
|
import SearchOptions from '@/Components/SearchOptions/SearchOptions'
|
||||||
import PanelResizer, { PanelSide, ResizeFinishCallback, PanelResizeType } from '@/Components/PanelResizer/PanelResizer'
|
import PanelResizer, { PanelSide, ResizeFinishCallback, PanelResizeType } from '@/Components/PanelResizer/PanelResizer'
|
||||||
import { Disclosure, DisclosureButton, DisclosurePanel } from '@reach/disclosure'
|
import { Disclosure, DisclosureButton, DisclosurePanel } from '@reach/disclosure'
|
||||||
import { useCloseOnBlur } from '@/Hooks/useCloseOnBlur'
|
import { useCloseOnBlur } from '@/Hooks/useCloseOnBlur'
|
||||||
|
import ContentListOptionsMenu from './ContentListOptionsMenu'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
application: WebApplication
|
application: WebApplication
|
||||||
@@ -233,8 +233,9 @@ const ContentListView: FunctionComponent<Props> = ({ application, appState }) =>
|
|||||||
</DisclosureButton>
|
</DisclosureButton>
|
||||||
<DisclosurePanel onBlur={closeDisplayOptMenuOnBlur}>
|
<DisclosurePanel onBlur={closeDisplayOptMenuOnBlur}>
|
||||||
{showDisplayOptionsMenu && (
|
{showDisplayOptionsMenu && (
|
||||||
<NotesListOptionsMenu
|
<ContentListOptionsMenu
|
||||||
application={application}
|
application={application}
|
||||||
|
appState={appState}
|
||||||
closeDisplayOptionsMenu={toggleDisplayOptionsMenu}
|
closeDisplayOptionsMenu={toggleDisplayOptionsMenu}
|
||||||
closeOnBlur={closeDisplayOptMenuOnBlur}
|
closeOnBlur={closeDisplayOptMenuOnBlur}
|
||||||
isOpen={showDisplayOptionsMenu}
|
isOpen={showDisplayOptionsMenu}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const Menu: FunctionComponent<MenuProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<menu
|
<menu
|
||||||
className={`m-0 p-0 list-style-none focus:shadow-none ${className}`}
|
className={`m-0 pl-0 list-style-none focus:shadow-none ${className}`}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
ref={menuElementRef}
|
ref={menuElementRef}
|
||||||
style={style}
|
style={style}
|
||||||
|
|||||||
Reference in New Issue
Block a user