]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add support button in channel page
authorChocobozzz <me@florianbigard.com>
Mon, 29 Mar 2021 13:56:01 +0000 (15:56 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Wed, 31 Mar 2021 07:05:51 +0000 (09:05 +0200)
16 files changed:
client/src/app/+video-channels/video-channels.component.html
client/src/app/+video-channels/video-channels.component.scss
client/src/app/+video-channels/video-channels.component.ts
client/src/app/+video-channels/video-channels.module.ts
client/src/app/+videos/+video-watch/modal/video-support.component.ts [deleted file]
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/app/+videos/+video-watch/video-watch.module.ts
client/src/app/shared/shared-main/video-channel/video-channel.model.ts
client/src/app/shared/shared-support-modal/index.ts [new file with mode: 0644]
client/src/app/shared/shared-support-modal/shared-support-modal.module.ts [new file with mode: 0644]
client/src/app/shared/shared-support-modal/support-modal.component.html [moved from client/src/app/+videos/+video-watch/modal/video-support.component.html with 74% similarity]
client/src/app/shared/shared-support-modal/support-modal.component.scss [moved from client/src/app/+videos/+video-watch/modal/video-support.component.scss with 100% similarity]
client/src/app/shared/shared-support-modal/support-modal.component.ts [new file with mode: 0644]
client/src/sass/application.scss
client/src/sass/classes.scss [new file with mode: 0644]

index 9f9c1f2cac1e2c69b888bf0a59cb6621e71cf499..b9ac13f0936ddc7ad82d76acc1d1daa184685cbc 100644 (file)
@@ -7,6 +7,11 @@
         </a>
 
         <my-subscribe-button *ngIf="!isManageable()" #subscribeButton [videoChannels]="[videoChannel]"></my-subscribe-button>
+
+        <button *ngIf="videoChannel.support" (click)="showSupportModal()" class="support-button peertube-button orange-button-inverted">
+          <my-global-icon iconName="support" aria-hidden="true"></my-global-icon>
+          <span class="icon-text" i18n>Support</span>
+        </button>
     </ng-template>
 
     <ng-template #ownerTemplate>
 
   <router-outlet></router-outlet>
 </div>
+
+<my-support-modal #supportModal [videoChannel]="videoChannel"></my-support-modal>
index fb71844bdfeef5a45c42c3cd6a9650a2c03acf42..ec8f67a7e8a9b8ed8b6df4c3334c8158fa3f51ab 100644 (file)
   @include avatar-row-responsive(var(--myChannelImgMargin), var(--myGreyChannelFontSize));
 }
 
+.support-button {
+  @include button-with-icon(21px, 0, -1px);
+}
+
 .channel-description {
   grid-column: 1;
 }
index 4fcc4210374205fa77560ce4e75e97488bc446de..a8ca3d6fff995855074adc4bc9fb87507034e200 100644 (file)
@@ -5,6 +5,7 @@ import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
 import { ActivatedRoute } from '@angular/router'
 import { AuthService, MarkdownService, Notifier, RestExtractor, ScreenService } from '@app/core'
 import { ListOverflowItem, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
+import { SupportModalComponent } from '@app/shared/shared-support-modal'
 import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
 import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 
@@ -14,6 +15,7 @@ import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
 })
 export class VideoChannelsComponent implements OnInit, OnDestroy {
   @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
+  @ViewChild('supportModal') supportModal: SupportModalComponent
 
   videoChannel: VideoChannel
   hotkeys: Hotkey[]
@@ -101,6 +103,10 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
     this.notifier.success($localize`Username copied`)
   }
 
+  showSupportModal () {
+    this.supportModal.show()
+  }
+
   private loadChannelVideosCount () {
     this.videoService.getVideoChannelVideos({
       videoChannel: this.videoChannel,
index 1b58a1d92e03263e07d6c0f22cbecbbe80c1647b..408f8622558699d8faa875874a6c10a787fd771a 100644 (file)
@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'
 import { SharedFormModule } from '@app/shared/shared-forms'
 import { SharedGlobalIconModule } from '@app/shared/shared-icons'
 import { SharedMainModule } from '@app/shared/shared-main'
+import { SharedSupportModal } from '@app/shared/shared-support-modal'
 import { SharedUserSubscriptionModule } from '@app/shared/shared-user-subscription'
 import { SharedVideoMiniatureModule } from '@app/shared/shared-video-miniature'
 import { SharedVideoPlaylistModule } from '@app/shared/shared-video-playlist'
@@ -19,7 +20,8 @@ import { VideoChannelsComponent } from './video-channels.component'
     SharedVideoPlaylistModule,
     SharedVideoMiniatureModule,
     SharedUserSubscriptionModule,
-    SharedGlobalIconModule
+    SharedGlobalIconModule,
+    SharedSupportModal
   ],
 
   declarations: [
diff --git a/client/src/app/+videos/+video-watch/modal/video-support.component.ts b/client/src/app/+videos/+video-watch/modal/video-support.component.ts
deleted file mode 100644 (file)
index bd5290a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Component, Input, ViewChild } from '@angular/core'
-import { MarkdownService } from '@app/core'
-import { VideoDetails } from '@app/shared/shared-main'
-import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
-
-@Component({
-  selector: 'my-video-support',
-  templateUrl: './video-support.component.html',
-  styleUrls: [ './video-support.component.scss' ]
-})
-export class VideoSupportComponent {
-  @Input() video: VideoDetails = null
-
-  @ViewChild('modal', { static: true }) modal: NgbModal
-
-  videoHTMLSupport = ''
-
-  constructor (
-    private markdownService: MarkdownService,
-    private modalService: NgbModal
-  ) { }
-
-  show () {
-    const modalRef = this.modalService.open(this.modal, { centered: true })
-
-    this.markdownService.enhancedMarkdownToHTML(this.video.support)
-      .then(r => this.videoHTMLSupport = r)
-
-    return modalRef
-  }
-}
index b17f898ce7b9038822101be96c892b9e806ef9de..07f7ab7e3509cf8d0a709d8ab8bd26ff5581ea49 100644 (file)
 </div>
 
 <ng-container *ngIf="video !== null">
-  <my-video-support #videoSupportModal [video]="video"></my-video-support>
+  <my-support-modal #supportModal [video]="video"></my-support-modal>
   <my-video-share #videoShareModal [video]="video" [videoCaptions]="videoCaptions" [playlist]="playlist"></my-video-share>
 </ng-container>
index ce115dfab99f4dbf72e800eb4ecfeffc3b523548..571d1e99a4a47409fa1ebedb59a98d64300f85ce 100644 (file)
@@ -21,6 +21,7 @@ import { RedirectService } from '@app/core/routing/redirect.service'
 import { isXPercentInViewport, scrollToTop } from '@app/helpers'
 import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
 import { VideoShareComponent } from '@app/shared/shared-share-modal'
+import { SupportModalComponent } from '@app/shared/shared-support-modal'
 import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
 import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/shared-video-miniature'
 import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
@@ -39,7 +40,6 @@ import {
 } from '../../../assets/player/peertube-player-manager'
 import { isWebRTCDisabled, timeToInt } from '../../../assets/player/utils'
 import { environment } from '../../../environments/environment'
-import { VideoSupportComponent } from './modal/video-support.component'
 import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
 
 type URLOptions = CustomizationOptions & { playerMode: PlayerMode }
@@ -54,7 +54,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
   @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent
   @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
-  @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent
+  @ViewChild('supportModal') supportModal: SupportModalComponent
   @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
   @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
 
@@ -282,7 +282,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
     this.pausePlayer()
 
-    const modalRef = this.videoSupportModal.show()
+    const modalRef = this.supportModal.show()
 
     modalRef.result.then(() => {
       if (isVideoPlaying) {
index fbda9b9c4a7575ea8e82c28c1eb55e229e2652d3..d65cf8d6824d3b92afd300bcc0fce9e096aab1a8 100644 (file)
@@ -4,6 +4,7 @@ import { SharedGlobalIconModule } from '@app/shared/shared-icons'
 import { SharedMainModule } from '@app/shared/shared-main'
 import { SharedModerationModule } from '@app/shared/shared-moderation'
 import { SharedShareModal } from '@app/shared/shared-share-modal'
+import { SharedSupportModal } from '@app/shared/shared-support-modal'
 import { SharedUserSubscriptionModule } from '@app/shared/shared-user-subscription'
 import { SharedVideoModule } from '@app/shared/shared-video'
 import { SharedVideoCommentModule } from '@app/shared/shared-video-comment'
@@ -13,7 +14,6 @@ import { VideoCommentService } from '../../shared/shared-video-comment/video-com
 import { VideoCommentAddComponent } from './comment/video-comment-add.component'
 import { VideoCommentComponent } from './comment/video-comment.component'
 import { VideoCommentsComponent } from './comment/video-comments.component'
-import { VideoSupportComponent } from './modal/video-support.component'
 import { RecommendationsModule } from './recommendations/recommendations.module'
 import { TimestampRouteTransformerDirective } from './timestamp-route-transformer.directive'
 import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
@@ -34,14 +34,14 @@ import { VideoWatchComponent } from './video-watch.component'
     SharedGlobalIconModule,
     SharedVideoCommentModule,
     SharedShareModal,
-    SharedVideoModule
+    SharedVideoModule,
+    SharedSupportModal
   ],
 
   declarations: [
     VideoWatchComponent,
     VideoWatchPlaylistComponent,
 
-    VideoSupportComponent,
     VideoCommentsComponent,
     VideoCommentAddComponent,
     VideoCommentComponent,
index c6a63fe6cea3d2fdec91cbe9e9971c4c99f56803..bd187a873665324b2eabf4e762b569928da40dbb 100644 (file)
@@ -46,7 +46,7 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
     if (hash.ownerAccount) {
       this.ownerAccount = hash.ownerAccount
       this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
-      this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
+      this.ownerAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.ownerAccount)
     }
   }
 
diff --git a/client/src/app/shared/shared-support-modal/index.ts b/client/src/app/shared/shared-support-modal/index.ts
new file mode 100644 (file)
index 0000000..f41bb4b
--- /dev/null
@@ -0,0 +1,3 @@
+export * from './support-modal.component'
+
+export * from './shared-support-modal.module'
diff --git a/client/src/app/shared/shared-support-modal/shared-support-modal.module.ts b/client/src/app/shared/shared-support-modal/shared-support-modal.module.ts
new file mode 100644 (file)
index 0000000..1101d55
--- /dev/null
@@ -0,0 +1,24 @@
+import { NgModule } from '@angular/core'
+import { SharedFormModule } from '../shared-forms'
+import { SharedGlobalIconModule } from '../shared-icons'
+import { SharedMainModule } from '../shared-main/shared-main.module'
+import { SupportModalComponent } from './support-modal.component'
+
+@NgModule({
+  imports: [
+    SharedMainModule,
+    SharedFormModule,
+    SharedGlobalIconModule
+  ],
+
+  declarations: [
+    SupportModalComponent
+  ],
+
+  exports: [
+    SupportModalComponent
+  ],
+
+  providers: [ ]
+})
+export class SharedSupportModal { }
similarity index 74%
rename from client/src/app/+videos/+video-watch/modal/video-support.component.html
rename to client/src/app/shared/shared-support-modal/support-modal.component.html
index 935656d23af3532aadefac53151bc15f90cb5646..4a967987f4e3608365b39a4320b6bcb46f35918e 100644 (file)
@@ -1,10 +1,10 @@
 <ng-template #modal let-hide="close">
   <div class="modal-header">
-    <h4 i18n class="modal-title">Support {{ video.account.displayName }}</h4>
+    <h4 i18n class="modal-title">Support {{ displayName }}</h4>
     <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
   </div>
 
-  <div class="modal-body" [innerHTML]="videoHTMLSupport"></div>
+  <div class="modal-body" [innerHTML]="htmlSupport"></div>
 
   <div class="modal-footer inputs">
     <input
diff --git a/client/src/app/shared/shared-support-modal/support-modal.component.ts b/client/src/app/shared/shared-support-modal/support-modal.component.ts
new file mode 100644 (file)
index 0000000..ae603c7
--- /dev/null
@@ -0,0 +1,40 @@
+import { Component, Input, ViewChild } from '@angular/core'
+import { MarkdownService } from '@app/core'
+import { VideoDetails } from '@app/shared/shared-main'
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { VideoChannel } from '@shared/models'
+
+@Component({
+  selector: 'my-support-modal',
+  templateUrl: './support-modal.component.html',
+  styleUrls: [ './support-modal.component.scss' ]
+})
+export class SupportModalComponent {
+  @Input() video: VideoDetails = null
+  @Input() videoChannel: VideoChannel = null
+
+  @ViewChild('modal', { static: true }) modal: NgbModal
+
+  htmlSupport = ''
+  displayName = ''
+
+  constructor (
+    private markdownService: MarkdownService,
+    private modalService: NgbModal
+  ) { }
+
+  show () {
+    const modalRef = this.modalService.open(this.modal, { centered: true })
+
+    const support = this.video?.support || this.videoChannel.support
+
+    this.markdownService.enhancedMarkdownToHTML(support)
+      .then(r => this.htmlSupport = r)
+
+    this.displayName = this.video
+      ? this.video.channel.displayName
+      : this.videoChannel.displayName
+
+    return modalRef
+  }
+}
index 0a92afef3c06895c889b8cd11e1bbcafbff62113..f4c3d86a8bbbc93059f6c6589a64af1dffe9b821 100644 (file)
@@ -15,6 +15,8 @@ $assets-path: '../../assets/';
 @import './primeng-custom';
 @import './ng-select.scss';
 
+@import './classes.scss';
+
 [hidden] {
   display: none !important;
 }
@@ -465,21 +467,3 @@ ngx-loading-bar {
     }
   }
 }
-
-// Utils
-
-.peertube-button {
-  @include peertube-button;
-}
-
-.peertube-button-link {
-  @include peertube-button-link;
-}
-
-.orange-button {
-  @include orange-button;
-}
-
-.orange-button-inverted {
-  @include orange-button-inverted;
-}
diff --git a/client/src/sass/classes.scss b/client/src/sass/classes.scss
new file mode 100644 (file)
index 0000000..af8e395
--- /dev/null
@@ -0,0 +1,22 @@
+@import '_variables';
+@import '_mixins';
+
+.peertube-button {
+  @include peertube-button;
+}
+
+.peertube-button-link {
+  @include peertube-button-link;
+}
+
+.orange-button {
+  @include orange-button;
+}
+
+.orange-button-inverted {
+  @include orange-button-inverted;
+}
+
+.grey-button {
+  @include grey-button;
+}