Skip to content
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

Prototype: Client pagination, searching sorting and filtering #2489

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2,769 changes: 1,492 additions & 1,277 deletions app/api/__generated__/validate.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/components/DocsPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const DocsPopover = ({ heading, icon, summary, links }: DocsPopoverProps)
<PopoverPanel
// DocsPopoverPanel needed for enter animation
className="DocsPopoverPanel z-10 w-96 rounded-lg border bg-raise border-secondary elevation-1"
anchor={{ to: 'bottom end', gap: 12 }}
anchor={{ to: 'bottom end', gap: 8 }}
>
<div className="px-4">
<h2 className="mt-4 flex items-center gap-1 text-sans-md">
Expand Down
28 changes: 18 additions & 10 deletions app/components/RefetchIntervalPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import cn from 'classnames'
import { useEffect, useState } from 'react'

import { Refresh16Icon, Time16Icon } from '@oxide/design-system/icons/react'
import { Refresh16Icon } from '@oxide/design-system/icons/react'

import { Listbox, type ListboxItem } from '~/ui/lib/Listbox'
import { SpinnerLoader } from '~/ui/lib/Spinner'
Expand Down Expand Up @@ -37,9 +37,17 @@ type Props = {
enabled: boolean
isLoading: boolean
fn: () => void
className?: string
variant?: 'table' | 'metrics'
}

export function useIntervalPicker({ enabled, isLoading, fn }: Props) {
export function useIntervalPicker({
enabled,
isLoading,
fn,
className,
variant = 'metrics',
}: Props) {
const [intervalPreset, setIntervalPreset] = useState<IntervalPreset>('10s')

const [lastFetched, setLastFetched] = useState(new Date())
Expand All @@ -53,18 +61,15 @@ export function useIntervalPicker({ enabled, isLoading, fn }: Props) {
return {
intervalMs: (enabled && intervalPresets[intervalPreset]) || undefined,
intervalPicker: (
<div className="mb-12 flex items-center justify-between">
<div className="hidden items-center gap-2 text-right text-mono-sm text-quaternary lg+:flex">
<Time16Icon className="text-quinary" /> Refreshed{' '}
{toLocaleTimeString(lastFetched)}
</div>
<div className={cn('flex items-center justify-between', className)}>
<div className="flex">
<button
type="button"
className={cn(
'flex w-10 items-center justify-center rounded-l border-b border-l border-t border-default disabled:cursor-default',
'flex w-9 items-center justify-center rounded-l border-b border-l border-t border-default disabled:cursor-default',
isLoading && 'hover:bg-hover',
!enabled && 'cursor-not-allowed bg-disabled'
!enabled && 'cursor-not-allowed bg-disabled',
variant === 'table' && 'h-8'
)}
onClick={fn}
disabled={isLoading || !enabled}
Expand All @@ -75,12 +80,15 @@ export function useIntervalPicker({ enabled, isLoading, fn }: Props) {
</button>
<Listbox
selected={enabled ? intervalPreset : 'Off'}
className="w-24 [&>button]:!rounded-l-none"
items={intervalItems}
onChange={setIntervalPreset}
disabled={!enabled}
variant="inline"
/>
</div>
<div className="ml-2 hidden items-center text-right text-sans-sm text-tertiary lg+:flex">
Updated {toLocaleTimeString(lastFetched)}
</div>
</div>
),
}
Expand Down
Loading
Loading