mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-02-15 13:17:32 +00:00
refactor(SidebarModals): move normalizeProjectForSettings into utils file
This commit is contained in:
@@ -58,3 +58,5 @@ export type MCPServerStatus = {
|
|||||||
export type TouchHandlerFactory = (
|
export type TouchHandlerFactory = (
|
||||||
callback: () => void,
|
callback: () => void,
|
||||||
) => (event: React.TouchEvent<HTMLElement>) => void;
|
) => (event: React.TouchEvent<HTMLElement>) => void;
|
||||||
|
|
||||||
|
export type SettingsProject = Pick<Project, 'name' | 'displayName' | 'fullPath' | 'path'>;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { Project } from '../../../types/app';
|
|||||||
import type {
|
import type {
|
||||||
AdditionalSessionsByProject,
|
AdditionalSessionsByProject,
|
||||||
ProjectSortOrder,
|
ProjectSortOrder,
|
||||||
|
SettingsProject,
|
||||||
SessionViewModel,
|
SessionViewModel,
|
||||||
SessionWithProvider,
|
SessionWithProvider,
|
||||||
} from '../types/types';
|
} from '../types/types';
|
||||||
@@ -198,3 +199,25 @@ export const getTaskIndicatorStatus = (
|
|||||||
|
|
||||||
return 'not-configured';
|
return 'not-configured';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const normalizeProjectForSettings = (project: Project): SettingsProject => {
|
||||||
|
const fallbackPath =
|
||||||
|
typeof project.fullPath === 'string' && project.fullPath.length > 0
|
||||||
|
? project.fullPath
|
||||||
|
: typeof project.path === 'string'
|
||||||
|
? project.path
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: project.name,
|
||||||
|
displayName:
|
||||||
|
typeof project.displayName === 'string' && project.displayName.trim().length > 0
|
||||||
|
? project.displayName
|
||||||
|
: project.name,
|
||||||
|
fullPath: fallbackPath,
|
||||||
|
path:
|
||||||
|
typeof project.path === 'string' && project.path.length > 0
|
||||||
|
? project.path
|
||||||
|
: fallbackPath,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useMemo } from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { AlertTriangle, Trash2 } from 'lucide-react';
|
import { AlertTriangle, Trash2 } from 'lucide-react';
|
||||||
import type { TFunction } from 'i18next';
|
import type { TFunction } from 'i18next';
|
||||||
@@ -7,7 +8,8 @@ import Settings from '../../../Settings';
|
|||||||
import VersionUpgradeModal from '../../../modals/VersionUpgradeModal';
|
import VersionUpgradeModal from '../../../modals/VersionUpgradeModal';
|
||||||
import type { Project } from '../../../../types/app';
|
import type { Project } from '../../../../types/app';
|
||||||
import type { ReleaseInfo } from '../../../../types/sharedTypes';
|
import type { ReleaseInfo } from '../../../../types/sharedTypes';
|
||||||
import type { DeleteProjectConfirmation, SessionDeleteConfirmation } from '../../types/types';
|
import { normalizeProjectForSettings } from '../../utils/utils';
|
||||||
|
import type { DeleteProjectConfirmation, SessionDeleteConfirmation, SettingsProject } from '../../types/types';
|
||||||
|
|
||||||
type SidebarModalsProps = {
|
type SidebarModalsProps = {
|
||||||
projects: Project[];
|
projects: Project[];
|
||||||
@@ -31,6 +33,19 @@ type SidebarModalsProps = {
|
|||||||
t: TFunction;
|
t: TFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type TypedSettingsProps = {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
projects: SettingsProject[];
|
||||||
|
initialTab: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const SettingsComponent = Settings as (props: TypedSettingsProps) => JSX.Element;
|
||||||
|
|
||||||
|
function TypedSettings(props: TypedSettingsProps) {
|
||||||
|
return <SettingsComponent {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
export default function SidebarModals({
|
export default function SidebarModals({
|
||||||
projects,
|
projects,
|
||||||
showSettings,
|
showSettings,
|
||||||
@@ -52,6 +67,12 @@ export default function SidebarModals({
|
|||||||
latestVersion,
|
latestVersion,
|
||||||
t,
|
t,
|
||||||
}: SidebarModalsProps) {
|
}: SidebarModalsProps) {
|
||||||
|
// Settings expects project identity/path fields to be present for dropdown labels and local-scope MCP config.
|
||||||
|
const settingsProjects = useMemo(
|
||||||
|
() => projects.map(normalizeProjectForSettings),
|
||||||
|
[projects],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showNewProject &&
|
{showNewProject &&
|
||||||
@@ -63,10 +84,10 @@ export default function SidebarModals({
|
|||||||
document.body,
|
document.body,
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Settings
|
<TypedSettings
|
||||||
isOpen={showSettings}
|
isOpen={showSettings}
|
||||||
onClose={onCloseSettings}
|
onClose={onCloseSettings}
|
||||||
projects={projects as any}
|
projects={settingsProjects}
|
||||||
initialTab={settingsInitialTab}
|
initialTab={settingsInitialTab}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user