Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Refactor orgnaization policy management #1147

Merged
merged 7 commits into from
Aug 25, 2021
Merged

Conversation

Hinton
Copy link
Member

@Hinton Hinton commented Aug 23, 2021

Objective

Refactors the policy management page for organizations. Instead of having a single component PolicyEditComponent containing a multitude of if statements, we now have a BasePolicy and BasePolicyComponent which encapsulates a single Policy. The PoliciesComponents displays a list of components which it retrives from the PolicyListService, and PolicyEditComponent lets the BasePolicyComponent handle the policy specific details.

I've also removed the deprecation warning for policies since it's no longer accurate.

Noteworthy Code Changes

  • src/app/app.component.ts: Policies are added during the bootstrap phase, not quite happy with the placement but I don't really see a good alternative.
  • src/app/organizations/manage/policy-edit.component.ts: Removed policy specific logic since it now exists in separate components. To load the policy component we needed to use a componentFactoryResolver.

Testing Considerations

Since this PR does some drastic changes to the policy management pages, we will have to do a full regression surrounding it.

Asana: https://app.asana.com/0/1198901840263430/1200796078487139

Copy link
Contributor

@cscharf cscharf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oscar I think this looks great and is a good refactor for our policies pattern. I'll let one other person on the team take a look and see if I missed anything as far as implementation details or technicalities.

@cscharf cscharf requested a review from a team August 24, 2021 20:38
Copy link
Contributor

@addisonbeck addisonbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question and some minor feedback. Looks great, Oscar!

Comment on lines +185 to +196
this.policyListService.addPolicies([
new TwoFactorAuthenticationPolicy(),
new MasterPasswordPolicy(),
new PasswordGeneratorPolicy(),
new SingleOrgPolicy(),
new RequireSsoPolicy(),
new PersonalOwnershipPolicy(),
new DisableSendPolicy(),
new SendOptionsPolicy(),
new ResetPasswordPolicy(),
]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you weren't happy about loading policies here, but I think it's perfect besides being in app.component. We get clear control and vision on what policies are supported & the addPolicies call taking an array is pretty clean.

Just curious, could we not populate the service in policies.component? What about in a constructor for the policy list service?

src/app/organizations/manage/policies.component.ts Outdated Show resolved Hide resolved
src/app/organizations/manage/policies.component.ts Outdated Show resolved Hide resolved
Comment on lines +10 to +18

<div class="modal-body">
<div class="modal-body" *ngIf="loading">
<i class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}" aria-hidden="true"></i>
<span class="sr-only">{{'loading' | i18n}}</span>
</div>
<div [hidden]="loading">
<p>{{policy.description | i18n}}</p>
<ng-template #policyForm></ng-template>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray for organized html 🥳

@Hinton Hinton merged commit 2cbe023 into master Aug 25, 2021
@Hinton Hinton deleted the feature/policy-refactor branch August 25, 2021 14:10
domdomegg added a commit to domdomegg/vaultwarden that referenced this pull request Sep 24, 2021
Boolean-toggle enterprise policies (like 'Two-Step Login' and 'Personal Ownership') don't provide a data attribute in the new version of the web client. This updates the backend to expect these to be optional.

Web change introduced in bitwarden/web#1147 which added https://github.com/bitwarden/web/blob/2cbe023a38792ff70a2a4907f4748354bb4e0573/src/app/organizations/policies/base-policy.component.ts#L48-L50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants