Skip to content
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(store): Auto-populate the agent submission form #9074

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autogpt_platform/backend/backend/server/v2/store/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ async def get_my_agents(
agent_version=agent.version,
agent_name=agent.name or "",
last_edited=agent.updatedAt or agent.createdAt,
description=agent.description or "",
)
for agent in agents
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class MyAgent(pydantic.BaseModel):
agent_id: str
agent_version: int
agent_name: str
description: str
last_edited: datetime.datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ export const PublishAgentInfo: React.FC<PublishAgentInfoProps> = ({
const [slug, setSlug] = React.useState(initialData?.slug || "");
const thumbnailsContainerRef = React.useRef<HTMLDivElement | null>(null);

React.useEffect(() => {
if (initialData) {
setImages(
initialData.additionalImages
? [initialData.thumbnailSrc, ...initialData.additionalImages]
: initialData.thumbnailSrc
? [initialData.thumbnailSrc]
: [],
);
setSelectedImage(initialData.thumbnailSrc || null);
setTitle(initialData.title);
setSubheader(initialData.subheader);
setYoutubeLink(initialData.youtubeLink);
setCategory(initialData.category);
setDescription(initialData.description);
setSlug(initialData.slug);
}
}, [initialData]);

const handleRemoveImage = (indexToRemove: number) => {
const newImages = [...images];
newImages.splice(indexToRemove, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
);
const [myAgents, setMyAgents] = React.useState<MyAgentsResponse | null>(null);
const [selectedAgent, setSelectedAgent] = React.useState<string | null>(null);
const [initialData, setInitialData] = React.useState<{
title: string;
subheader: string;
slug: string;
thumbnailSrc: string;
youtubeLink: string;
category: string;
description: string;
additionalImages?: string[];
} | null>(null);
const [publishData, setPublishData] =
React.useState<StoreSubmissionRequest>(submissionData);
const [selectedAgentId, setSelectedAgentId] = React.useState<string | null>(
Expand Down Expand Up @@ -102,6 +112,23 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
};

const handleNextFromSelect = (agentId: string, agentVersion: number) => {
const selectedAgentData = myAgents?.agents.find(
(agent) => agent.agent_id === agentId,
);

const name = selectedAgentData?.agent_name || "";
const description = selectedAgentData?.description || "";
setInitialData({
title: name,
subheader: "",
description: description,
thumbnailSrc: "",
youtubeLink: "",
category: "",
slug: name.replace(/ /g, "-"),
additionalImages: [],
});

setStep("info");
setSelectedAgentId(agentId);
setSelectedAgentVersion(agentVersion);
Expand Down Expand Up @@ -203,6 +230,7 @@ export const PublishAgentPopout: React.FC<PublishAgentPopoutProps> = ({
onBack={handleBack}
onSubmit={handleNextFromInfo}
onClose={handleClose}
initialData={initialData}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ export type MyAgent = {
agent_version: number;
agent_name: string;
last_edited: string;
description: string;
};

export type MyAgentsResponse = {
Expand Down
Loading