Skip to content

Commit

Permalink
Merge branch 'master' into check-file-sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
kafkasl authored Jul 21, 2022
2 parents 0cc705b + 1fb19d7 commit 8ed149c
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 12 deletions.
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ module.exports = withPlugins([
{
publicRuntimeConfig: {
domainName: process.env.DOMAIN_NAME,
accountId: process.env.AWS_ACCOUNT_ID,
},
},
], nextConfig);
1 change: 0 additions & 1 deletion src/__test__/components/header/HelpButton.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { act } from 'react-dom/test-utils';
import { screen, render } from '@testing-library/react';

import HelpButton from 'components/header/HelpButton';
Expand Down
7 changes: 4 additions & 3 deletions src/components/data-management/FileUploadModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -149,7 +150,7 @@ const FileUploadModal = (props) => {
<Text type='secondary'>
<i>
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:
<a href='mailto:[email protected]'> [email protected]</a>
<a href={`mailto:${config.supportEmail}`}>{config.supportEmail}</a>
</i>
</Text>
</Space>
Expand All @@ -172,7 +173,7 @@ const FileUploadModal = (props) => {
<Paragraph type='secondary'>
<i>
Don’t have the data in the accepted format? Email us for help with file conversion (e.g. from Fastq or H5 file):
<a href='mailto:[email protected]'> [email protected]</a>
<a href={`mailto:${config.supportEmail}`}>{config.supportEmail}</a>
</i>
<span style={{ display: 'block', height: '0.6rem' }} />
<i>
Expand Down
25 changes: 18 additions & 7 deletions src/components/header/HelpButton.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
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 { AccountId } from 'utils/deploymentInfo';

const accountId = nextConfig()?.publicRuntimeConfig?.accountId;

const HelpButton = () => {
const [visible, setVisible] = useState(false);

const overlay = () => (
<Card size='small' style={{ padding: '1em', width: '265px' }}>
For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit
{' '}
<a href='https://www.biomage.net/get-started' target='_blank' rel='noreferrer'>our website</a>
.
<br />
<br />
{accountId !== AccountId.HMS && (
<>
For tutorial videos, ‘how to’ guides and FAQs on how to use Cellenics, visit
{' '}
<a href='https://www.biomage.net/get-started' target='_blank' rel='noreferrer'>our website</a>
.
<br />
<br />
</>
)}

If you need additional help with your analysis, email:
{' '}
<a href='mailto:[email protected]'>[email protected]</a>
<a href={`mailto:${config.supportEmail}`}>{config.supportEmail}</a>
</Card>
);

Expand Down
16 changes: 16 additions & 0 deletions src/config/defaultConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import nextConfig from 'next/config';

import { AccountId } from 'utils/deploymentInfo';

const accountId = nextConfig()?.publicRuntimeConfig?.accountId ?? AccountId.BIOMAGE;

const supportEmailsByAccountId = {
[AccountId.BIOMAGE]: '[email protected]',
[AccountId.HMS]: '[email protected]',
};

const config = {
supportEmail: supportEmailsByAccountId[accountId],
};

export default config;
12 changes: 12 additions & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions src/config/testConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
supportEmail: '[email protected]',
};

export default config;
2 changes: 2 additions & 0 deletions src/utils/apiEndpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
7 changes: 6 additions & 1 deletion src/utils/deploymentInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const DomainName = {
BIOMAGE_STAGING: 'scp-staging.biomage.net',
};

const AccountId = {
BIOMAGE: '242905224710',
HMS: '160782110667',
};

const ssrGetDeploymentInfo = () => {
let currentEnvironment = null;

Expand Down Expand Up @@ -47,5 +52,5 @@ const ssrGetDeploymentInfo = () => {
};

export {
isBrowser, ssrGetDeploymentInfo, DomainName, Environment, privacyPolicyIsNotAccepted,
isBrowser, ssrGetDeploymentInfo, DomainName, AccountId, Environment, privacyPolicyIsNotAccepted,
};

0 comments on commit 8ed149c

Please sign in to comment.