diff --git a/.gitignore b/.gitignore index 1f5dc80a..a5505419 100644 --- a/.gitignore +++ b/.gitignore @@ -132,8 +132,6 @@ hs_err_pid* # End of https://www.toptal.com/developers/gitignore/api/java,intellij -config.json - .DS_Store frontend/package-lock.json diff --git a/frontend/CommitHash.js b/frontend/CommitHash.js deleted file mode 100644 index 22713eb1..00000000 --- a/frontend/CommitHash.js +++ /dev/null @@ -1,8 +0,0 @@ -const { execSync } = require('child_process'); -const fs = require('fs'); -const path = require('path'); - -const commitHash = execSync('git rev-parse HEAD').toString().trim(); -const outputPath = path.join(__dirname, 'public', 'commitHash.txt'); - -fs.writeFileSync(outputPath, commitHash); \ No newline at end of file diff --git a/frontend/components/Admin/Explorer.js b/frontend/components/Admin/Explorer.js index aeaa0995..d73fdc68 100644 --- a/frontend/components/Admin/Explorer.js +++ b/frontend/components/Admin/Explorer.js @@ -1,11 +1,10 @@ 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'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; export default function Explorer() { const token = useSelector(state => state.user.token); @@ -39,7 +38,7 @@ export default function Explorer() { //Update SBOLExplorer Index const handleUpdateIndex = async () => { const params = new URLSearchParams(); - const url = `${publicRuntimeConfig.backend}/admin/explorerUpdateIndex`; + const url = `${feConfig.backend}/admin/explorerUpdateIndex`; const response = await axios .post(url, params, { headers: { @@ -56,7 +55,7 @@ export default function Explorer() { //View SBOLExplorer Log const handleDownloadGeneralLog = async () => { - const url = `${publicRuntimeConfig.backend}/admin/explorerlog`; + const url = `${feConfig.backend}/admin/explorerlog`; const res = await axios .get(url, { headers: { @@ -84,7 +83,7 @@ export default function Explorer() { //admin/explorerIndexingLog const handleDownloadIndexLog = async () => { - const url = `${publicRuntimeConfig.backend}/admin/explorerIndexingLog`; + const url = `${feConfig.backend}/admin/explorerIndexingLog`; const res = await axios .get(url, { headers: { @@ -137,7 +136,7 @@ export default function Explorer() { 'whichSearch': USchecked ? 'usearch' : 'vsearch' }; - const url = `${publicRuntimeConfig.backend}/admin/explorer`; + const url = `${feConfig.backend}/admin/explorer`; let res = await axios .post(url, params, { headers: { @@ -406,7 +405,7 @@ export default function Explorer() { // if SBOLExplorer is on const useConfig = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/explorer`, token, dispatch], + [`${feConfig.backend}/admin/explorer`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Graphs.js b/frontend/components/Admin/Graphs.js index 4270a6c7..d8af5107 100644 --- a/frontend/components/Admin/Graphs.js +++ b/frontend/components/Admin/Graphs.js @@ -1,8 +1,7 @@ import axios from 'axios'; -import getConfig from 'next/config'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; import Table from '../Reusable/Table/Table'; import { addError } from '../../redux/actions'; @@ -49,7 +48,7 @@ const sortMethods = { const useGraphs = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/graphs`, token, dispatch], + [`${feConfig.backend}/admin/graphs`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Log.js b/frontend/components/Admin/Log.js index 75754b56..40df6a27 100644 --- a/frontend/components/Admin/Log.js +++ b/frontend/components/Admin/Log.js @@ -1,10 +1,9 @@ import axios from 'axios'; import he from 'he'; -import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; import styles from '../../styles/admin.module.css'; import Loading from '../Reusable/Loading'; @@ -72,7 +71,7 @@ const decodeHtml = (line, index) => { const useLog = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/log`, token, dispatch], + [`${feConfig.backend}/admin/log`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Mail.js b/frontend/components/Admin/Mail.js index aca1931f..93226617 100644 --- a/frontend/components/Admin/Mail.js +++ b/frontend/components/Admin/Mail.js @@ -1,10 +1,9 @@ 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'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; import styles from '../../styles/admin.module.css'; import InputField from '../Login/InputField'; @@ -97,7 +96,7 @@ export default function Mail() { const useEmail = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch], + [`${feConfig.backend}/admin/mail`, token, dispatch], fetcher ); return { @@ -134,7 +133,7 @@ const updateEmail = async ( actualSendGridEmail, dispatch ) => { - const url = `${publicRuntimeConfig.backend}/admin/mail`; + const url = `${feConfig.backend}/admin/mail`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -161,6 +160,6 @@ const updateEmail = async ( setSendGridEmail(actualSendGridEmail); } else { setError(''); - mutate([`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch]); + mutate([`${feConfig.backend}/admin/mail`, token, dispatch]); } }; diff --git a/frontend/components/Admin/Plugins.js b/frontend/components/Admin/Plugins.js index c047eb90..c851ed3f 100644 --- a/frontend/components/Admin/Plugins.js +++ b/frontend/components/Admin/Plugins.js @@ -27,9 +27,8 @@ const authorizationType = 'authorization'; const searchable = ['index', 'name', 'url']; const headers = ['ID', 'Name', 'URL', '']; -import getConfig from 'next/config'; import { addError } from '../../redux/actions'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /* eslint sonarjs/no-duplicate-string: "off" */ @@ -296,7 +295,7 @@ function PluginDisplay(properties) { } const deletePlugin = async (id, type, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/admin/deletePlugin`; + const url = `${feConfig.backend}/admin/deletePlugin`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -317,12 +316,12 @@ const deletePlugin = async (id, type, token, dispatch) => { } if (response.status === 200) { - mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]); + mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]); } }; const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/admin/savePlugin`; + const url = `${feConfig.backend}/admin/savePlugin`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -345,7 +344,7 @@ const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => { } if (response.status === 200) { - mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]); + mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]); } }; @@ -376,7 +375,7 @@ const sortMethods = { const usePlugins = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch], + [`${feConfig.backend}/admin/plugins`, token, dispatch], fetcher ); return { @@ -390,7 +389,7 @@ const usePlugins = (token, dispatch) => { async function fetchStatus(plugin, type) { return await axios({ method: 'POST', - url: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.backend}/call`, params: { name: plugin.name, endpoint: 'status', diff --git a/frontend/components/Admin/Registries.js b/frontend/components/Admin/Registries.js index 0b75826b..4d03c9fe 100644 --- a/frontend/components/Admin/Registries.js +++ b/frontend/components/Admin/Registries.js @@ -6,7 +6,6 @@ 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 +15,7 @@ import Table from '../Reusable/Table/Table'; import ActionButton from './Reusable/ActionButton'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /* eslint sonarjs/cognitive-complexity: "off" */ @@ -208,11 +207,11 @@ function RegistryActions() { const token = useSelector(state => state.user.token); const dispatch = useDispatch(); - const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`; + const url = `${feConfig.backend}/admin/deleteRegistry`; const handleFederate = async () => { try { - await axios.post(`${publicRuntimeConfig.backend}/admin/federate`, { + await axios.post(`${feConfig.backend}/admin/federate`, { administratorEmail: inputTwo, webOfRegistries: inputOne }, { @@ -230,7 +229,7 @@ function RegistryActions() { const handleRetrieve = async () => { try { - const response = await axios.post(`${publicRuntimeConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, { + const response = await axios.post(`${feConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, { headers: { 'Accept': 'application/json', 'X-authorization': token @@ -240,7 +239,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([ - `${publicRuntimeConfig.backend}/admin/registries`, + `${feConfig.backend}/admin/registries`, token, dispatch ]); @@ -272,7 +271,7 @@ function RegistryActions() { } const deleteRegistry = async (uri, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`; + const url = `${feConfig.backend}/admin/deleteRegistry`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -293,7 +292,7 @@ const deleteRegistry = async (uri, token, dispatch) => { if (response.status === 200) { mutate([ - `${publicRuntimeConfig.backend}/admin/registries`, + `${feConfig.backend}/admin/registries`, token, dispatch ]); @@ -301,7 +300,7 @@ const deleteRegistry = async (uri, token, dispatch) => { }; const saveRegistry = async (uri, sbhUrl, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/admin/saveRegistry`; + const url = `${feConfig.backend}/admin/saveRegistry`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -323,7 +322,7 @@ const saveRegistry = async (uri, sbhUrl, token, dispatch) => { if (response.status === 200) { mutate([ - `${publicRuntimeConfig.backend}/admin/registries`, + `${feConfig.backend}/admin/registries`, token, dispatch ]); diff --git a/frontend/components/Admin/Remotes.js b/frontend/components/Admin/Remotes.js index 42442b2a..e18d41ce 100644 --- a/frontend/components/Admin/Remotes.js +++ b/frontend/components/Admin/Remotes.js @@ -6,7 +6,6 @@ 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 +15,7 @@ import Table from '../Reusable/Table/Table'; import ActionButton from './Reusable/ActionButton'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /* eslint sonarjs/cognitive-complexity: "off" */ @@ -230,7 +229,7 @@ function Dropdown() { const useRegistries = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/remotes`, token, dispatch], + [`${feConfig.backend}/admin/remotes`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Sparql.js b/frontend/components/Admin/Sparql.js index 90cad659..02fa93ed 100644 --- a/frontend/components/Admin/Sparql.js +++ b/frontend/components/Admin/Sparql.js @@ -1,6 +1,5 @@ import { faDatabase } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import getConfig from 'next/config'; import dynamic from 'next/dynamic'; import { useState } from 'react'; import { useSelector } from 'react-redux'; @@ -8,7 +7,7 @@ import Select from 'react-select'; import styles from '../../styles/sparql.module.css'; import Table from '../Reusable/Table/Table'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; const CodeMirror = dynamic( () => { @@ -121,7 +120,7 @@ const submitQuery = async ( setError(); setLoading(true); const url = `${ - publicRuntimeConfig.backend + feConfig.backend }/admin/sparql?query=${encodeURIComponent(query)}`; const headers = { diff --git a/frontend/components/Admin/Status.js b/frontend/components/Admin/Status.js index f10aef93..4e7927d6 100644 --- a/frontend/components/Admin/Status.js +++ b/frontend/components/Admin/Status.js @@ -1,9 +1,8 @@ import axios from 'axios'; -import getConfig from 'next/config'; import Loader from 'react-loader-spinner'; import { useDispatch, useSelector } from 'react-redux'; import useSWR from 'swr'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; import styles from '../../styles/defaulttable.module.css'; import { addError } from '../../redux/actions'; @@ -94,7 +93,7 @@ export default function Status() { export const useStatus = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin`, token, dispatch], + [`${feConfig.backend}/admin`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Admin/Theme.js b/frontend/components/Admin/Theme.js index 78c38457..46a84c24 100644 --- a/frontend/components/Admin/Theme.js +++ b/frontend/components/Admin/Theme.js @@ -1,5 +1,4 @@ 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'; @@ -8,7 +7,7 @@ import { useState, useEffect } from 'react'; import Loader from 'react-loader-spinner'; import { isValidURI } from '../Viewing/Shell'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; export default function Theme() { const dispatch = useDispatch(); @@ -62,16 +61,16 @@ export default function Theme() { }; const handleSave = async () => { - const url = `${publicRuntimeConfig.backend}/admin/theme`; + const url = `${feConfig.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 fd0c424d..fcbf3b5c 100644 --- a/frontend/components/Admin/Users.js +++ b/frontend/components/Admin/Users.js @@ -6,7 +6,6 @@ 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'; @@ -17,7 +16,7 @@ import ActionButton from './Reusable/ActionButton'; import Checkbox from './Reusable/CheckBox'; import TableInput from './Reusable/TableInput'; import { addError } from '../../redux/actions'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /* eslint sonarjs/cognitive-complexity: "off" */ @@ -53,7 +52,7 @@ export default function Users() { const handleAllowPublicSignup = async () => { try { - const url = `${publicRuntimeConfig.backend}/admin/users`; + const url = `${feConfig.backend}/admin/users`; const headers = { Accept: 'text/plain', 'X-authorization': token, @@ -350,7 +349,7 @@ function UserDisplay(properties) { } const deleteUser = async (id, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/admin/deleteUser`; + const url = `${feConfig.backend}/admin/deleteUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -370,7 +369,7 @@ const deleteUser = async (id, token, dispatch) => { } if (response && response.status === 200) { - mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); + mutate([`${feConfig.backend}/admin/users`, token, dispatch]); } }; @@ -385,7 +384,7 @@ const saveUser = async ( token, dispatch ) => { - const url = `${publicRuntimeConfig.backend}/admin/updateUser`; + const url = `${feConfig.backend}/admin/updateUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -411,7 +410,7 @@ const saveUser = async ( } if (response.status === 200) { - mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); + mutate([`${feConfig.backend}/admin/users`, token, dispatch]); } }; @@ -426,7 +425,7 @@ const createUser = async ( token, dispatch ) => { - const url = `${publicRuntimeConfig.backend}/admin/newUser`; + const url = `${feConfig.backend}/admin/newUser`; const headers = { Accept: 'text/plain', 'X-authorization': token @@ -454,7 +453,7 @@ const createUser = async ( // const responseText = await response.data; if (response && response.status === 200) { - mutate([`${publicRuntimeConfig.backend}/admin/users`, token, dispatch]); + mutate([`${feConfig.backend}/admin/users`, token, dispatch]); } }; @@ -501,7 +500,7 @@ const sortMethods = { const useUsers = (token, dispatch) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/admin/users`, token, dispatch], + [`${feConfig.backend}/admin/users`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Basket/Basket.js b/frontend/components/Basket/Basket.js index 33c69a7a..baff55dc 100644 --- a/frontend/components/Basket/Basket.js +++ b/frontend/components/Basket/Basket.js @@ -20,8 +20,7 @@ import CreateCollection from './CreateCollection'; const searchable = ['name', 'displayId', 'type', 'description']; -import getConfig from 'next/config'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /** * This component represents the basket in the search page. It stores the uri/name/displayId of @@ -203,7 +202,7 @@ const downloadCheckedItems = (items, selected, setSelected, dispatch) => { setSelected, function (item) { return { - url: `${publicRuntimeConfig.backend}${item.url}/sbol`, + url: `${feConfig.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 8975eb60..70066664 100644 --- a/frontend/components/Basket/BasketItem.js +++ b/frontend/components/Basket/BasketItem.js @@ -1,8 +1,7 @@ -import getConfig from 'next/config'; import { useRouter } from 'next/router'; import styles from '../../styles/submissions.module.css'; -const { publicRuntimeConfig } = getConfig(); +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 26d60702..67407761 100644 --- a/frontend/components/Navbar/Navbar.js +++ b/frontend/components/Navbar/Navbar.js @@ -2,7 +2,8 @@ import { faAlignLeft, faCloudUploadAlt, faSearch, - faSignInAlt + faSignInAlt, + faHome } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Image from 'next/image'; @@ -13,8 +14,7 @@ import { useSelector } from 'react-redux'; import styles from '../../styles/navbar.module.css'; import Profile from './Profile'; import Selector from './Selector'; -import getConfig from 'next/config'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; /** * 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 = `${publicRuntimeConfig.backend}/logo`; + const urlLogo = `${feConfig.backend}/logo`; setLogoUrl(urlLogo); } else { setLogoUrl(defaultLogo); } - }, [publicRuntimeConfig.backend]); + }, [feConfig.backend]); return (
+ )} diff --git a/frontend/components/Reusable/SelectorButton.js b/frontend/components/Reusable/SelectorButton.js index ea2eee9f..52b4d482 100644 --- a/frontend/components/Reusable/SelectorButton.js +++ b/frontend/components/Reusable/SelectorButton.js @@ -1,8 +1,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import getConfig from 'next/config'; import { useRouter } from 'next/router'; import { useEffect } from 'react'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; import styles from '../../styles/searchheader.module.css'; @@ -31,7 +30,7 @@ export default function SearchTypeSelector(properties) { onClick={() => { if (properties.onClick) properties.onClick(); else if (!properties.external) router.replace(`/${properties.route}`); - else router.push(`${publicRuntimeConfig.backend}/${properties.route}`); + else router.push(`${feConfig.backend}/${properties.route}`); }} > {properties.icon ? ( diff --git a/frontend/components/Search/AdvancedSearch/Options.js b/frontend/components/Search/AdvancedSearch/Options.js index 6dd92ab1..0c3751f2 100644 --- a/frontend/components/Search/AdvancedSearch/Options.js +++ b/frontend/components/Search/AdvancedSearch/Options.js @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import { faPlus, faInfoCircle } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import getConfig from 'next/config'; import { useDispatch, useSelector } from 'react-redux'; import axios from 'axios'; @@ -17,7 +16,7 @@ import AdditionalFilter from './AdditionalFilter'; import SelectLoader from './SelectLoader'; import { addError } from '../../../redux/actions'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; // tooltip component to show descriptions on hover const Tooltip = ({ text, children }) => { @@ -196,7 +195,7 @@ const loadPredicates = async (setPredicates, token, dispatch) => { // function to fetch predicates const fetchPredicates = async (token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( + const url = `${feConfig.backend}/sparql?query=${encodeURIComponent( getPredicates )}`; try { diff --git a/frontend/components/Search/AdvancedSearch/SelectLoader.js b/frontend/components/Search/AdvancedSearch/SelectLoader.js index 25705fcc..33e9669b 100644 --- a/frontend/components/Search/AdvancedSearch/SelectLoader.js +++ b/frontend/components/Search/AdvancedSearch/SelectLoader.js @@ -1,4 +1,3 @@ -import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import WindowedSelect from 'react-windowed-select'; import { createFilter } from 'react-windowed-select'; @@ -8,7 +7,7 @@ import Loading from '../../Reusable/MiniLoading'; import { useDispatch, useSelector } from 'react-redux'; import { addError } from '../../../redux/actions'; import axios from 'axios'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; const customFilter = createFilter({ ignoreAccents: false }); @@ -86,7 +85,7 @@ const fetchOptions = async ( }; const submitQuery = async (query, token, dispatch) => { - const url = `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( + const url = `${feConfig.backend}/sparql?query=${encodeURIComponent( query )}`; try { diff --git a/frontend/components/Search/NavbarSearch/NavbarSearch.js b/frontend/components/Search/NavbarSearch/NavbarSearch.js index 32f47c20..5038cdcb 100644 --- a/frontend/components/Search/NavbarSearch/NavbarSearch.js +++ b/frontend/components/Search/NavbarSearch/NavbarSearch.js @@ -6,8 +6,7 @@ import { useRouter } from 'next/router'; import { useSelector } from 'react-redux'; import { useState } from 'react'; import { useEffect } from 'react'; -import getConfig from 'next/config'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; import styles from '../../../styles/navbar.module.css'; import SearchBar from './SearchBar'; @@ -27,12 +26,12 @@ export default function NavbarSearch(properties) { useEffect(() => { if (localStorage.getItem('logo')) { - const urlLogo = `${publicRuntimeConfig.backend}/logo`; + const urlLogo = `${feConfig.backend}/logo`; setLogoUrl(urlLogo); } else { setLogoUrl(defaultLogo); } - }, [publicRuntimeConfig.backend]); + }, [feConfig.backend]); return (
{ return { - url: `${publicRuntimeConfig.backend}${item.url}/sbol`, + url: `${feConfig.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 b6d05bd5..e239435e 100644 --- a/frontend/components/Search/StandardSearch/StandardSearch.js +++ b/frontend/components/Search/StandardSearch/StandardSearch.js @@ -1,5 +1,4 @@ import axios from 'axios'; -import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import Loader from 'react-loader-spinner'; import { useDispatch, useSelector } from 'react-redux'; @@ -8,7 +7,7 @@ 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'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; import SearchHeader from '../SearchHeader/SearchHeader'; import { processUrl } from '../../Admin/Registries'; @@ -278,7 +277,7 @@ const useSearchResults = (query, url, offset, limit, token, dispatch) => { query = url + query; const { data, error } = useSWR( [ - `${publicRuntimeConfig.backend}/search/${query}?offset=${offset}&limit=${limit}`, + `${feConfig.backend}/search/${query}?offset=${offset}&limit=${limit}`, token, dispatch ], @@ -294,7 +293,7 @@ const useSearchResults = (query, url, offset, limit, token, dispatch) => { const useSearchCount = (query, url, token, dispatch) => { query = url + query; const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/searchCount/${query}`, token, dispatch], + [`${feConfig.backend}/searchCount/${query}`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Submission/PublishModal.js b/frontend/components/Submission/PublishModal.js index d45d7705..4a0f1378 100644 --- a/frontend/components/Submission/PublishModal.js +++ b/frontend/components/Submission/PublishModal.js @@ -5,7 +5,6 @@ import { } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import axios from 'axios'; -import getConfig from 'next/config'; import { useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; import { useSelector } from 'react-redux'; @@ -17,7 +16,7 @@ import SelectorButton from '../Reusable/SelectorButton'; import Table from '../Reusable/Table/Table'; import PublishCollectionButton from './PublishCollectionButton'; import NewCollectionForm from './PublishNewCollectionForm'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; const EXISTING = 'to Existing'; const NEW = 'as New'; @@ -215,7 +214,7 @@ const sortMethods = { const useRootCollections = (dispatch, token) => { const { data, error } = useSWR( - [`${publicRuntimeConfig.backend}/rootCollections`, token, dispatch], + [`${feConfig.backend}/rootCollections`, token, dispatch], fetcher ); return { diff --git a/frontend/components/Submission/TableButtons.js b/frontend/components/Submission/TableButtons.js index 53e5dad4..11b63cc1 100644 --- a/frontend/components/Submission/TableButtons.js +++ b/frontend/components/Submission/TableButtons.js @@ -5,7 +5,6 @@ import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'; import axios from 'axios'; -import getConfig from 'next/config'; import React from 'react'; import { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; @@ -15,7 +14,7 @@ import { addError, addToBasket, downloadFiles } from '../../redux/actions'; import styles from '../../styles/submissions.module.css'; import TableButton from '../Reusable/TableButton'; import PublishModal from './PublishModal'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; export default function TableButtons(properties) { const dispatch = useDispatch(); @@ -44,7 +43,7 @@ export default function TableButtons(properties) { properties.setSelected, function (submission) { return { - url: `${publicRuntimeConfig.backend}${submission.url}/sbol`, + url: `${feConfig.backend}${submission.url}/sbol`, name: submission.name, displayId: submission.displayId, type: 'xml', @@ -63,7 +62,7 @@ export default function TableButtons(properties) { properties.setSelected, function (submission) { return { - url: `${publicRuntimeConfig.backend}${submission.url}/removeCollection`, + url: `${feConfig.backend}${submission.url}/removeCollection`, name: submission.name, privacy: submission.privacy }; @@ -172,8 +171,8 @@ const removeCollections = ( Promise.all(removeCollectionPromises) .then(() => { setProcessUnderway(false); - mutate([`${publicRuntimeConfig.backend}/shared`, token, dispatch]); - mutate([`${publicRuntimeConfig.backend}/manage`, token, dispatch]); + mutate([`${feConfig.backend}/shared`, token, dispatch]); + mutate([`${feConfig.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 eadfdd85..408c8088 100644 --- a/frontend/components/Submit/ReusableComponents/InputField.js +++ b/frontend/components/Submit/ReusableComponents/InputField.js @@ -24,9 +24,11 @@ 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 6d536268..699d89e0 100644 --- a/frontend/components/Submit/ReusableComponents/SubmissionHandler.js +++ b/frontend/components/Submit/ReusableComponents/SubmissionHandler.js @@ -2,7 +2,7 @@ import styles from '../../../styles/submit.module.css' import Select from "react-select"; import axios from 'axios'; import getConfig from "next/config"; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; export default function SubmissionHandler(properties) { @@ -17,7 +17,7 @@ export default function SubmissionHandler(properties) { axios({ method: 'GET', - url: `${publicRuntimeConfig.backend}/admin/plugins`, + url: `${feConfig.backend}/admin/plugins`, params: { category: 'submit' }, @@ -30,7 +30,7 @@ export default function SubmissionHandler(properties) { for(let plugin of submitPlugins) { axios({ method: 'POST', - url: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.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 f174a5b9..b15e4d85 100644 --- a/frontend/components/Submit/ReusableComponents/SubmitLabel.js +++ b/frontend/components/Submit/ReusableComponents/SubmitLabel.js @@ -4,31 +4,32 @@ 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 3d73dfc9..b49361a4 100644 --- a/frontend/components/TopLevel.js +++ b/frontend/components/TopLevel.js @@ -8,10 +8,9 @@ import Footer from './Footer'; import Navbar from './Navbar/Navbar'; import DownloadStatus from './Reusable/Download/DownloadStatus'; import Errors from './Error/Errors'; -import getConfig from 'next/config'; import axios from 'axios'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../config.json"; /* eslint sonarjs/cognitive-complexity: "off" */ @@ -39,13 +38,13 @@ export default function TopLevel(properties) { if (!registriesData || !themeData) { const [registriesResponse, themeResponse] = await Promise.all([ - axios.get(`${publicRuntimeConfig.backend}/admin/registries`, { + axios.get(`${feConfig.backend}/admin/registries`, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, }), - axios.get(`${publicRuntimeConfig.backend}/admin/theme`, { + axios.get(`${feConfig.backend}/admin/theme`, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', @@ -95,7 +94,7 @@ export default function TopLevel(properties) { return (
- SynBioHub + {theme.instanceName} | SynBioHub diff --git a/frontend/components/Viewing/Collection/Members.js b/frontend/components/Viewing/Collection/Members.js index 6e0ba753..f6bcf0d6 100644 --- a/frontend/components/Viewing/Collection/Members.js +++ b/frontend/components/Viewing/Collection/Members.js @@ -4,8 +4,7 @@ import useSWR from 'swr'; import axios from 'axios'; import Select from 'react-select'; -import getConfig from 'next/config'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; import CountMembers from '../../../sparql/CountMembers'; import CountMembersTotal from '../../../sparql/CountMembersSearch'; @@ -49,7 +48,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(publicRuntimeConfig.backend); + const [processedUri, setProcessedUri] = useState(feConfig.backend); const theme = JSON.parse(localStorage.getItem('theme')) || {}; const registries = JSON.parse(localStorage.getItem("registries")) || {}; @@ -335,7 +334,7 @@ function MemberTable(properties) { } const objectUriParts = getAfterThirdSlash(properties.uri); - const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; + const objectUri = `${feConfig.backend}/${objectUriParts}`; const icon = compareUri(member.uri, `/${objectUriParts}`); @@ -355,7 +354,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(`${publicRuntimeConfig.backend}${member.uri}/remove`, { + await axios.get(`${feConfig.backend}${member.uri}/remove`, { headers: { "Accept": "text/plain; charset=UTF-8", "X-authorization": token @@ -462,7 +461,7 @@ function compareUri(memberUri, baseUri) { const createUrl = (query, options) => { query = loadTemplate(query, options); - return `${publicRuntimeConfig.backend}/sparql?query=${encodeURIComponent( + return `${feConfig.backend}/sparql?query=${encodeURIComponent( query )}`; }; diff --git a/frontend/components/Viewing/MetadataInfo.js b/frontend/components/Viewing/MetadataInfo.js index 3ad084dd..5804e152 100644 --- a/frontend/components/Viewing/MetadataInfo.js +++ b/frontend/components/Viewing/MetadataInfo.js @@ -11,7 +11,7 @@ import getConfig from "next/config"; import { getAfterThirdSlash } from './ViewHeader'; import { isUriOwner, formatMultipleTitles } from './Shell'; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../config.json"; export default function MetadataInfo({ title, link, label, icon, specific, uri }) { const theme = JSON.parse(localStorage.getItem('theme')) || {}; @@ -52,7 +52,7 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } if (uri) { objectUriParts = getAfterThirdSlash(uri); } - const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; + const objectUri = `${feConfig.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 42cbcd7c..fcf93432 100644 --- a/frontend/components/Viewing/Modals/AddToCollectionModal.js +++ b/frontend/components/Viewing/Modals/AddToCollectionModal.js @@ -11,7 +11,7 @@ import { getCanSubmitTo } from '../../../redux/actions'; import { useSelector, useDispatch } from "react-redux"; import getConfig from "next/config"; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; 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 = `${publicRuntimeConfig.backend}${properties.url}/addToCollection`; + const url = `${feConfig.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 eada7022..890af857 100644 --- a/frontend/components/Viewing/Modals/CurationModal.js +++ b/frontend/components/Viewing/Modals/CurationModal.js @@ -8,7 +8,7 @@ import Select from "react-select"; import CustomModal from "./CustomModal"; import getConfig from "next/config"; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; import axios from "axios"; import parse from 'html-react-parser'; @@ -65,7 +65,7 @@ export default function CurationModal(properties) { axios({ method: 'GET', - url: `${publicRuntimeConfig.backend}/admin/plugins`, + url: `${feConfig.backend}/admin/plugins`, params: { category: 'curation' }, @@ -78,7 +78,7 @@ export default function CurationModal(properties) { for(let plugin of curatePlugins) { axios({ method: 'POST', - url: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.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: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.backend}/call`, params: { name: pluginName, endpoint: 'run', diff --git a/frontend/components/Viewing/Modals/DownloadModal.js b/frontend/components/Viewing/Modals/DownloadModal.js index 8b935161..6c35052d 100644 --- a/frontend/components/Viewing/Modals/DownloadModal.js +++ b/frontend/components/Viewing/Modals/DownloadModal.js @@ -8,7 +8,7 @@ import Select from "react-select"; import CustomModal from "./CustomModal"; import getConfig from "next/config"; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; 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: `${publicRuntimeConfig.backend}${properties.url}/${type}`, + url: `${feConfig.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: `${publicRuntimeConfig.backend}/`, + instanceUrl: `${feConfig.backend}/`, size: 1, type: properties.type }; @@ -95,7 +95,7 @@ export default function DownloadModal(properties) { axios({ method: 'GET', - url: `${publicRuntimeConfig.backend}/admin/plugins`, + url: `${feConfig.backend}/admin/plugins`, params: { category: 'download' }, @@ -128,7 +128,7 @@ export default function DownloadModal(properties) { axios({ method: 'POST', - url: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.backend}/call`, params: { name: plugin.name, endpoint: 'status', @@ -140,7 +140,7 @@ export default function DownloadModal(properties) { axios({ method: 'POST', - url: `${publicRuntimeConfig.backend}/call`, + url: `${feConfig.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 0f031841..6c072999 100644 --- a/frontend/components/Viewing/Modals/ShareModal.js +++ b/frontend/components/Viewing/Modals/ShareModal.js @@ -10,7 +10,7 @@ import { useSelector } from "react-redux"; import Select from "react-select"; import getConfig from "next/config"; -const { publicRuntimeConfig } = getConfig(); +import feConfig from "../../../config.json"; 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 = `${publicRuntimeConfig.backend}${properties.url}/addOwner`; + const url = `${feConfig.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", publicRuntimeConfig.backend + properties.url); + parameters.append("uri", feConfig.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(`${publicRuntimeConfig.backend}${properties.url}`).then(() => { + navigator.clipboard.writeText(`${feConfig.backend}${properties.url}`).then(() => { setTimeout(() => { setCopyText("Copy"); }, 1000); @@ -139,7 +139,7 @@ export default function ShareModal(properties) { size="1x" /> - +