@@ -392,7 +392,6 @@ function initialize(api) {
392392 api . addPostSmallActionIcon ( "unassigned_group" , "group-times" ) ;
393393 api . addPostSmallActionIcon ( "unassigned_from_post" , "user-xmark" ) ;
394394 api . addPostSmallActionIcon ( "unassigned_group_from_post" , "group-times" ) ;
395- api . includePostAttributes ( "assigned_to_user" , "assigned_to_group" ) ;
396395 api . addPostSmallActionIcon ( "reassigned" , "user-plus" ) ;
397396 api . addPostSmallActionIcon ( "reassigned_group" , "group-plus" ) ;
398397
@@ -712,6 +711,30 @@ function initialize(api) {
712711}
713712
714713function customizePost ( api ) {
714+ api . addTrackedPostProperties ( "assigned_to_user" , "assigned_to_group" ) ;
715+
716+ api . modifyClass (
717+ "model:post" ,
718+ ( Superclass ) =>
719+ class extends Superclass {
720+ get can_edit ( ) {
721+ return isAssignSmallAction ( this . action_code ) ? true : super . can_edit ;
722+ }
723+
724+ // overriding tracked properties requires overriding both the getter and the setter.
725+ // otherwise the superclass will throw an error when the application sets the field value
726+ set can_edit ( value ) {
727+ super . can_edit = value ;
728+ }
729+
730+ get isSmallAction ( ) {
731+ return isAssignSmallAction ( this . action_code )
732+ ? true
733+ : super . isSmallAction ;
734+ }
735+ }
736+ ) ;
737+
715738 api . renderAfterWrapperOutlet (
716739 "post-content-cooked-html" ,
717740 PostAssignmentsDisplay
@@ -872,33 +895,34 @@ function customizeWidgetPost(api) {
872895 } ,
873896 } ) ;
874897
875- // This won't have a direct translation in the Glimmer API as it uses can_edit from the model
876- // TODO (glimmer-post-stream): check the post small action component and introduce a transformer to override the
877- // canEdit behavior there
898+ // `addPostTransformCallback` doesn't have a direct translation in the new Glimmer API.
899+ // We need to use a modify class in the post model instead
878900 api . addPostTransformCallback ( ( transformed ) => {
879- if (
880- [
881- "assigned" ,
882- "unassigned" ,
883- "reassigned" ,
884- "assigned_group" ,
885- "unassigned_group" ,
886- "reassigned_group" ,
887- "assigned_to_post" ,
888- "assigned_group_to_post" ,
889- "unassigned_from_post" ,
890- "unassigned_group_from_post" ,
891- "details_change" ,
892- "note_change" ,
893- "status_change" ,
894- ] . includes ( transformed . actionCode )
895- ) {
901+ if ( isAssignSmallAction ( transformed . actionCode ) ) {
896902 transformed . isSmallAction = true ;
897903 transformed . canEdit = true ;
898904 }
899905 } ) ;
900906}
901907
908+ function isAssignSmallAction ( actionCode ) {
909+ return [
910+ "assigned" ,
911+ "unassigned" ,
912+ "reassigned" ,
913+ "assigned_group" ,
914+ "unassigned_group" ,
915+ "reassigned_group" ,
916+ "assigned_to_post" ,
917+ "assigned_group_to_post" ,
918+ "unassigned_from_post" ,
919+ "unassigned_group_from_post" ,
920+ "details_change" ,
921+ "note_change" ,
922+ "status_change" ,
923+ ] . includes ( actionCode ) ;
924+ }
925+
902926function customizePostMenu ( api ) {
903927 api . registerValueTransformer (
904928 "post-menu-buttons" ,
0 commit comments