Skip to content

Commit

Permalink
fix: Delete evaluator modal is light in dark mode #1424
Browse files Browse the repository at this point in the history
  • Loading branch information
VenkataRavitejaGullapudi committed Mar 9, 2024
1 parent 8f6a996 commit d855eda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion agenta-web/src/components/AlertPopup/AlertPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {ReactNode} from "react"
import {Modal, ModalFuncProps} from "antd"
import {ExclamationCircleOutlined} from "@ant-design/icons"
import {globalErrorHandler} from "@/lib/helpers/errorHandler"
import { HookAPI } from "antd/es/modal/useModal"

function handleCb(cb: AlertPopupProps["onOk"]) {
if (typeof cb !== "function") return cb
Expand All @@ -19,6 +20,7 @@ function handleCb(cb: AlertPopupProps["onOk"]) {
export type AlertPopupProps = ModalFuncProps & {
message: ReactNode
cancellable?: boolean
modalInstance?: HookAPI
}

export default function AlertPopup({
Expand All @@ -29,10 +31,12 @@ export default function AlertPopup({
onOk,
onCancel,
cancellable = true,
modalInstance,
type,
...ModalProps
}: AlertPopupProps) {
return Modal[type || "confirm"]({
const modalIns = modalInstance as any || Modal;
return modalIns[type || "confirm"]({
title,
content: message,
okText,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import {EvaluatorConfig, JSSTheme} from "@/lib/Types"
import {DeleteOutlined, EditOutlined} from "@ant-design/icons"
import {Card, Tag, Typography} from "antd"
import {Card, Tag, Typography, Modal} from "antd"
import {createUseStyles} from "react-jss"
import dayjs from "dayjs"
import Image from "next/image"
Expand Down Expand Up @@ -60,11 +60,13 @@ const EvaluatorCard: React.FC<Props> = ({evaluatorConfig, onEdit, onSuccessDelet
const classes = useStyles()
const [evaluators] = useAtom(evaluatorsAtom)
const evaluator = evaluators.find((item) => item.key === evaluatorConfig.evaluator_key)!
const [modal, contextHolder] = Modal.useModal()

const onDelete = async () => {
AlertPopup({
title: "Delete evaluator",
message: "Are you sure you want to delete this evaluator?",
modalInstance: modal,
onOk: async () => {
if (
!(await checkIfResourceValidForDeletion({
Expand Down Expand Up @@ -122,6 +124,7 @@ const EvaluatorCard: React.FC<Props> = ({evaluatorConfig, onEdit, onSuccessDelet
{evaluatorConfig.name}
</Typography.Title>
</div>
{contextHolder}
</Card>
)
}
Expand Down

0 comments on commit d855eda

Please sign in to comment.