@@ -37,6 +37,8 @@ import IconizedContextMenu, {
3737} from "../context_menus/IconizedContextMenu" ;
3838import { AppTileActionPayload } from "../../../dispatcher/payloads/AppTileActionPayload" ;
3939import { Capability } from "../../../widgets/WidgetApi" ;
40+ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton" ;
41+ import classNames from "classnames" ;
4042
4143interface IProps {
4244 room : Room ;
@@ -134,13 +136,39 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
134136 WidgetUtils . editWidget ( room , app ) ;
135137 } ;
136138
137- const footer = < React . Fragment >
138- < AccessibleButton kind = "secondary" onClick = { onEditClick } disabled = { ! canModify } >
139+ let editButton ;
140+ if ( canModify ) {
141+ editButton = < AccessibleButton kind = "secondary" onClick = { onEditClick } >
139142 { _t ( "Edit" ) }
140- </ AccessibleButton >
141- < AccessibleButton kind = "secondary" onClick = { onPinClick } disabled = { ! WidgetStore . instance . canPin ( app . id ) } >
143+ </ AccessibleButton > ;
144+ }
145+
146+ const pinButtonClasses = canModify ? "" : "mx_WidgetCard_widePinButton" ;
147+
148+ let pinButton ;
149+ if ( WidgetStore . instance . canPin ( app . id ) ) {
150+ pinButton = < AccessibleButton
151+ kind = "secondary"
152+ onClick = { onPinClick }
153+ className = { pinButtonClasses }
154+ >
142155 { _t ( "Pin to room" ) }
143- </ AccessibleButton >
156+ </ AccessibleButton > ;
157+ } else {
158+ pinButton = < AccessibleTooltipButton
159+ title = { _t ( "You can only pin 2 apps at a time" ) }
160+ tooltipClassName = "mx_WidgetCard_maxPinnedTooltip"
161+ kind = "secondary"
162+ className = { pinButtonClasses }
163+ disabled
164+ >
165+ { _t ( "Pin to room" ) }
166+ </ AccessibleTooltipButton > ;
167+ }
168+
169+ const footer = < React . Fragment >
170+ { editButton }
171+ { pinButton }
144172 < ContextMenuButton
145173 kind = "secondary"
146174 className = { "" }
@@ -158,7 +186,9 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
158186 return < BaseCard
159187 header = { header }
160188 footer = { footer }
161- className = "mx_WidgetCard"
189+ className = { classNames ( "mx_WidgetCard" , {
190+ mx_WidgetCard_noEdit : ! canModify ,
191+ } ) }
162192 onClose = { onClose }
163193 previousPhase = { RightPanelPhases . RoomSummary }
164194 withoutScrollContainer
0 commit comments