@@ -8,6 +8,7 @@ export class PageComment extends Component {
88 protected commentLocalId : string ;
99 protected deletedText : string ;
1010 protected updatedText : string ;
11+ protected archiveText : string ;
1112
1213 protected wysiwygEditor : any = null ;
1314 protected wysiwygLanguage : string ;
@@ -20,14 +21,16 @@ export class PageComment extends Component {
2021 protected editButton : HTMLElement ;
2122 protected deleteButton : HTMLElement ;
2223 protected replyButton : HTMLElement ;
24+ protected archiveButton : HTMLElement ;
2325 protected input : HTMLInputElement ;
2426
2527 setup ( ) {
2628 // Options
2729 this . commentId = this . $opts . commentId ;
2830 this . commentLocalId = this . $opts . commentLocalId ;
2931 this . deletedText = this . $opts . deletedText ;
30- this . updatedText = this . $opts . updatedText ;
32+ this . deletedText = this . $opts . deletedText ;
33+ this . archiveText = this . $opts . archiveText ;
3134
3235 // Editor reference and text options
3336 this . wysiwygLanguage = this . $opts . wysiwygLanguage ;
@@ -41,6 +44,7 @@ export class PageComment extends Component {
4144 this . editButton = this . $refs . editButton ;
4245 this . deleteButton = this . $refs . deleteButton ;
4346 this . replyButton = this . $refs . replyButton ;
47+ this . archiveButton = this . $refs . archiveButton ;
4448 this . input = this . $refs . input as HTMLInputElement ;
4549
4650 this . setupListeners ( ) ;
@@ -63,6 +67,10 @@ export class PageComment extends Component {
6367 if ( this . deleteButton ) {
6468 this . deleteButton . addEventListener ( 'click' , this . delete . bind ( this ) ) ;
6569 }
70+
71+ if ( this . archiveButton ) {
72+ this . archiveButton . addEventListener ( 'click' , this . archive . bind ( this ) ) ;
73+ }
6674 }
6775
6876 protected toggleEditMode ( show : boolean ) : void {
@@ -126,6 +134,15 @@ export class PageComment extends Component {
126134 window . $events . success ( this . deletedText ) ;
127135 }
128136
137+ protected async archive ( ) : Promise < void > {
138+ this . showLoading ( ) ;
139+ const isArchived = this . archiveButton . dataset . isArchived === 'true' ;
140+
141+ await window . $http . put ( `/comment/${ this . commentId } /${ isArchived ? 'unarchive' : 'archive' } ` ) ;
142+ this . $emit ( 'archive' ) ;
143+ window . $events . success ( this . archiveText ) ;
144+ }
145+
129146 protected showLoading ( ) : HTMLElement {
130147 const loading = getLoading ( ) ;
131148 loading . classList . add ( 'px-l' ) ;
0 commit comments