mirror of https://github.com/buster-so/buster.git
update dashboard controller to use scroller
This commit is contained in:
parent
9149b0cfaa
commit
e851769341
|
@ -45,25 +45,25 @@ export const NonScrollable: Story = {
|
||||||
export const WithCustomClassName: Story = {
|
export const WithCustomClassName: Story = {
|
||||||
args: {
|
args: {
|
||||||
className: 'bg-gray-50',
|
className: 'bg-gray-50',
|
||||||
header: <div className="bg-gray-100">Header Content</div>,
|
header: <div className="">Header Content</div>,
|
||||||
children: <div className="">Content with custom background</div>
|
children: <div className="">Content with custom background</div>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LongContent: Story = {
|
export const LongContent: Story = {
|
||||||
args: {
|
args: {
|
||||||
header: <div className="bg-gray-100">Header Content</div>,
|
header: <div className="">Header Content</div>,
|
||||||
scrollable: true,
|
scrollable: true,
|
||||||
headerBorderVariant: 'ghost',
|
headerBorderVariant: 'ghost',
|
||||||
children: (
|
children: (
|
||||||
<>
|
<div className="border border-red-500 bg-red-100 p-1">
|
||||||
{Array.from({ length: 100 }, (_, i) => (
|
{Array.from({ length: 100 }, (_, i) => (
|
||||||
<p key={i} className="mb-4">
|
<p key={i} className="mb-4">
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
||||||
incididunt ut labore et dolore magna aliqua.
|
incididunt ut labore et dolore magna aliqua.
|
||||||
</p>
|
</p>
|
||||||
))}
|
))}
|
||||||
</>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,10 +11,9 @@ export const AppPageLayoutContent: React.FC<
|
||||||
const Selector = scrollable ? ScrollArea : 'main';
|
const Selector = scrollable ? ScrollArea : 'main';
|
||||||
const ChildSelector = scrollable ? 'main' : React.Fragment;
|
const ChildSelector = scrollable ? 'main' : React.Fragment;
|
||||||
|
|
||||||
console.log('scrollable', scrollable);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Selector className={cn('bg-page-background app-content h-full max-h-[100%] p-0', className)}>
|
<Selector
|
||||||
|
className={cn('bg-page-background app-content h-full max-h-full overflow-hidden', className)}>
|
||||||
<ChildSelector>{children}</ChildSelector>
|
<ChildSelector>{children}</ChildSelector>
|
||||||
</Selector>
|
</Selector>
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,9 +3,15 @@ import { EditableTitle } from '@/components/ui/typography/EditableTitle';
|
||||||
import { Input } from '@/components/ui/inputs';
|
import { Input } from '@/components/ui/inputs';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { type useUpdateDashboard } from '@/api/buster_rest/dashboards';
|
import { type useUpdateDashboard } from '@/api/buster_rest/dashboards';
|
||||||
|
import { InputTextArea } from '@/components/ui/inputs/InputTextArea';
|
||||||
|
|
||||||
export const DASHBOARD_TITLE_INPUT_ID = 'dashboard-title-input';
|
export const DASHBOARD_TITLE_INPUT_ID = 'dashboard-title-input';
|
||||||
|
|
||||||
|
const descriptionAutoResize = {
|
||||||
|
minRows: 1,
|
||||||
|
maxRows: 25
|
||||||
|
};
|
||||||
|
|
||||||
export const DashboardEditTitles: React.FC<{
|
export const DashboardEditTitles: React.FC<{
|
||||||
title: string;
|
title: string;
|
||||||
onUpdateDashboard: ReturnType<typeof useUpdateDashboard>['mutateAsync'];
|
onUpdateDashboard: ReturnType<typeof useUpdateDashboard>['mutateAsync'];
|
||||||
|
@ -18,14 +24,14 @@ export const DashboardEditTitles: React.FC<{
|
||||||
});
|
});
|
||||||
|
|
||||||
const { run: onChangeDashboardDescription } = useDebounceFn(
|
const { run: onChangeDashboardDescription } = useDebounceFn(
|
||||||
useMemoizedFn((value: React.ChangeEvent<HTMLInputElement>) => {
|
useMemoizedFn((value: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
if (!readOnly) onUpdateDashboard({ description: value.target.value, id: dashboardId });
|
if (!readOnly) onUpdateDashboard({ description: value.target.value, id: dashboardId });
|
||||||
}),
|
}),
|
||||||
{ wait: 650 }
|
{ wait: 650 }
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-0">
|
<div className="flex flex-col space-y-1.5">
|
||||||
<EditableTitle
|
<EditableTitle
|
||||||
className="w-full truncate"
|
className="w-full truncate"
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
|
@ -37,12 +43,13 @@ export const DashboardEditTitles: React.FC<{
|
||||||
</EditableTitle>
|
</EditableTitle>
|
||||||
|
|
||||||
{(description || !readOnly) && (
|
{(description || !readOnly) && (
|
||||||
<Input
|
<InputTextArea
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className={'pl-0!'}
|
className={'py-0! pl-0!'}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
onChange={onChangeDashboardDescription}
|
onChange={onChangeDashboardDescription}
|
||||||
defaultValue={description}
|
defaultValue={description}
|
||||||
|
autoResize={descriptionAutoResize}
|
||||||
placeholder="Add description..."
|
placeholder="Add description..."
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -25,22 +25,24 @@ export const DashboardViewDashboardController: React.FC<DashboardViewProps> = ({
|
||||||
const dashboard = dashboardResponse?.dashboard;
|
const dashboard = dashboardResponse?.dashboard;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea className="flex h-full flex-col space-y-3 p-10">
|
<ScrollArea className="h-full">
|
||||||
<DashboardEditTitles
|
<div className="flex h-full flex-col space-y-3 p-10">
|
||||||
onUpdateDashboard={onUpdateDashboard}
|
<DashboardEditTitles
|
||||||
dashboardId={dashboardId}
|
onUpdateDashboard={onUpdateDashboard}
|
||||||
readOnly={readOnly}
|
dashboardId={dashboardId}
|
||||||
title={dashboardResponse?.dashboard?.name || ''}
|
readOnly={readOnly}
|
||||||
description={dashboardResponse?.dashboard?.description || ''}
|
title={dashboardResponse?.dashboard?.name || ''}
|
||||||
/>
|
description={dashboardResponse?.dashboard?.description || ''}
|
||||||
|
/>
|
||||||
|
|
||||||
<DashboardContentController
|
<DashboardContentController
|
||||||
metrics={metrics}
|
metrics={metrics}
|
||||||
dashboard={dashboard}
|
dashboard={dashboard}
|
||||||
onUpdateDashboardConfig={onUpdateDashboardConfig}
|
onUpdateDashboardConfig={onUpdateDashboardConfig}
|
||||||
onOpenAddContentModal={onOpenAddContentModal}
|
onOpenAddContentModal={onOpenAddContentModal}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue