-
Notifications
You must be signed in to change notification settings - Fork 610
fix: audit log filters use search params #2769
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 0 additions & 58 deletions
58
apps/dashboard/app/(app)/audit/[bucket]/components/filters/bucket-select.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
apps/dashboard/app/(app)/audit/components/filters/bucket-select.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| "use client"; | ||
| import { | ||
| Select, | ||
| SelectContent, | ||
| SelectItem, | ||
| SelectTrigger, | ||
| SelectValue, | ||
| } from "@/components/ui/select"; | ||
|
|
||
| import { parseAsString, useQueryState } from "nuqs"; | ||
| import type React from "react"; | ||
|
|
||
| type Props = { | ||
| buckets: { id: string; name: string }[]; | ||
| }; | ||
|
|
||
| export const BucketSelect: React.FC<Props> = ({ buckets }) => { | ||
| const [selected, setSelected] = useQueryState( | ||
| "bucket", | ||
| parseAsString.withDefault("unkey_mutations").withOptions({ | ||
| history: "push", | ||
| shallow: false, // otherwise server components won't notice the change | ||
| clearOnDefault: true, | ||
| }), | ||
| ); | ||
|
|
||
| return ( | ||
| <div> | ||
| <Select | ||
| value={selected} | ||
| onValueChange={(value) => { | ||
| setSelected(value); | ||
| }} | ||
| > | ||
| <SelectTrigger> | ||
| <SelectValue /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| {buckets.map((b) => ( | ||
| <SelectItem key={b.id} value={b.name}> | ||
| {b.name === "unkey_mutations" ? "System" : `Ratelimit: ${b.name}`} | ||
| </SelectItem> | ||
| ))} | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
| ); | ||
| }; |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,55 @@ | ||
| import { redirect } from "next/navigation"; | ||
| import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder"; | ||
| import { Navbar } from "@/components/navbar"; | ||
| import { PageContent } from "@/components/page-content"; | ||
| import { getTenantId } from "@/lib/auth"; | ||
| import { InputSearch, Ufo } from "@unkey/icons"; | ||
| import { type SearchParams, getWorkspace, parseFilterParams } from "./actions"; | ||
| import { Filters } from "./components/filters"; | ||
| import { AuditLogTableClient } from "./components/table/audit-log-table-client"; | ||
|
|
||
| export default function Page() { | ||
| return redirect("/audit/unkey_mutations"); | ||
| export const dynamic = "force-dynamic"; | ||
| export const runtime = "edge"; | ||
|
|
||
| type Props = { | ||
| searchParams: SearchParams; | ||
| }; | ||
|
|
||
| export default async function AuditPage(props: Props) { | ||
| const tenantId = getTenantId(); | ||
| const workspace = await getWorkspace(tenantId); | ||
| const parsedParams = parseFilterParams(props.searchParams); | ||
|
|
||
| return ( | ||
| <div> | ||
| <Navbar> | ||
| <Navbar.Breadcrumbs icon={<InputSearch />}> | ||
| <Navbar.Breadcrumbs.Link href="/audit">Audit</Navbar.Breadcrumbs.Link> | ||
| </Navbar.Breadcrumbs> | ||
| </Navbar> | ||
| <PageContent> | ||
| {workspace.auditLogBuckets.length > 0 ? ( | ||
| <main className="mb-5"> | ||
| <Filters | ||
| workspace={workspace} | ||
| parsedParams={parsedParams} | ||
| selectedBucketName={parsedParams.bucketName} | ||
| /> | ||
|
|
||
| <AuditLogTableClient /> | ||
| </main> | ||
| ) : ( | ||
| <EmptyPlaceholder> | ||
| <EmptyPlaceholder.Icon> | ||
| <Ufo /> | ||
| </EmptyPlaceholder.Icon> | ||
| <EmptyPlaceholder.Title>No logs</EmptyPlaceholder.Title> | ||
| <EmptyPlaceholder.Description> | ||
| There are no audit logs available yet. Create a key or another resource and come back | ||
| here. | ||
| </EmptyPlaceholder.Description> | ||
| </EmptyPlaceholder> | ||
| )} | ||
| </PageContent> | ||
| </div> | ||
| ); | ||
| } | ||
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.