Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Correctly do not open again welcome modal

Chocobozzz39f37643c1d4
diff --git a/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.html b/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.html
index ac326179b5..06d17374ed 100644
--- a/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.html
+++ b/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.html
@@ -1,9 +1,9 @@
-<ng-template #modal let-hide="close">
+<ng-template #modal>
<div class="modal-body">
<my-admin-config-wizard-stepper #stepper>
@if (showWelcome) {
<cdk-step i18n-label label="Welcome introduction">
- <my-admin-config-wizard-welcome (back)="stepper.previous()" (next)="stepper.next()" (hide)="hide()"></my-admin-config-wizard-welcome>
+ <my-admin-config-wizard-welcome (back)="stepper.previous()" (next)="stepper.next()" (hide)="hide($event)"></my-admin-config-wizard-welcome>
</cdk-step>
}
@@ -32,7 +32,7 @@
@if (showWelcome) {
<cdk-step i18n-label label="Post configuration documentation">
- <my-admin-config-wizard-documentation (hide)="hide()"></my-admin-config-wizard-documentation>
+ <my-admin-config-wizard-documentation (hide)="hide({ doNotOpenAgain: true })"></my-admin-config-wizard-documentation>
</cdk-step>
}
</my-admin-config-wizard-stepper>
diff --git a/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.ts b/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.ts
index 90a1c9797b..d2ba3552bc 100644
--- a/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.ts
+++ b/client/src/app/modal/admin-config-wizard/admin-config-wizard-modal.component.ts
@@ -1,7 +1,8 @@
import { CdkStepperModule } from '@angular/cdk/stepper'
import { Component, ElementRef, OnInit, inject, output, viewChild } from '@angular/core'
-import { User } from '@app/core'
-import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { Notifier, User, UserService } from '@app/core'
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
+import { logger } from '@root-helpers/logger'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { AdminConfigWizardStepperComponent } from './admin-config-wizard-stepper.component'
import { getNoWelcomeModalLocalStorageKey } from './shared/admin-config-wizard-modal-utils'
@@ -28,6 +29,8 @@ import { UsageType } from './steps/usage-type/usage-type.model'
})
export class AdminConfigWizardModalComponent implements OnInit {
private modalService = inject(NgbModal)
+ private userService = inject(UserService)
+ private notifier = inject(Notifier)
readonly modal = viewChild<ElementRef>('modal')
readonly stepper = viewChild<AdminConfigWizardStepperComponent>('stepper')
@@ -40,6 +43,8 @@ export class AdminConfigWizardModalComponent implements OnInit {
showWelcome: boolean
dryRun: boolean
+ private modalRef: NgbModalRef
+
ngOnInit () {
this.created.emit()
}
@@ -58,7 +63,7 @@ export class AdminConfigWizardModalComponent implements OnInit {
this.showWelcome = showWelcome
this.dryRun = this.getFragment() === '#admin-welcome-wizard-test'
- this.modalService.open(this.modal(), {
+ this.modalRef = this.modalService.open(this.modal(), {
centered: true,
backdrop: 'static',
keyboard: false,
@@ -88,6 +93,25 @@ export class AdminConfigWizardModalComponent implements OnInit {
return totalSteps
}
+ hide (options: { doNotOpenAgain?: boolean } = {}) {
+ const { doNotOpenAgain = false } = options
+
+ if (doNotOpenAgain) this.doNotOpenAgain()
+
+ this.modalRef.close()
+ }
+
+ private doNotOpenAgain () {
+ peertubeLocalStorage.setItem(getNoWelcomeModalLocalStorageKey(), 'true')
+
+ this.userService.updateMyProfile({ noWelcomeModal: true })
+ .subscribe({
+ next: () => logger.info('We will not open the welcome modal again.'),
+
+ error: err => this.notifier.error(err.message)
+ })
+ }
+
private getFragment () {
return window.location.hash
}
diff --git a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.html b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.html
index a3ecd641ca..3ff0f9e297 100644
--- a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.html
+++ b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.html
@@ -13,7 +13,7 @@
<div class="buttons">
<my-button i18n theme="primary" (click)="next.emit()">Let's go!</my-button>
- <my-button i18n (click)="hide.emit()" theme="secondary">Remind me later</my-button>
- <button i18n (click)="doNotOpenAgain(); hide.emit()" class="button-as-link">Do not display again</button>
+ <my-button i18n (click)="hide.emit({ doNotOpenAgain: false })" theme="secondary">Remind me later</my-button>
+ <button i18n (click)="hide.emit({ doNotOpenAgain: true })" class="button-as-link">Do not display again</button>
</div>
</div>
diff --git a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.ts b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.ts
index 3f1f8b07f6..d2fab14d35 100644
--- a/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.ts
+++ b/client/src/app/modal/admin-config-wizard/steps/admin-config-wizard-welcome.component.ts
@@ -1,12 +1,8 @@
import { CdkStepperModule } from '@angular/cdk/stepper'
-import { Component, inject, output } from '@angular/core'
+import { Component, output } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
-import { Notifier, UserService } from '@app/core'
import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'
-import { logger } from '@root-helpers/logger'
-import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
-import { getNoWelcomeModalLocalStorageKey } from '../shared/admin-config-wizard-modal-utils'
@Component({
selector: 'my-admin-config-wizard-welcome',
@@ -15,21 +11,7 @@ import { getNoWelcomeModalLocalStorageKey } from '../shared/admin-config-wizard-
imports: [ FormsModule, ReactiveFormsModule, CdkStepperModule, ButtonComponent ]
})
export class AdminConfigWizardWelcomeComponent {
- private userService = inject(UserService)
- private notifier = inject(Notifier)
-
readonly back = output()
readonly next = output()
- readonly hide = output()
-
- doNotOpenAgain () {
- peertubeLocalStorage.setItem(getNoWelcomeModalLocalStorageKey(), 'true')
-
- this.userService.updateMyProfile({ noWelcomeModal: true })
- .subscribe({
- next: () => logger.info('We will not open the welcome modal again.'),
-
- error: err => this.notifier.error(err.message)
- })
- }
+ readonly hide = output<{ doNotOpenAgain: boolean }>()
}