2022-12-14 07:07:01 +00:00
|
|
|
import { createEffect, createSignal, For } from 'solid-js'
|
2022-12-12 08:11:43 +00:00
|
|
|
import type { PopupProps } from '../_shared/Popup'
|
|
|
|
import { Popup } from '../_shared/Popup'
|
2022-12-14 07:07:01 +00:00
|
|
|
import { t } from '../../utils/intl'
|
2022-12-12 08:11:43 +00:00
|
|
|
|
2022-12-14 07:07:01 +00:00
|
|
|
type MessageActionsPopup = {
|
|
|
|
actionSelect?: (selectedAction) => void
|
|
|
|
} & Omit<PopupProps, 'children'>
|
|
|
|
|
|
|
|
const actions = [
|
|
|
|
{ name: t('Reply'), action: 'reply' },
|
|
|
|
{ name: t('Copy'), action: 'copy' },
|
|
|
|
{ name: t('Pin'), action: 'pin' },
|
|
|
|
{ name: t('Forward'), action: 'forward' },
|
|
|
|
{ name: t('Select'), action: 'select' },
|
|
|
|
{ name: t('Delete'), action: 'delete' }
|
|
|
|
]
|
2022-12-12 08:11:43 +00:00
|
|
|
|
|
|
|
export const MessageActionsPopup = (props: MessageActionsPopup) => {
|
2022-12-14 07:07:01 +00:00
|
|
|
const [selectedAction, setSelectedAction] = createSignal<string>()
|
|
|
|
createEffect(() => {
|
|
|
|
if (props.actionSelect) props.actionSelect(selectedAction())
|
|
|
|
})
|
2022-12-12 08:11:43 +00:00
|
|
|
return (
|
2022-12-13 11:10:54 +00:00
|
|
|
<Popup {...props} variant="tiny">
|
2022-12-12 08:11:43 +00:00
|
|
|
<ul class="nodash">
|
2022-12-14 07:07:01 +00:00
|
|
|
<For each={actions}>
|
|
|
|
{(item) => <li onClick={() => setSelectedAction(item.action)}>{item.name}</li>}
|
|
|
|
</For>
|
2022-12-12 08:11:43 +00:00
|
|
|
</ul>
|
|
|
|
</Popup>
|
|
|
|
)
|
|
|
|
}
|