From: Chocobozzz Date: Wed, 28 Aug 2019 13:46:56 +0000 (+0200) Subject: Add config instance warning modal X-Git-Tag: v2.0.0-rc.1~81 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=589d9f55f6f3f0d069d4bbb207d3d20769cc4ded;p=oweals%2Fpeertube.git Add config instance warning modal --- diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index f68641047..6b18e5feb 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -244,15 +244,19 @@ export class AppComponent implements OnInit { if (user.noWelcomeModal !== true) return this.welcomeModal.show() const config = this.serverService.getConfig() - - if (user.noInstanceConfigWarningModal !== true && config.signup.allowed && config.instance.name.toLowerCase() === 'peertube') { - this.instanceService.getAbout() - .subscribe(about => { - if (!about.instance.terms) { - this.instanceConfigWarningModal.show() - } - }) - } + if (user.noInstanceConfigWarningModal === true || !config.signup.allowed) return + + this.instanceService.getAbout() + .subscribe(about => { + if ( + config.instance.name.toLowerCase() === 'peertube' || + !about.instance.terms || + !about.instance.administrator || + !about.instance.maintenanceLifetime + ) { + this.instanceConfigWarningModal.show(about) + } + }) } private initHotkeys () { diff --git a/client/src/app/modal/instance-config-warning-modal.component.html b/client/src/app/modal/instance-config-warning-modal.component.html index 595afb103..f9e07333a 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.html +++ b/client/src/app/modal/instance-config-warning-modal.component.html @@ -1,14 +1,41 @@ diff --git a/client/src/app/modal/instance-config-warning-modal.component.scss b/client/src/app/modal/instance-config-warning-modal.component.scss index 51834c649..5888736c1 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.scss +++ b/client/src/app/modal/instance-config-warning-modal.component.scss @@ -4,3 +4,17 @@ .action-button-cancel { margin-right: 0 !important; } + +.modal-body { + font-size: 15px; +} + +li { + margin-bottom: 10px; +} + +.configure-instance { + text-align: center; + font-weight: 600; + font-size: 18px; +} diff --git a/client/src/app/modal/instance-config-warning-modal.component.ts b/client/src/app/modal/instance-config-warning-modal.component.ts index 5cc9207cd..08d83f383 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts @@ -1,7 +1,8 @@ import { Component, ElementRef, ViewChild } from '@angular/core' import { Notifier } from '@app/core' -import { I18n } from '@ngx-translate/i18n-polyfill' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { About } from '@shared/models/server' +import { UserService } from '@app/shared' @Component({ selector: 'my-instance-config-warning-modal', @@ -11,13 +12,31 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' export class InstanceConfigWarningModalComponent { @ViewChild('modal', { static: true }) modal: ElementRef + stopDisplayModal = false + about: About + constructor ( + private userService: UserService, private modalService: NgbModal, - private notifier: Notifier, - private i18n: I18n + private notifier: Notifier ) { } - show () { - this.modalService.open(this.modal) + show (about: About) { + this.about = about + + const ref = this.modalService.open(this.modal) + + ref.result.finally(() => { + if (this.stopDisplayModal === true) this.doNotOpenAgain() + }) + } + + private doNotOpenAgain () { + this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) + .subscribe( + () => console.log('We will not open the instance config warning modal again.'), + + err => this.notifier.error(err.message) + ) } } diff --git a/client/src/app/modal/welcome-modal.component.html b/client/src/app/modal/welcome-modal.component.html index c83b53c2c..79e6d4667 100644 --- a/client/src/app/modal/welcome-modal.component.html +++ b/client/src/app/modal/welcome-modal.component.html @@ -7,24 +7,24 @@ diff --git a/client/src/app/modal/welcome-modal.component.scss b/client/src/app/modal/welcome-modal.component.scss index ab57bb993..a59c5b7a9 100644 --- a/client/src/app/modal/welcome-modal.component.scss +++ b/client/src/app/modal/welcome-modal.component.scss @@ -5,10 +5,6 @@ font-size: 15px; } -.action-button-cancel { - margin-right: 0 !important; -} - .subtitle { font-weight: $font-semibold; margin-bottom: 10px; diff --git a/client/src/app/modal/welcome-modal.component.ts b/client/src/app/modal/welcome-modal.component.ts index bff2968d4..05412a4cd 100644 --- a/client/src/app/modal/welcome-modal.component.ts +++ b/client/src/app/modal/welcome-modal.component.ts @@ -34,7 +34,5 @@ export class WelcomeModalComponent { err => this.notifier.error(err.message) ) - - return true } } diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index fb1ddbc6d..bf872ca52 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -190,19 +190,19 @@ async function updateMe (req: express.Request, res: express.Response) { } } - if (body.displayName !== undefined || body.description !== undefined) { - await sequelizeTypescript.transaction(async t => { - const userAccount = await AccountModel.load(user.Account.id, t) + await sequelizeTypescript.transaction(async t => { + await user.save({ transaction: t }) - await user.save({ transaction: t }) + if (body.displayName !== undefined || body.description !== undefined) { + const userAccount = await AccountModel.load(user.Account.id, t) if (body.displayName !== undefined) userAccount.name = body.displayName if (body.description !== undefined) userAccount.description = body.description await userAccount.save({ transaction: t }) await sendUpdateActor(userAccount, t) - }) - } + } + }) if (sendVerificationEmail === true) { await sendVerifyUserEmail(user, true)