diff options
author | Kim <1877318+kimsible@users.noreply.github.com> | 2020-07-28 15:18:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 15:18:38 +0200 |
commit | dfe3f7b72ef46401206f6f461077a7984a0c72f0 (patch) | |
tree | 775a747f2dd4bc098afc2ec254792e2e8e8cbbb4 /client/src/app/+videos | |
parent | 0579dee3b29e301838387f53b91b58bff2ffb19a (diff) | |
download | PeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.tar.gz PeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.tar.zst PeerTube-dfe3f7b72ef46401206f6f461077a7984a0c72f0.zip |
Add alert and hide upload view when no upload is possible (#2966)
* Add alert and hide upload view when no upload is possible
* Add about instance link to alert
* Hide videos and imports links when no upload is possible
* Correct curly spacing lint
* Put logic canUpload to User model + add isHidden param to to-menu-dropdown
* Use canSeeVideoLinks from user model
* Rename and change logic canUpload to isUploadDisabled
* Use isDisplayed() method intead of isHidden value
* Refactor client and check videos count using quota
Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'client/src/app/+videos')
3 files changed, 43 insertions, 5 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add.component.html b/client/src/app/+videos/+video-edit/video-add.component.html index 5690ac37f..14d41f95b 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.html +++ b/client/src/app/+videos/+video-edit/video-add.component.html | |||
@@ -1,4 +1,12 @@ | |||
1 | <div class="margin-content"> | 1 | <div *ngIf="user.isUploadDisabled()" class="no-upload"> |
2 | <div class="alert alert-warning"> | ||
3 | <div i18n>Sorry, the upload feature is disabled for your account. If you want to add videos, an admin must unlock your quota.</div> | ||
4 | <a i18n routerLink="/about/instance" class="about-link">Read instance rules for help</a> | ||
5 | </div> | ||
6 | <img src="/client/assets/images/mascot/defeated.svg" alt="defeated mascot"> | ||
7 | </div> | ||
8 | |||
9 | <div *ngIf="!user.isUploadDisabled()" class="margin-content"> | ||
2 | <div class="alert alert-warning" *ngIf="isRootUser()" i18n> | 10 | <div class="alert alert-warning" *ngIf="isRootUser()" i18n> |
3 | We recommend you to not use the <strong>root</strong> user to publish your videos, since it's the super-admin account of your instance. | 11 | We recommend you to not use the <strong>root</strong> user to publish your videos, since it's the super-admin account of your instance. |
4 | <br /> | 12 | <br /> |
@@ -45,4 +53,4 @@ | |||
45 | </div> | 53 | </div> |
46 | 54 | ||
47 | <div [ngbNavOutlet]="nav"></div> | 55 | <div [ngbNavOutlet]="nav"></div> |
48 | </div> | 56 | </div> \ No newline at end of file |
diff --git a/client/src/app/+videos/+video-edit/video-add.component.scss b/client/src/app/+videos/+video-edit/video-add.component.scss index f9977bda0..5db9e823d 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.scss +++ b/client/src/app/+videos/+video-edit/video-add.component.scss | |||
@@ -6,6 +6,34 @@ $border-type: solid; | |||
6 | $border-color: #EAEAEA; | 6 | $border-color: #EAEAEA; |
7 | $nav-link-height: 40px; | 7 | $nav-link-height: 40px; |
8 | 8 | ||
9 | .no-upload { | ||
10 | height: 100%; | ||
11 | width: 100%; | ||
12 | text-align: center; | ||
13 | |||
14 | .about-link { | ||
15 | @include peertube-button-link; | ||
16 | @include orange-button; | ||
17 | |||
18 | height: fit-content; | ||
19 | margin-top: 10px; | ||
20 | } | ||
21 | |||
22 | img { | ||
23 | margin-top: 10px; | ||
24 | margin-bottom: 75px; | ||
25 | width: 220px; | ||
26 | height: auto; | ||
27 | } | ||
28 | |||
29 | @media screen and (max-height: 600px) { | ||
30 | img { | ||
31 | margin-top: 5px; | ||
32 | width: 160px; | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
9 | .margin-content { | 37 | .margin-content { |
10 | padding-top: 20px; | 38 | padding-top: 20px; |
11 | } | 39 | } |
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index 016791d59..94e85efc1 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' |
2 | import { AuthService, CanComponentDeactivate, ServerService, User } from '@app/core' | 2 | import { AuthService, AuthUser, CanComponentDeactivate, ServerService } from '@app/core' |
3 | import { ServerConfig } from '@shared/models' | 3 | import { ServerConfig } from '@shared/models' |
4 | import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' | 4 | import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' |
5 | import { VideoImportUrlComponent } from './video-add-components/video-import-url.component' | 5 | import { VideoImportUrlComponent } from './video-add-components/video-import-url.component' |
@@ -15,7 +15,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
15 | @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent | 15 | @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent |
16 | @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent | 16 | @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent |
17 | 17 | ||
18 | user: User = null | 18 | user: AuthUser = null |
19 | 19 | ||
20 | secondStepType: 'upload' | 'import-url' | 'import-torrent' | 20 | secondStepType: 'upload' | 'import-url' | 'import-torrent' |
21 | videoName: string | 21 | videoName: string |
@@ -37,6 +37,8 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
37 | 37 | ||
38 | this.serverService.getConfig() | 38 | this.serverService.getConfig() |
39 | .subscribe(config => this.serverConfig = config) | 39 | .subscribe(config => this.serverConfig = config) |
40 | |||
41 | this.user = this.auth.getUser() | ||
40 | } | 42 | } |
41 | 43 | ||
42 | onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { | 44 | onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { |
@@ -80,6 +82,6 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
80 | } | 82 | } |
81 | 83 | ||
82 | isRootUser () { | 84 | isRootUser () { |
83 | return this.auth.getUser().username === 'root' | 85 | return this.user.username === 'root' |
84 | } | 86 | } |
85 | } | 87 | } |