mirror of https://github.com/buster-so/buster.git
setup warning
This commit is contained in:
parent
33312538e1
commit
c77107500e
|
@ -4,8 +4,13 @@ import React, { useMemo } from 'react';
|
||||||
import { Title } from '@/components/ui/typography';
|
import { Title } from '@/components/ui/typography';
|
||||||
import { useUserConfigContextSelector } from '@/context/Users';
|
import { useUserConfigContextSelector } from '@/context/Users';
|
||||||
import { NewChatInput } from './NewChatInput';
|
import { NewChatInput } from './NewChatInput';
|
||||||
|
import { useNewChatWarning } from './useNewChatWarning';
|
||||||
|
import { NewChatWarning } from './NewChatWarning';
|
||||||
|
|
||||||
export const HomePageController: React.FC<{}> = () => {
|
export const HomePageController: React.FC<{}> = () => {
|
||||||
|
const newChatWarningProps = useNewChatWarning();
|
||||||
|
const { showWarning } = newChatWarningProps;
|
||||||
|
|
||||||
const user = useUserConfigContextSelector((state) => state.user);
|
const user = useUserConfigContextSelector((state) => state.user);
|
||||||
const userName = user?.name;
|
const userName = user?.name;
|
||||||
|
|
||||||
|
@ -24,6 +29,11 @@ export const HomePageController: React.FC<{}> = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center p-4.5">
|
<div className="flex flex-col items-center justify-center p-4.5">
|
||||||
|
{showWarning ? (
|
||||||
|
<div className="mt-18 flex w-full max-w-[650px] flex-col space-y-6">
|
||||||
|
<NewChatWarning {...newChatWarningProps} />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<div className="mt-[150px] flex w-full max-w-[650px] flex-col space-y-6">
|
<div className="mt-[150px] flex w-full max-w-[650px] flex-col space-y-6">
|
||||||
<div className="flex flex-col justify-center gap-y-1 text-center">
|
<div className="flex flex-col justify-center gap-y-1 text-center">
|
||||||
<Title as="h1" className="mb-0!">
|
<Title as="h1" className="mb-0!">
|
||||||
|
@ -36,6 +46,7 @@ export const HomePageController: React.FC<{}> = () => {
|
||||||
|
|
||||||
<NewChatInput />
|
<NewChatInput />
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,12 +20,10 @@ export const NewChatInput: React.FC<{}> = () => {
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const newChatWarningProps = useNewChatWarning();
|
|
||||||
const { showWarning } = newChatWarningProps;
|
|
||||||
|
|
||||||
const disabledSubmit = useMemo(() => {
|
const disabledSubmit = useMemo(() => {
|
||||||
return !inputHasText(inputValue) || showWarning;
|
return !inputHasText(inputValue);
|
||||||
}, [inputValue, showWarning]);
|
}, [inputValue]);
|
||||||
|
|
||||||
const onSubmit = useMemoizedFn(async (value: string) => {
|
const onSubmit = useMemoizedFn(async (value: string) => {
|
||||||
if (disabledSubmit) return;
|
if (disabledSubmit) return;
|
||||||
|
@ -54,23 +52,20 @@ export const NewChatInput: React.FC<{}> = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-2">
|
<>
|
||||||
<InputTextAreaButton
|
<InputTextAreaButton
|
||||||
className={
|
className={'transition-all duration-300 hover:shadow-lg active:shadow-md'}
|
||||||
!showWarning ? 'transition-all duration-300 hover:shadow-lg active:shadow-md' : ''
|
|
||||||
}
|
|
||||||
placeholder="Ask Buster a question..."
|
placeholder="Ask Buster a question..."
|
||||||
autoResize={autoResizeConfig}
|
autoResize={autoResizeConfig}
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onStop={onStop}
|
onStop={onStop}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
disabled={showWarning}
|
disabled={false}
|
||||||
disabledSubmit={disabledSubmit}
|
disabledSubmit={disabledSubmit}
|
||||||
autoFocus
|
autoFocus
|
||||||
ref={textAreaRef}
|
ref={textAreaRef}
|
||||||
/>
|
/>
|
||||||
{newChatWarningProps.showWarning && <NewChatWarning {...newChatWarningProps} />}
|
</>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,20 +16,24 @@ export const NewChatWarning = React.memo(({}: ReturnType<typeof useNewChatWarnin
|
||||||
const progressPercentage = (progress / 2) * 100;
|
const progressPercentage = (progress / 2) * 100;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-gray-200 bg-white p-6 shadow-sm">
|
<div className="flex flex-col rounded-xl border border-gray-200 bg-white p-6 shadow-sm">
|
||||||
<div className="mb-4 flex items-center justify-between">
|
<div className="mb-2 flex items-center justify-between">
|
||||||
<Text className="text-xl font-medium text-gray-800">Setup Checklist</Text>
|
<Text className="text-xl font-medium text-gray-800">Setup Checklist</Text>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="text-sm font-medium text-gray-500">{progress}/2 completed</div>
|
<div className="text-sm font-medium text-gray-500">{progress}/2 completed</div>
|
||||||
<div className="h-2 w-20 rounded-full bg-gray-100">
|
<div className="h-2 w-20 rounded-full bg-purple-100">
|
||||||
<div
|
<div
|
||||||
className="h-full rounded-full bg-gray-500 transition-all duration-500 ease-in-out"
|
className="h-full rounded-full bg-purple-500 transition-all duration-500 ease-in-out"
|
||||||
style={{ width: `${progressPercentage}%` }}
|
style={{ width: `${progressPercentage}%` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Paragraph className="mb-4 text-sm text-gray-500">
|
||||||
|
In order to ask questions, you need to connect a data source and create a dataset.
|
||||||
|
</Paragraph>
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<SetupItem
|
<SetupItem
|
||||||
number="1"
|
number="1"
|
||||||
|
@ -96,13 +100,13 @@ const SetupItem = ({ number, status, title, description, link, linkText }: Setup
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'group relative flex items-start space-x-4 rounded-lg border p-4 transition-all duration-200',
|
'group relative flex items-start space-x-4 rounded-lg border p-4 transition-all duration-200 hover:shadow-sm',
|
||||||
status ? 'border-green-700/30 bg-green-50' : 'border-gray-200'
|
status ? 'border-purple-700/30 bg-purple-50' : 'border-gray-200'
|
||||||
)}>
|
)}>
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'text-md flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full font-medium',
|
'text-md flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full font-medium',
|
||||||
status ? 'bg-green-200 text-green-700' : 'bg-gray-100 text-gray-500'
|
status ? 'bg-purple-200/60 text-purple-700' : 'bg-gray-100 text-gray-500'
|
||||||
)}>
|
)}>
|
||||||
{status ? <CircleCheck title="Complete" /> : number}
|
{status ? <CircleCheck title="Complete" /> : number}
|
||||||
</div>
|
</div>
|
||||||
|
@ -111,7 +115,7 @@ const SetupItem = ({ number, status, title, description, link, linkText }: Setup
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<Text className="font-medium text-gray-800">{title}</Text>
|
<Text className="font-medium text-gray-800">{title}</Text>
|
||||||
{status && (
|
{status && (
|
||||||
<span className="rounded-full bg-green-200 px-2 py-1 text-xs font-medium text-green-700">
|
<span className="rounded-full bg-purple-200/60 px-2 py-1 text-xs font-medium text-purple-700">
|
||||||
Complete
|
Complete
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -7,7 +7,6 @@ export const useNewChatWarning = () => {
|
||||||
const { data: datasources, isFetched: isDatasourcesFetched } = useListDatasources();
|
const { data: datasources, isFetched: isDatasourcesFetched } = useListDatasources();
|
||||||
|
|
||||||
const showWarning = useMemo(() => {
|
const showWarning = useMemo(() => {
|
||||||
return true;
|
|
||||||
if (!isDatasetsFetched || !isDatasourcesFetched) return false;
|
if (!isDatasetsFetched || !isDatasourcesFetched) return false;
|
||||||
if (datasets?.length === 0) return true;
|
if (datasets?.length === 0) return true;
|
||||||
if (datasources?.length === 0) return true;
|
if (datasources?.length === 0) return true;
|
||||||
|
|
Loading…
Reference in New Issue