-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-13014] - Add CanToggleStatus property to PolicyRepsonseModel based on Policy Validators #4940
base: main
Are you sure you want to change the base?
Changes from 6 commits
d2c6e2b
55d1d96
af262c4
6f5ce9d
dfa3f98
65fe1e0
1b0e4d7
82aac75
9007556
2503021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
๏ปฟusing Bit.Core.AdminConsole.Entities; | ||
using Bit.Core.AdminConsole.Enums; | ||
using Bit.Core.AdminConsole.Models.Api.Response; | ||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationDomains.Interfaces; | ||
|
||
namespace Bit.Api.AdminConsole.Models.Response.Helpers; | ||
|
||
public static class PolicyDetailResponses | ||
{ | ||
public static async Task<PolicyDetailResponseModel> GetSingleOrgPolicyDetailResponseAsync(Policy policy, IOrganizationHasVerifiedDomainsQuery hasVerifiedDomainsQuery) | ||
{ | ||
if (policy.Type is not PolicyType.SingleOrg) | ||
{ | ||
throw new ArgumentException($"'{nameof(policy)}' must be of type '{nameof(PolicyType.SingleOrg)}'.", nameof(policy)); | ||
} | ||
|
||
return new PolicyDetailResponseModel(policy, await hasVerifiedDomainsQuery.HasVerifiedDomainsAsync(policy.OrganizationId)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the bool needs to be inverted:
(Probably a drawback of a bool that defaults to |
||
} | ||
} |
jrmccannon marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Api request/response models live in the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
๏ปฟusing Bit.Core.AdminConsole.Entities; | ||
|
||
namespace Bit.Core.AdminConsole.Models.Api.Response; | ||
|
||
public class PolicyDetailResponseModel : PolicyResponseModel | ||
{ | ||
public PolicyDetailResponseModel(Policy policy, string obj = "policy") : base(policy, obj) | ||
{ | ||
} | ||
|
||
public PolicyDetailResponseModel(Policy policy, bool canToggleState) : base(policy) | ||
{ | ||
CanToggleState = canToggleState; | ||
} | ||
|
||
/// <summary> | ||
/// Indicates whether the Policy can be enabled/disabled | ||
/// </summary> | ||
public bool CanToggleState { get; set; } = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes required, but I am interested in the decision to use an extension method here vs. a static method on the class itself. I can make some guesses but would like to hear your thoughts.