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

chore: updated strucutre of main page #396

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ChoudharyHarish
Copy link
Collaborator

Updated the file structure of main page

@sayan-truefoundry sayan-truefoundry changed the title updated strucutre of main page chore: updated strucutre of main page Oct 28, 2024
import Input from '@/components/base/atoms/Input'
import Button from '@/components/base/atoms/Button'

const Form = (props: any) => {
Copy link
Contributor

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

Copy link
Contributor

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) => {
Copy link
Contributor

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

Copy link
Contributor

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'}
Copy link
Contributor

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?

Copy link
Collaborator Author

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 }
Copy link
Contributor

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.

Copy link
Collaborator Author

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) => {
Copy link
Contributor

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

Copy link
Contributor

@Blakeinstein Blakeinstein left a 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">
Copy link
Contributor

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 />

Copy link
Collaborator Author

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">
Copy link
Contributor

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?

@ChoudharyHarish
Copy link
Collaborator Author

@Blakeinstein Review it now and check if everything is as we discussed in meet or not

Copy link
Contributor

@Blakeinstein Blakeinstein left a 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.

Comment on lines 13 to 14
isCreateApplicationModalOpen,
setIsCreateApplicationModalOpen,
Copy link
Contributor

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>
Copy link
Contributor

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'
Copy link
Contributor

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?

Copy link
Collaborator Author

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'
Copy link
Contributor

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'
Copy link
Contributor

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 () => {
Copy link
Contributor

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?

Copy link
Collaborator Author

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 (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this.

Comment on lines +230 to +249
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,
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants