plugins: PeerTubePlugin[] = []
updating: { [name: string]: boolean } = {}
+ uninstalling: { [name: string]: boolean } = {}
onDataSubject = new Subject<any[]>()
}
isUpdating (plugin: PeerTubePlugin) {
- return !!this.updating[this.getUpdatingKey(plugin)]
+ return !!this.updating[this.getPluginKey(plugin)]
+ }
+
+ isUninstalling (plugin: PeerTubePlugin) {
+ return !!this.uninstall[this.getPluginKey(plugin)]
}
isTheme (plugin: PeerTubePlugin) {
}
async uninstall (plugin: PeerTubePlugin) {
+ const pluginKey = this.getPluginKey(plugin)
+ if (this.uninstalling[pluginKey]) return
+
const res = await this.confirmService.confirm(
$localize`Do you really want to uninstall ${plugin.name}?`,
$localize`Uninstall`
)
if (res === false) return
+ this.uninstalling[pluginKey] = true
+
this.pluginApiService.uninstall(plugin.name, plugin.type)
.subscribe({
next: () => {
this.plugins = this.plugins.filter(p => p.name !== plugin.name)
this.pagination.totalItems--
+
+ this.uninstalling[pluginKey] = false
},
- error: err => this.notifier.error(err.message)
+ error: err => {
+ this.notifier.error(err.message)
+ this.uninstalling[pluginKey] = false
+ }
})
}
async update (plugin: PeerTubePlugin) {
- const updatingKey = this.getUpdatingKey(plugin)
- if (this.updating[updatingKey]) return
+ const pluginKey = this.getPluginKey(plugin)
+ if (this.updating[pluginKey]) return
if (this.isMajorUpgrade(plugin)) {
const res = await this.confirmService.confirm(
if (res === false) return
}
- this.updating[updatingKey] = true
+ this.updating[pluginKey] = true
this.pluginApiService.update(plugin.name, plugin.type)
.pipe()
.subscribe({
next: res => {
- this.updating[updatingKey] = false
+ this.updating[pluginKey] = false
this.notifier.success($localize`${plugin.name} updated.`)
Object.assign(plugin, res)
},
- error: err => this.notifier.error(err.message)
+ error: err => {
+ this.notifier.error(err.message)
+ this.updating[pluginKey] = false
+ }
})
}
return this.pluginApiService.getPluginOrThemeHref(this.pluginType, name)
}
- private getUpdatingKey (plugin: PeerTubePlugin) {
+ private getPluginKey (plugin: PeerTubePlugin) {
return plugin.name + plugin.type
}
@Component({
selector: 'my-delete-button',
template: `
- <my-button icon="delete" className="grey-button" [label]="label" [title]="title" [responsiveLabel]="responsiveLabel"></my-button>
+ <my-button
+ icon="delete" className="grey-button"
+ [disabled]="disabled" [label]="label" [title]="title"
+ [responsiveLabel]="responsiveLabel"
+ ></my-button>
`
})
export class DeleteButtonComponent implements OnInit {
@Input() label: string
@Input() title: string
@Input() responsiveLabel = false
+ @Input() disabled: boolean
ngOnInit () {
if (this.label === undefined && !this.title) {