This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Call dropdown for plugins * Update i18n * Remove plugings channel header call and reuse channel header plug * Fix tooltip and i18n error * Add minimum required version and remove unneeded react fragment * Add call button to post * Extract i18n * Change icon by camera icon * Remove header button for calls * Fix tests and remove changes from the header button * Fix lint * Update i18n * Remove unneeded divs, change CameraIcon to functional component, simplify aria label, prevent default on # link and fix typo * Remove channel header references, fix lint and remove unused style * Fix bug * Change callbutton to functional component * Fix CSS
- Loading branch information
Showing
8 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {injectIntl} from 'react-intl'; | ||
|
||
import {intlShape} from 'utils/react_intl'; | ||
|
||
import MenuWrapper from 'components/widgets/menu/menu_wrapper'; | ||
import Menu from 'components/widgets/menu/menu'; | ||
import CameraIcon from 'components/widgets/icons/camera_icon'; | ||
|
||
const customStyles = { | ||
left: 'inherit', | ||
right: 0, | ||
bottom: '100%', | ||
top: 'auto', | ||
}; | ||
|
||
function CallButton(props) { | ||
const {formatMessage} = props.intl; | ||
|
||
let bodyAction; | ||
|
||
if (props.pluginCallMethods.length === 0) { | ||
bodyAction = null; | ||
} else if (props.pluginCallMethods.length === 1) { | ||
const item = props.pluginCallMethods[0]; | ||
bodyAction = ( | ||
<button | ||
type='button' | ||
className='style--none post-action icon icon--attachment' | ||
onClick={() => { | ||
if (item.action) { | ||
item.action(props.currentChannel, props.channelMember); | ||
} | ||
}} | ||
onTouchEnd={() => { | ||
if (item.action) { | ||
item.action(props.currentChannel, props.channelMember); | ||
} | ||
}} | ||
> | ||
{item.icon} | ||
</button> | ||
); | ||
} else { | ||
const pluginCallMethods = props.pluginCallMethods.map((item) => { | ||
return ( | ||
<li | ||
key={item.id} | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
if (item.action) { | ||
item.action(props.currentChannel, props.channelMember); | ||
} | ||
}} | ||
> | ||
<a href='#'> | ||
<span className='call-plugin-icon'> | ||
{item.icon} | ||
</span> | ||
{item.dropdownText} | ||
</a> | ||
</li> | ||
); | ||
}); | ||
bodyAction = ( | ||
<MenuWrapper> | ||
<button | ||
type='button' | ||
className='style--none post-action' | ||
> | ||
<div | ||
className='icon icon--attachment' | ||
> | ||
<CameraIcon className='d-flex'/> | ||
</div> | ||
</button> | ||
<Menu | ||
id='callOptions' | ||
openLeft={true} | ||
openUp={true} | ||
ariaLabel={formatMessage({id: 'call_button.menuAriaLabel', defaultMessage: 'Call type selector'})} | ||
customStyles={customStyles} | ||
> | ||
{pluginCallMethods} | ||
</Menu> | ||
</MenuWrapper> | ||
); | ||
} | ||
|
||
return bodyAction; | ||
} | ||
|
||
CallButton.propTypes = { | ||
currentChannel: PropTypes.object.isRequired, | ||
channelMember: PropTypes.object, | ||
intl: intlShape.isRequired, | ||
locale: PropTypes.string.isRequired, | ||
pluginCallMethods: PropTypes.arrayOf(PropTypes.object), | ||
}; | ||
|
||
CallButton.defaultProps = { | ||
pluginCallMethods: [], | ||
}; | ||
|
||
const wrappedComponent = injectIntl(CallButton); | ||
wrappedComponent.displayName = 'injectIntl(CallButton)'; | ||
export default wrappedComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {connect} from 'react-redux'; | ||
|
||
import {getCurrentChannel, getMyCurrentChannelMembership} from 'mattermost-redux/selectors/entities/channels'; | ||
|
||
import {getCurrentLocale} from 'selectors/i18n'; | ||
|
||
import CallButton from './call_button.jsx'; | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
currentChannel: getCurrentChannel(state), | ||
locale: getCurrentLocale(state), | ||
pluginCallMethods: state.plugins.components.CallButton, | ||
channelMember: getMyCurrentChannelMembership(state), | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(CallButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import {useIntl} from 'react-intl'; | ||
|
||
export default function CameraIcon(props) { | ||
const intl = useIntl(); | ||
return ( | ||
<span {...props}> | ||
<svg | ||
width='14px' | ||
height='10px' | ||
viewBox='0 0 16 12' | ||
role='img' | ||
aria-label={intl.formatMessage({id: 'generic_icons.camera', defaultMessage: 'Camera Icon'})} | ||
> | ||
<g | ||
stroke='none' | ||
strokeWidth='1' | ||
fill='inherit' | ||
fillRule='evenodd' | ||
> | ||
<g | ||
transform='translate(-696.000000, -34.000000)' | ||
fillRule='nonzero' | ||
fill='inherit' | ||
> | ||
<g transform='translate(-1.000000, 0.000000)'> | ||
<g transform='translate(687.000000, 22.000000)'> | ||
<g transform='translate(10.000000, 12.000000)'> | ||
<path d='M15.105,1.447 L12,3 L12,1 C12,0.447 11.553,0 11,0 L1,0 C0.447,0 0,0.447 0,1 L0,11 C0,11.553 0.447,12 1,12 L11,12 C11.553,12 12,11.553 12,11 L12,9 L15.105,10.553 C15.6,10.8 16,10.553 16,10 L16,2 C16,1.447 15.6,1.2 15.105,1.447 Z M12.895,7.211 C12.612,7.07 12.306,7 12,7 L10.5,7 C10.224,7 10,7.224 10,7.5 L10,10 L2,10 L2,2 L10,2 L10,4.5 C10,4.776 10.224,5 10.5,5 L12,5 C12.306,5 12.612,4.93 12.895,4.789 L14,4.236 L14,7.763 L12.895,7.211 Z'/> | ||
</g> | ||
</g> | ||
</g> | ||
</g> | ||
</g> | ||
</svg> | ||
</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters