Added SidebarPanelGroup for StatusPromotionPanel
• Added: - SidebarPanelGroup for StatusPromotionPanel
This commit is contained in:
parent
f61449d706
commit
81ddccbdfd
33
app/javascript/gabsocial/components/sidebar_panel_group.js
Normal file
33
app/javascript/gabsocial/components/sidebar_panel_group.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { Fragment } from 'react'
|
||||
import { me, promotions } from '../initial_state'
|
||||
import StatusPromotionPanel from './panel/status_promotion_panel'
|
||||
|
||||
export default class SidebarPanelGroup extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
layout: PropTypes.array.isRequired,
|
||||
page: PropTypes.string.isRequired,
|
||||
promotion: PropTypes.object,
|
||||
}
|
||||
|
||||
render() {
|
||||
const { layout, page } = this.props
|
||||
|
||||
if (Array.isArray(promotions) && Array.isArray(layout) && !!me) {
|
||||
const sidebarPromotionPageId = `${page}.sidebar`
|
||||
const promotion = promotions.find(p => p.timeline_id === sidebarPromotionPageId)
|
||||
|
||||
if (!!promotion) {
|
||||
const correctedPosition = promotion.position - 1 > layout.length ? layout.length - 1 : promotion.position
|
||||
layout.splice(correctedPosition, 0, <StatusPromotionPanel key='status-promotion-panel' statusId={promotion.status_id} />)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{layout}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user