Change designer to plugin in code
[sdc.git] / catalog-ui / src / app / view-models / workspace / tabs / plugins / plugins-context-view-model.ts
1 import {Plugin, IUserProperties} from "app/models";
2 import {CacheService} from "app/services";
3 import {PluginsService} from "../../../../ng2/services/plugins.service";
4 import {IWorkspaceViewModelScope} from "../../workspace-view-model";
5
6
7 interface IPluginsContextViewModelScope extends IWorkspaceViewModelScope {
8     plugin: Plugin;
9     user:IUserProperties;
10     queryParams: Object;
11 }
12
13 export class PluginsContextViewModel {
14     static '$inject' = [
15         '$scope',
16         '$stateParams',
17         'Sdc.Services.CacheService',
18         'PluginsService'
19     ];
20
21     constructor(private $scope:IPluginsContextViewModelScope,
22                 private $stateParams:any,
23                 private cacheService:CacheService,
24                 private pluginsService:PluginsService) {
25
26         this.initScope();
27     }
28
29     private initScope = ():void => {
30         this.$scope.plugin = this.pluginsService.getPluginByStateUrl(this.$stateParams.path);
31
32         this.$scope.user = this.cacheService.get('user');
33
34         this.$scope.queryParams = {
35             userId: this.$scope.user.userId,
36             contextType: this.$scope.component.componentType,
37             uuid: this.$scope.component.uuid,
38             lifecycleState: this.$scope.component.lifecycleState,
39             isOwner: this.$scope.component.lastUpdaterUserId === this.$scope.user.userId
40         };
41
42     }
43 }