-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3466 from quantified-uncertainty/sqvalue-compare
New /admin/upgrade-versions UI; compareVersions function
- Loading branch information
Showing
12 changed files
with
666 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
apps/hub/src/app/admin/upgrade-versions/compare/UpgradeButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
import { useRouter } from "next/navigation"; | ||
import { FC } from "react"; | ||
|
||
import { defaultSquiggleVersion } from "@quri/versioned-squiggle-components"; | ||
|
||
import { SafeActionButton } from "@/components/ui/SafeActionButton"; | ||
import { adminUpdateModelVersionAction } from "@/models/actions/adminUpdateModelVersionAction"; | ||
import { ModelFullDTO } from "@/models/data/full"; | ||
|
||
export const UpgradeButton: FC<{ | ||
model: ModelFullDTO; | ||
}> = ({ model }) => { | ||
const router = useRouter(); | ||
|
||
if ( | ||
model.currentRevision.contentType === "SquiggleSnippet" && | ||
model.currentRevision.squiggleSnippet.version === defaultSquiggleVersion | ||
) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<SafeActionButton | ||
action={adminUpdateModelVersionAction} | ||
input={{ | ||
modelId: model.id, | ||
version: defaultSquiggleVersion, | ||
}} | ||
onSuccess={() => router.refresh()} | ||
theme="primary" | ||
> | ||
Upgrade to {defaultSquiggleVersion} | ||
</SafeActionButton> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { notFound } from "next/navigation"; | ||
|
||
import { H2 } from "@/components/ui/Headers"; | ||
import { StyledLink } from "@/components/ui/StyledLink"; | ||
import { modelRoute } from "@/lib/routes"; | ||
import { loadModelFull } from "@/models/data/full"; | ||
|
||
import { UpgradeableModel } from "./UpgradeableModel"; | ||
import { UpgradeButton } from "./UpgradeButton"; | ||
|
||
type Props = { | ||
searchParams: Promise<{ owner: string; slug: string }>; | ||
}; | ||
|
||
export default async function CompareVersionsPage({ searchParams }: Props) { | ||
const { owner, slug } = await searchParams; | ||
|
||
const model = await loadModelFull({ owner, slug }); | ||
if (!model) { | ||
notFound(); | ||
} | ||
|
||
const { contentType } = model.currentRevision; | ||
if (contentType !== "SquiggleSnippet") { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<div className="bg-white"> | ||
<H2> | ||
<div className="flex items-center gap-4"> | ||
<div> | ||
Compare model{" "} | ||
<StyledLink | ||
href={modelRoute({ owner: model.owner.slug, slug: model.slug })} | ||
> | ||
{model.owner.slug}/{model.slug} | ||
</StyledLink> | ||
</div> | ||
<UpgradeButton model={model} /> | ||
</div> | ||
</H2> | ||
<div> | ||
<p className="text-xs"> | ||
Check models with their current version and the new version, then | ||
press the upgrade button if everything is ok. | ||
</p> | ||
<p className="text-xs"> | ||
<strong> | ||
{`Code edits won't be saved, "Upgrade" button bumps only the model's version.`} | ||
</strong> | ||
</p> | ||
</div> | ||
<UpgradeableModel model={model} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.