@@ -79,6 +79,7 @@ type TopicArgs = {
7979  zulipFeatureLevel : number , 
8080  dispatch : Dispatch , 
8181  _ : GetText , 
82+   startEditTopic : ( streamId : number ,  topic : string )  =>  void , 
8283  ...
8384} ; 
8485
@@ -171,6 +172,14 @@ const deleteMessage = {
171172  } , 
172173} ; 
173174
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+ 
174183const  markTopicAsRead  =  { 
175184  title : 'Mark topic as read' , 
176185  errorMessage : 'Failed to mark topic as read' , 
@@ -532,9 +541,18 @@ export const constructTopicActionButtons = (args: {|
532541
533542  const  buttons  =  [ ] ; 
534543  const  unreadCount  =  getUnreadCountForTopic ( unread ,  streamId ,  topic ) ; 
544+   const  isAdmin  =  roleIsAtLeast ( ownUserRole ,  Role . Admin ) ; 
535545  if  ( unreadCount  >  0 )  { 
536546    buttons . push ( markTopicAsRead ) ; 
537547  } 
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+   } 
538556  if  ( isTopicMuted ( streamId ,  topic ,  mute ) )  { 
539557    buttons . push ( unmuteTopic ) ; 
540558  }  else  { 
@@ -545,7 +563,7 @@ export const constructTopicActionButtons = (args: {|
545563  }  else  { 
546564    buttons . push ( unresolveTopic ) ; 
547565  } 
548-   if  ( roleIsAtLeast ( ownUserRole ,   Role . Admin ) )  { 
566+   if  ( isAdmin )  { 
549567    buttons . push ( deleteTopic ) ; 
550568  } 
551569  const  sub  =  subscriptions . get ( streamId ) ; 
@@ -705,6 +723,7 @@ export const showTopicActionSheet = (args: {|
705723  showActionSheetWithOptions : ShowActionSheetWithOptions , 
706724  callbacks : { | 
707725    dispatch : Dispatch , 
726+     startEditTopic : ( streamId : number ,  topic : string )  =>  void , 
708727    _ : GetText , 
709728  | } , 
710729  backgroundData : $ReadOnly < { 
0 commit comments