AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(platform): add ability to reject approved agents in admin dashboard (#10671)
Nicholas Tindlebd977277638d
diff --git a/autogpt_platform/backend/backend/server/v2/store/db.py b/autogpt_platform/backend/backend/server/v2/store/db.pyindex 850d38dd96..2f53b1cec1 100644--- a/autogpt_platform/backend/backend/server/v2/store/db.py+++ b/autogpt_platform/backend/backend/server/v2/store/db.py@@ -1252,6 +1252,13 @@ async def review_store_submission(detail=f"Store listing version {store_listing_version_id} not found",)+ # Check if we're rejecting an already approved agent+ is_rejecting_approved = (+ not is_approved+ and store_listing_version.submissionStatus+ == prisma.enums.SubmissionStatus.APPROVED+ )+# If approving, update the listing to indicate it has an approved versionif is_approved and store_listing_version.AgentGraph:heading = f"Sub-graph of {store_listing_version.name}v{store_listing_version.agentGraphVersion}"@@ -1282,6 +1289,37 @@ async def review_store_submission(},)+ # If rejecting an approved agent, update the StoreListing accordingly+ if is_rejecting_approved:+ # Check if there are other approved versions+ other_approved = (+ await prisma.models.StoreListingVersion.prisma().find_first(+ where={+ "storeListingId": store_listing_version.StoreListing.id,+ "id": {"not": store_listing_version_id},+ "submissionStatus": prisma.enums.SubmissionStatus.APPROVED,+ }+ )+ )++ if not other_approved:+ # No other approved versions, update hasApprovedVersion to False+ await prisma.models.StoreListing.prisma().update(+ where={"id": store_listing_version.StoreListing.id},+ data={+ "hasApprovedVersion": False,+ "ActiveVersion": {"disconnect": True},+ },+ )+ else:+ # Set the most recent other approved version as active+ await prisma.models.StoreListing.prisma().update(+ where={"id": store_listing_version.StoreListing.id},+ data={+ "ActiveVersion": {"connect": {"id": other_approved.id}},+ },+ )+submission_status = (prisma.enums.SubmissionStatus.APPROVEDif is_approveddiff --git a/autogpt_platform/frontend/src/components/admin/marketplace/approve-reject-buttons.tsx b/autogpt_platform/frontend/src/components/admin/marketplace/approve-reject-buttons.tsxindex b0e6b1d9d6..a2ac8deb94 100644--- a/autogpt_platform/frontend/src/components/admin/marketplace/approve-reject-buttons.tsx+++ b/autogpt_platform/frontend/src/components/admin/marketplace/approve-reject-buttons.tsx@@ -29,6 +29,8 @@ export function ApproveRejectButtons({const [isApproveDialogOpen, setIsApproveDialogOpen] = useState(false);const [isRejectDialogOpen, setIsRejectDialogOpen] = useState(false);+ const isApproved = version.status === "APPROVED";+const handleApproveSubmit = async (formData: FormData) => {setIsApproveDialogOpen(false);try {@@ -51,18 +53,20 @@ export function ApproveRejectButtons({return (<>- <Button- size="sm"- variant="outline"- className="text-green-600 hover:bg-green-50 hover:text-green-700"- onClick={(e) => {- e.stopPropagation();- setIsApproveDialogOpen(true);- }}- >- <CheckCircle className="mr-2 h-4 w-4" />- Approve- </Button>+ {!isApproved && (+ <Button+ size="sm"+ variant="outline"+ className="text-green-600 hover:bg-green-50 hover:text-green-700"+ onClick={(e) => {+ e.stopPropagation();+ setIsApproveDialogOpen(true);+ }}+ >+ <CheckCircle className="mr-2 h-4 w-4" />+ Approve+ </Button>+ )}<Buttonsize="sm"variant="outline"@@ -73,7 +77,7 @@ export function ApproveRejectButtons({}}><XCircle className="mr-2 h-4 w-4" />- Reject+ {isApproved ? "Revoke" : "Reject"}</Button>{/* Approve Dialog */}@@ -124,9 +128,13 @@ export function ApproveRejectButtons({<Dialog open={isRejectDialogOpen} onOpenChange={setIsRejectDialogOpen}><DialogContent><DialogHeader>- <DialogTitle>Reject Agent</DialogTitle>+ <DialogTitle>+ {isApproved ? "Revoke Approved Agent" : "Reject Agent"}+ </DialogTitle><DialogDescription>- Please provide feedback on why this agent is being rejected.+ {isApproved+ ? "Are you sure you want to revoke approval for this agent? This will remove it from the marketplace."+ : "Please provide feedback on why this agent is being rejected."}</DialogDescription></DialogHeader>@@ -167,7 +175,7 @@ export function ApproveRejectButtons({Cancel</Button><Button type="submit" variant="destructive">- Reject+ {isApproved ? "Revoke" : "Reject"}</Button></DialogFooter></form>diff --git a/autogpt_platform/frontend/src/components/admin/marketplace/expandable-row.tsx b/autogpt_platform/frontend/src/components/admin/marketplace/expandable-row.tsxindex 569bdc7eaf..e1f936da5b 100644--- a/autogpt_platform/frontend/src/components/admin/marketplace/expandable-row.tsx+++ b/autogpt_platform/frontend/src/components/admin/marketplace/expandable-row.tsx@@ -83,7 +83,8 @@ export function ExpandableRow({/>)}- {latestVersion?.status === SubmissionStatus.PENDING && (+ {(latestVersion?.status === SubmissionStatus.PENDING ||+ latestVersion?.status === SubmissionStatus.APPROVED) && (<ApproveRejectButtons version={latestVersion} />)}</div>@@ -188,7 +189,8 @@ export function ExpandableRow({}/>)}- {version.status === SubmissionStatus.PENDING && (+ {(version.status === SubmissionStatus.PENDING ||+ version.status === SubmissionStatus.APPROVED) && (<ApproveRejectButtons version={version} />)}</div>