Skip to content

Commit

Permalink
Merge pull request #218 from pnnl/merging_workflows
Browse files Browse the repository at this point in the history
Merging all workflows into one app
  • Loading branch information
sudhacheran authored Sep 9, 2024
2 parents 02c70d7 + 3ae106c commit 7ef6a61
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 93 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
"workbox-webpack-plugin": "^6.4.1"
},
"scripts": {
"start": "HTTPS=true REACT_APP_ENV=quality-install-tool node scripts/start.js",
"start-ira": "HTTPS=true REACT_APP_ENV=ira-quality-install-tool node scripts/start.js",
"start": "HTTPS=true node scripts/start.js",
"build": "TSC_COMPILE_ON_ERROR=true node scripts/build.js",
"test": "node scripts/test.js",
"lint": "NODE_ENV=development BABEL_ENV=development eslint 'src/**/*.{js,jsx,ts,tsx}'",
Expand Down
27 changes: 2 additions & 25 deletions src/components/db_details.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
/**
* Define the database name based on the deployment environment configured in AWS S3.
*
* When deploying the application to AWS S3, the environment variable 'REACT_APP_ENV'
* is set to 'quality-install-tool' or 'ira-quality-install-tool' for the respective applications.
*
* The environment variable can be accessed in code using the `process.env` object,
* which will be populated with the specified value during the build process.
*
* For Local dev environment, the env variable REACT_APP_ENV is set in 'package.json'
* in start script as below
* "scripts": {
"start": "HTTPS=true REACT_APP_ENV=ira-quality-install-tool node scripts/start.js",
....
*
*
* This `DBName` constant exports the value of `process.env.REACT_APP_ENV`, which will
* determine the PouchDB database name created in the browser.
*
* Example usage in code:
*
* import DBName from './db_details';
* console.log(`Using database: ${DBName}`); // Output will depend on the environment variable 'REACT_APP_ENV' set in the AWS S3 deployment.
*
* Respective DBName exported are ('quality-install-tool' or 'ira-quality-install-tool').
* Define the database name
*/

const DBName = process.env.REACT_APP_ENV
const DBName = 'quality-install-tool'
export default DBName
10 changes: 2 additions & 8 deletions src/components/root_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ const RootLayout: FC<RootLayoutProps> = ({ children }) => {
}, [location.pathname])

/**
* When deploying the application to AWS S3, the environment variable 'REACT_APP_ENV'
* is set to 'quality-install-tool' or 'ira-quality-install-tool' for the respective applications.
*
* The title of the application is set accordingly
* The title of the application
*/
const app_title =
process.env.REACT_APP_ENV === 'quality-install-tool'
? 'Quality Install Tool'
: 'IRA - Quality Install Tool'
const app_title = 'Quality Install Tool'

return (
<div id="root-background">
Expand Down
69 changes: 11 additions & 58 deletions src/templates/templates_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface TemplatesConfig {
const templateRegex = /^(?!_)(?!.*_$)[a-z0-9_]{1,64}$/

// Add workflow templates for 'quality-install-tool'
const GENERAL_WORKFLOW_TEMPLATES = {
const templatesConfig: TemplatesConfig = {
doe_workflow_attic_air_sealing: {
title: 'Attic Air Sealing',
template: DOEWorkflowAtticAirSealTemplate,
Expand All @@ -33,87 +33,40 @@ const GENERAL_WORKFLOW_TEMPLATES = {
title: 'Attic Insulation',
template: DOEWorkflowAtticInsulationTemplate,
},
doe_workflow_central_ducted_split_heat_pump: {
title: 'Heat Pump Ducted',
template: DOEWorkflowCentralDuctedSplitHeatPumpTemplate,
},
doe_workflow_ductless_heat_pump: {
title: 'Heat Pump Ductless',
template: DOEWorkflowDuctlessHeatPumpTemplate,
},
doe_workflow_hpwh: {
title: 'Heat Pump Water Heater',
template: DOEWorkflowHPWHTemplate,
ira_doe_workflow_full_frame_replacement_windows: {
title: 'Full Frame Replacement Windows',
template: IRADOEWorkflowFullFrameReplacementWindows,
},
}

// Add workflow templates for 'ira-quality-install-tool'
const IRA_WORKFLOW_TEMPLATES = {
ira_doe_workflow_central_ducted_split_heat_pump: {
title: 'IRA - Heat Pump Ducted',
title: 'Heat Pump Ducted',
template: IRADOEWorkflowCentralDuctedSplitHeatPumpTemplate,
},
ira_doe_workflow_ductless_heat_pump: {
title: 'IRA - Heat Pump Ductless',
title: 'Heat Pump Ductless',
template: IRADOEWorkflowDuctlessHeatPumpTemplate,
},
ira_doe_workflow_hpwh: {
title: 'IRA - Heat Pump Water Heater',
title: 'Heat Pump Water Heater',
template: IRADOEWorkflowHPWHTemplate,
},
ira_doe_workflow_high_efficiency_gas_furnace: {
title: 'IRA - High Efficiency Gas Furnace',
title: 'High Efficiency Gas Furnace',
template: IRADOEWorkflowHighEfficiencyGasFurnace,
},
ira_doe_workflow_high_efficiency_water_heater: {
title: 'IRA - High Efficiency Water Heater',
title: 'High Efficiency Water Heater',
template: IRADOEWorkflowHighEfficiencyWaterHeater,
},
ira_doe_workflow_high_efficiency_modulating_boiler: {
title: 'IRA - High Efficiency Modulating Boiler',
title: 'High Efficiency Modulating Boiler',
template: IRADOEWorkflowHighEfficiencyModulatingBoiler,
},
ira_doe_workflow_full_frame_replacement_windows: {
title: 'IRA - Full Frame Replacement Windows',
template: IRADOEWorkflowFullFrameReplacementWindows,
},
ira_doe_workflow_insert_replacement_windows: {
title: 'IRA - Insert Replacement Windows',
title: 'Insert Replacement Windows',
template: IRADOEWorkflowInsertReplacementWindows,
},
}

/**
* Configure and render workflow templates based on the deployment environment configured in AWS S3 or local development.
*
* When deploying the application to AWS S3, the environment variable 'REACT_APP_ENV'
* is set to 'quality-install-tool' or 'ira-quality-install-tool' for the respective applications.
*
* In local development, the 'REACT_APP_ENV' environment variable can be set directly in the 'package.json'
* under the start script, as shown below:
*
* ```
* "scripts": {
* "start": "HTTPS=true REACT_APP_ENV=ira-quality-install-tool node scripts/start.js",
* ...
* }
* ```
*
* The environment variable 'REACT_APP_ENV' is accessed in code using the `process.env` object,
* which will be populated with the specified value ('quality-install-tool' or 'ira-quality-install-tool')
* during the build process or local development startup.
*
* The `templatesConfig` constant determines which set of workflow templates (`GENERAL_WORKFLOW_TEMPLATES`
* or `IRA_WORKFLOW_TEMPLATES`) to use based on the value of `process.env.REACT_APP_ENV`.
*
* The respective environments ('quality-install-tool' or 'ira-quality-install-tool').
*/

const templatesConfig: TemplatesConfig =
process.env.REACT_APP_ENV === 'quality-install-tool'
? GENERAL_WORKFLOW_TEMPLATES
: IRA_WORKFLOW_TEMPLATES

// Assuming TemplatesConfig is defined somewhere as a type or interface

/**
Expand Down

0 comments on commit 7ef6a61

Please sign in to comment.