chat file layout update

This commit is contained in:
Nate Kelley 2025-03-21 22:01:14 -06:00
parent 9304e3f8a6
commit 83e9b0b1b5
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
6 changed files with 29 additions and 7 deletions

View File

@ -0,0 +1,15 @@
import { MetricController } from '@/controllers/MetricController';
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
export default async function MetricPage(props: {
params: Promise<{ metricId: string; dashboardId: string }>;
}) {
const params = await props.params;
const { metricId, dashboardId } = params;
return (
<AppAssetCheckLayout assetId={metricId} type="metric">
<MetricController metricId={metricId} />
</AppAssetCheckLayout>
);
}

View File

@ -1,10 +1,7 @@
import { MetricController } from '@/controllers/MetricController'; import { MetricController } from '@/controllers/MetricController';
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
export default async function MetricPage(props: { export default async function MetricPage(props: { params: Promise<{ metricId: string }> }) {
params: Promise<{ metricId: string }>;
searchParams: Promise<{ embed?: string }>;
}) {
const params = await props.params; const params = await props.params;
const { metricId } = params; const { metricId } = params;

View File

@ -21,6 +21,7 @@ import {
DragStartEvent, DragStartEvent,
DragEndEvent DragEndEvent
} from '@dnd-kit/core'; } from '@dnd-kit/core';
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
import { import {
arrayMove, arrayMove,
SortableContext, SortableContext,
@ -31,6 +32,8 @@ import {
import { CSS } from '@dnd-kit/utilities'; import { CSS } from '@dnd-kit/utilities';
import { useMemoizedFn } from '@/hooks'; import { useMemoizedFn } from '@/hooks';
const modifiers = [restrictToVerticalAxis];
interface SidebarTriggerProps { interface SidebarTriggerProps {
label: string; label: string;
isOpen: boolean; isOpen: boolean;
@ -181,7 +184,8 @@ export const SidebarCollapsible: React.FC<
sensors={sensors} sensors={sensors}
collisionDetection={closestCenter} collisionDetection={closestCenter}
onDragStart={handleDragStart} onDragStart={handleDragStart}
onDragEnd={handleDragEnd}> onDragEnd={handleDragEnd}
modifiers={modifiers}>
<SortableContext <SortableContext
items={sortedItems.map((item) => item.id)} items={sortedItems.map((item) => item.id)}
strategy={verticalListSortingStrategy}> strategy={verticalListSortingStrategy}>

View File

@ -45,7 +45,7 @@ export const MetricTitle: React.FC<{
}, [title, useEllipsis]); }, [title, useEllipsis]);
return ( return (
<Link className="flex px-4" href={metricLink}> <Link className="flex px-4" href={metricLink} prefetch>
<div <div
{...attributes} {...attributes}
{...listeners} {...listeners}

View File

@ -1,3 +1,5 @@
'use client';
import { FileType } from '@/api/asset_interfaces'; import { FileType } from '@/api/asset_interfaces';
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { FileConfig, FileView, FileViewConfig, FileViewSecondary } from './interfaces'; import { FileConfig, FileView, FileViewConfig, FileViewSecondary } from './interfaces';

View File

@ -1,6 +1,6 @@
'use client'; 'use client';
import { useMemo, useState, useTransition } from 'react'; import { useEffect, useMemo, useState, useTransition } from 'react';
import type { ChatLayoutView, SelectedFile } from '../../interfaces'; import type { ChatLayoutView, SelectedFile } from '../../interfaces';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
import { parsePathnameSegments } from './parsePathnameSegments'; import { parsePathnameSegments } from './parsePathnameSegments';
@ -73,6 +73,10 @@ export const useSelectedFileAndLayout = ({
}); });
}); });
useEffect(() => {
setSelectedFile(initializeSelectedFile(params));
}, [Object.keys(params).join('')]);
return useMemo( return useMemo(
() => ({ () => ({
onSetSelectedFile, onSetSelectedFile,