Commit 498869b1 authored by Dave Pisek's avatar Dave Pisek

Show license-approvals inactive when no approvals required

This fix adds an extra check to make sure that the license-compliance
approvals rule only shows as active within the policy management
section, if the number of required approvals is greater than zero.
parent 42f861cc
...@@ -25,7 +25,8 @@ export default { ...@@ -25,7 +25,8 @@ export default {
return this.rules?.find(({ name }) => name === this.licenseCheckRuleName); return this.rules?.find(({ name }) => name === this.licenseCheckRuleName);
}, },
hasLicenseCheckRule() { hasLicenseCheckRule() {
return this.licenseCheckRule !== undefined; const { licenseCheckRule: { approvalsRequired = 0 } = {} } = this;
return approvalsRequired > 0;
}, },
licenseCheckStatusText() { licenseCheckStatusText() {
return this.hasLicenseCheckRule return this.hasLicenseCheckRule
......
---
title: 'License Compliance: Show license-approvals to be inactive if no approvals
required'
merge_request: 37170
author:
type: changed
...@@ -132,10 +132,12 @@ describe('EE Approvals LicenseCompliance', () => { ...@@ -132,10 +132,12 @@ describe('EE Approvals LicenseCompliance', () => {
}); });
describe.each` describe.each`
givenApprovalRule | expectedStatus givenApprovalRule | expectedStatus
${{}} | ${'inactive'} ${{}} | ${'inactive'}
${{ name: 'Foo' }} | ${'inactive'} ${{ name: 'Foo', approvalsRequired: 0 }} | ${'inactive'}
${{ name: TEST_LOCKED_APPROVALS_RULE_NAME }} | ${'active'} ${{ name: 'Foo', approvalsRequired: 1 }} | ${'inactive'}
${{ name: TEST_LOCKED_APPROVALS_RULE_NAME, approvalsRequired: 0 }} | ${'inactive'}
${{ name: TEST_LOCKED_APPROVALS_RULE_NAME, approvalsRequired: 1 }} | ${'active'}
`('when approval rule is "$givenApprovalRule.name"', ({ givenApprovalRule, expectedStatus }) => { `('when approval rule is "$givenApprovalRule.name"', ({ givenApprovalRule, expectedStatus }) => {
beforeEach(() => { beforeEach(() => {
store.modules.approvals.state.rules = [givenApprovalRule]; store.modules.approvals.state.rules = [givenApprovalRule];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment