Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix backup component being disabled by verification

Oliver Günther365963019b31
diff --git a/frontend/src/app/core/setup/globals/components/admin/backup.component.html b/frontend/src/app/core/setup/globals/components/admin/backup.component.html
index 269b6ada726..e5e8a99e8c9 100644
--- a/frontend/src/app/core/setup/globals/components/admin/backup.component.html
+++ b/frontend/src/app/core/setup/globals/components/admin/backup.component.html
@@ -25,11 +25,11 @@
<h3 class="form--section-title">
{{ text.title }}
</h3>
-
+
<p>
{{ text.info }}
</p>
-
+
<p class="danger-zone--warning">
<span class="icon icon-error"></span>
<span>{{ text.note }}</span>
@@ -63,7 +63,13 @@
(input)="backupToken = $event.target.value"
#backupTokenInput
/>
- <button name="button" type="submit" class="-highlight button" (click)="triggerBackup($event)" [disabled]="backupToken.length == 0">
+ <button
+ name="button"
+ type="submit"
+ class="-highlight button"
+ [disabled]="backupToken.length === 0"
+ (click)="triggerBackup($event)"
+ >
<i class="button--icon icon-export"></i>
<span class="button--text">{{ text.requestBackup }}</span>
</button>
diff --git a/frontend/src/app/core/setup/globals/components/admin/backup.component.ts b/frontend/src/app/core/setup/globals/components/admin/backup.component.ts
index 63ea24a3148..cfbc48fd4e2 100644
--- a/frontend/src/app/core/setup/globals/components/admin/backup.component.ts
+++ b/frontend/src/app/core/setup/globals/components/admin/backup.component.ts
@@ -26,9 +26,9 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { HttpErrorResponse } from '@angular/common/http';
import {
AfterViewInit,
+ ChangeDetectionStrategy,
Component,
ElementRef,
Injector,
@@ -49,6 +49,7 @@ export const backupSelector = 'backup';
@Component({
selector: backupSelector,
templateUrl: './backup.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BackupComponent implements AfterViewInit {
public text = {
@@ -93,7 +94,7 @@ export class BackupComponent implements AfterViewInit {
this.includeAttachments = this.mayIncludeAttachments;
}
- ngAfterViewInit() {
+ ngAfterViewInit():void {
this.backupTokenInput.nativeElement.focus();
}
diff --git a/frontend/src/app/core/setup/globals/global-listeners/danger-zone-validation.ts b/frontend/src/app/core/setup/globals/global-listeners/danger-zone-validation.ts
index df0efb144fa..62498221f99 100644
--- a/frontend/src/app/core/setup/globals/global-listeners/danger-zone-validation.ts
+++ b/frontend/src/app/core/setup/globals/global-listeners/danger-zone-validation.ts
@@ -28,14 +28,21 @@
// Moved from app/assets/javascript/danger_zone_validation.js
// Make the whole danger zone a component the next time this needs changes!
+
export function dangerZoneValidation() {
// This will only work iff there is a single danger zone on the page
const dangerZoneVerification = jQuery('.danger-zone--verification');
- const expectedValue = jQuery('.danger-zone--expected-value').text();
+ const expectedValue = jQuery('.danger-zone--expected-value');
+
+ // When no expected value is set up, do not disable button
+ if (!expectedValue[0]) {
+ return;
+ }
+ const expectedText = expectedValue.text();
dangerZoneVerification.find('input').on('input', () => {
const actualValue = dangerZoneVerification.find('input').val() as string;
- if (expectedValue.toLowerCase() === actualValue.toLowerCase()) {
+ if (expectedText.toLowerCase() === actualValue.toLowerCase()) {
dangerZoneVerification.find('button').prop('disabled', false);
} else {
dangerZoneVerification.find('button').prop('disabled', true);