Skip to content

Conversation

@SierraTran
Copy link
Contributor

Closes: #997
Closes: #998

@SierraTran SierraTran self-assigned this Dec 1, 2025
Copy link
Contributor

@ZZwatermelon ZZwatermelon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fully close #998, client/src/pages/lab_management/audit_logs/AuditLogEntity.tsx needs to be modified such that a handler for organizations is present in the getEntityUrl function

SierraTran and others added 2 commits December 4, 2025 15:07
commit suggestion from ZZwatermelon. Required notes

Co-authored-by: ZZwatermelon <63483612+ZZwatermelon@users.noreply.github.com>
commit suggestion from ZZwatermelon. non-null notes

Co-authored-by: ZZwatermelon <63483612+ZZwatermelon@users.noreply.github.com>
Comment on lines 49 to 56
// If the entity is an organization, use its data to build its URL
if (entityType === "organization") {
const { data: orgData } = useQuery(GET_ORG_BY_ID, {
variables: { id: id },
});
url = `/makerspace/${makerspaceID}/currency?a=${orgData?.getOrganizationByID?.username}`;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, you should be able to make the URL the same way as all the others in getEntityUrl.

When we create the log message in the resolver, we give 3 pieces of information:

  • The ID
  • The type ("organization" in this case)
  • The displayname

It is then kept in the log message with the format {id:type:displayname}.
This component simply parses that information out of that format to construct a link and have it display with the given displayname.

It extracts that information on line 45, so there is no need to make any calls to the backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should I do if /makerspace/${makerspaceID}/currency?a=${displayname} brings up more than one organization?

Screenshot 2025-12-05 162132

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine, it is okay to assume that even if it does not limit it to one, it will at least reduce the options to the point that the user will be able to determine for themselves what account they are looking for.

That being said the ?a={} should take an ID in ?a={id} which should limit it to one. getEntityUrl shouldn't have the orgUsername parameter added to the function.

I will make another comment about it, I thought the OrganizationsRepo search function already did that but I checked and it does not. It should be done in a way similar to the CurrencyAccountsRepo does it.

Comment on lines +3 to +17
export const GET_ORG_BY_ID = gql`
query GetOrganizationByID($id: ID!) {
getOrganizationByID(id: $id) {
id
username
notes
displayname
accountID
account {
id
balance
}
}
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though you shouldn't need this to construct the audit log entity, this is fine to leave in case someone needs to use it for something in the future.

Also good job separating out the queries into their own file!


return await knex("Organizations").select("*").limit(limit)
.whereILike("displayname", `%${searchText}%`)
.orWhereILike("username", `%${searchText}%`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.orWhereILike("username", `%${searchText}%`)
.orWhere("id", Number.isNaN(Number(searchtext)) ? -1 : searchText);

What I meant by it should handle passing in the id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put just this line in before the other conditions, and I got a currency account (that belonged to a user) whose ID matched the search text. For example, the launchinitiative org has its ID in the Organizations table as 2. With ?a=2, I get an account whose ID in the CurrencyAccounts table (and therefore Account ID) is 2.

image image

Should I be trying to get the organization's accountID instead? Or is there another way to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just noticed this.

In getEntityUrl it currently constructs the organization URL like this:
return `/makerspace/${makerspaceID}/currency?a=${orgUsername}`;
the /currency is going to the currency/accounts page when we want to go the organizations page, which would look like this:
return `/makerspace/${makerspaceID}/organizations?q=${orgID}`;
This causes another problem because you will probably get a lot of results. I think an easy way around that is where if the search query is a number return only results where the orgID is that number, while if it is NaN, do the search it is currently doing now.

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll try implementing this.

Copy link
Contributor

@ZZwatermelon ZZwatermelon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks good 👍

}

function getEntityUrl(entityType: string, id: string, makerspaceID: string) {
function getEntityUrl(entityType: string, id: string, makerspaceID: string, orgUsername?: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need orgUsername anymore

Removed optional parameter 'orgUsername' from getEntityUrl function.
@SierraTran SierraTran merged commit c242409 into main Dec 11, 2025
2 checks passed
@SierraTran SierraTran deleted the SierraTran/organization-notes-and-logs branch December 11, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Organization creation is not logged properly Organizational Notes

3 participants