aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-09-16 10:02:46 +0200
committerChocobozzz <me@florianbigard.com>2022-09-16 10:02:46 +0200
commite1eada8bae03d06dcd9549c06c67392a55a0fc96 (patch)
tree3d832feb2351ad8853386681fb07a25ae116c937 /client
parent81ed2de85c4d1cedcb5b4d58f3bfa39c3601ed2a (diff)
downloadPeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.tar.gz
PeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.tar.zst
PeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.zip
Disable uninstall button on plugin uninstallation
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html9
-rw-r--r--client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts34
-rw-r--r--client/src/app/+admin/plugins/plugin-search/plugin-search.component.html2
-rw-r--r--client/src/app/shared/shared-main/buttons/delete-button.component.ts7
4 files changed, 40 insertions, 12 deletions
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
index c5d440c8c..374c4d96d 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.html
@@ -15,10 +15,15 @@
15 15
16 <my-button 16 <my-button
17 class="update-button" *ngIf="isUpdateAvailable(plugin)" (click)="update(plugin)" [loading]="isUpdating(plugin)" 17 class="update-button" *ngIf="isUpdateAvailable(plugin)" (click)="update(plugin)" [loading]="isUpdating(plugin)"
18 [label]="getUpdateLabel(plugin)" icon="refresh" [attr.disabled]="isUpdating(plugin)" [responsiveLabel]="true" 18 [attr.disabled]="isUpdating(plugin) || isUninstalling(plugin)"
19 [label]="getUpdateLabel(plugin)" icon="refresh" [responsiveLabel]="true"
19 ></my-button> 20 ></my-button>
20 21
21 <my-delete-button (click)="uninstall(plugin)" label="Uninstall" i18n-label [responsiveLabel]="true"></my-delete-button> 22 <my-delete-button
23 (click)="uninstall(plugin)"
24 label="Uninstall" i18n-label [responsiveLabel]="true"
25 [disabled]="isUpdating(plugin) || isUninstalling(plugin)"
26 ></my-delete-button>
22 </div> 27 </div>
23 </my-plugin-card> 28 </my-plugin-card>
24 </ng-container> 29 </ng-container>
diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
index 960e711b4..2fdc14d85 100644
--- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts
@@ -24,6 +24,7 @@ export class PluginListInstalledComponent implements OnInit {
24 24
25 plugins: PeerTubePlugin[] = [] 25 plugins: PeerTubePlugin[] = []
26 updating: { [name: string]: boolean } = {} 26 updating: { [name: string]: boolean } = {}
27 uninstalling: { [name: string]: boolean } = {}
27 28
28 onDataSubject = new Subject<any[]>() 29 onDataSubject = new Subject<any[]>()
29 30
@@ -99,7 +100,11 @@ export class PluginListInstalledComponent implements OnInit {
99 } 100 }
100 101
101 isUpdating (plugin: PeerTubePlugin) { 102 isUpdating (plugin: PeerTubePlugin) {
102 return !!this.updating[this.getUpdatingKey(plugin)] 103 return !!this.updating[this.getPluginKey(plugin)]
104 }
105
106 isUninstalling (plugin: PeerTubePlugin) {
107 return !!this.uninstall[this.getPluginKey(plugin)]
103 } 108 }
104 109
105 isTheme (plugin: PeerTubePlugin) { 110 isTheme (plugin: PeerTubePlugin) {
@@ -107,12 +112,17 @@ export class PluginListInstalledComponent implements OnInit {
107 } 112 }
108 113
109 async uninstall (plugin: PeerTubePlugin) { 114 async uninstall (plugin: PeerTubePlugin) {
115 const pluginKey = this.getPluginKey(plugin)
116 if (this.uninstalling[pluginKey]) return
117
110 const res = await this.confirmService.confirm( 118 const res = await this.confirmService.confirm(
111 $localize`Do you really want to uninstall ${plugin.name}?`, 119 $localize`Do you really want to uninstall ${plugin.name}?`,
112 $localize`Uninstall` 120 $localize`Uninstall`
113 ) 121 )
114 if (res === false) return 122 if (res === false) return
115 123
124 this.uninstalling[pluginKey] = true
125
116 this.pluginApiService.uninstall(plugin.name, plugin.type) 126 this.pluginApiService.uninstall(plugin.name, plugin.type)
117 .subscribe({ 127 .subscribe({
118 next: () => { 128 next: () => {
@@ -120,15 +130,20 @@ export class PluginListInstalledComponent implements OnInit {
120 130
121 this.plugins = this.plugins.filter(p => p.name !== plugin.name) 131 this.plugins = this.plugins.filter(p => p.name !== plugin.name)
122 this.pagination.totalItems-- 132 this.pagination.totalItems--
133
134 this.uninstalling[pluginKey] = false
123 }, 135 },
124 136
125 error: err => this.notifier.error(err.message) 137 error: err => {
138 this.notifier.error(err.message)
139 this.uninstalling[pluginKey] = false
140 }
126 }) 141 })
127 } 142 }
128 143
129 async update (plugin: PeerTubePlugin) { 144 async update (plugin: PeerTubePlugin) {
130 const updatingKey = this.getUpdatingKey(plugin) 145 const pluginKey = this.getPluginKey(plugin)
131 if (this.updating[updatingKey]) return 146 if (this.updating[pluginKey]) return
132 147
133 if (this.isMajorUpgrade(plugin)) { 148 if (this.isMajorUpgrade(plugin)) {
134 const res = await this.confirmService.confirm( 149 const res = await this.confirmService.confirm(
@@ -140,20 +155,23 @@ export class PluginListInstalledComponent implements OnInit {
140 if (res === false) return 155 if (res === false) return
141 } 156 }
142 157
143 this.updating[updatingKey] = true 158 this.updating[pluginKey] = true
144 159
145 this.pluginApiService.update(plugin.name, plugin.type) 160 this.pluginApiService.update(plugin.name, plugin.type)
146 .pipe() 161 .pipe()
147 .subscribe({ 162 .subscribe({
148 next: res => { 163 next: res => {
149 this.updating[updatingKey] = false 164 this.updating[pluginKey] = false
150 165
151 this.notifier.success($localize`${plugin.name} updated.`) 166 this.notifier.success($localize`${plugin.name} updated.`)
152 167
153 Object.assign(plugin, res) 168 Object.assign(plugin, res)
154 }, 169 },
155 170
156 error: err => this.notifier.error(err.message) 171 error: err => {
172 this.notifier.error(err.message)
173 this.updating[pluginKey] = false
174 }
157 }) 175 })
158 } 176 }
159 177
@@ -165,7 +183,7 @@ export class PluginListInstalledComponent implements OnInit {
165 return this.pluginApiService.getPluginOrThemeHref(this.pluginType, name) 183 return this.pluginApiService.getPluginOrThemeHref(this.pluginType, name)
166 } 184 }
167 185
168 private getUpdatingKey (plugin: PeerTubePlugin) { 186 private getPluginKey (plugin: PeerTubePlugin) {
169 return plugin.name + plugin.type 187 return plugin.name + plugin.type
170 } 188 }
171 189
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html
index c989d2e38..08430913a 100644
--- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html
+++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html
@@ -46,7 +46,7 @@
46 ></my-edit-button> 46 ></my-edit-button>
47 47
48 <my-button 48 <my-button
49 class="update-button" *ngIf="plugin.installed === false" (click)="install(plugin)" 49 *ngIf="plugin.installed === false" (click)="install(plugin)"
50 [loading]="isInstalling(plugin)" label="Install" [responsiveLabel]="true" 50 [loading]="isInstalling(plugin)" label="Install" [responsiveLabel]="true"
51 icon="cloud-download" [attr.disabled]="isInstalling(plugin)" 51 icon="cloud-download" [attr.disabled]="isInstalling(plugin)"
52 ></my-button> 52 ></my-button>
diff --git a/client/src/app/shared/shared-main/buttons/delete-button.component.ts b/client/src/app/shared/shared-main/buttons/delete-button.component.ts
index 1cab10803..0ee7d3757 100644
--- a/client/src/app/shared/shared-main/buttons/delete-button.component.ts
+++ b/client/src/app/shared/shared-main/buttons/delete-button.component.ts
@@ -3,13 +3,18 @@ import { Component, Input, OnInit } from '@angular/core'
3@Component({ 3@Component({
4 selector: 'my-delete-button', 4 selector: 'my-delete-button',
5 template: ` 5 template: `
6 <my-button icon="delete" className="grey-button" [label]="label" [title]="title" [responsiveLabel]="responsiveLabel"></my-button> 6 <my-button
7 icon="delete" className="grey-button"
8 [disabled]="disabled" [label]="label" [title]="title"
9 [responsiveLabel]="responsiveLabel"
10 ></my-button>
7 ` 11 `
8}) 12})
9export class DeleteButtonComponent implements OnInit { 13export class DeleteButtonComponent implements OnInit {
10 @Input() label: string 14 @Input() label: string
11 @Input() title: string 15 @Input() title: string
12 @Input() responsiveLabel = false 16 @Input() responsiveLabel = false
17 @Input() disabled: boolean
13 18
14 ngOnInit () { 19 ngOnInit () {
15 if (this.label === undefined && !this.title) { 20 if (this.label === undefined && !this.title) {