Skip to content

Commit 3471781

Browse files
fix(frontend/marketplace): require category selection (#10031)
## Summary - require categories to be selected in PublishAgent popout ### Changes 🏗️ Makes it require the categories to be set before allowing an agent to be uploaded added popup notification to say its missing categories ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: <!-- Put your test plan here: --> - [x] Try to upload a agent with out setting categories and it will error and show message saying "Missing Required Fields, Please fill in: Categories" - [x] Now try to upload a agent with the categories set and it will work Co-authored-by: Bently <[email protected]>
1 parent 17e973a commit 3471781

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

autogpt_platform/frontend/src/components/agptui/PublishAgentSelectInfo.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,16 @@ export const PublishAgentInfo: React.FC<PublishAgentInfoProps> = ({
159159

160160
const handleSubmit = (e: React.MouseEvent<HTMLButtonElement>) => {
161161
e.preventDefault();
162-
onSubmit(title, subheader, slug, description, images, youtubeLink, [
163-
category,
164-
]);
162+
const categories = category ? [category] : [];
163+
onSubmit(
164+
title,
165+
subheader,
166+
slug,
167+
description,
168+
images,
169+
youtubeLink,
170+
categories,
171+
);
165172
};
166173

167174
return (

autogpt_platform/frontend/src/components/agptui/composite/PublishAgentPopout.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
155155
if (!subHeading) missingFields.push("Sub-heading");
156156
if (!description) missingFields.push("Description");
157157
if (!imageUrls.length) missingFields.push("Image");
158-
if (!categories.length) missingFields.push("Categories");
158+
if (!categories.filter(Boolean).length) missingFields.push("Categories");
159159

160160
if (missingFields.length > 0) {
161161
toast({
@@ -166,6 +166,7 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
166166
return;
167167
}
168168

169+
const filteredCategories = categories.filter(Boolean);
169170
setPublishData({
170171
name,
171172
sub_heading: subHeading,
@@ -175,7 +176,7 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
175176
agent_id: selectedAgentId || "",
176177
agent_version: selectedAgentVersion || 0,
177178
slug,
178-
categories,
179+
categories: filteredCategories,
179180
});
180181

181182
// Create store submission
@@ -189,7 +190,7 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
189190
agent_id: selectedAgentId || "",
190191
agent_version: selectedAgentVersion || 0,
191192
slug: slug.replace(/\s+/g, "-"),
192-
categories: categories,
193+
categories: filteredCategories,
193194
});
194195
} catch (error) {
195196
console.error("Error creating store submission:", error);

0 commit comments

Comments
 (0)