-
Notifications
You must be signed in to change notification settings - Fork 22
Improve "Jump To" (cmd-k) dialog #3129
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
Changes from all commits
89f10cf
41e14fe
c2a8469
c6e7581
d92355a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import { | |
| ProjectAccessEditUserSideModal, | ||
| } from '~/forms/project-access' | ||
| import { getProjectSelector, useProjectSelector } from '~/hooks/use-params' | ||
| import { useQuickActions } from '~/hooks/use-quick-actions' | ||
| import { confirmDelete } from '~/stores/confirm-delete' | ||
| import { addToast } from '~/stores/toast' | ||
| import { getActionsCol } from '~/table/columns/action-col' | ||
|
|
@@ -205,6 +206,18 @@ export default function ProjectAccessPage() { | |
| getCoreRowModel: getCoreRowModel(), | ||
| }) | ||
|
|
||
| useQuickActions( | ||
| useMemo( | ||
| () => [ | ||
| { | ||
| value: 'Add user or group', | ||
| onSelect: () => setAddModalOpen(true), | ||
| }, | ||
| ], | ||
| [] | ||
| ) | ||
| ) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh and it's janky if you click the background because that only affects the form, so you close the form but not the ctrl-k popup. Out of scope for this PR, just noting it. |
||
| return ( | ||
| <> | ||
| <PageHeader> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,10 @@ | |
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import { useQuery } from '@tanstack/react-query' | ||
| import { createColumnHelper } from '@tanstack/react-table' | ||
| import { useCallback, useMemo } from 'react' | ||
| import { Outlet, type LoaderFunctionArgs } from 'react-router' | ||
| import { Outlet, useNavigate, type LoaderFunctionArgs } from 'react-router' | ||
|
|
||
| import { | ||
| api, | ||
|
|
@@ -26,6 +27,7 @@ import { HL } from '~/components/HL' | |
| import { DiskStateBadge, DiskTypeBadge, ReadOnlyBadge } from '~/components/StateBadge' | ||
| import { makeCrumb } from '~/hooks/use-crumbs' | ||
| import { getProjectSelector, useProjectSelector } from '~/hooks/use-params' | ||
| import { useQuickActions } from '~/hooks/use-quick-actions' | ||
| import { confirmDelete } from '~/stores/confirm-delete' | ||
| import { addToast } from '~/stores/toast' | ||
| import { InstanceLinkCell } from '~/table/cells/InstanceLinkCell' | ||
|
|
@@ -37,6 +39,7 @@ import { CreateLink } from '~/ui/lib/CreateButton' | |
| import { EmptyMessage } from '~/ui/lib/EmptyMessage' | ||
| import { PageHeader, PageTitle } from '~/ui/lib/PageHeader' | ||
| import { TableActions } from '~/ui/lib/Table' | ||
| import { ALL_ISH } from '~/util/consts' | ||
| import { docLinks } from '~/util/links' | ||
| import { pb } from '~/util/path-builder' | ||
| import type * as PP from '~/util/path-params' | ||
|
|
@@ -186,6 +189,27 @@ export default function DisksPage() { | |
| emptyState: <EmptyState />, | ||
| }) | ||
|
|
||
| const navigate = useNavigate() | ||
| const { data: allDisks } = useQuery( | ||
| q(api.diskList, { query: { project, limit: ALL_ISH } }) | ||
| ) | ||
| useQuickActions( | ||
| useMemo( | ||
| () => [ | ||
| { | ||
| value: 'New disk', | ||
| onSelect: () => navigate(pb.disksNew({ project })), | ||
| }, | ||
| ...(allDisks?.items || []).map((d) => ({ | ||
| value: d.name, | ||
| onSelect: () => navigate(pb.disk({ project, disk: d.name })), | ||
| navGroup: 'Go to disk', | ||
| })), | ||
| ], | ||
| [navigate, project, allDisks] | ||
| ) | ||
| ) | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested the menu with 1000 disks at http://localhost:4000/projects/other-project/disks and filtering and scrolling were instantaneous. My computer is fast, but I think the menu is also just fast. It's just a big |
||
| return ( | ||
| <> | ||
| <PageHeader> | ||
|
|
@@ -198,7 +222,7 @@ export default function DisksPage() { | |
| /> | ||
| </PageHeader> | ||
| <TableActions> | ||
| <CreateLink to={pb.disksNew({ project })}>New Disk</CreateLink> | ||
| <CreateLink to={pb.disksNew({ project })}>New disk</CreateLink> | ||
| </TableActions> | ||
| {table} | ||
| <Outlet /> | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did these out of perfectionism, but it doesn't matter in practice because the button text get all caps from CSS anyway.