Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed issue with whitespace in render, removed processurlreverse an… #670

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions frontend/components/Admin/Registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,4 @@ export async function processUrl(inputUrl, registries) {
}
}
return { original: inputUrl };
}

export async function processUrlReverse(inputUrl, registries) {
for (const registry of registries) {
if (inputUrl.startsWith(registry.url)) {
const uriRemovedForLink = inputUrl.replace(registry.url, "");
const uriReplacedForBackend = inputUrl.replace(registry.url, registry.uri);
return { uriRemovedForLink, uriReplacedForBackend };
}
}
return { original: inputUrl };
}
12 changes: 3 additions & 9 deletions frontend/components/Viewing/Collection/Members.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { shortName } from '../../../namespace/namespace';
import lookupRole from '../../../namespace/lookupRole';
import Link from 'next/link';
import { addError, logoutUser } from '../../../redux/actions';
import { processUrl, processUrlReverse } from '../../Admin/Registries';
import { processUrl } from '../../Admin/Registries';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTrash, faUnlink } from '@fortawesome/free-solid-svg-icons';
import { getAfterThirdSlash } from '../ViewHeader';
Expand All @@ -40,7 +40,6 @@ const sortOptions = [
];

export default function Members(properties) {
console.log(properties);
const token = useSelector(state => state.user.token);
const privateGraph = useSelector(state => state.user.graphUri);
const [search, setSearch] = useState('');
Expand All @@ -53,7 +52,6 @@ export default function Members(properties) {
const [processedUri, setProcessedUri] = useState(publicRuntimeConfig.backend);
const theme = JSON.parse(localStorage.getItem('theme')) || {};
const registries = JSON.parse(localStorage.getItem("registries")) || {};
console.log("processedUri is ", processedUri);

let preparedSearch =
search !== ''
Expand Down Expand Up @@ -152,16 +150,14 @@ export default function Members(properties) {
useEffect(() => {
let isMounted = true;
async function processUri() {
const result = await processUrlReverse(publicRuntimeConfig.backend, registries);
console.log("result of process url reverse is ", result);
if (isMounted) {
setProcessedUri(result.uriReplacedForBackend);
setProcessedUri(theme.uriPrefix);
}
}

processUri();
return () => { isMounted = false };
}, [token, dispatch]);
}, [dispatch]);

return (
<React.Fragment>
Expand Down Expand Up @@ -369,8 +365,6 @@ function MemberTable(properties) {
};

const handleUnlink = async (member, processedUri) => {
console.log(processedUri, member.uri);
console.log(objectUri);
if (member.uri && window.confirm("Would you like to unlink this item from the collection?")) {
try {
await axios.post(`${objectUri}/removeMembership`, {
Expand Down
85 changes: 42 additions & 43 deletions frontend/components/Viewing/MetadataInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri,
</>
)
}

</>
)}
</div>
Expand Down Expand Up @@ -344,57 +343,57 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri,
return (
<tr key={index}>
<td>
{isEditingThisItem ? (
// Edit mode
<div>
<input
type="text"
value={currentValue}
onChange={(e) => handleEditMetadata(index, e.target.value, label)}
/>
<button className={styles.button} onClick={() => handleSaveEditMetadata(index, data, label)}
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
>Save</button>
<button className={styles.button} onClick={() => handleCancelEdit(label)}
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
>Cancel</button>
</div>
) : (
// Display mode
<a
href={correspondingLink ? correspondingLink : `http://localhost:3333/${processedSource}`}
target="_blank"
rel="noopener noreferrer"
>
{processedSource}
</a>
)}

</td>
{(label === "Source" || label === "Type" || label === "Role") && data && (
<td>
{isEditingThisItem ? null : (
{isEditingThisItem ? (
<div>
<input
type="text"
value={currentValue}
onChange={(e) => handleEditMetadata(index, e.target.value, label)}
/>
<button className={styles.button} onClick={() => handleSaveEditMetadata(index, data, label)}
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
>
Save
</button>
<button className={styles.button} onClick={() => handleCancelEdit(label)}
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
>
Cancel
</button>
</div>
) : (
<a
href={correspondingLink ? correspondingLink : `http://localhost:3333/${processedSource}`}
target="_blank"
rel="noopener noreferrer"
>
{processedSource}
</a>
)}
</td><td>
{(label === "Source" || label === "Type" || label === "Role") && data && (
isEditingThisItem ? null : (
<div>
{isOwner && (
<>
<button onClick={() => handleEditMetadata(index, data, label)}>
<FontAwesomeIcon icon={faPencilAlt} title="Edit metadata" style={{ cursor: 'pointer' }} />
</button>
<button onClick={(e) => handleDeleteMetadata(e, data, label)}>
<FontAwesomeIcon icon={faTrash} title="Delete metadata" style={{ cursor: 'pointer' }} />
<FontAwesomeIcon icon={faTrash} title="Delete metadata" style={{ cursor: 'pointer' }} />
</button>
</>
)}
</div>
)}
</td>
)}
)
)}
</td>
</tr>
);
})}
Expand Down Expand Up @@ -440,7 +439,7 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri,
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
}}
>Save</button>
<button className={styles.button} type="button" onClick={() => {
setIsEditing(false);
Expand All @@ -449,7 +448,7 @@ export default function MetadataInfo({ title, link, label, icon, specific, uri,
style={{
backgroundColor: theme?.themeParameters?.[0]?.value || '#333', // Use theme color or default to #333
color: theme?.themeParameters?.[1]?.value || '#fff', // Use text color from theme or default to #fff
}}
}}
>Cancel</button>
</div>
) : null}
Expand Down
Loading