Skip to content

Commit

Permalink
Merge pull request #672 from SynBioHub/displaymembersbug
Browse files Browse the repository at this point in the history
added null checks for compare strings, fixed issue with filters not w…
  • Loading branch information
bigautam authored Jun 5, 2024
2 parents ee02edf + 38f5a7a commit 0d00eb6
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 16 deletions.
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

0 comments on commit 0d00eb6

Please sign in to comment.