Updated StatusOptionsPopover to use new StatusSharePopover
• Updated: - StatusOptionsPopover to use new StatusSharePopover instead of existing three options: copy, embed, email
This commit is contained in:
parent
083218648a
commit
97a9fa546e
@ -30,10 +30,14 @@ import {
|
|||||||
import { initMuteModal } from '../../actions/mutes'
|
import { initMuteModal } from '../../actions/mutes'
|
||||||
import { initReport } from '../../actions/reports'
|
import { initReport } from '../../actions/reports'
|
||||||
import { openModal } from '../../actions/modal'
|
import { openModal } from '../../actions/modal'
|
||||||
import { closePopover } from '../../actions/popover'
|
import {
|
||||||
|
closePopover,
|
||||||
|
openPopover,
|
||||||
|
} from '../../actions/popover'
|
||||||
import {
|
import {
|
||||||
MODAL_EMBED,
|
MODAL_EMBED,
|
||||||
MODAL_PRO_UPGRADE,
|
MODAL_PRO_UPGRADE,
|
||||||
|
POPOVER_STATUS_SHARE,
|
||||||
} from '../../constants'
|
} from '../../constants'
|
||||||
import PopoverLayout from './popover_layout'
|
import PopoverLayout from './popover_layout'
|
||||||
import List from '../list'
|
import List from '../list'
|
||||||
@ -116,28 +120,9 @@ class StatusOptionsPopover extends ImmutablePureComponent {
|
|||||||
this.props.onQuote(this.props.status, this.context.router)
|
this.props.onQuote(this.props.status, this.context.router)
|
||||||
}
|
}
|
||||||
|
|
||||||
handleOnOpenEmbedModal = () => {
|
handleOnOpenSharePopover = () => {
|
||||||
this.props.onOpenEmbedModal(this.props.status.get('url'))
|
console.log("this.props:", this.props)
|
||||||
}
|
this.props.onOpenSharePopover(this.props.innerRef, this.props.status)
|
||||||
|
|
||||||
handleCopy = () => {
|
|
||||||
const url = this.props.status.get('url');
|
|
||||||
const textarea = document.createElement('textarea');
|
|
||||||
|
|
||||||
textarea.textContent = url;
|
|
||||||
textarea.style.position = 'fixed';
|
|
||||||
|
|
||||||
document.body.appendChild(textarea);
|
|
||||||
|
|
||||||
try {
|
|
||||||
textarea.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
} catch (e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.removeChild(textarea);
|
|
||||||
this.handleClosePopover()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClosePopover = () => {
|
handleClosePopover = () => {
|
||||||
@ -156,7 +141,6 @@ class StatusOptionsPopover extends ImmutablePureComponent {
|
|||||||
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'))
|
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'))
|
||||||
const isReply = !!status.get('in_reply_to_id')
|
const isReply = !!status.get('in_reply_to_id')
|
||||||
const withGroupAdmin = !!groupRelationships ? (groupRelationships.get('admin') || groupRelationships.get('moderator')) : false
|
const withGroupAdmin = !!groupRelationships ? (groupRelationships.get('admin') || groupRelationships.get('moderator')) : false
|
||||||
const mailToHref = !status ? undefined : `mailto:?subject=Gab&body=${status.get('url')}`
|
|
||||||
|
|
||||||
let menu = []
|
let menu = []
|
||||||
|
|
||||||
@ -261,22 +245,10 @@ class StatusOptionsPopover extends ImmutablePureComponent {
|
|||||||
|
|
||||||
menu.push(null)
|
menu.push(null)
|
||||||
menu.push({
|
menu.push({
|
||||||
icon: 'copy',
|
icon: 'share',
|
||||||
hideArrow: true,
|
hideArrow: true,
|
||||||
title: intl.formatMessage(messages.copy),
|
title: intl.formatMessage(messages.share),
|
||||||
onClick: this.handleCopy,
|
onClick: this.handleOnOpenSharePopover,
|
||||||
})
|
|
||||||
menu.push({
|
|
||||||
icon: 'email',
|
|
||||||
hideArrow: true,
|
|
||||||
title: intl.formatMessage(messages.email),
|
|
||||||
href: mailToHref,
|
|
||||||
})
|
|
||||||
menu.push({
|
|
||||||
icon: 'code',
|
|
||||||
hideArrow: true,
|
|
||||||
title: intl.formatMessage(messages.embed),
|
|
||||||
onClick: this.handleOnOpenEmbedModal,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isStaff) {
|
if (isStaff) {
|
||||||
@ -338,9 +310,7 @@ const messages = defineMessages({
|
|||||||
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
||||||
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove status from group' },
|
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove status from group' },
|
||||||
repostWithComment: { id: 'repost_with_comment', defaultMessage: 'Repost with comment' },
|
repostWithComment: { id: 'repost_with_comment', defaultMessage: 'Repost with comment' },
|
||||||
embed: { id: 'status.embed', defaultMessage: 'Embed' },
|
share: { id: 'status.share_gab', defaultMessage: 'Share gab' },
|
||||||
email: { id: 'status.email', defaultMessage: 'Email this gab' },
|
|
||||||
copy: { id: 'status.copy', defaultMessage: 'Copy link to status' },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapStateToProps = (state, { status }) => {
|
const mapStateToProps = (state, { status }) => {
|
||||||
@ -474,10 +444,12 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
dispatch(fetchGroupRelationships([groupId]))
|
dispatch(fetchGroupRelationships([groupId]))
|
||||||
},
|
},
|
||||||
|
|
||||||
onOpenEmbedModal(url) {
|
onOpenSharePopover(targetRef, status) {
|
||||||
dispatch(closePopover())
|
dispatch(closePopover())
|
||||||
dispatch(openModal(MODAL_EMBED, {
|
dispatch(openPopover(POPOVER_STATUS_SHARE, {
|
||||||
url,
|
targetRef,
|
||||||
|
status,
|
||||||
|
position: 'top',
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user