({ onChangeConnection }: WelcomeProps)
| 18 | }; |
| 19 | |
| 20 | export function Welcome({ onChangeConnection }: WelcomeProps) { |
| 21 | const { t } = useTranslation(); |
| 22 | const projectName = useSQLEditorEditorState((s) => s.project); |
| 23 | |
| 24 | const resolvedProject = useAppProject(projectName); |
| 25 | const project = projectName ? resolvedProject : undefined; |
| 26 | |
| 27 | const [showCreateInstanceButton] = usePermissionCheck([ |
| 28 | "bb.instances.create", |
| 29 | ]); |
| 30 | const [showConnectButton] = usePermissionCheck(["bb.sql.select"], project); |
| 31 | |
| 32 | const handleCreateInstance = () => { |
| 33 | router.push({ |
| 34 | name: INSTANCE_ROUTE_DASHBOARD, |
| 35 | hash: "#add", |
| 36 | }); |
| 37 | }; |
| 38 | |
| 39 | return ( |
| 40 | <div className="w-full h-full flex flex-col items-center justify-center gap-y-4"> |
| 41 | <BytebaseLogo /> |
| 42 | <div className="flex items-center flex-wrap gap-4"> |
| 43 | {showCreateInstanceButton && ( |
| 44 | <WelcomeButton |
| 45 | variant="secondary" |
| 46 | icon={<LayersIcon strokeWidth={1.5} className="size-8" />} |
| 47 | onClick={handleCreateInstance} |
| 48 | > |
| 49 | {t("sql-editor.add-a-new-instance")} |
| 50 | </WelcomeButton> |
| 51 | )} |
| 52 | {showConnectButton && ( |
| 53 | <WelcomeButton |
| 54 | variant="primary" |
| 55 | icon={<LinkIcon strokeWidth={1.5} className="size-8" />} |
| 56 | onClick={onChangeConnection} |
| 57 | > |
| 58 | {t("sql-editor.connect-to-a-database")} |
| 59 | </WelcomeButton> |
| 60 | )} |
| 61 | </div> |
| 62 | </div> |
| 63 | ); |
| 64 | } |
nothing calls this directly
no test coverage detected