-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[FEAT] New Workspace Settings Layout #718
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
[FEAT] New Workspace Settings Layout #718
Conversation
frontend/src/components/Sidebar/ActiveWorkspaces/index.jsxInstead of calling useEffect(() => {
async function getWorkspaces() {
try {
const workspaces = await Workspace.all();
setWorkspaces(workspaces);
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
getWorkspaces();
}, []);frontend/src/pages/WorkspaceSettings/VectorDatabase/index.jsxConsider destructuring const handleUpdate = async (e) => {
setSaving(true);
e.preventDefault();
const data = {};
const form = new FormData(formEl.current);
for (var [key, value] of form.entries()) data[key] = castToType(key, value);
const { slug } = workspace;
const { workspace: updatedWorkspace, message } = await Workspace.update(slug, data);
// rest of the code
};frontend/src/pages/WorkspaceSettings/ChatSettings/index.jsxConsider using the useCallback hook for the handleUpdate function in the ChatSettings component. This will prevent unnecessary re-renders of the component when the function is used as a prop or within a useEffect, useMemo, or another useCallback. const handleUpdate = useCallback(async (e) => {
+ setSaving(true);
+ e.preventDefault();
+ const data = {};
+ const form = new FormData(formEl.current);
+ for (var [key, value] of form.entries()) data[key] = castToType(key, value);
+ const { workspace: updatedWorkspace, message } = await Workspace.update(
+ workspace.slug,
+ data
+ );
+ if (!!updatedWorkspace) {
+ showToast("Workspace updated!", "success", { clear: true });
+ } else {
+ showToast(`Error: ${message}`, "error", { clear: true });
+ }
+ setSaving(false);
+ setHasChanges(false);
+ }, [workspace.slug]);
+ ```git fetch origin && git checkout -b ReviewBot/Impro-thkn4rz origin/ReviewBot/Impro-thkn4rz Consider using React.lazy for code splitting to load each tab content only when it's needed. This will improve the initial load time of your application. const GeneralInfo = React.lazy(() => import('./GeneralInfo'));
const ChatSettings = React.lazy(() => import('./ChatSettings'));
const VectorDatabase = React.lazy(() => import('./VectorDatabase'));
const tabsMapping = {
"general-info": GeneralInfo,
"chat-settings": ChatSettings,
"vector-database": VectorDatabase,
};
const TabContent = tabsMapping[tab];
return (
<React.Suspense fallback={<div>Loading...</div>}>
<TabContent slug={slug} workspace={workspace} />
</React.Suspense>
);frontend/src/hooks/useGetProvidersModels.jsInstead of using a reduce function to group models, consider using a more declarative approach with the help of a Map object. This will make the code easier to read and maintain. function groupModels(models) {
const groupedModels = new Map();
models.forEach(model => {
const modelsList = groupedModels.get(model.organization) || [];
modelsList.push(model);
groupedModels.set(model.organization, modelsList);
});
return Object.fromEntries(groupedModels);
}Consider using the functional update form of the useState hook's setter function. This will ensure that the state updates are always based on the most recent state and avoid unnecessary re-rendering. setDefaultModels(prevModels => PROVIDER_DEFAULT_MODELS[provider] || prevModels);
setCustomModels(prevModels => provider === "togetherai" ? groupModels(models) : models || prevModels);frontend/src/utils/types.jsInstead of using a definitions object to handle the casting of values, consider using a Map object. This will make the code easier to read and maintain. export function castToType(key, value) {
const definitions = new Map([
['openAiTemp', Number],
['openAiHistory', Number],
['similarityThreshold', parseFloat],
['topN', Number]
]);
const castFunction = definitions.get(key);
return castFunction ? castFunction(value) : value;
} |
* WIP new settings layout * add suggested messages to general & appearance and clean up/make more user friendly * lazy load workspace settings pages * css fix on X button for document picker where button is barely clickable * remove additional workspace settings page * fix thread selection action when on thread * refactor inputs into sub-components remove unused paths --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
Pull Request Type
Relevant Issues
resolves #705
What is in this change?
Describe the changes in this PR that are impactful to the repo.
Additional Information
Add any other context about the Pull Request here that was not captured above.
Developer Validations
yarn lintfrom the root of the repo & committed changes