|
1 | 1 | export default class ExtensionHelperService {
|
2 |
| - constructor({ storeService, pluginService, extensionApiService }) { |
| 2 | + constructor({ storeService, extensionStoreActionService }) { |
3 | 3 | this.storeService = storeService;
|
4 |
| - this.pluginService = pluginService; |
5 |
| - this.extensionApiService = extensionApiService; |
| 4 | + this.extensionStoreActionService = extensionStoreActionService; |
6 | 5 | }
|
7 | 6 |
|
8 |
| - async downloadAndActivateExtension(extensionName) { |
| 7 | + async downloadAndActivateExtension(extensionName, type = 'plugin') { |
9 | 8 | const extensionStatus = await this.getStatusOfExtension(extensionName);
|
10 | 9 |
|
11 | 10 | if (!extensionStatus.downloaded) {
|
12 | 11 | await this.downloadStoreExtension(extensionName);
|
13 | 12 | }
|
14 | 13 |
|
15 | 14 | if (!extensionStatus.installedAt) {
|
16 |
| - await this.installStoreExtension(extensionName); |
| 15 | + await this.installStoreExtension(extensionName, type); |
17 | 16 | }
|
18 | 17 |
|
19 | 18 | if (!extensionStatus.active) {
|
20 |
| - await this.activateStoreExtension(extensionName); |
| 19 | + await this.activateStoreExtension(extensionName, type); |
21 | 20 | }
|
22 | 21 | }
|
23 | 22 |
|
24 | 23 | downloadStoreExtension(extensionName) {
|
25 | 24 | return this.storeService.downloadPlugin(extensionName, true, true);
|
26 | 25 | }
|
27 | 26 |
|
28 |
| - installStoreExtension(extensionName) { |
29 |
| - return this.pluginService.install(extensionName); |
| 27 | + installStoreExtension(extensionName, type) { |
| 28 | + return this.extensionStoreActionService.installExtension(extensionName, type); |
30 | 29 | }
|
31 | 30 |
|
32 |
| - activateStoreExtension(extensionName) { |
33 |
| - return this.pluginService.activate(extensionName); |
| 31 | + activateStoreExtension(extensionName, type) { |
| 32 | + return this.extensionStoreActionService.activateExtension(extensionName, type); |
34 | 33 | }
|
35 | 34 |
|
36 | 35 | async getStatusOfExtension(extensionName) {
|
37 |
| - const extensions = await this.extensionApiService.getMyExtensions(); |
| 36 | + const extensions = await this.extensionStoreActionService.getMyExtensions(); |
38 | 37 | const extension = extensions.find(e => e && e.name === extensionName);
|
39 | 38 |
|
40 | 39 | if (!extension) {
|
|
0 commit comments