refactor: slim ConfigProfilesPage to 150 lines
Extract handleReset callback, compact loading/error states. Quality gates: tsc --noEmit pass
This commit is contained in:
@@ -61,21 +61,18 @@ export const ConfigProfilesPage = () => {
|
||||
populateForm,
|
||||
} = useConfigProfiles();
|
||||
|
||||
if (status === "loading") {
|
||||
return (
|
||||
<div className="container">
|
||||
<LoadingState message="Loading Config Profiles..." />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const handleReset = () => {
|
||||
if (isCreating) {
|
||||
setFormData({ name: "", description: "", env_vars: {}, runtime_hints: {}, mounts: [], git_mounts: [], files: {}, is_default: false });
|
||||
setIncludedProfileIds([]);
|
||||
setSaveStatus("idle");
|
||||
} else if (selectedProfile) {
|
||||
populateForm(selectedProfile);
|
||||
}
|
||||
};
|
||||
|
||||
if (status === "error") {
|
||||
return (
|
||||
<div className="container">
|
||||
<ErrorState message="Failed to load Config Profiles." onRetry={loadData} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (status === "loading") return <div className="container"><LoadingState message="Loading Config Profiles..." /></div>;
|
||||
if (status === "error") return <div className="container"><ErrorState message="Failed to load Config Profiles." onRetry={loadData} /></div>;
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
@@ -126,24 +123,7 @@ export const ConfigProfilesPage = () => {
|
||||
getScopeLabel={getScopeLabel}
|
||||
onFormChange={updateFormField}
|
||||
onSubmit={handleSubmit}
|
||||
onReset={() => {
|
||||
if (isCreating) {
|
||||
setFormData({
|
||||
name: "",
|
||||
description: "",
|
||||
env_vars: {},
|
||||
runtime_hints: {},
|
||||
mounts: [],
|
||||
git_mounts: [],
|
||||
files: {},
|
||||
is_default: false,
|
||||
});
|
||||
setIncludedProfileIds([]);
|
||||
setSaveStatus("idle");
|
||||
} else if (selectedProfile) {
|
||||
populateForm(selectedProfile);
|
||||
}
|
||||
}}
|
||||
onReset={handleReset}
|
||||
onPreview={() => selectedProfile && handlePreview(selectedProfile.id)}
|
||||
onAddInclude={addInclude}
|
||||
onRemoveInclude={removeInclude}
|
||||
|
||||
Reference in New Issue
Block a user