diff options
author | Chocobozzz <me@florianbigard.com> | 2022-09-16 10:02:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-09-16 10:02:46 +0200 |
commit | e1eada8bae03d06dcd9549c06c67392a55a0fc96 (patch) | |
tree | 3d832feb2351ad8853386681fb07a25ae116c937 /client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts | |
parent | 81ed2de85c4d1cedcb5b4d58f3bfa39c3601ed2a (diff) | |
download | PeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.tar.gz PeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.tar.zst PeerTube-e1eada8bae03d06dcd9549c06c67392a55a0fc96.zip |
Disable uninstall button on plugin uninstallation
Diffstat (limited to 'client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts')
-rw-r--r-- | client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts | 34 |
1 files changed, 26 insertions, 8 deletions
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 | ||