-
Notifications
You must be signed in to change notification settings - Fork 267
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
chore: updated strucutre of main page #396
base: main
Are you sure you want to change the base?
Conversation
import Input from '@/components/base/atoms/Input' | ||
import Button from '@/components/base/atoms/Button' | ||
|
||
const Form = (props: any) => { |
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.
this component name is confusing ... Form represents an atomic component ... this could be PromptForm or something like that
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 agree with this, additionally, instead of doing an onclick handler, use the form onSubmit handler instead.
handleOnChange: (e: any) => void | ||
} | ||
|
||
const Option = (props: OptionProps) => { |
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.
let's call it ConfigSelector if we want to create this component dedicatedly for configs select dropdown in main page ... but if we want to make it more generic then we have to refactor this component
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 hade made an atomic picker component, its actually there in my webcrawler branch https://github.com/truefoundry/cognita/blob/feat/web-crawler/frontend/src/components/base/atoms/Picker.tsx
<div className="h-[calc(100%-3.125rem)] flex justify-center items-center overflow-y-auto"> | ||
<div className="min-h-[23rem]"> | ||
<DocsQaInformation | ||
header={'Welcome to DocsQA'} |
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.
Why is this in curly braces?
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.
It was like this only i will remove it
import ErrorAnswer from './ErrorAnswer' | ||
import Answer from './Answer' | ||
|
||
export { Option, ApplicationModal, Form, NoAnswer, ErrorAnswer, Answer } |
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.
Lets avoid maintaining an index.tsx
, I'd rather suggest using index.tsx
in main screen pages where all the components are imported instead.
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 was thinking like in /screens we will have one main index.tsx which will contain path to pages only and inside page folder and inside that partials we can have one index.tsx more for the component path we can remove it as well it was optional.
handleOnChange: (e: any) => void | ||
} | ||
|
||
const Option = (props: OptionProps) => { |
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 hade made an atomic picker component, its actually there in my webcrawler branch https://github.com/truefoundry/cognita/blob/feat/web-crawler/frontend/src/components/base/atoms/Picker.tsx
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.
So i submitted a review as soon as you updated... oh well. I think it would be better to break the page into components for sections and use React Context to avoid prop drilling.
) : selectedCollection ? ( | ||
<> | ||
<div className="h-full border rounded-lg border-[#CEE0F8] w-[23.75rem] bg-white p-4 overflow-auto"> | ||
<div className="flex flex-col gap-3"> |
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 suppose this can also be broken down into <Sidebar />
or <QueryConfig />
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.
Yes i was also thinking same but in that case will have to do more prop drilling like sidebar have all config data and right section will have that form so we need to supply it to both so either we can pass from parent so that will be a lot of props for both file if it is fine i can do like that
onClick={() => setIsCreateApplicationModalOpen(true)} | ||
/> | ||
</div> | ||
<div className="h-full border rounded-lg border-[#CEE0F8] w-[calc(100%-25rem)] bg-white p-4"> |
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.
And this into <QA />
or something?
@Blakeinstein Review it now and check if everything is as we discussed in meet or not |
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.
LGTM, minor changes needed.
isCreateApplicationModalOpen, | ||
setIsCreateApplicationModalOpen, |
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.
Why is the modal state part of the context? Shouldn't the pattern be passing the modal state as prop to this component, and conditionally rendering it as a component in the parent (and not in this component?), effectively when isCreateApplicationModalOpen = false
this is a dead component with an empty react fragment, instead of not being rendered at all.
className="w-full btn-sm mt-4" | ||
onClick={() => setIsCreateApplicationModalOpen(true)} | ||
/> | ||
</div> |
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 would add the conditional rendering of the modal here, since this page controls it, maintain the modal state here and pass it as props instead of having it in the context.
@@ -0,0 +1,25 @@ | |||
import React from 'react' | |||
|
|||
import DocsQaInformation from '../../DocsQaInformation' |
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.
Why is this a parent import? I am assuming the component is also used elsewhere?
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.
yes yes it is used in 2,3 files.
@@ -0,0 +1,31 @@ | |||
import React from 'react' |
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.
Can we call this something more meaningful than Right
?
@@ -0,0 +1,141 @@ | |||
import { MenuItem, Switch, TextareaAutosize } from '@mui/material' |
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.
Can we call this something more meaningful than Left
?
})) | ||
}, [selectedQueryController, openapiSpecs]) | ||
|
||
const handlePromptSubmit = async () => { |
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.
Define submit handler where used, Are multiple components submitting the form?
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.
no no, i have changes this one and also that createApplication function
} | ||
} | ||
|
||
const createChatApplication = async ( |
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.
Same for this.
if (collections && collections.length) setSelectedCollection(collections[0]) | ||
|
||
if (allQueryControllers && allQueryControllers.length) | ||
setSelectedQueryController(allQueryControllers[0]) | ||
|
||
if (allEnabledModels && allEnabledModels.length) | ||
setSelectedQueryModel(allEnabledModels[0].name) | ||
|
||
if (allRetrieverOptions && allRetrieverOptions.length) { | ||
setSelectedRetriever(allRetrieverOptions[0]) | ||
setPromptTemplate(allRetrieverOptions[0].promptTemplate) | ||
} | ||
if (selectedRetriever) | ||
setRetrieverConfig(JSON.stringify(selectedRetriever.config, null, 2)) | ||
}, [ | ||
collections, | ||
allQueryControllers, | ||
allEnabledModels, | ||
allRetrieverOptions, | ||
selectedRetriever, |
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.
Are these interdependent, can we break this use-effect if not?
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.
we can use multiple use effect as well they are not connected
Updated the file structure of main page