]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add alert modal in plugins on major upgrade
authorChocobozzz <me@florianbigard.com>
Mon, 12 Apr 2021 08:20:31 +0000 (10:20 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 12 Apr 2021 09:19:15 +0000 (11:19 +0200)
client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts

index c78b195850ec14c77e6923285123b884c3c850f9..cbdc379a878df2e9ee00fdf6ff9cf75e2e9ed109 100644 (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
+  }
 }