Skip to content

Commit

Permalink
Merge f5d3505 into 12004e8
Browse files Browse the repository at this point in the history
  • Loading branch information
Allison Gruninger committed Oct 9, 2018
2 parents 12004e8 + f5d3505 commit 7ff54c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/src/app/shared/models/function-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface FunctionConfig {
disabled?: boolean; // can be null for empty template
disabled?: boolean | string; // can be null for empty template
bindings: FunctionBinding[];
}

Expand Down
22 changes: 21 additions & 1 deletion client/src/app/tree-view/function-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { PortalResources } from '../shared/models/portal-resources';
import { FunctionInfo } from '../shared/models/function-info';
import { Url } from 'app/shared/Utilities/url';
import { ScenarioService } from './../shared/services/scenario/scenario.service';
import { ScenarioIds} from './../shared/models/constants';
import { ScenarioIds, LogCategories} from './../shared/models/constants';
import { SiteService } from 'app/shared/services/site.service';
import { LogService } from './../shared/services/log.service';
import { errorIds } from '../shared/models/error-ids';

export class FunctionNode extends TreeNode implements CanBlockNavChange, Disposable, CustomSelection {
public dashboardType = DashboardType.FunctionDashboard;
Expand All @@ -25,6 +28,8 @@ export class FunctionNode extends TreeNode implements CanBlockNavChange, Disposa
private _broadcastService: BroadcastService;
private _ngUnsubscribe = new Subject();
private _scenarioService: ScenarioService;
private _siteService: SiteService;
private _logService: LogService;

public static blockNavChangeHelper(currentNode: TreeNode) {
let canSwitchFunction = true;
Expand Down Expand Up @@ -57,6 +62,8 @@ export class FunctionNode extends TreeNode implements CanBlockNavChange, Disposa
this._scenarioService = this.sideNav.injector.get(ScenarioService);
this._broadcastService = sideNav.injector.get(BroadcastService);
this._globalStateService = sideNav.injector.get(GlobalStateService);
this._siteService = sideNav.injector.get(SiteService);
this._logService = sideNav.injector.get(LogService);

this.iconClass = 'tree-node-svg-icon';
this.iconUrl = 'image/function_f.svg';
Expand All @@ -65,6 +72,19 @@ export class FunctionNode extends TreeNode implements CanBlockNavChange, Disposa
if (this.sideNav.portalService.isEmbeddedFunctions) {
this.showExpandIcon = false;
}

if (typeof this.functionInfo.config.disabled === 'string') {
const settingName = this.functionInfo.config.disabled;
this._siteService.getAppSettings(this.context.site.id)
.subscribe(r => {
if (r.isSuccessful) {
const result = r.result.properties[settingName];
this.functionInfo.config.disabled = result === '1' || result === 'true';
} else {
this._logService.error(LogCategories.SideNav, errorIds.failedToGetAppSettings, r.error);
}
});
}
}

// This will be called on every change detection run. So I'm making sure to always
Expand Down

0 comments on commit 7ff54c3

Please sign in to comment.