@@ -79,6 +79,7 @@ type TopicArgs = {
79
79
zulipFeatureLevel : number ,
80
80
dispatch : Dispatch ,
81
81
_ : GetText ,
82
+ startEditTopic : ( streamId : number , topic : string ) => void ,
82
83
...
83
84
} ;
84
85
@@ -171,6 +172,14 @@ const deleteMessage = {
171
172
} ,
172
173
} ;
173
174
175
+ const editTopic = {
176
+ title : 'Edit topic' ,
177
+ errorMessage : 'Failed to edit topic' ,
178
+ action : ( { streamId, topic, startEditTopic } ) => {
179
+ startEditTopic ( streamId , topic ) ;
180
+ } ,
181
+ } ;
182
+
174
183
const markTopicAsRead = {
175
184
title : 'Mark topic as read' ,
176
185
errorMessage : 'Failed to mark topic as read' ,
@@ -532,9 +541,18 @@ export const constructTopicActionButtons = (args: {|
532
541
533
542
const buttons = [ ] ;
534
543
const unreadCount = getUnreadCountForTopic ( unread , streamId , topic ) ;
544
+ const isAdmin = roleIsAtLeast ( ownUserRole , Role . Admin ) ;
535
545
if ( unreadCount > 0 ) {
536
546
buttons . push ( markTopicAsRead ) ;
537
547
}
548
+ // At present, the permissions for editing the topic of a message are highly complex.
549
+ // Until we move to a better set of policy options, we'll only display the edit topic
550
+ // button to admins.
551
+ // Issue: https://github.com/zulip/zulip/issues/21739
552
+ // Relevant comment: https://github.com/zulip/zulip-mobile/issues/5365#issuecomment-1197093294
553
+ if ( isAdmin ) {
554
+ buttons . push ( editTopic ) ;
555
+ }
538
556
if ( isTopicMuted ( streamId , topic , mute ) ) {
539
557
buttons . push ( unmuteTopic ) ;
540
558
} else {
@@ -545,7 +563,7 @@ export const constructTopicActionButtons = (args: {|
545
563
} else {
546
564
buttons . push ( unresolveTopic ) ;
547
565
}
548
- if ( roleIsAtLeast ( ownUserRole , Role . Admin ) ) {
566
+ if ( isAdmin ) {
549
567
buttons . push ( deleteTopic ) ;
550
568
}
551
569
const sub = subscriptions . get ( streamId ) ;
@@ -705,6 +723,7 @@ export const showTopicActionSheet = (args: {|
705
723
showActionSheetWithOptions : ShowActionSheetWithOptions ,
706
724
callbacks : { |
707
725
dispatch : Dispatch ,
726
+ startEditTopic : ( streamId : number , topic : string ) => void ,
708
727
_ : GetText ,
709
728
| } ,
710
729
backgroundData : $ReadOnly < {
0 commit comments