ruvector/studio/components/interfaces/Advisors/DisableRuleModal.tsx
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

90 lines
2.6 KiB
TypeScript

import { useRouter } from 'next/router'
import { useState } from 'react'
import { toast } from 'sonner'
import { useParams } from 'common'
import { useLintRuleCreateMutation } from 'data/lint/create-lint-rule-mutation'
import {
Button,
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogSection,
DialogSectionSeparator,
DialogTitle,
DialogTrigger,
} from 'ui'
import { LintInfo } from '../Linter/Linter.constants'
import { lintInfoMap } from '../Linter/Linter.utils'
interface DisableRuleModalProps {
lint: LintInfo
}
export const DisableRuleModal = ({ lint }: DisableRuleModalProps) => {
const { ref } = useParams()
const router = useRouter()
const routeCategory = router.pathname.split('/').pop()
const [open, setOpen] = useState(false)
const { mutate: createRule, isPending: isCreating } = useLintRuleCreateMutation({
onSuccess: (_, vars) => {
const ruleLint = vars.exception.lint_name
const ruleLintMeta = lintInfoMap.find((x) => x.name === ruleLint)
toast.success(`Successfully disabled the "${ruleLintMeta?.title}" rule`)
if (ruleLintMeta) {
if (!!routeCategory && routeCategory !== ruleLintMeta.category) {
router.push(
`/project/${ref}/advisors/rules/${ruleLintMeta.category}?lint=${ruleLintMeta.name}`
)
}
}
setOpen(false)
},
})
const onCreateRule = () => {
if (!ref) return console.error('Project ref is required')
createRule({
projectRef: ref,
exception: {
is_disabled: true,
lint_category: undefined,
lint_name: lint.name,
assigned_to: undefined,
},
})
}
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button type="default">Disable rule</Button>
</DialogTrigger>
<DialogContent size="small">
<DialogHeader>
<DialogTitle>Confirm to disable rule</DialogTitle>
</DialogHeader>
<DialogSectionSeparator />
<DialogSection>
<p className="text-sm">
This will silence the "{lint.title}" by hiding this rule in the Advisor reports, as well
omitting this rule from email notifications for this project.
</p>
</DialogSection>
<DialogFooter>
<Button disabled={isCreating} type="default" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button loading={isCreating} type="primary" onClick={onCreateRule}>
Disable
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
}