Skip to content

Commit

Permalink
Merge pull request #12984 from transcom/B-20010-INT
Browse files Browse the repository at this point in the history
B 20010 int Add FF for HQ role
  • Loading branch information
r-mettler authored Jun 12, 2024
2 parents 0b3a711 + a77a607 commit d409718
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 80 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ commands:
export FEATURE_FLAG_COAST_GUARD_EMPLID=true
export FEATURE_FLAG_MOVE_LOCK=false
export FEATURE_FLAG_OKTA_DODID_INPUT=false
export FEATURE_FLAG_HEADQUARTERS_ROLE=false
export FEATURE_FLAG_SAFETY_MOVE=false
export FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
Expand Down Expand Up @@ -906,6 +907,7 @@ commands:
FEATURE_FLAG_COAST_GUARD_EMPLID: 'true'
FEATURE_FLAG_MOVE_LOCK: 'false'
FEATURE_FLAG_OKTA_DODID_INPUT: 'false'
FEATURE_FLAG_HEADQUARTERS_ROLE: 'false'
FEATURE_FLAG_SAFETY_MOVE: 'false'
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS: 'false'
command: |
Expand Down
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ export FEATURE_FLAG_MOVE_LOCK=false
export FEATURE_FLAG_OKTA_DODID_INPUT=false
export FEATURE_FLAG_SAFETY_MOVE=true

# Feature flag to disable/enable headquarters role
export FEATURE_FLAG_HEADQUARTERS_ROLE=true
# Feature flag for additional supporting documents uploaded by customer
export FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=true

Expand Down
1 change: 1 addition & 0 deletions config/env/demo.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/demo.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/exp.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/exp.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/loadtest.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/loadtest.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/prd.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/prd.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/stg.app-client-tls.env
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
1 change: 1 addition & 0 deletions config/env/stg.app.env
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
FEATURE_FLAG_COAST_GUARD_EMPLID=false
FEATURE_FLAG_MOVE_LOCK=false
FEATURE_FLAG_OKTA_DODID_INPUT=false
FEATURE_FLAG_HEADQUARTERS_ROLE=false
FEATURE_FLAG_SAFETY_MOVE=false
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
8 changes: 8 additions & 0 deletions config/flipt/storage/development.features.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: "1.2"
namespace: development
flags:
- key: headquarters_role
name: Headquarters Role feature flag
type: BOOLEAN_FLAG_TYPE
enabled: true
rollouts:
- segment:
key: mil-app
value: true
- key: safety_move
name: Safety Move feature flag
type: BOOLEAN_FLAG_TYPE
Expand Down
3 changes: 2 additions & 1 deletion pkg/handlers/authentication/devlocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,8 @@ func loginUser(h devlocalAuthHandler, user *models.User, userType string, w http
}

func isOfficeUser(userType string) bool {
if userType == TOOOfficeUserType || userType == TIOOfficeUserType || userType == ServicesCounselorOfficeUserType || userType == QaeOfficeUserType || userType == CustomerServiceRepresentativeOfficeUserType || userType == HQOfficeUserType {
if userType == TOOOfficeUserType || userType == TIOOfficeUserType || userType == ServicesCounselorOfficeUserType ||
userType == QaeOfficeUserType || userType == CustomerServiceRepresentativeOfficeUserType || userType == HQOfficeUserType {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg/handlers/authentication/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var CustomerServiceRepresentative = RolePermissions{
},
}

var AllRolesPermissions = []RolePermissions{TOO, TIO, ServicesCounselor, QAE, HQ, CustomerServiceRepresentative}
var AllRolesPermissions = []RolePermissions{TOO, TIO, ServicesCounselor, QAE, CustomerServiceRepresentative, HQ}

// check if a [user.role] has permissions on a given object
func checkUserPermission(appCtx appcontext.AppContext, session *auth.Session, permission string) (bool, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ describe('RequestAccountForm component', () => {
const qsaCheckbox = screen.getByTestId('qualityAssuranceEvaluatorCheckBox');
expect(qsaCheckbox).toBeInstanceOf(HTMLInputElement);
expect(qsaCheckbox).not.toBeChecked(false);

const hqCheckbox = screen.getByTestId('headquartersCheckBox');
expect(hqCheckbox).toBeInstanceOf(HTMLInputElement);
expect(hqCheckbox).not.toBeChecked(false);
});

it('cancels requesting office account when cancel button is clicked', async () => {
Expand Down Expand Up @@ -149,51 +145,6 @@ describe('RequestAccountForm component', () => {
expect(testProps.onSubmit).toHaveBeenCalled();
});

it('submits Headquarters office account form when submit button is clicked', async () => {
const mockOfficeId = '3210a533-19b8-4805-a564-7eb452afce10';
const mockHeadquartersOffice = {
address: {
city: 'Test City',
country: 'United States',
id: 'a13806fc-0e7d-4dc3-91ca-b802d9da50f1',
postalCode: '85309',
state: 'AZ',
streetAddress1: '7383 N Litchfield Rd',
streetAddress2: 'Rm 1122',
},
created_at: '2018-05-28T14:27:39.198Z',
gbloc: 'KKFA',
id: mockOfficeId,
name: 'Tester',
phone_lines: [],
updated_at: '2018-05-28T14:27:39.198Z',
};

const mockSearchHeadquartersOfficesOpen = () => Promise.resolve([mockHeadquartersOffice]);
searchTransportationOfficesOpen.mockImplementation(mockSearchHeadquartersOfficesOpen);

renderWithRouter(<RequestAccountForm {...testProps} />);

await userEvent.type(screen.getByLabelText('First Name'), 'Bob');
await userEvent.type(screen.getByLabelText('Last Name'), 'Banks');
await userEvent.type(screen.getByLabelText('Email'), '[email protected]');
await userEvent.type(screen.getByLabelText('Telephone'), '333-333-3333');
await userEvent.type(screen.getByTestId('officeAccountRequestEdipi'), '1111111111');
await userEvent.type(screen.getByTestId('officeAccountRequestOtherUniqueId'), '1111111111');

const transportationOfficeInput = screen.getByLabelText('Transportation Office');
fireEvent.change(transportationOfficeInput, { target: { value: 'Tester' } });
await act(() => selectEvent.select(transportationOfficeInput, /Tester/));

const tooCheckbox = screen.getByTestId('headquartersCheckBox');
await userEvent.click(tooCheckbox);

const submitButton = await screen.getByTestId('requestOfficeAccountSubmitButton');
await userEvent.click(submitButton);

expect(testProps.onSubmit).toHaveBeenCalled();
});

it('shows policy error when both TOO and TIO checkboxes are both selected, and goes away after unselecting one of them', async () => {
renderWithRouter(<RequestAccountForm {...testProps} />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ export const OfficeAccountRequestFields = ({ render }) => {
name="customerSupportRepresentativeCheckBox"
label="Customer Support Representative"
/>
<CheckboxField
id="headquartersCheckBox"
data-testid="headquartersCheckBox"
name="headquartersCheckBox"
label="Headquarters"
/>
</>,
)}
</Fieldset>
Expand Down
6 changes: 3 additions & 3 deletions src/constants/userRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const roleTypes = {
CONTRACTING_OFFICER: 'contracting_officer',
SERVICES_COUNSELOR: 'services_counselor',
PRIME_SIMULATOR: 'prime_simulator',
QAE: 'qae',
HQ: 'headquarters',
CUSTOMER_SERVICE_REPRESENTATIVE: 'customer_service_representative',
QAE: 'qae',
};

export const adminOfficeRoles = [
Expand All @@ -18,17 +18,17 @@ export const adminOfficeRoles = [
{ roleType: 'contracting_officer', name: 'Contracting Officer' },
{ roleType: 'services_counselor', name: 'Services Counselor' },
{ roleType: 'prime_simulator', name: 'Prime Simulator' },
{ roleType: 'qae', name: 'Quality Assurance Evaluator' },
{ roleType: 'headquarters', name: 'Headquarters' },
{ roleType: 'customer_service_representative', name: 'Customer Service Representative' },
{ roleType: 'qae', name: 'Quality Assurance Evaluator' },
];

export const officeRoles = [
roleTypes.TOO,
roleTypes.TIO,
roleTypes.SERVICES_COUNSELOR,
roleTypes.PRIME_SIMULATOR,
roleTypes.QAE,
roleTypes.HQ,
roleTypes.CUSTOMER_SERVICE_REPRESENTATIVE,
roleTypes.QAE,
];
6 changes: 0 additions & 6 deletions src/pages/Office/RequestAccount/RequestAccount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export const RequestAccount = ({ setFlashMessage }) => {
roleType: 'qae',
});
}
if (values.headquartersCheckBox) {
requestedRoles.push({
name: 'Headquarters',
roleType: 'headquarters',
});
}
if (values.customerSupportRepresentativeCheckBox) {
requestedRoles.push({
name: 'Customer Service Representative',
Expand Down
67 changes: 53 additions & 14 deletions src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import { CheckboxGroupInput } from 'react-admin';

import { adminOfficeRoles } from 'constants/userRoles';
import { officeUserPrivileges } from 'constants/userPrivileges';
import { adminOfficeRoles, roleTypes } from 'constants/userRoles';
import { officeUserPrivileges, elevatedPrivilegeTypes } from 'constants/userPrivileges';
import { isBooleanFlagEnabled } from 'utils/featureFlags';

const RolesPrivilegesCheckboxInput = (props) => {
let rolesSelected = [];
let privilegesSelected = [];

const [isHeadquartersRoleFF, setHeadquartersRoleFF] = useState(false);

useEffect(() => {
isBooleanFlagEnabled('headquarters_role')?.then((enabled) => {
setHeadquartersRoleFF(enabled);
});
}, []);

const makeRoleTypeArray = (roles) => {
if (!roles || roles.length === 0) {
rolesSelected = [];
return undefined;
}
return roles.reduce((rolesArray, role) => {
if (role.roleType) {
rolesArray.push(role.roleType);
if (isHeadquartersRoleFF || (!isHeadquartersRoleFF && role.roleType !== roleTypes.HQ)) {
rolesArray.push(role.roleType);
}
}

rolesSelected = rolesArray;
Expand All @@ -24,16 +35,35 @@ const RolesPrivilegesCheckboxInput = (props) => {
};

const parseRolesCheckboxInput = (input) => {
if (privilegesSelected.includes('supervisor') || privilegesSelected.includes('safety')) {
if (
privilegesSelected.includes(elevatedPrivilegeTypes.SUPERVISOR) ||
privilegesSelected.includes(elevatedPrivilegeTypes.SAFETY)
) {
var index;
if (input.includes('customer')) {
index = input.indexOf('customer');
if (input.includes(roleTypes.CUSTOMER)) {
index = input.indexOf(roleTypes.CUSTOMER);
if (index !== -1) {
input.splice(index, 1);
}
}
if (input.includes('contracting_officer')) {
index = input.indexOf('contracting_officer');
if (input.includes(roleTypes.CONTRACTING_OFFICER)) {
index = input.indexOf(roleTypes.CONTRACTING_OFFICER);
if (index !== -1) {
input.splice(index, 1);
}
}
}

if (!isHeadquartersRoleFF && input.includes(roleTypes.HQ)) {
if (input.includes(roleTypes.HQ)) {
index = input.indexOf(roleTypes.HQ);
if (index !== -1) {
input.splice(index, 1);
}
}
} else if (isHeadquartersRoleFF && privilegesSelected.includes(elevatedPrivilegeTypes.SAFETY)) {
if (input.includes(roleTypes.HQ)) {
index = input.indexOf(roleTypes.HQ);
if (index !== -1) {
input.splice(index, 1);
}
Expand Down Expand Up @@ -62,17 +92,26 @@ const RolesPrivilegesCheckboxInput = (props) => {
};

const parsePrivilegesCheckboxInput = (input) => {
if (rolesSelected.includes('customer') || rolesSelected.includes('contracting_officer')) {
if (rolesSelected.includes(roleTypes.CUSTOMER) || rolesSelected.includes(roleTypes.CONTRACTING_OFFICER)) {
var index;
if (input.includes('supervisor')) {
index = input.indexOf('supervisor');
if (input.includes(elevatedPrivilegeTypes.SUPERVISOR)) {
index = input.indexOf(elevatedPrivilegeTypes.SUPERVISOR);
if (index !== -1) {
input.splice(index, 1);
}
}

if (input.includes('safety')) {
index = input.indexOf('safety');
if (input.includes(elevatedPrivilegeTypes.SAFETY)) {
index = input.indexOf(elevatedPrivilegeTypes.SAFETY);
if (index !== -1) {
input.splice(index, 1);
}
}
}

if (isHeadquartersRoleFF && rolesSelected.includes(roleTypes.HQ)) {
if (input.includes(elevatedPrivilegeTypes.SAFETY)) {
index = input.indexOf(elevatedPrivilegeTypes.SAFETY);
if (index !== -1) {
input.splice(index, 1);
}
Expand Down

0 comments on commit d409718

Please sign in to comment.