diff --git a/frontend/components/Admin/Explorer.js b/frontend/components/Admin/Explorer.js index d73fdc68..aeaa0995 100644 --- a/frontend/components/Admin/Explorer.js +++ b/frontend/components/Admin/Explorer.js @@ -1,10 +1,11 @@ import axios from 'axios'; +import getConfig from 'next/config'; import styles from '../../styles/admin.module.css'; import { useState, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; import ActionButton from './Reusable/ActionButton'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); export default function Explorer() { const token = useSelector(state => state.user.token); @@ -38,7 +39,7 @@ export default function Explorer() { //Update SBOLExplorer Index const handleUpdateIndex = async () => { const params = new URLSearchParams(); - const url = `${feConfig.backend}/admin/explorerUpdateIndex`; + const url = `${publicRuntimeConfig.backend}/admin/explorerUpdateIndex`; const response = await axios .post(url, params, { headers: { @@ -55,7 +56,7 @@ export default function Explorer() { //View SBOLExplorer Log const handleDownloadGeneralLog = async () => { - const url = `${feConfig.backend}/admin/explorerlog`; + const url = `${publicRuntimeConfig.backend}/admin/explorerlog`; const res = await axios .get(url, { headers: { @@ -83,7 +84,7 @@ export default function Explorer() { //admin/explorerIndexingLog const handleDownloadIndexLog = async () => { - const url = `${feConfig.backend}/admin/explorerIndexingLog`; + const url = `${publicRuntimeConfig.backend}/admin/explorerIndexingLog`; const res = await axios .get(url, { headers: { @@ -136,7 +137,7 @@ export default function Explorer() { 'whichSearch': USchecked ? 'usearch' : 'vsearch' }; - const url = `${feConfig.backend}/admin/explorer`; + const url = `${publicRuntimeConfig.backend}/admin/explorer`; let res = await axios .post(url, params, { headers: { @@ -405,7 +406,7 @@ export default function Explorer() { // if SBOLExplorer is on const useConfig = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/explorer`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/explorer`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Graphs.js b/frontend/components/Admin/Graphs.js index d8af5107..4270a6c7 100644 --- a/frontend/components/Admin/Graphs.js +++ b/frontend/components/Admin/Graphs.js @@ -1,7 +1,8 @@ import axios from 'axios'; +import getConfig from 'next/config'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); import Table from '../Reusable/Table/Table'; import { addError } from '../../redux/actions'; @@ -48,7 +49,7 @@ const sortMethods = { const useGraphs = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/graphs`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/graphs`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Log.js b/frontend/components/Admin/Log.js index 40df6a27..31477ff8 100644 --- a/frontend/components/Admin/Log.js +++ b/frontend/components/Admin/Log.js @@ -1,9 +1,10 @@ import axios from 'axios'; +import getConfig from 'next/config'; import he from 'he'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); import styles from '../../styles/admin.module.css'; import Loading from '../Reusable/Loading'; @@ -71,7 +72,7 @@ const decodeHtml = (line, index) => { const useLog = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/log`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/log`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Mail.js b/frontend/components/Admin/Mail.js index 93226617..aca1931f 100644 --- a/frontend/components/Admin/Mail.js +++ b/frontend/components/Admin/Mail.js @@ -1,9 +1,10 @@ import { faEnvelope, faKey } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; +import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR, { mutate } from 'swr'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); import styles from '../../styles/admin.module.css'; import InputField from '../Login/InputField'; @@ -96,7 +97,7 @@ export default function Mail() { const useEmail = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/mail`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch], fetcher ); return { @@ -133,7 +134,7 @@ const updateEmail = async ( actualSendGridEmail, dispatch ) => { - const url = `${feConfig.backend}/admin/mail`; + const url = `${publicRuntimeConfig.backend}/admin/mail`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -160,6 +161,6 @@ const updateEmail = async ( setSendGridEmail(actualSendGridEmail); } else { setError(''); - mutate([`${feConfig.backend}/admin/mail`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch]); } }; diff --git a/frontend/components/Admin/Plugins.js b/frontend/components/Admin/Plugins.js index c851ed3f..8f19e433 100644 --- a/frontend/components/Admin/Plugins.js +++ b/frontend/components/Admin/Plugins.js @@ -8,6 +8,7 @@ import { faRedo } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; +import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR, { mutate } from 'swr'; @@ -17,6 +18,7 @@ import styles from '../../styles/admin.module.css'; import Table from '../Reusable/Table/Table'; import ActionButton from './Reusable/ActionButton'; import TableInput from './Reusable/TableInput'; +const { publicRuntimeConfig } = getConfig(); const renderingType = 'rendering'; const submittingType = 'submit'; @@ -28,7 +30,6 @@ const searchable = ['index', 'name', 'url']; const headers = ['ID', 'Name', 'URL', '']; import { addError } from '../../redux/actions'; -import feConfig from "../../config.json"; /* eslint sonarjs/no-duplicate-string: "off" */ @@ -295,7 +296,7 @@ function PluginDisplay(properties) { } const deletePlugin = async (id, type, token, dispatch) => { - const url = `${feConfig.backend}/admin/deletePlugin`; + const url = `${publicRuntimeConfig.backend}/admin/deletePlugin`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -316,12 +317,12 @@ const deletePlugin = async (id, type, token, dispatch) => { } if (response.status === 200) { - mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]); } }; const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => { - const url = `${feConfig.backend}/admin/savePlugin`; + const url = `${publicRuntimeConfig.backend}/admin/savePlugin`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -344,7 +345,7 @@ const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => { } if (response.status === 200) { - mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]); } }; @@ -375,7 +376,7 @@ const sortMethods = { const usePlugins = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/plugins`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch], fetcher ); return { @@ -389,7 +390,7 @@ const usePlugins = (token, dispatch) => { async function fetchStatus(plugin, type) { return await axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: plugin.name, endpoint: 'status', diff --git a/frontend/components/Admin/Registries.js b/frontend/components/Admin/Registries.js index 4d03c9fe..0b75826b 100644 --- a/frontend/components/Admin/Registries.js +++ b/frontend/components/Admin/Registries.js @@ -6,6 +6,7 @@ import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; +import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR, { mutate } from 'swr'; @@ -15,7 +16,7 @@ import Table from '../Reusable/Table/Table'; import ActionButton from './Reusable/ActionButton'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); /* eslint sonarjs/cognitive-complexity: "off" */ @@ -207,11 +208,11 @@ function RegistryActions() { const token = useSelector(state => state.user.token); const dispatch = useDispatch(); - const url = `${feConfig.backend}/admin/deleteRegistry`; + const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`; const handleFederate = async () => { try { - await axios.post(`${feConfig.backend}/admin/federate`, { + await axios.post(`${publicRuntimeConfig.backend}/admin/federate`, { administratorEmail: inputTwo, webOfRegistries: inputOne }, { @@ -229,7 +230,7 @@ function RegistryActions() { const handleRetrieve = async () => { try { - const response = await axios.post(`${feConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, { + const response = await axios.post(`${publicRuntimeConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, { headers: { 'Accept': 'application/json', 'X-authorization': token @@ -239,7 +240,7 @@ function RegistryActions() { if (response.data && Array.isArray(response.data.registries)) { // Assuming 'registries' is the correct key in response and it's an array of registry objects mutate([ - `${feConfig.backend}/admin/registries`, + `${publicRuntimeConfig.backend}/admin/registries`, token, dispatch ]); @@ -271,7 +272,7 @@ function RegistryActions() { } const deleteRegistry = async (uri, token, dispatch) => { - const url = `${feConfig.backend}/admin/deleteRegistry`; + const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -292,7 +293,7 @@ const deleteRegistry = async (uri, token, dispatch) => { if (response.status === 200) { mutate([ - `${feConfig.backend}/admin/registries`, + `${publicRuntimeConfig.backend}/admin/registries`, token, dispatch ]); @@ -300,7 +301,7 @@ const deleteRegistry = async (uri, token, dispatch) => { }; const saveRegistry = async (uri, sbhUrl, token, dispatch) => { - const url = `${feConfig.backend}/admin/saveRegistry`; + const url = `${publicRuntimeConfig.backend}/admin/saveRegistry`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -322,7 +323,7 @@ const saveRegistry = async (uri, sbhUrl, token, dispatch) => { if (response.status === 200) { mutate([ - `${feConfig.backend}/admin/registries`, + `${publicRuntimeConfig.backend}/admin/registries`, token, dispatch ]); diff --git a/frontend/components/Admin/Remotes.js b/frontend/components/Admin/Remotes.js index e18d41ce..42442b2a 100644 --- a/frontend/components/Admin/Remotes.js +++ b/frontend/components/Admin/Remotes.js @@ -6,6 +6,7 @@ import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; +import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR, { mutate } from 'swr'; @@ -15,7 +16,7 @@ import Table from '../Reusable/Table/Table'; import ActionButton from './Reusable/ActionButton'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); /* eslint sonarjs/cognitive-complexity: "off" */ @@ -229,7 +230,7 @@ function Dropdown() { const useRegistries = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/remotes`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/remotes`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Sparql.js b/frontend/components/Admin/Sparql.js index 02fa93ed..24324da0 100644 --- a/frontend/components/Admin/Sparql.js +++ b/frontend/components/Admin/Sparql.js @@ -4,10 +4,11 @@ import dynamic from 'next/dynamic'; import { useState } from 'react'; import { useSelector } from 'react-redux'; import Select from 'react-select'; +import getConfig from 'next/config'; import styles from '../../styles/sparql.module.css'; import Table from '../Reusable/Table/Table'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); const CodeMirror = dynamic( () => { @@ -120,7 +121,7 @@ const submitQuery = async ( setError(); setLoading(true); const url = `${ - feConfig.backend + publicRuntimeConfig.backend }/admin/sparql?query=${encodeURIComponent(query)}`; const headers = { diff --git a/frontend/components/Admin/Status.js b/frontend/components/Admin/Status.js index 4e7927d6..343a4731 100644 --- a/frontend/components/Admin/Status.js +++ b/frontend/components/Admin/Status.js @@ -2,11 +2,12 @@ import axios from 'axios'; import Loader from 'react-loader-spinner'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -import feConfig from "../../config.json"; +import getConfig from 'next/config'; import styles from '../../styles/defaulttable.module.css'; import { addError } from '../../redux/actions'; import { logoutUser } from '../../redux/actions'; +const { publicRuntimeConfig } = getConfig(); export default function Status() { const dispatch = useDispatch(); @@ -93,7 +94,7 @@ export default function Status() { export const useStatus = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Theme.js b/frontend/components/Admin/Theme.js index 46a84c24..3a65363a 100644 --- a/frontend/components/Admin/Theme.js +++ b/frontend/components/Admin/Theme.js @@ -1,4 +1,5 @@ import axios from 'axios'; +import getConfig from 'next/config'; import styles from '../../styles/defaulttable.module.css'; import Loading from '../Reusable/Loading'; import { addError } from '../../redux/actions'; @@ -6,8 +7,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { useState, useEffect } from 'react'; import Loader from 'react-loader-spinner'; import { isValidURI } from '../Viewing/Shell'; - -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); export default function Theme() { const dispatch = useDispatch(); @@ -61,16 +61,16 @@ export default function Theme() { }; const handleSave = async () => { - const url = `${feConfig.backend}/admin/theme`; + const url = `${publicRuntimeConfig.backend}/admin/theme`; const headers = { Accept: 'text/plain', 'X-authorization': token }; - // if (altHome !== '' && !isValidURI(altHome)) { - // alert('Alternate Home Page must be empty or contain a valid URL.'); - // return; // Prevent form submission - // } + if (altHome !== '' && !isValidURI(altHome)) { + alert('Alternate Home Page must be empty or contain a valid URL.'); + return; // Prevent form submission + } const formData = new FormData(); formData.append('instanceName', instanceName); diff --git a/frontend/components/Admin/Users.js b/frontend/components/Admin/Users.js index fcbf3b5c..fd0c424d 100644 --- a/frontend/components/Admin/Users.js +++ b/frontend/components/Admin/Users.js @@ -6,6 +6,7 @@ import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; +import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR, { mutate } from 'swr'; @@ -16,7 +17,7 @@ import ActionButton from './Reusable/ActionButton'; import Checkbox from './Reusable/CheckBox'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -import feConfig from "../../config.json"; +const { publicRuntimeConfig } = getConfig(); /* eslint sonarjs/cognitive-complexity: "off" */ @@ -52,7 +53,7 @@ export default function Users() { const handleAllowPublicSignup = async () => { try { - const url = `${feConfig.backend}/admin/users`; + const url = `${publicRuntimeConfig.backend}/admin/users`; const headers = { Accept: 'text/plain', 'X-authorization': token, @@ -349,7 +350,7 @@ function UserDisplay(properties) { } const deleteUser = async (id, token, dispatch) => { - const url = `${feConfig.backend}/admin/deleteUser`; + const url = `${publicRuntimeConfig.backend}/admin/deleteUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -369,7 +370,7 @@ const deleteUser = async (id, token, dispatch) => { } if (response && response.status === 200) { - mutate([`${feConfig.backend}/admin/users`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); } }; @@ -384,7 +385,7 @@ const saveUser = async ( token, dispatch ) => { - const url = `${feConfig.backend}/admin/updateUser`; + const url = `${publicRuntimeConfig.backend}/admin/updateUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -410,7 +411,7 @@ const saveUser = async ( } if (response.status === 200) { - mutate([`${feConfig.backend}/admin/users`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); } }; @@ -425,7 +426,7 @@ const createUser = async ( token, dispatch ) => { - const url = `${feConfig.backend}/admin/newUser`; + const url = `${publicRuntimeConfig.backend}/admin/newUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -453,7 +454,7 @@ const createUser = async ( // const responseText = await response.data; if (response && response.status === 200) { - mutate([`${feConfig.backend}/admin/users`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); } }; @@ -500,7 +501,7 @@ const sortMethods = { const useUsers = (token, dispatch) => { const { data, error } = useSWR( - [`${feConfig.backend}/admin/users`, token, dispatch], + [`${publicRuntimeConfig.backend}/admin/users`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Basket/Basket.js b/frontend/components/Basket/Basket.js index baff55dc..357b8aa0 100644 --- a/frontend/components/Basket/Basket.js +++ b/frontend/components/Basket/Basket.js @@ -19,8 +19,8 @@ import BasketItem from './BasketItem'; import CreateCollection from './CreateCollection'; const searchable = ['name', 'displayId', 'type', 'description']; - -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); /** * This component represents the basket in the search page. It stores the uri/name/displayId of @@ -202,7 +202,7 @@ const downloadCheckedItems = (items, selected, setSelected, dispatch) => { setSelected, function (item) { return { - url: `${feConfig.backend}${item.url}/sbol`, + url: `${publicRuntimeConfig.backend}${item.url}/sbol`, name: item.name, displayId: item.displayId, type: 'xml', diff --git a/frontend/components/Basket/BasketItem.js b/frontend/components/Basket/BasketItem.js index 70066664..a8d08137 100644 --- a/frontend/components/Basket/BasketItem.js +++ b/frontend/components/Basket/BasketItem.js @@ -1,7 +1,6 @@ import { useRouter } from 'next/router'; import styles from '../../styles/submissions.module.css'; -import feConfig from "../../config.json"; import { processUrl } from '../Admin/Registries'; import { useSelector } from 'react-redux'; diff --git a/frontend/components/Navbar/Navbar.js b/frontend/components/Navbar/Navbar.js index 67407761..26d60702 100644 --- a/frontend/components/Navbar/Navbar.js +++ b/frontend/components/Navbar/Navbar.js @@ -2,8 +2,7 @@ import { faAlignLeft, faCloudUploadAlt, faSearch, - faSignInAlt, - faHome + faSignInAlt } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Image from 'next/image'; @@ -14,7 +13,8 @@ import { useSelector } from 'react-redux'; import styles from '../../styles/navbar.module.css'; import Profile from './Profile'; import Selector from './Selector'; -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); /** * This component renders the navigation bar at the top of sbh. Users use this to access @@ -49,12 +49,12 @@ export default function Navbar() { useEffect(() => { if (localStorage.getItem('logo')) { - const urlLogo = `${feConfig.backend}/logo`; + const urlLogo = `${publicRuntimeConfig.backend}/logo`; setLogoUrl(urlLogo); } else { setLogoUrl(defaultLogo); } - }, [feConfig.backend]); + }, [publicRuntimeConfig.backend]); return (
+ )} diff --git a/frontend/components/Reusable/SelectorButton.js b/frontend/components/Reusable/SelectorButton.js index 52b4d482..bb449b95 100644 --- a/frontend/components/Reusable/SelectorButton.js +++ b/frontend/components/Reusable/SelectorButton.js @@ -1,7 +1,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useRouter } from 'next/router'; import { useEffect } from 'react'; -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import styles from '../../styles/searchheader.module.css'; @@ -30,7 +31,7 @@ export default function SearchTypeSelector(properties) { onClick={() => { if (properties.onClick) properties.onClick(); else if (!properties.external) router.replace(`/${properties.route}`); - else router.push(`${feConfig.backend}/${properties.route}`); + else router.push(`${publicRuntimeConfig.backend}/${properties.route}`); }} > {properties.icon ? ( diff --git a/frontend/components/Search/AdvancedSearch/Options.js b/frontend/components/Search/AdvancedSearch/Options.js index 0c3751f2..35534423 100644 --- a/frontend/components/Search/AdvancedSearch/Options.js +++ b/frontend/components/Search/AdvancedSearch/Options.js @@ -15,8 +15,8 @@ import styles from '../../../styles/advancedsearch.module.css'; import AdditionalFilter from './AdditionalFilter'; import SelectLoader from './SelectLoader'; import { addError } from '../../../redux/actions'; - -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); // tooltip component to show descriptions on hover const Tooltip = ({ text, children }) => { @@ -195,7 +195,7 @@ const loadPredicates = async (setPredicates, token, dispatch) => { // function to fetch predicates const fetchPredicates = async (token, dispatch) => { - const url = `${feConfig.backend}/sparql?query=${encodeURIComponent( + const url = `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( getPredicates )}`; try { diff --git a/frontend/components/Search/AdvancedSearch/SelectLoader.js b/frontend/components/Search/AdvancedSearch/SelectLoader.js index 33e9669b..a00874f9 100644 --- a/frontend/components/Search/AdvancedSearch/SelectLoader.js +++ b/frontend/components/Search/AdvancedSearch/SelectLoader.js @@ -7,7 +7,8 @@ import Loading from '../../Reusable/MiniLoading'; import { useDispatch, useSelector } from 'react-redux'; import { addError } from '../../../redux/actions'; import axios from 'axios'; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); const customFilter = createFilter({ ignoreAccents: false }); @@ -85,7 +86,7 @@ const fetchOptions = async ( }; const submitQuery = async (query, token, dispatch) => { - const url = `${feConfig.backend}/sparql?query=${encodeURIComponent( + const url = `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( query )}`; try { diff --git a/frontend/components/Search/NavbarSearch/NavbarSearch.js b/frontend/components/Search/NavbarSearch/NavbarSearch.js index 5038cdcb..32f47c20 100644 --- a/frontend/components/Search/NavbarSearch/NavbarSearch.js +++ b/frontend/components/Search/NavbarSearch/NavbarSearch.js @@ -6,7 +6,8 @@ import { useRouter } from 'next/router'; import { useSelector } from 'react-redux'; import { useState } from 'react'; import { useEffect } from 'react'; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import styles from '../../../styles/navbar.module.css'; import SearchBar from './SearchBar'; @@ -26,12 +27,12 @@ export default function NavbarSearch(properties) { useEffect(() => { if (localStorage.getItem('logo')) { - const urlLogo = `${feConfig.backend}/logo`; + const urlLogo = `${publicRuntimeConfig.backend}/logo`; setLogoUrl(urlLogo); } else { setLogoUrl(defaultLogo); } - }, [feConfig.backend]); + }, [publicRuntimeConfig.backend]); return (
{ return { - url: `${feConfig.backend}${item.url}/sbol`, + url: `${publicRuntimeConfig.backend}${item.url}/sbol`, name: item.name, displayId: item.displayId, type: 'xml', diff --git a/frontend/components/Search/StandardSearch/StandardSearch.js b/frontend/components/Search/StandardSearch/StandardSearch.js index e239435e..6a105422 100644 --- a/frontend/components/Search/StandardSearch/StandardSearch.js +++ b/frontend/components/Search/StandardSearch/StandardSearch.js @@ -7,7 +7,8 @@ import { faHatWizard, faBars} from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useRouter } from 'next/router'; import Options from '../AdvancedSearch/Options'; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import SearchHeader from '../SearchHeader/SearchHeader'; import { processUrl } from '../../Admin/Registries'; @@ -277,7 +278,7 @@ const useSearchResults = (query, url, offset, limit, token, dispatch) => { query = url + query; const { data, error } = useSWR( [ - `${feConfig.backend}/search/${query}?offset=${offset}&limit=${limit}`, + `${publicRuntimeConfig.backend}/search/${query}?offset=${offset}&limit=${limit}`, token, dispatch ], @@ -293,7 +294,7 @@ const useSearchResults = (query, url, offset, limit, token, dispatch) => { const useSearchCount = (query, url, token, dispatch) => { query = url + query; const { data, error } = useSWR( - [`${feConfig.backend}/searchCount/${query}`, token, dispatch], + [`${publicRuntimeConfig.backend}/searchCount/${query}`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Submission/PublishModal.js b/frontend/components/Submission/PublishModal.js index 4a0f1378..15ce15d9 100644 --- a/frontend/components/Submission/PublishModal.js +++ b/frontend/components/Submission/PublishModal.js @@ -16,7 +16,8 @@ import SelectorButton from '../Reusable/SelectorButton'; import Table from '../Reusable/Table/Table'; import PublishCollectionButton from './PublishCollectionButton'; import NewCollectionForm from './PublishNewCollectionForm'; -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); const EXISTING = 'to Existing'; const NEW = 'as New'; @@ -214,7 +215,7 @@ const sortMethods = { const useRootCollections = (dispatch, token) => { const { data, error } = useSWR( - [`${feConfig.backend}/rootCollections`, token, dispatch], + [`${publicRuntimeConfig.backend}/rootCollections`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Submission/TableButtons.js b/frontend/components/Submission/TableButtons.js index 11b63cc1..a4a460d3 100644 --- a/frontend/components/Submission/TableButtons.js +++ b/frontend/components/Submission/TableButtons.js @@ -14,7 +14,8 @@ import { addError, addToBasket, downloadFiles } from '../../redux/actions'; import styles from '../../styles/submissions.module.css'; import TableButton from '../Reusable/TableButton'; import PublishModal from './PublishModal'; -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); export default function TableButtons(properties) { const dispatch = useDispatch(); @@ -43,7 +44,7 @@ export default function TableButtons(properties) { properties.setSelected, function (submission) { return { - url: `${feConfig.backend}${submission.url}/sbol`, + url: `${publicRuntimeConfig.backend}${submission.url}/sbol`, name: submission.name, displayId: submission.displayId, type: 'xml', @@ -62,7 +63,7 @@ export default function TableButtons(properties) { properties.setSelected, function (submission) { return { - url: `${feConfig.backend}${submission.url}/removeCollection`, + url: `${publicRuntimeConfig.backend}${submission.url}/removeCollection`, name: submission.name, privacy: submission.privacy }; @@ -171,8 +172,8 @@ const removeCollections = ( Promise.all(removeCollectionPromises) .then(() => { setProcessUnderway(false); - mutate([`${feConfig.backend}/shared`, token, dispatch]); - mutate([`${feConfig.backend}/manage`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/shared`, token, dispatch]); + mutate([`${publicRuntimeConfig.backend}/manage`, token, dispatch]); }) .catch(error => { setProcessUnderway(false); diff --git a/frontend/components/Submit/ReusableComponents/InputField.js b/frontend/components/Submit/ReusableComponents/InputField.js index 408c8088..eadfdd85 100644 --- a/frontend/components/Submit/ReusableComponents/InputField.js +++ b/frontend/components/Submit/ReusableComponents/InputField.js @@ -24,11 +24,9 @@ export default function InputField(properties) {
properties.onChange(event)} className={`${styles.submitinput} ${properties.customStyling}`} placeholder={properties.placeholder} - disabled={properties.disabled} - style={properties.inputStyle} - > - { - (properties.options) ? - properties.options.map((option, index) => ( - - )) - : null - } - + />
); } diff --git a/frontend/components/Submit/ReusableComponents/SubmissionHandler.js b/frontend/components/Submit/ReusableComponents/SubmissionHandler.js index 699d89e0..d7af95a7 100644 --- a/frontend/components/Submit/ReusableComponents/SubmissionHandler.js +++ b/frontend/components/Submit/ReusableComponents/SubmissionHandler.js @@ -1,8 +1,8 @@ import styles from '../../../styles/submit.module.css' import Select from "react-select"; import axios from 'axios'; -import getConfig from "next/config"; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); export default function SubmissionHandler(properties) { @@ -17,7 +17,7 @@ export default function SubmissionHandler(properties) { axios({ method: 'GET', - url: `${feConfig.backend}/admin/plugins`, + url: `${publicRuntimeConfig.backend}/admin/plugins`, params: { category: 'submit' }, @@ -30,7 +30,7 @@ export default function SubmissionHandler(properties) { for(let plugin of submitPlugins) { axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: plugin.name, endpoint: 'status', diff --git a/frontend/components/Submit/ReusableComponents/SubmitLabel.js b/frontend/components/Submit/ReusableComponents/SubmitLabel.js index b15e4d85..99c4ec37 100644 --- a/frontend/components/Submit/ReusableComponents/SubmitLabel.js +++ b/frontend/components/Submit/ReusableComponents/SubmitLabel.js @@ -4,15 +4,15 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import styles from '../../../styles/submit.module.css'; export default function SubmitLabel(properties) { - // if (!properties.required) - // return ( - // - // ); + if (!properties.required) + return ( + + ); return ( ); } diff --git a/frontend/components/TopLevel.js b/frontend/components/TopLevel.js index b49361a4..353b97e4 100644 --- a/frontend/components/TopLevel.js +++ b/frontend/components/TopLevel.js @@ -9,8 +9,8 @@ import Navbar from './Navbar/Navbar'; import DownloadStatus from './Reusable/Download/DownloadStatus'; import Errors from './Error/Errors'; import axios from 'axios'; - -import feConfig from "../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); /* eslint sonarjs/cognitive-complexity: "off" */ @@ -38,13 +38,13 @@ export default function TopLevel(properties) { if (!registriesData || !themeData) { const [registriesResponse, themeResponse] = await Promise.all([ - axios.get(`${feConfig.backend}/admin/registries`, { + axios.get(`${publicRuntimeConfig.backend}/admin/registries`, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, }), - axios.get(`${feConfig.backend}/admin/theme`, { + axios.get(`${publicRuntimeConfig.backend}/admin/theme`, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', @@ -94,7 +94,7 @@ export default function TopLevel(properties) { return (
- {theme.instanceName} | SynBioHub + SynBioHub diff --git a/frontend/components/Viewing/Collection/Members.js b/frontend/components/Viewing/Collection/Members.js index f6bcf0d6..6e0ba753 100644 --- a/frontend/components/Viewing/Collection/Members.js +++ b/frontend/components/Viewing/Collection/Members.js @@ -4,7 +4,8 @@ import useSWR from 'swr'; import axios from 'axios'; import Select from 'react-select'; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import CountMembers from '../../../sparql/CountMembers'; import CountMembersTotal from '../../../sparql/CountMembersSearch'; @@ -48,7 +49,7 @@ export default function Members(properties) { const [customBounds, setCustomBounds] = useState([0, 10000]); const [typeFilter, setTypeFilter] = useState('Show Only Root Objects'); const dispatch = useDispatch(); - const [processedUri, setProcessedUri] = useState(feConfig.backend); + const [processedUri, setProcessedUri] = useState(publicRuntimeConfig.backend); const theme = JSON.parse(localStorage.getItem('theme')) || {}; const registries = JSON.parse(localStorage.getItem("registries")) || {}; @@ -334,7 +335,7 @@ function MemberTable(properties) { } const objectUriParts = getAfterThirdSlash(properties.uri); - const objectUri = `${feConfig.backend}/${objectUriParts}`; + const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; const icon = compareUri(member.uri, `/${objectUriParts}`); @@ -354,7 +355,7 @@ function MemberTable(properties) { const handleDelete = async (member) => { if (member.uri && window.confirm("Would you like to remove this item from the collection?")) { try { - await axios.get(`${feConfig.backend}${member.uri}/remove`, { + await axios.get(`${publicRuntimeConfig.backend}${member.uri}/remove`, { headers: { "Accept": "text/plain; charset=UTF-8", "X-authorization": token @@ -461,7 +462,7 @@ function compareUri(memberUri, baseUri) { const createUrl = (query, options) => { query = loadTemplate(query, options); - return `${feConfig.backend}/sparql?query=${encodeURIComponent( + return `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( query )}`; }; diff --git a/frontend/components/Viewing/MetadataInfo.js b/frontend/components/Viewing/MetadataInfo.js index 5804e152..3177cc07 100644 --- a/frontend/components/Viewing/MetadataInfo.js +++ b/frontend/components/Viewing/MetadataInfo.js @@ -6,12 +6,11 @@ import { faPlus, faTrash, faPencilAlt } from '@fortawesome/free-solid-svg-icons' import RenderIcon from './PageJSON/Rendering/RenderIcon'; import styles from '../../styles/view.module.css'; import axios from 'axios'; -import getConfig from "next/config"; import { getAfterThirdSlash } from './ViewHeader'; import { isUriOwner, formatMultipleTitles } from './Shell'; - -import feConfig from "../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); export default function MetadataInfo({ title, link, label, icon, specific, uri }) { const theme = JSON.parse(localStorage.getItem('theme')) || {}; @@ -52,7 +51,7 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } if (uri) { objectUriParts = getAfterThirdSlash(uri); } - const objectUri = `${feConfig.backend}/${objectUriParts}`; + const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; const [editSourceIndex, setEditSourceIndex] = useState(null); const [editedSource, setEditedSource] = useState(''); diff --git a/frontend/components/Viewing/Modals/AddToCollectionModal.js b/frontend/components/Viewing/Modals/AddToCollectionModal.js index fcf93432..462d5e82 100644 --- a/frontend/components/Viewing/Modals/AddToCollectionModal.js +++ b/frontend/components/Viewing/Modals/AddToCollectionModal.js @@ -10,8 +10,8 @@ import Select from "react-select"; import { getCanSubmitTo } from '../../../redux/actions'; import { useSelector, useDispatch } from "react-redux"; -import getConfig from "next/config"; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; @@ -87,7 +87,7 @@ export default function AddToCollectionModal(properties) { * @param {String} collection The uri of the collection to add to. */ const addToCollection = async (collection) => { - const url = `${feConfig.backend}${properties.url}/addToCollection`; + const url = `${publicRuntimeConfig.backend}${properties.url}/addToCollection`; var headers = { Accept: "text/plain; charset=UTF-8", "X-authorization": token diff --git a/frontend/components/Viewing/Modals/CurationModal.js b/frontend/components/Viewing/Modals/CurationModal.js index 890af857..4ec6a590 100644 --- a/frontend/components/Viewing/Modals/CurationModal.js +++ b/frontend/components/Viewing/Modals/CurationModal.js @@ -7,8 +7,8 @@ import React, { useEffect, useState } from "react"; import Select from "react-select"; import CustomModal from "./CustomModal"; -import getConfig from "next/config"; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import axios from "axios"; import parse from 'html-react-parser'; @@ -65,7 +65,7 @@ export default function CurationModal(properties) { axios({ method: 'GET', - url: `${feConfig.backend}/admin/plugins`, + url: `${publicRuntimeConfig.backend}/admin/plugins`, params: { category: 'curation' }, @@ -78,7 +78,7 @@ export default function CurationModal(properties) { for(let plugin of curatePlugins) { axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: plugin.name, endpoint: 'evaluate', @@ -141,7 +141,7 @@ export default function CurationModal(properties) { async function runPlugin(pluginName, pluginData) { return await axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: pluginName, endpoint: 'run', diff --git a/frontend/components/Viewing/Modals/DownloadModal.js b/frontend/components/Viewing/Modals/DownloadModal.js index 6c35052d..10df89d1 100644 --- a/frontend/components/Viewing/Modals/DownloadModal.js +++ b/frontend/components/Viewing/Modals/DownloadModal.js @@ -7,8 +7,8 @@ import React, { useEffect, useState } from "react"; import Select from "react-select"; import CustomModal from "./CustomModal"; -import getConfig from "next/config"; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import { useDispatch } from "react-redux"; import { downloadFiles } from "../../../redux/actions"; @@ -41,7 +41,7 @@ export default function DownloadModal(properties) { if (type != 'plugin') { const item = { - url: `${feConfig.backend}${properties.url}/${type}`, + url: `${publicRuntimeConfig.backend}${properties.url}/${type}`, name: properties.name, displayId: properties.displayId, type: "xml", @@ -62,7 +62,7 @@ export default function DownloadModal(properties) { const pluginData = { uri: properties.uri, - instanceUrl: `${feConfig.backend}/`, + instanceUrl: `${publicRuntimeConfig.backend}/`, size: 1, type: properties.type }; @@ -95,7 +95,7 @@ export default function DownloadModal(properties) { axios({ method: 'GET', - url: `${feConfig.backend}/admin/plugins`, + url: `${publicRuntimeConfig.backend}/admin/plugins`, params: { category: 'download' }, @@ -128,7 +128,7 @@ export default function DownloadModal(properties) { axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: plugin.name, endpoint: 'status', @@ -140,7 +140,7 @@ export default function DownloadModal(properties) { axios({ method: 'POST', - url: `${feConfig.backend}/call`, + url: `${publicRuntimeConfig.backend}/call`, params: { name: plugin.name, endpoint: 'evaluate', diff --git a/frontend/components/Viewing/Modals/ShareModal.js b/frontend/components/Viewing/Modals/ShareModal.js index 6c072999..1abde6e2 100644 --- a/frontend/components/Viewing/Modals/ShareModal.js +++ b/frontend/components/Viewing/Modals/ShareModal.js @@ -9,8 +9,8 @@ import { useSelector } from "react-redux"; import Select from "react-select"; -import getConfig from "next/config"; -import feConfig from "../../../config.json"; +import getConfig from 'next/config'; +const { publicRuntimeConfig } = getConfig(); import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; @@ -52,7 +52,7 @@ export default function ShareModal(properties) { * @param {String} owner The owner to add. */ const addOwner = async (owner) => { - const url = `${feConfig.backend}${properties.url}/addOwner`; + const url = `${publicRuntimeConfig.backend}${properties.url}/addOwner`; var headers = { Accept: "text/plain; charset=UTF-8", "X-authorization": token @@ -60,7 +60,7 @@ export default function ShareModal(properties) { const parameters = new URLSearchParams(); parameters.append("user", owner); - parameters.append("uri", feConfig.backend + properties.url); + parameters.append("uri", publicRuntimeConfig.backend + properties.url); let response; @@ -79,7 +79,7 @@ export default function ShareModal(properties) { * Copies the link to the users clipboard. */ const copyToClipboard = () => { - navigator.clipboard.writeText(`${feConfig.backend}${properties.url}`).then(() => { + navigator.clipboard.writeText(`${publicRuntimeConfig.backend}${properties.url}`).then(() => { setTimeout(() => { setCopyText("Copy"); }, 1000); @@ -139,7 +139,7 @@ export default function ShareModal(properties) { size="1x" /> - +