Skip to content

Commit

Permalink
Merge pull request #2918 from bcgov/feat/hamed-tfrs-teardown-bceid-id…
Browse files Browse the repository at this point in the history
…ir-959-1066

Feat: Implement TFRS Teardown for BCeID and IDIR Users - #959, #1066
  • Loading branch information
hamed-valiollahi authored Nov 8, 2024
2 parents e329210 + c95ef6b commit c06c470
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,4 @@ process.on("unhandledRejection", (reason) => {
process.exit(1);
});

module.exports = exports = { phases, options };
module.exports = exports = { phases, options };
24 changes: 23 additions & 1 deletion charts/tfrs-apps/charts/tfrs-frontend/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,27 @@ data:
"credit_calculation_api.enabled": true,
"exclusion_reports.enabled": true,
"exclusion_reports.create_effective_date": "2019-01-01",
"api_base": "https://tfrs-backend{{ .Values.suffix }}.apps.silver.devops.gov.bc.ca/api"
"api_base": "https://tfrs-backend{{ .Values.suffix }}.apps.silver.devops.gov.bc.ca/api",
"tear_down.bceid.widgets.balance": false,
"tear_down.bceid.widgets.feedback": false,
"tear_down.bceid.widgets.website": false,
"tear_down.bceid.widgets.creditTransactions": false,
"tear_down.bceid.widgets.fileSubmissions": false,
"tear_down.bceid.header.creditInformation": false,
"tear_down.bceid.navigation.transactions": false,
"tear_down.bceid.navigation.fileSubmissions": false,
"tear_down.bceid.navigation.helpLink": false,
"tear_down.bceid.organization.creditInformation": false,
"tear_down.bceid.organization.roles.fileSubmission": false,
"tear_down.bceid.organization.roles.creditTransfers": false,
"tear_down.idir.widgets.balance": false,
"tear_down.idir.widgets.creditTransactions": false,
"tear_down.idir.widgets.fileSubmissions": false,
"tear_down.idir.navigation.transactions": false,
"tear_down.idir.navigation.fileSubmissions": false,
"tear_down.idir.navigation.helpLink": false,
"tear_down.idir.organizations.tableColumns.complianceUnits": false,
"tear_down.idir.organizations.tableColumns.inReserve": false,
"tear_down.idir.organization.creditInformation": false
};
24 changes: 23 additions & 1 deletion frontend/public/config/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,27 @@ window.tfrs_config = {
'credit_transfer.enabled': true,
'compliance_reporting.enabled': true,
'credit_calculation_api.enabled': true,
'exclusion_reports.enabled': true
'exclusion_reports.enabled': true,

'tear_down.bceid.widgets.balance': false,
'tear_down.bceid.widgets.feedback': false,
'tear_down.bceid.widgets.website': false,
'tear_down.bceid.widgets.creditTransactions': false,
'tear_down.bceid.widgets.fileSubmissions': false,
'tear_down.bceid.header.creditInformation': false,
'tear_down.bceid.navigation.transactions': false,
'tear_down.bceid.navigation.fileSubmissions': false,
'tear_down.bceid.navigation.helpLink': false,
"tear_down.bceid.organization.creditInformation": false,
'tear_down.bceid.organization.roles.fileSubmission': false,
'tear_down.bceid.organization.roles.creditTransfers': false,
'tear_down.idir.widgets.balance': false,
'tear_down.idir.widgets.creditTransactions': false,
'tear_down.idir.widgets.fileSubmissions': false,
'tear_down.idir.navigation.transactions': false,
'tear_down.idir.navigation.fileSubmissions': false,
'tear_down.idir.navigation.helpLink': false,
'tear_down.idir.organizations.tableColumns.complianceUnits': false,
'tear_down.idir.organizations.tableColumns.inReserve': false,
'tear_down.idir.organization.creditInformation': false
}
130 changes: 76 additions & 54 deletions frontend/src/admin/users/components/UserFormDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ import AutocompletedInput from '../../../app/components/AutocompletedInput'

import CheckBox from '../../../app/components/CheckBox'
// import FuelSupplierAdapter from '../../../app/components/FuelSupplierAdapter';
import CONFIG from '../../../config'

const UserFormDetails = props => (
<div className="user-details">
const UserFormDetails = props => {
// Access the BCeID tear-down configuration
const tearDownConfig = CONFIG.TEAR_DOWN.BCeID

// Define the roles to be torn down based on the configuration
const rolesToTearDown = []
if (tearDownConfig.ORGANIZATION.ROLES.FILE_SUBMISSION) {
rolesToTearDown.push(10) // Role ID for File Submission
}
if (tearDownConfig.ORGANIZATION.ROLES.CREDIT_TRANSFERS) {
rolesToTearDown.push(4) // Role ID for Credit Transfers
}

return (
<div className="user-details">
<div className="main-form">
<div className="row">
<div className="col-sm-6">
Expand Down Expand Up @@ -257,64 +271,72 @@ const UserFormDetails = props => (
</div>
</div>
</div>

{props.editPrimaryFields &&
props.roles &&
<div className="form-group">
<div className="row">
<div className="col-sm-6">
<label htmlFor="status">Role(s):</label>
</div>
</div>

<div className="row roles" id="user-roles">
{props.roles.items.filter((role) => {
if (document.location.pathname.indexOf('/admin/users/') >= 0) {
return role.isGovernmentRole
}
props.roles &&
<div className="form-group">
<div className="row">
<div className="col-sm-6">
<label htmlFor="status">Role(s):</label>
</div>
</div>

return !role.isGovernmentRole
}).map(role => (
<div className="col-sm-4 checkbox-group" key={role.id}>
<CheckBox
addToFields={props.addToFields}
className="checkbox"
fields={props.fields.roles}
id={role.id}
toggleCheck={props.toggleCheck}
/>
<OverlayTrigger
placement="top"
overlay={(
<Tooltip id={`tooltip-${role.id}`} placement="top">
<ul>
<div className="heading">This role will have the ability to:</div>
{role.permissions &&
role.permissions.map(permission => (
<li className="permission" key={permission.id}>{permission.name}</li>
))
}
</ul>
</Tooltip>
)}
>
<span className="text">{role.description}</span>
</OverlayTrigger>
<div className="row roles" id="user-roles">
{props.roles.items
.filter((role) => {
// For BCeID users, filter out roles based on tear-down configuration
if (
!props.loggedInUser.isGovernmentUser &&
rolesToTearDown.includes(role.id)
) {
return false
}
if (document.location.pathname.indexOf('/admin/users/') >= 0) {
return role.isGovernmentRole
}
return !role.isGovernmentRole
}).map(role => (
<div className="col-sm-4 checkbox-group" key={role.id}>
<CheckBox
addToFields={props.addToFields}
className="checkbox"
fields={props.fields.roles}
id={role.id}
toggleCheck={props.toggleCheck}
/>
<OverlayTrigger
placement="top"
overlay={(
<Tooltip id={`tooltip-${role.id}`} placement="top">
<ul>
<div className="heading">This role will have the ability to:</div>
{role.permissions &&
role.permissions.map(permission => (
<li className="permission" key={permission.id}>{permission.name}</li>
))
}
</ul>
</Tooltip>
)}
>
<span className="text">{role.description}</span>
</OverlayTrigger>
</div>
))
}
</div>
))
}
</div>

<div className="row">
<div className="col-sm-12">
* Hover over the roles to view the permissions available to that role.
<div className="row">
<div className="col-sm-12">
* Hover over the roles to view the permissions available to that role.
</div>
</div>
</div>
</div>
</div>
}
}
</div>
</div>
</div>
)
)
}

UserFormDetails.defaultProps = {
fuelSuppliers: null,
Expand Down
81 changes: 47 additions & 34 deletions frontend/src/app/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class Navbar extends Component {

render () {
const { organization } = this.props.loggedInUser
const userType = this.props.loggedInUser.isGovernmentUser ? 'IDIR' : 'BCeID'
const tearDownConfig = CONFIG.TEAR_DOWN[userType]

const SecondLevelNavigation = (
<div className="level2Navigation">
Expand Down Expand Up @@ -102,17 +104,20 @@ class Navbar extends Component {
Organizations
</NavLink>
}
<NavLink
// activeClassName="active"
id="navbar-credit-transactions"
to={CREDIT_TRANSACTIONS.LIST}
>
Transactions
</NavLink>
{!tearDownConfig.NAVIGATION.TRANSACTIONS &&
<NavLink
// activeClassName="active"
id="navbar-credit-transactions"
to={CREDIT_TRANSACTIONS.LIST}
>
Transactions
</NavLink>
}
{CONFIG.COMPLIANCE_REPORTING.ENABLED &&
typeof this.props.loggedInUser.hasPermission === 'function' &&
this.props.loggedInUser.hasPermission(PERMISSIONS_SECURE_DOCUMENT_UPLOAD.VIEW) &&
!this.props.loggedInUser.isGovernmentUser &&
!tearDownConfig.NAVIGATION.FILE_SUBMISSIONS &&
<NavLink
// activeClassName="active"
id="navbar-secure-document-upload"
Expand Down Expand Up @@ -143,6 +148,7 @@ class Navbar extends Component {
typeof this.props.loggedInUser.hasPermission === 'function' &&
this.props.loggedInUser.hasPermission(PERMISSIONS_SECURE_DOCUMENT_UPLOAD.VIEW) &&
this.props.loggedInUser.isGovernmentUser &&
!tearDownConfig.NAVIGATION.FILE_SUBMISSIONS &&
<NavLink
// activeClassName="active"
id="navbar-secure-document-upload"
Expand Down Expand Up @@ -212,13 +218,15 @@ class Navbar extends Component {
>
<FontAwesomeIcon icon="cog" /> Settings
</MenuItem>
<MenuItem
className="dropdown-hidden-item"
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
target="_blank"
>
<FontAwesomeIcon icon={['far', 'question-circle']} /> Help
</MenuItem>
{!tearDownConfig.NAVIGATION.HELP_LINK &&
<MenuItem
className="dropdown-hidden-item"
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
target="_blank"
>
<FontAwesomeIcon icon={['far', 'question-circle']} /> Help
</MenuItem>
}
<MenuItem onClick={(e) => {
e.preventDefault()
this.props.logout()
Expand All @@ -242,17 +250,19 @@ class Navbar extends Component {
}
</div>
</NavLink>
<a
className="navbar-item"
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
id="navbar-help"
rel="noopener noreferrer"
target="_blank"
>
<div>
<FontAwesomeIcon icon={['far', 'question-circle']} />
</div>
</a>
{!tearDownConfig.NAVIGATION.HELP_LINK &&
<a
className="navbar-item"
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
id="navbar-help"
rel="noopener noreferrer"
target="_blank"
>
<div>
<FontAwesomeIcon icon={['far', 'question-circle']} />
</div>
</a>
}
</div>
</div>
</div>
Expand Down Expand Up @@ -395,15 +405,17 @@ class Navbar extends Component {
Settings
</NavLink>
</li>
<li>
<a
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
rel="noopener noreferrer"
target="_blank"
>
Help
</a>
</li>
{!tearDownConfig.NAVIGATION.HELP_LINK &&
<li>
<a
href={`https://www2.gov.bc.ca/assets/gov/farming-natural-resources-and-industry/electricity-alternative-energy/transportation/renewable-low-carbon-fuels/transportation_fuels_reporting_system_${this.props.loggedInUser.isGovernmentUser ? 'idir' : 'bceid'}_user_guide.pdf`}
rel="noopener noreferrer"
target="_blank"
>
Help
</a>
</li>
}
<li>
<NavLink
id="navbar-logout"
Expand Down Expand Up @@ -485,6 +497,7 @@ class Navbar extends Component {
</h5>
{this.props.loggedInUser.roles &&
!this.props.loggedInUser.isGovernmentUser &&
!tearDownConfig.HEADER.CREDIT_INFORMATION &&
<span id="organization-balance">
Compliance Units: {
numeral(organization.organizationBalance.validatedCredits)
Expand Down
Loading

0 comments on commit c06c470

Please sign in to comment.