Add alert modal in plugins on major upgrade

This commit is contained in:
Chocobozzz 2021-04-12 10:20:31 +02:00
parent fe19f600da
commit 40a5242168
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 19 additions and 0 deletions

View File

@ -128,6 +128,16 @@ export class PluginListInstalledComponent implements OnInit {
const updatingKey = this.getUpdatingKey(plugin)
if (this.updating[updatingKey]) return
if (this.isMajorUpgrade(plugin)) {
const res = await this.confirmService.confirm(
$localize`This is a major plugin upgrade. Please go on the plugin homepage to check potential release notes.`,
$localize`Upgrade`,
$localize`Proceed upgrade`
)
if (res === false) return
}
this.updating[updatingKey] = true
this.pluginApiService.update(plugin.name, plugin.type)
@ -156,4 +166,13 @@ export class PluginListInstalledComponent implements OnInit {
private getUpdatingKey (plugin: PeerTubePlugin) {
return plugin.name + plugin.type
}
private isMajorUpgrade (plugin: PeerTubePlugin) {
if (!plugin.latestVersion) return false
const latestMajor = plugin.latestVersion.split('.')[0]
const currentMajor = plugin.version.split('.')[0]
return latestMajor > currentMajor
}
}