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,
|
populateForm,
|
||||||
} = useConfigProfiles();
|
} = useConfigProfiles();
|
||||||
|
|
||||||
if (status === "loading") {
|
const handleReset = () => {
|
||||||
return (
|
if (isCreating) {
|
||||||
<div className="container">
|
setFormData({ name: "", description: "", env_vars: {}, runtime_hints: {}, mounts: [], git_mounts: [], files: {}, is_default: false });
|
||||||
<LoadingState message="Loading Config Profiles..." />
|
setIncludedProfileIds([]);
|
||||||
</div>
|
setSaveStatus("idle");
|
||||||
);
|
} else if (selectedProfile) {
|
||||||
}
|
populateForm(selectedProfile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (status === "error") {
|
if (status === "loading") return <div className="container"><LoadingState message="Loading Config Profiles..." /></div>;
|
||||||
return (
|
if (status === "error") return <div className="container"><ErrorState message="Failed to load Config Profiles." onRetry={loadData} /></div>;
|
||||||
<div className="container">
|
|
||||||
<ErrorState message="Failed to load Config Profiles." onRetry={loadData} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
return (
|
return (
|
||||||
@@ -126,24 +123,7 @@ export const ConfigProfilesPage = () => {
|
|||||||
getScopeLabel={getScopeLabel}
|
getScopeLabel={getScopeLabel}
|
||||||
onFormChange={updateFormField}
|
onFormChange={updateFormField}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
onReset={() => {
|
onReset={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);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onPreview={() => selectedProfile && handlePreview(selectedProfile.id)}
|
onPreview={() => selectedProfile && handlePreview(selectedProfile.id)}
|
||||||
onAddInclude={addInclude}
|
onAddInclude={addInclude}
|
||||||
onRemoveInclude={removeInclude}
|
onRemoveInclude={removeInclude}
|
||||||
|
|||||||
Reference in New Issue
Block a user