From 3c2f64238e4f5832624bedd6564b504f71835d49 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Mon, 18 Jul 2022 14:33:10 -0300 Subject: [PATCH 1/8] Set alex email instead of biomage when deployment is hms, still pending checking the dpeloyment name for hms --- src/components/data-management/FileUploadModal.jsx | 7 ++++--- src/components/header/HelpButton.jsx | 4 +++- src/config/defaultConfig.js | 13 +++++++++++++ src/config/index.js | 12 ++++++++++++ src/config/testConfig.js | 5 +++++ src/utils/deploymentInfo.js | 8 ++++++++ 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/config/defaultConfig.js create mode 100644 src/config/index.js create mode 100644 src/config/testConfig.js create mode 100644 src/utils/deploymentInfo.js diff --git a/src/components/data-management/FileUploadModal.jsx b/src/components/data-management/FileUploadModal.jsx index fba796fe9e..d61b617e49 100644 --- a/src/components/data-management/FileUploadModal.jsx +++ b/src/components/data-management/FileUploadModal.jsx @@ -15,10 +15,11 @@ import { } from 'antd'; import { CheckCircleTwoTone, CloseCircleTwoTone, DeleteOutlined } from '@ant-design/icons'; import Dropzone from 'react-dropzone'; + +import config from 'config'; import techOptions from 'utils/upload/fileUploadSpecifications'; import handleError from 'utils/http/handleError'; import { fileObjectToFileRecord } from 'utils/upload/processUpload'; - import integrationTestConstants from 'utils/integrationTestConstants'; import endUserMessages from 'utils/endUserMessages'; @@ -149,7 +150,7 @@ const FileUploadModal = (props) => { Is your dataset generated using another single cell RNA-seq technology (e.g. Nadia, BD Rhapsody, etc.)? Email us to find out if we can support your data: - hello@biomage.net + {config.supportEmail} @@ -172,7 +173,7 @@ const FileUploadModal = (props) => { Don’t have the data in the accepted format? Email us for help with file conversion (e.g. from Fastq or H5 file): - hello@biomage.net + {config.supportEmail} diff --git a/src/components/header/HelpButton.jsx b/src/components/header/HelpButton.jsx index 1a4e7ac1b4..971fa1075f 100644 --- a/src/components/header/HelpButton.jsx +++ b/src/components/header/HelpButton.jsx @@ -2,6 +2,8 @@ import React, { useState } from 'react'; import { Button, Dropdown, Card } from 'antd'; import { QuestionCircleOutlined, DownOutlined } from '@ant-design/icons'; +import config from 'config'; + const HelpButton = () => { const [visible, setVisible] = useState(false); @@ -15,7 +17,7 @@ const HelpButton = () => {
If you need additional help with your analysis, email: {' '} - hello@biomage.net + {config.supportEmail} ); diff --git a/src/config/defaultConfig.js b/src/config/defaultConfig.js new file mode 100644 index 0000000000..8b6f9c1581 --- /dev/null +++ b/src/config/defaultConfig.js @@ -0,0 +1,13 @@ +import { DomainName } from 'utils/deploymentInfo'; + +const supportEmailsByDomainName = { + [DomainName.BIOMAGE]: 'hello@biomage.net', + [DomainName.BIOMAGE_STAGING]: 'hello@biomage.net', + [DomainName.HMS]: 'alex_pickering@hms.harvard.edu', +}; + +const config = { + supportEmail: supportEmailsByDomainName[process.env.DOMAIN_NAME], +}; + +export default config; diff --git a/src/config/index.js b/src/config/index.js new file mode 100644 index 0000000000..8f5b24feaa --- /dev/null +++ b/src/config/index.js @@ -0,0 +1,12 @@ +import defaultConfig from 'config/defaultConfig'; +import testConfig from 'config/testConfig'; + +// eslint-disable-next-line import/no-mutable-exports +let config; +if (process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID) { + config = testConfig; +} else { + config = defaultConfig; +} + +export default config; diff --git a/src/config/testConfig.js b/src/config/testConfig.js new file mode 100644 index 0000000000..ecc66c968b --- /dev/null +++ b/src/config/testConfig.js @@ -0,0 +1,5 @@ +const config = { + supportEmail: 'hello@biomage.net', +}; + +export default config; diff --git a/src/utils/deploymentInfo.js b/src/utils/deploymentInfo.js new file mode 100644 index 0000000000..a4ad3e4cb6 --- /dev/null +++ b/src/utils/deploymentInfo.js @@ -0,0 +1,8 @@ +const DomainName = { + BIOMAGE: 'scp.biomage.net', + BIOMAGE_STAGING: 'scp-staging.biomage.net', + HMS: '???@??.net', +}; + +// eslint-disable-next-line import/prefer-default-export +export { DomainName }; From 0b365d510a433d4e66dd5c73c1d4d5047382ab7a Mon Sep 17 00:00:00 2001 From: cosa65 Date: Mon, 18 Jul 2022 15:49:44 -0300 Subject: [PATCH 2/8] WIP --- src/components/header/HelpButton.jsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/header/HelpButton.jsx b/src/components/header/HelpButton.jsx index 971fa1075f..d5e1dcb8b3 100644 --- a/src/components/header/HelpButton.jsx +++ b/src/components/header/HelpButton.jsx @@ -3,18 +3,30 @@ import { Button, Dropdown, Card } from 'antd'; import { QuestionCircleOutlined, DownOutlined } from '@ant-design/icons'; import config from 'config'; +import { DomainName } from 'utils/deploymentInfo'; + +// const getStartedLinkIfNotHMS = () => { +// if (process.env.DOMAIN_NAME !== DomainName.HMS) { +// return () +// } +// }; const HelpButton = () => { const [visible, setVisible] = useState(false); const overlay = () => ( - For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit - {' '} - our website - . -
-
+ {process.env.DOMAIN_NAME !== DomainName.HMS ?? ( + <> + For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit + {' '} + our website + . +
+
+ + )} + If you need additional help with your analysis, email: {' '} {config.supportEmail} From 79f774950ab640d5f4ff80f6b01b63a64e9bc114 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Tue, 19 Jul 2022 11:41:26 -0300 Subject: [PATCH 3/8] Fill in correct hms domain name --- src/utils/deploymentInfo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/deploymentInfo.js b/src/utils/deploymentInfo.js index a4ad3e4cb6..8f1d28d5b1 100644 --- a/src/utils/deploymentInfo.js +++ b/src/utils/deploymentInfo.js @@ -1,7 +1,7 @@ const DomainName = { BIOMAGE: 'scp.biomage.net', BIOMAGE_STAGING: 'scp-staging.biomage.net', - HMS: '???@??.net', + HMS: 'cellenics.hms.harvard.edu', }; // eslint-disable-next-line import/prefer-default-export From c1f7587a0abf113e7de9870c4f244d66b3afda33 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Tue, 19 Jul 2022 12:55:56 -0300 Subject: [PATCH 4/8] Remove commented out lines --- src/components/header/HelpButton.jsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/header/HelpButton.jsx b/src/components/header/HelpButton.jsx index d5e1dcb8b3..4c9fa3f497 100644 --- a/src/components/header/HelpButton.jsx +++ b/src/components/header/HelpButton.jsx @@ -5,12 +5,6 @@ import { QuestionCircleOutlined, DownOutlined } from '@ant-design/icons'; import config from 'config'; import { DomainName } from 'utils/deploymentInfo'; -// const getStartedLinkIfNotHMS = () => { -// if (process.env.DOMAIN_NAME !== DomainName.HMS) { -// return () -// } -// }; - const HelpButton = () => { const [visible, setVisible] = useState(false); From f3c6b4624c2a45c0ff8fdd4a90779c57d930f577 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Tue, 19 Jul 2022 14:46:49 -0300 Subject: [PATCH 5/8] Fix help button and tests --- .../components/header/HelpButton.test.jsx | 17 ++++++++++++++++- src/components/header/HelpButton.jsx | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/__test__/components/header/HelpButton.test.jsx b/src/__test__/components/header/HelpButton.test.jsx index 6b9e5d6bd2..f97e0aaf75 100644 --- a/src/__test__/components/header/HelpButton.test.jsx +++ b/src/__test__/components/header/HelpButton.test.jsx @@ -1,13 +1,28 @@ import React from 'react'; -import { act } from 'react-dom/test-utils'; import { screen, render } from '@testing-library/react'; import HelpButton from 'components/header/HelpButton'; import userEvent from '@testing-library/user-event'; +import { DomainName } from 'utils/deploymentInfo'; const renderHelpButton = () => render(); describe('HelpButton', () => { + let originalEnv; + + // We are going to mess with the process env so save the original to avoid leak into other tests + beforeAll(() => { + originalEnv = { ...process.env }; + }); + + afterAll(() => { + process.env = originalEnv; + }); + + beforeEach(() => { + process.env = { DOMAIN_NAME: DomainName.BIOMAGE }; + }); + it('Renders the testing buttton properly', () => { renderHelpButton(); diff --git a/src/components/header/HelpButton.jsx b/src/components/header/HelpButton.jsx index 4c9fa3f497..a1a79bc3af 100644 --- a/src/components/header/HelpButton.jsx +++ b/src/components/header/HelpButton.jsx @@ -10,7 +10,7 @@ const HelpButton = () => { const overlay = () => ( - {process.env.DOMAIN_NAME !== DomainName.HMS ?? ( + {process.env.DOMAIN_NAME !== DomainName.HMS && ( <> For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit {' '} From 28504cafb4199f67a52083c9888948e3d4f3cddd Mon Sep 17 00:00:00 2001 From: cosa65 Date: Wed, 20 Jul 2022 10:27:21 -0300 Subject: [PATCH 6/8] Switch to using accountId instead of domain name --- next.config.js | 1 + src/components/header/HelpButton.jsx | 7 +++++-- src/config/defaultConfig.js | 15 +++++++++------ src/utils/apiEndpoint.js | 2 ++ src/utils/deploymentInfo.js | 7 ++++++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/next.config.js b/next.config.js index 35cf1811fc..c3305ac692 100644 --- a/next.config.js +++ b/next.config.js @@ -110,6 +110,7 @@ module.exports = withPlugins([ { publicRuntimeConfig: { domainName: process.env.DOMAIN_NAME, + accountId: process.env.AWS_ACCOUNT_ID, }, }, ], nextConfig); diff --git a/src/components/header/HelpButton.jsx b/src/components/header/HelpButton.jsx index a1a79bc3af..b41fd41d46 100644 --- a/src/components/header/HelpButton.jsx +++ b/src/components/header/HelpButton.jsx @@ -1,16 +1,19 @@ import React, { useState } from 'react'; import { Button, Dropdown, Card } from 'antd'; import { QuestionCircleOutlined, DownOutlined } from '@ant-design/icons'; +import nextConfig from 'next/config'; import config from 'config'; -import { DomainName } from 'utils/deploymentInfo'; +import { AccountId } from 'utils/deploymentInfo'; + +const accountId = nextConfig()?.publicRuntimeConfig?.accountId; const HelpButton = () => { const [visible, setVisible] = useState(false); const overlay = () => ( - {process.env.DOMAIN_NAME !== DomainName.HMS && ( + {accountId !== AccountId.HMS && ( <> For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit {' '} diff --git a/src/config/defaultConfig.js b/src/config/defaultConfig.js index 8b6f9c1581..965745ec56 100644 --- a/src/config/defaultConfig.js +++ b/src/config/defaultConfig.js @@ -1,13 +1,16 @@ -import { DomainName } from 'utils/deploymentInfo'; +import nextConfig from 'next/config'; -const supportEmailsByDomainName = { - [DomainName.BIOMAGE]: 'hello@biomage.net', - [DomainName.BIOMAGE_STAGING]: 'hello@biomage.net', - [DomainName.HMS]: 'alex_pickering@hms.harvard.edu', +import { AccountId } from 'utils/deploymentInfo'; + +const accountId = nextConfig()?.publicRuntimeConfig?.accountId; + +const supportEmailsByAccountId = { + [AccountId.BIOMAGE]: 'hello@biomage.net', + [AccountId.HMS]: 'alex_pickering@hms.harvard.edu', }; const config = { - supportEmail: supportEmailsByDomainName[process.env.DOMAIN_NAME], + supportEmail: supportEmailsByAccountId[accountId], }; export default config; diff --git a/src/utils/apiEndpoint.js b/src/utils/apiEndpoint.js index 3baf2cc7ee..b5fc213c1e 100644 --- a/src/utils/apiEndpoint.js +++ b/src/utils/apiEndpoint.js @@ -11,7 +11,9 @@ const getApiEndpoint = (location) => { if (url.hostname.includes('localhost') || url.hostname.includes('127.0.0.1')) { return 'http://localhost:3000'; } + const domainName = nextConfig()?.publicRuntimeConfig?.domainName; + return `https://api.${domainName}`; } catch (error) { console.error('Failed to get API endpoint.'); diff --git a/src/utils/deploymentInfo.js b/src/utils/deploymentInfo.js index b7c83dd2f9..1458fb9945 100644 --- a/src/utils/deploymentInfo.js +++ b/src/utils/deploymentInfo.js @@ -17,6 +17,11 @@ const DomainName = { HMS: 'cellenics.hms.harvard.edu', }; +const AccountId = { + BIOMAGE: '242905224710', + HMS: '160782110667', +}; + const ssrGetDeploymentInfo = () => { let currentEnvironment = null; @@ -48,5 +53,5 @@ const ssrGetDeploymentInfo = () => { }; export { - isBrowser, ssrGetDeploymentInfo, DomainName, Environment, privacyPolicyIsNotAccepted, + isBrowser, ssrGetDeploymentInfo, DomainName, AccountId, Environment, privacyPolicyIsNotAccepted, }; From 800596d4ba7b4426535c021a6cea61f04c330051 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Wed, 20 Jul 2022 15:00:37 -0300 Subject: [PATCH 7/8] Add handling for undefined account id, case development --- src/config/defaultConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/defaultConfig.js b/src/config/defaultConfig.js index 965745ec56..e959f158cf 100644 --- a/src/config/defaultConfig.js +++ b/src/config/defaultConfig.js @@ -2,7 +2,7 @@ import nextConfig from 'next/config'; import { AccountId } from 'utils/deploymentInfo'; -const accountId = nextConfig()?.publicRuntimeConfig?.accountId; +const accountId = nextConfig()?.publicRuntimeConfig?.accountId ?? AccountId.BIOMAGE; const supportEmailsByAccountId = { [AccountId.BIOMAGE]: 'hello@biomage.net', From df464a99bf9c5d8c9592ef76bb44015fb3a69e27 Mon Sep 17 00:00:00 2001 From: cosa65 Date: Wed, 20 Jul 2022 15:18:06 -0300 Subject: [PATCH 8/8] Remove hms domainName --- .../components/header/HelpButton.test.jsx | 16 ---------------- src/utils/deploymentInfo.js | 1 - 2 files changed, 17 deletions(-) diff --git a/src/__test__/components/header/HelpButton.test.jsx b/src/__test__/components/header/HelpButton.test.jsx index f97e0aaf75..b2e243faa3 100644 --- a/src/__test__/components/header/HelpButton.test.jsx +++ b/src/__test__/components/header/HelpButton.test.jsx @@ -3,26 +3,10 @@ import { screen, render } from '@testing-library/react'; import HelpButton from 'components/header/HelpButton'; import userEvent from '@testing-library/user-event'; -import { DomainName } from 'utils/deploymentInfo'; const renderHelpButton = () => render(); describe('HelpButton', () => { - let originalEnv; - - // We are going to mess with the process env so save the original to avoid leak into other tests - beforeAll(() => { - originalEnv = { ...process.env }; - }); - - afterAll(() => { - process.env = originalEnv; - }); - - beforeEach(() => { - process.env = { DOMAIN_NAME: DomainName.BIOMAGE }; - }); - it('Renders the testing buttton properly', () => { renderHelpButton(); diff --git a/src/utils/deploymentInfo.js b/src/utils/deploymentInfo.js index 1458fb9945..b0e125ba08 100644 --- a/src/utils/deploymentInfo.js +++ b/src/utils/deploymentInfo.js @@ -14,7 +14,6 @@ const Environment = { const DomainName = { BIOMAGE: 'scp.biomage.net', BIOMAGE_STAGING: 'scp-staging.biomage.net', - HMS: 'cellenics.hms.harvard.edu', }; const AccountId = {