2023-03-06 08:21:20 +00:00
|
|
|
import { ReactNode } from 'react'
|
2023-03-03 13:55:04 +00:00
|
|
|
import {
|
|
|
|
|
Dropdown,
|
|
|
|
|
DropdownOption,
|
|
|
|
|
DropdownSeparator,
|
|
|
|
|
} from '../elements/DropdownElements'
|
2024-07-29 09:30:47 +00:00
|
|
|
import { ArticleAttributes } from '../../lib/networking/library_items/useLibraryItems'
|
2024-07-28 12:41:16 +00:00
|
|
|
import { State } from '../../lib/networking/fragments/articleFragment'
|
2023-03-03 13:55:04 +00:00
|
|
|
|
|
|
|
|
type DropdownMenuProps = {
|
|
|
|
|
triggerElement: ReactNode
|
2024-07-28 12:41:16 +00:00
|
|
|
libraryItem?: ArticleAttributes
|
2023-03-03 13:55:04 +00:00
|
|
|
articleActionHandler: (action: string, arg?: unknown) => void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ReaderDropdownMenu(props: DropdownMenuProps): JSX.Element {
|
|
|
|
|
return (
|
|
|
|
|
<Dropdown triggerElement={props.triggerElement}>
|
|
|
|
|
<DropdownOption
|
2024-07-28 12:41:16 +00:00
|
|
|
onSelect={async () => {
|
|
|
|
|
if (props.libraryItem?.state === State.ARCHIVED) {
|
|
|
|
|
props.articleActionHandler('unarchive')
|
|
|
|
|
} else {
|
|
|
|
|
props.articleActionHandler('archive')
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
title={
|
|
|
|
|
props.libraryItem?.state === State.ARCHIVED
|
|
|
|
|
? 'Unarchive (e)'
|
|
|
|
|
: 'Archive (e)'
|
|
|
|
|
}
|
2023-03-03 13:55:04 +00:00
|
|
|
/>
|
|
|
|
|
<DropdownOption
|
2023-04-10 08:15:57 +00:00
|
|
|
onSelect={() => props.articleActionHandler('setLabels')}
|
2023-11-01 07:16:05 +00:00
|
|
|
title="Edit labels (l)"
|
2023-03-03 13:55:04 +00:00
|
|
|
/>
|
|
|
|
|
<DropdownOption
|
|
|
|
|
onSelect={() => props.articleActionHandler('showEditModal')}
|
2023-11-01 07:16:05 +00:00
|
|
|
title="Edit info (i)"
|
2023-03-03 13:55:04 +00:00
|
|
|
/>
|
|
|
|
|
<DropdownOption
|
2024-07-28 12:41:16 +00:00
|
|
|
onSelect={async () => {
|
|
|
|
|
props.articleActionHandler('delete')
|
|
|
|
|
}}
|
2023-04-14 03:27:01 +00:00
|
|
|
title="Remove (#)"
|
2023-03-03 13:55:04 +00:00
|
|
|
/>
|
|
|
|
|
<DropdownSeparator />
|
|
|
|
|
<DropdownOption
|
|
|
|
|
onSelect={() => window.Intercom('show')}
|
|
|
|
|
title="Feedback"
|
|
|
|
|
/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
)
|
|
|
|
|
}
|