Skip to content

Commit

Permalink
DSAT-87 - Fix policy building (#77)
Browse files Browse the repository at this point in the history
* Fix policy editing by using policy.builder()
* Update changelog
  • Loading branch information
NathanAB authored and dmihalcik-virtru committed Aug 2, 2019
1 parent 4d09078 commit f0ddac3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/virtru/protect-and-track/compare/master...HEAD)

- NO-REF: _patch_
- Fix policy building by using `policy.builder()`
- NO-REF: _patch_
- Use Audit from SDK

Expand Down
17 changes: 14 additions & 3 deletions src/utils/VirtruWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ function _pushAction(action) {
*
* @param {?object} opts
*/
function policyBuilder(opts) {
const builder = new Virtru.PolicyBuilder(opts);
let actions = [`const policy = new Virtru.PolicyBuilder(${opts ? 'policy' : ''})`];
function policyBuilder(existingPolicy) {
if (existingPolicy) {
_pushAction({
title: 'Get Policy Builder',
code: 'const builder = existingPolicy.builder();',
});
} else {
_pushAction({
title: 'Create Policy Builder',
code: 'const builder = new Virtru.PolicyBuilder();',
});
}
const builder = existingPolicy ? existingPolicy.builder() : new Virtru.PolicyBuilder();
let actions = ['const policy = builder'];
// This proxy records all calls, then logs them to the UI on `build` invocations.
return new Proxy(builder, {
get(target, propKey, receiver) {
Expand Down

0 comments on commit f0ddac3

Please sign in to comment.