web.lib.components.extensions-picker.extension-more-dropdown.tsx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-quarkus Show documentation
Show all versions of code-quarkus Show documentation
Customize a Web Interface to generate Quarkus starter projects.
import React, { useEffect, useState } from 'react';
import { useAnalytics } from '../../core/analytics';
import { CopyToClipboard } from '../../core/components';
import { ExtensionEntry } from './extensions-picker';
import { FaAngleDown, FaAngleUp, FaMap } from 'react-icons/fa';
import DropdownItem from 'react-bootstrap/DropdownItem';
import { Button, Dropdown } from 'react-bootstrap';
interface ExtensionMoreDropdownProps extends ExtensionEntry {
active: boolean;
buildTool?: string;
}
export function ExtensionMoreDropdown(props: ExtensionMoreDropdownProps) {
const [ isOpen , setIsOpen ] = useState(false);
const analytics = useAnalytics();
const gav = `${props.id}:${props.version}`;
const gavArray = gav.split(':');
const bomArray = props.bom && props.bom.split(':');
const addMvnExt = `./mvnw quarkus:add-extension -Dextensions="${props.id}"`;
const addCliExt = `quarkus ext add ${props.id}`;
const addGradleExt = `./gradlew addExtension --extensions="${props.id}"`;
const gradleDep = `implementation "${props.platform ? props.id : gav}"`;
const gradleBom = `implementation enforcedPlatform("${props.bom}")`;
const gradleDepKot = `implementation("${props.platform ? props.id : gav}")`;
const gradleBomKot = `implementation(enforcedPlatform("${props.bom}"))`;
const pomDepXml = ` \n ${gavArray[0]} \n ${gavArray[1]} \n${props.platform ? '' : ` ${props.version} \n`} `;
const pomBomXml = bomArray && ` \n ${bomArray[0]} \n ${bomArray[1]} \n ${bomArray[2]} \n pom \n import \n `;
const buildTool = props.buildTool;
const context = { element: 'extension-more-dropdown', extension: props.id };
const openGuide = () => {
analytics.event('Click',{ label: 'open extension guide', ...context });
};
useEffect(() => {
if(!props.active && isOpen) {
setIsOpen(false);
}
}, [ props.active, isOpen, setIsOpen ]);
return (
e.stopPropagation()} onToggle={setIsOpen} show={isOpen}>
{isOpen ? : }
{props.active && (
e.stopPropagation()}
>
Copy the CLI command to add this extension
{buildTool==='MAVEN' && (
Copy the Maven command to add this extension
)}
{buildTool==='GRADLE' && (
Copy the Gradle command to add this extension
)}
{buildTool==='MAVEN' && (
Copy the pom.xml dependency snippet
)}
{buildTool==='GRADLE' && (
Copy the build.gradle dependency snippet
)}
{buildTool==='GRADLE_KOTLIN_DSL' && (
Copy the build.gradle.kts dependency snippet
)}
{pomBomXml && buildTool==='MAVEN' && (
Copy the pom.xml bom snippet
)}
{gradleBom && buildTool==='GRADLE' && (
Copy the build.gradle bom snippet
)}
{gradleBomKot && buildTool==='GRADLE_KOTLIN_DSL' && (
Copy the build.gradle.kts bom snippet
)}
Copy the groupId:artifactId:version
{props.guide && (
See the extension guide
)}
)
}
);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy