web.lib.components.info-picker.info-picker.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 * as React from 'react';
import { optionalBool, ExtendedTextInput, TogglePanel } from '../../core/components';
import { InputProps } from '../../core/types';
import './info-picker.scss';
import { BuildToolSelect } from './build-tool-select';
import { NoCodeSelect } from './no-code-select';
import { JavaVersionSelect } from './java-version-select';
import { Stream } from '../api/model';
export interface InfoPickerValue {
groupId?: string;
artifactId?: string;
version?: string;
noCode?: boolean;
buildTool?: string;
javaVersion?: string;
}
interface InfoPickerProps extends InputProps {
showMoreOptions?: boolean;
currentStream: Stream;
}
const ARTIFACTID_PATTERN = /^[a-z][a-z0-9-._]*$/;
const GROUPID_PATTERN = /^([a-zA-Z_$][a-zA-Z\d_$]*\.)*[a-zA-Z_$][a-zA-Z\d_$]*$/;
const isValidId = (value?: string) => !!value && ARTIFACTID_PATTERN.test(value || '');
const isValidGroupId = (value?: string) => !!value && GROUPID_PATTERN.test(value);
export const isValidInfo = (value: InfoPickerValue) => {
return isValidGroupId(value.groupId)
&& isValidId(value.artifactId)
&& !!value.version;
};
export const InfoPicker = (props: InfoPickerProps) => {
const onInputChange = props.onChange;
const onGroupIdChange = (newValue: string) => onInputChange({ ...props.value, groupId: newValue });
const onArtifactIdChange = (newValue: string) => onInputChange({ ...props.value, artifactId: newValue });
const onVersionChange = (newValue: string) => onInputChange({ ...props.value, version: newValue });
const onNoCodeChange = (newValue: boolean) => onInputChange({ ...props.value, noCode: newValue });
const onBuildToolChange = (newValue: string) => onInputChange({ ...props.value, buildTool: newValue });
const onJavaVersionChange = (newValue: string) => onInputChange({ ...props.value, javaVersion: newValue });
return (
{optionalBool(props.showMoreOptions, true) && (
)}
);
};
© 2015 - 2025 Weber Informatics LLC | Privacy Policy