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

added null checks for compare strings, fixed issue with filters not w… #672

Merged
merged 1 commit into from
Jun 5, 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
9 changes: 8 additions & 1 deletion frontend/components/Admin/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,14 @@ const options = [
];

const compareStrings = (string1, string2) => {
return (string1.toLowerCase() > string2.toLowerCase() && 1) || -1;
if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
if (!string1) return -1; // Only string1 is undefined or null, string1 is less
if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const lowerString1 = string1.toLowerCase();
const lowerString2 = string2.toLowerCase();

return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
};

const sortMethods = {
Expand Down
9 changes: 8 additions & 1 deletion frontend/components/Admin/Registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,14 @@ const options = [
];

const compareStrings = (string1, string2) => {
return (string1.toLowerCase() > string2.toLowerCase() && 1) || -1;
if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
if (!string1) return -1; // Only string1 is undefined or null, string1 is less
if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const lowerString1 = string1.toLowerCase();
const lowerString2 = string2.toLowerCase();

return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
};

const sortMethods = {
Expand Down
21 changes: 14 additions & 7 deletions frontend/components/Admin/Remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,21 @@ function Dropdown() {
}


const compareStrings = (string1, string2) => {
return (string1?.toLowerCase() > string2?.toLowerCase() && 1) || -1;
};
// const compareStrings = (string1, string2) => {
// if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
// if (!string1) return -1; // Only string1 is undefined or null, string1 is less
// if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const sortMethods = {
uri: (registry1, registry2) => compareStrings(registry1.uri, registry2.uri),
url: (registry1, registry2) => compareStrings(registry1.url, registry2.url)
};
// const lowerString1 = string1.toLowerCase();
// const lowerString2 = string2.toLowerCase();

// return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
// };

// const sortMethods = {
// uri: (registry1, registry2) => compareStrings(registry1.uri, registry2.uri),
// url: (registry1, registry2) => compareStrings(registry1.url, registry2.url)
// };

const useRegistries = (token, dispatch) => {
const { data, error } = useSWR(
Expand Down
9 changes: 8 additions & 1 deletion frontend/components/Admin/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,14 @@ const options = [
];

const compareStrings = (string1, string2) => {
return (string1.toLowerCase() > string2.toLowerCase() && 1) || -1;
if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
if (!string1) return -1; // Only string1 is undefined or null, string1 is less
if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const lowerString1 = string1.toLowerCase();
const lowerString2 = string2.toLowerCase();

return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
};

const compareBools = (bool1, bool2) => {
Expand Down
9 changes: 8 additions & 1 deletion frontend/components/Basket/Basket.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,14 @@ const options = [
];

const compareStrings = (string1, string2) => {
return (string1.toLowerCase() > string2.toLowerCase() && 1) || -1;
if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
if (!string1) return -1; // Only string1 is undefined or null, string1 is less
if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const lowerString1 = string1.toLowerCase();
const lowerString2 = string2.toLowerCase();

return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
};

const sortMethods = {
Expand Down
8 changes: 6 additions & 2 deletions frontend/components/Viewing/Collection/Members.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ export default function Members(properties) {
} else {
}

const searchQuery = preparedSearch || typeFilter !== 'Show Only Root Objects';
const searchQuery = typeFilter !== 'Show Only Root Objects';

let query = searchQuery ? getCollectionMembersSearch : getCollectionMembers;
let query = getCollectionMembers;

if (typeFilter === 'Show All Objects') {
query = getCollectionMembersSearch;
}

const { members, mutate } = privateGraph
? useMembers(query, parameters, token, dispatch)
Expand Down
9 changes: 8 additions & 1 deletion frontend/pages/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ const options = [
];

const compareStrings = (string1, string2) => {
return (string1.toLowerCase() > string2.toLowerCase() && 1) || -1;
if (!string1 && !string2) return 0; // Both strings are undefined or null, they are equal
if (!string1) return -1; // Only string1 is undefined or null, string1 is less
if (!string2) return 1; // Only string2 is undefined or null, string1 is greater

const lowerString1 = string1.toLowerCase();
const lowerString2 = string2.toLowerCase();

return (lowerString1 > lowerString2 && 1) || (lowerString1 < lowerString2 && -1) || 0;
};

const sortMethods = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/commitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
666013bbfabf3b5ea9144e3288d10ee391901bab
ee02edf1d93748a2bab27328c0a80bf7e9e82515
2 changes: 1 addition & 1 deletion frontend/sparql/getCollectionMembersSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SELECT ?uri
?type
?sbolType
?role

$from
WHERE { {
SELECT DISTINCT ?uri
?displayId
Expand Down
Loading