mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat(run-code): activate Submissions panel after running code
This commit is contained in:
parent
d9d9db16fe
commit
8809dbdb1a
@ -11,6 +11,7 @@ import { useState } from "react";
|
|||||||
import { judge } from "@/actions/judge";
|
import { judge } from "@/actions/judge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useProblem } from "@/hooks/use-problem";
|
import { useProblem } from "@/hooks/use-problem";
|
||||||
|
import { useDockviewStore } from "@/stores/dockview";
|
||||||
import { LoaderCircleIcon, PlayIcon } from "lucide-react";
|
import { LoaderCircleIcon, PlayIcon } from "lucide-react";
|
||||||
import { showStatusToast } from "@/hooks/show-status-toast";
|
import { showStatusToast } from "@/hooks/show-status-toast";
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ export function RunCode({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: RunCodeProps) {
|
}: RunCodeProps) {
|
||||||
|
const { api } = useDockviewStore();
|
||||||
const { currentLang, editor, problemId } = useProblem();
|
const { currentLang, editor, problemId } = useProblem();
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
@ -34,6 +36,10 @@ export function RunCode({
|
|||||||
try {
|
try {
|
||||||
const result = await judge(currentLang, code, problemId);
|
const result = await judge(currentLang, code, problemId);
|
||||||
showStatusToast({ status: result.status });
|
showStatusToast({ status: result.status });
|
||||||
|
const panel = api?.getPanel("Submissions");
|
||||||
|
if (panel && !panel.api.isActive) {
|
||||||
|
panel.api.setActive();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error occurred while judging the code:");
|
console.error("Error occurred while judging the code:");
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -51,7 +57,7 @@ export function RunCode({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
className={cn("h-8 px-3 py-1.5", className)}
|
className={cn("h-8 px-3 py-1.5", className)}
|
||||||
onClick={handleJudge}
|
onClick={handleJudge}
|
||||||
disabled={isLoading}
|
disabled={isLoading || !api?.getPanel("Submissions")}
|
||||||
>
|
>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<LoaderCircleIcon
|
<LoaderCircleIcon
|
||||||
|
Loading…
Reference in New Issue
Block a user