Skip to content

chore: move back to single audit log page #14212

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

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Filter audit org dropdown by auditable orgs
  • Loading branch information
code-asher committed Aug 9, 2024
commit 39defe59b8483d39200325acba98f44c55a6502c
41 changes: 29 additions & 12 deletions site/src/pages/AuditPage/AuditFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,36 @@ export const useOrganizationsFilterMenu = ({
return null;
},
getOptions: async () => {
const organizationsRes = await API.getOrganizations();
return organizationsRes.map<SelectFilterOption>((organization) => ({
label: organization.display_name || organization.name,
value: organization.name,
startIcon: (
<UserAvatar
key={organization.id}
size="xs"
username={organization.display_name || organization.name}
avatarURL={organization.icon}
/>
// Only show the organizations for which you can view audit logs.
const organizations = await API.getOrganizations();
const permissions = await API.checkAuthorization({
checks: Object.fromEntries(
organizations.map((organization) => [
organization.id,
{
object: {
resource_type: "audit_log",
organization_id: organization.id,
},
action: "read",
},
]),
),
}));
});
return organizations
.filter((organization) => permissions[organization.id])
.map<SelectFilterOption>((organization) => ({
label: organization.display_name || organization.name,
value: organization.name,
startIcon: (
<UserAvatar
key={organization.id}
size="xs"
username={organization.display_name || organization.name}
avatarURL={organization.icon}
/>
),
}));
},
});
};
Expand Down
Loading