mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-22 23:09:38 -04:00
Make the alert dialog more configurable
Improve the wording on the install alert Standardize the CanUpdate logic
This commit is contained in:
@@ -118,6 +118,8 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
data: {
|
||||
title: this.translate.instant("APP.WOWUP_UPDATE.INSTALL_TITLE"),
|
||||
message: this.translate.instant("APP.WOWUP_UPDATE.SNACKBAR_TEXT"),
|
||||
positiveButton: "APP.WOWUP_UPDATE.DOWNLOADED_TOOLTIP",
|
||||
positiveButtonColor: "primary",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
<div mat-dialog-content>
|
||||
<pre class="message" [innerHTML]="data.message"></pre>
|
||||
</div>
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>
|
||||
{{ "DIALOGS.ALERT.POSITIVE_BUTTON" | translate }}
|
||||
<div mat-dialog-actions [ngSwitch]="data.positiveButtonStyle">
|
||||
<button *ngSwitchCase="raised" mat-raised-button [mat-dialog-close]="true" [color]="data.positiveButtonColor"
|
||||
cdkFocusInitial>
|
||||
{{ (data.positiveButton ?? "DIALOGS.ALERT.POSITIVE_BUTTON") | translate }}
|
||||
</button>
|
||||
<button *ngSwitchDefault mat-button [mat-dialog-close]="true" [color]="data.positiveButtonColor" cdkFocusInitial>
|
||||
{{ (data.positiveButton ?? "DIALOGS.ALERT.POSITIVE_BUTTON") | translate }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -4,6 +4,9 @@ import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
|
||||
export interface AlertDialogData {
|
||||
title: string;
|
||||
message: string;
|
||||
positiveButton?: string;
|
||||
positiveButtonColor?: "primary" | "accent" | "warn";
|
||||
positiveButtonStyle?: "raised" | "flat" | "stroked";
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -446,7 +446,7 @@ export class MyAddonsComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
|
||||
const addons = await this.addonService.getAddons(this.selectedInstallation, false);
|
||||
try {
|
||||
const filteredAddons = _.filter(addons, (addon) => this.addonService.canUpdateAddon(addon));
|
||||
const filteredAddons = _.filter(addons, (addon) => AddonUtils.needsUpdate(addon));
|
||||
|
||||
const promises = _.map(filteredAddons, async (addon) => {
|
||||
try {
|
||||
|
||||
@@ -517,7 +517,7 @@ export class AddonService {
|
||||
await this.syncAddons(installation, addons);
|
||||
|
||||
for (const addon of addons) {
|
||||
if (!this.canUpdateAddon(addon) || !addon.id) {
|
||||
if (!AddonUtils.needsUpdate(addon) || !addon.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -532,19 +532,6 @@ export class AddonService {
|
||||
return updatedAddons;
|
||||
}
|
||||
|
||||
public canUpdateAddon(addon: Addon): boolean {
|
||||
if (addon.isIgnored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sometimes authors push out new builds without changing the toc version.
|
||||
if (addon.externalLatestReleaseId && addon.externalLatestReleaseId !== addon.installedExternalReleaseId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!addon.installedVersion && addon.installedVersion !== addon.latestVersion;
|
||||
}
|
||||
|
||||
public getAutoUpdateEnabledAddons(): Addon[] {
|
||||
return this._addonStorage.queryAll((addon) => {
|
||||
return addon.isIgnored !== true && addon.autoUpdateEnabled;
|
||||
@@ -1909,7 +1896,7 @@ export class AddonService {
|
||||
|
||||
private areAnyAddonsAvailableForUpdate(): boolean {
|
||||
const updateReadyAddons = this._addonStorage.queryAll((addon) => {
|
||||
return addon.isIgnored !== true && this.canUpdateAddon(addon);
|
||||
return addon.isIgnored !== true && AddonUtils.needsUpdate(addon);
|
||||
});
|
||||
|
||||
return updateReadyAddons.length > 0;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { first } from "rxjs/operators";
|
||||
import { AddonChannelType } from "../../../common/wowup/models";
|
||||
import { AddonViewModel } from "../../business-objects/addon-view-model";
|
||||
import { AddonDetailComponent, AddonDetailModel } from "../../components/addon-detail/addon-detail.component";
|
||||
import { AlertDialogComponent } from "../../components/alert-dialog/alert-dialog.component";
|
||||
import { AlertDialogComponent, AlertDialogData } from "../../components/alert-dialog/alert-dialog.component";
|
||||
import { ConfirmDialogComponent } from "../../components/confirm-dialog/confirm-dialog.component";
|
||||
import { AddonSearchResult } from "../../models/wowup/addon-search-result";
|
||||
|
||||
@@ -38,18 +38,18 @@ export class DialogFactory {
|
||||
});
|
||||
}
|
||||
|
||||
public getAlertDialog(title: string, message: string): MatDialogRef<AlertDialogComponent, any> {
|
||||
public getAlertDialog(data: AlertDialogData): MatDialogRef<AlertDialogComponent, any> {
|
||||
return this._dialog.open(AlertDialogComponent, {
|
||||
minWidth: 250,
|
||||
data: {
|
||||
title,
|
||||
message,
|
||||
},
|
||||
data: { ...data },
|
||||
});
|
||||
}
|
||||
|
||||
public getErrorDialog(title: string, message: string): MatDialogRef<AlertDialogComponent, any> {
|
||||
return this.getAlertDialog(title, message);
|
||||
return this.getAlertDialog({
|
||||
title,
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
||||
public getPotentialAddonDetailsDialog(
|
||||
|
||||
@@ -26,14 +26,16 @@ export function getAddonDependencies(
|
||||
}
|
||||
|
||||
export function needsUpdate(addon: Addon | undefined): boolean {
|
||||
if (addon === undefined) {
|
||||
if (addon.isIgnored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
(addon.externalLatestReleaseId && addon.externalLatestReleaseId !== addon.installedExternalReleaseId) ||
|
||||
addon.installedVersion !== addon.latestVersion
|
||||
);
|
||||
// Sometimes authors push out new builds without changing the toc version.
|
||||
if (addon.externalLatestReleaseId && addon.externalLatestReleaseId !== addon.installedExternalReleaseId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!addon.installedVersion && addon.installedVersion !== addon.latestVersion;
|
||||
}
|
||||
|
||||
export function needsInstall(addon: Addon): boolean {
|
||||
|
||||
Reference in New Issue
Block a user