diff --git a/frontend/components/Viewing/Collection/Members.js b/frontend/components/Viewing/Collection/Members.js index ca058796..b111edc8 100644 --- a/frontend/components/Viewing/Collection/Members.js +++ b/frontend/components/Viewing/Collection/Members.js @@ -72,7 +72,7 @@ export default function Members(properties) { } const parameters = { - graphs: '', + from: '', graphPrefix: 'https://synbiohub.org/', // TODO: Maybe get this from somewhere? collection: properties.uri, sort: sort, @@ -81,10 +81,8 @@ export default function Members(properties) { limit: ' LIMIT 10000 ' }; - const { adminStatus, loading, error } = useStatus(token, dispatch); - if (token) { - parameters.graphs = privateGraph + parameters.from = "FROM <" + privateGraph + ">"; } else { } diff --git a/frontend/components/Viewing/MetadataInfo.js b/frontend/components/Viewing/MetadataInfo.js index 95f49e27..59f2f192 100644 --- a/frontend/components/Viewing/MetadataInfo.js +++ b/frontend/components/Viewing/MetadataInfo.js @@ -10,6 +10,7 @@ import axios from 'axios'; import getConfig from "next/config"; import { getAfterThirdSlash } from './ViewHeader'; +import { isUriOwner } from './Shell'; const { publicRuntimeConfig } = getConfig(); @@ -19,10 +20,18 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } const [isEditingSource, setIsEditingSource] = useState(false); const [newSource, setNewSource] = useState(''); const token = useSelector(state => state.user.token); + const username = useSelector(state => state.user.username); + + let objectUriParts = ""; + if (uri) { + objectUriParts = getAfterThirdSlash(uri); + } + const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; const [editSourceIndex, setEditSourceIndex] = useState(null); const [editedSource, setEditedSource] = useState(''); const [sources, setSources] = useState(processTitle(title)); // Assuming processTitle is your existing function + var isOwner = isUriOwner(objectUri, username); const handleEditSource = (index, source) => { @@ -44,9 +53,6 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } return; // Do not proceed with saving an empty source } - const objectUriParts = getAfterThirdSlash(uri); - const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; - axios .post( `${objectUri}/edit/wasDerivedFrom`, @@ -80,8 +86,6 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } }; const handleAddSource = () => { - const objectUriParts = getAfterThirdSlash(uri); - const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; const editedText = newSource; axios.post(`${objectUri}/add/wasDerivedFrom`, { @@ -109,8 +113,6 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } event.stopPropagation(); // Prevent event from propagating to parent elements if (window.confirm("Do you want to delete this source?")) { - const objectUriParts = getAfterThirdSlash(uri); - const objectUri = `${publicRuntimeConfig.backend}/${objectUriParts}`; // Find the index of the source to delete const indexToDelete = sources.findIndex(source => source === sourceToDelete); @@ -141,11 +143,18 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } {(label === "Source") && ( <> {/* Add space */} - setIsEditingSource(true)} - className={styles.plusIcon} - /> + { + isOwner && ( + <> + setIsEditingSource(true)} + className={styles.plusIcon} + /> + + ) + } + )} @@ -210,12 +219,18 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri } {editSourceIndex === index ? null : (
- - + { + isOwner && ( + <> + + + + ) + }
)} diff --git a/frontend/components/Viewing/ViewHeader.js b/frontend/components/Viewing/ViewHeader.js index ba6b4361..f070d594 100644 --- a/frontend/components/Viewing/ViewHeader.js +++ b/frontend/components/Viewing/ViewHeader.js @@ -143,11 +143,18 @@ export default function ViewHeader(properties) { ) : (

{displayedTitle}

- + { + isOwner && ( + <> + + + ) + } +
)} diff --git a/frontend/sparql/CountMembers.js b/frontend/sparql/CountMembers.js index 76c51329..181380f9 100644 --- a/frontend/sparql/CountMembers.js +++ b/frontend/sparql/CountMembers.js @@ -1,7 +1,7 @@ const query = `PREFIX sbol2: PREFIX dcterms: SELECT (COUNT(DISTINCT ?uri) AS ?count) -FROM <$graphs> +$from WHERE { <$collection> sbol2:member ?uri . OPTIONAL { ?uri a ?type . } diff --git a/frontend/sparql/CountMembersSearch.js b/frontend/sparql/CountMembersSearch.js index 10d75cc5..c8f3ca88 100644 --- a/frontend/sparql/CountMembersSearch.js +++ b/frontend/sparql/CountMembersSearch.js @@ -1,7 +1,7 @@ const query = `PREFIX sbol2: PREFIX dcterms: SELECT (COUNT(DISTINCT ?uri) AS ?count) -FROM <$graphs> +$from WHERE { <$collection> sbol2:member ?uri . OPTIONAL { ?uri a ?type . } diff --git a/frontend/sparql/getCollectionMembers.js b/frontend/sparql/getCollectionMembers.js index 6e3a4c95..5782b786 100644 --- a/frontend/sparql/getCollectionMembers.js +++ b/frontend/sparql/getCollectionMembers.js @@ -7,7 +7,7 @@ SELECT ?uri ?type ?sbolType ?role -FROM <$graphs> +$from WHERE { { SELECT DISTINCT ?uri ?displayId